:root {
  --ink: #17211b;
  --muted: #68736c;
  --line: #dfe5df;
  --paper: #f7f8f4;
  --panel: #ffffff;
  --forest: #173d2b;
  --green: #2e7653;
  --mint: #dceee4;
  --amber: #a65a16;
  --amber-soft: #fff0d8;
  --red: #a63f3f;
  --red-soft: #fbe8e6;
  --shadow: 0 18px 50px rgba(28, 47, 36, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(136, 185, 157, 0.18), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  color: #eef6f0;
  background: var(--forest);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 8px 38px;
  color: inherit;
  text-decoration: none;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; }
.brand small { margin-top: 2px; color: #a9c1b1; font-size: .75rem; }

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  color: var(--forest);
  background: #d9f0df;
  font: 700 1.1rem Georgia, serif;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.25);
}

.brand-mark.large { width: 52px; height: 52px; margin-bottom: 24px; font-size: 1.4rem; }

nav { display: grid; gap: 8px; }

nav a {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border-radius: 12px;
  color: #d9e7dd;
  text-decoration: none;
}

nav a:hover, nav a.active { background: rgba(255,255,255,.1); color: white; }
nav a span { font-weight: 650; }
nav a small { color: #9eb5a5; }

.logout-form { margin-top: auto; }
.logout-form button {
  width: 100%;
  border: 1px solid rgba(255,255,255,.15);
  background: transparent;
  color: #d9e7dd;
}

main { min-width: 0; padding: 36px clamp(22px, 4vw, 58px) 60px; }

.page-header, .section-heading, .action-bar, .account-card-top, .account-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-header { margin-bottom: 30px; }
.page-header h1, .section-heading h2, .account-card h2 { margin: 0; }
.page-header h1 { font: 700 clamp(2rem, 4vw, 3.35rem)/1 Georgia, serif; letter-spacing: -.035em; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.live-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: .82rem;
}

.live-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #3d9b69;
  box-shadow: 0 0 0 5px rgba(61,155,105,.12);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 38px;
}

.metrics article, .account-card, .table-panel, .empty-state, .action-bar {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}

.metrics article { padding: 20px; border-radius: 18px; }
.metrics span, .metrics small { display: block; color: var(--muted); }
.metrics strong { display: block; margin: 12px 0 6px; font: 700 2.35rem/1 Georgia, serif; }

.fleet-breakdown {
  display: grid;
  grid-template-columns: repeat(8, minmax(74px, 1fr));
  gap: 1px;
  margin: -20px 0 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}
.fleet-breakdown div { display: grid; gap: 4px; padding: 12px; background: var(--panel); }
.fleet-breakdown span { color: var(--muted); font-size: .72rem; }
.fleet-breakdown strong { font-size: 1.05rem; }

.section-heading { margin-bottom: 18px; }
.section-heading p:last-child, .action-bar p { color: var(--muted); }

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.account-card { padding: 22px; border-radius: 20px; }
.account-id { margin: 0 0 5px; color: var(--muted); font: 600 .72rem ui-monospace, monospace; }
.health { padding: 7px 10px; border-radius: 999px; font-size: .72rem; font-weight: 750; }
.health.healthy { color: #226144; background: var(--mint); }
.health.attention { color: var(--amber); background: var(--amber-soft); }
.health.warning { color: var(--amber); background: var(--amber-soft); }
.health.neutral { color: #59645d; background: #edf0ec; }

.pills { display: flex; flex-wrap: wrap; gap: 7px; margin: 17px 0; }
.pills.compact { margin: 0; }
.pill { padding: 5px 8px; border-radius: 7px; font-size: .68rem; font-weight: 750; }
.pill.on { color: #226144; background: var(--mint); }
.pill.off { color: #748078; background: #edf0ec; }
.pill.warning { color: var(--amber); background: var(--amber-soft); }

.account-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 16px 0;
  border-top: 1px solid var(--line);
}

.account-facts div { padding: 13px 8px 10px 0; border-bottom: 1px solid var(--line); }
.account-facts dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.account-facts dd { margin: 5px 0 0; font-size: .86rem; font-weight: 650; }
.account-error { padding: 10px 12px; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: .8rem; }
.account-footer { margin-top: 18px; }
.account-footer a, td a { color: var(--green); font-size: .82rem; font-weight: 750; text-decoration: none; }

.action-bar { margin-bottom: 18px; padding: 18px 20px; border-radius: 16px; }
.action-bar p { margin: 0; }
.button, button {
  display: inline-block;
  padding: 11px 16px;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}
.primary { color: white; background: var(--forest); }

.table-panel { overflow: auto; border-radius: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f4f6f2; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .84rem; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); }
.detail-cell {
  min-width: 260px;
  max-width: 520px;
  overflow-wrap: anywhere;
  white-space: normal;
}
.activity-message { line-height: 1.45; }
.empty-cell { padding: 42px; color: var(--muted); text-align: center; }

.empty-state {
  max-width: 700px;
  padding: 48px;
  border-radius: 24px;
  text-align: center;
}
.empty-state h2 { margin: 0; font: 700 2rem Georgia, serif; }
.empty-state p:not(.eyebrow) { margin: 12px 0 24px; color: var(--muted); }

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 10%, rgba(99, 161, 124, .25), transparent 30rem),
    var(--forest);
}

.login-card {
  width: min(430px, 100%);
  padding: 42px;
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 30px 90px rgba(0,0,0,.24);
}
.login-card h1 { margin: 0; font: 700 2.55rem/1 Georgia, serif; }
.login-copy { margin: 12px 0 28px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.login-form input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  font: inherit;
}
.form-error { padding: 10px 12px; border-radius: 10px; color: var(--red); background: var(--red-soft); }
.form-banner { margin-bottom: 18px; }

.account-form { display: grid; gap: 18px; }
.form-section {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow);
}
.form-section-heading {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 22px;
}
.form-section-heading > span {
  display: grid;
  flex: 0 0 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--forest);
  font-weight: 800;
}
.form-section-heading h2 { margin: 0; font: 700 1.35rem Georgia, serif; }
.form-section-heading p, .review-bar p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.form-grid input, .form-grid select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}
.form-grid select[multiple] { min-height: 142px; }
.form-grid label small { color: var(--muted); font-weight: 500; line-height: 1.45; }
.toggle-row, .service-toggles { color: var(--ink); font-weight: 700; }
.toggle-row.separated { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.service-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; }
.service-toggles label {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f9f6;
}
.top-gap { margin-top: 18px; }
.connection-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.connection-actions button {
  border: 1px solid var(--line);
  color: var(--forest);
  background: #edf5ef;
}
.connection-actions span { color: var(--muted); font-size: .8rem; }
.connection-actions span.success { color: var(--green); font-weight: 750; }
.connection-actions span.error { color: var(--red); font-weight: 750; }
.form-success { color: #226144; border-color: #bcdcc8; background: var(--mint); }
.review-bar {
  position: sticky;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  border: 1px solid rgba(23,61,43,.2);
  border-radius: 16px;
  background: rgba(247, 250, 246, .96);
  box-shadow: 0 16px 50px rgba(23,61,43,.18);
  backdrop-filter: blur(10px);
}
.review-confirm {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.review-confirm span, .review-confirm small { display: block; }
.review-confirm small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.account-search { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.account-search input {
  min-width: min(340px, 60vw);
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}
.audit-history { margin-top: 24px; }
.audit-list { display: grid; gap: 10px; }
.audit-event {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.audit-event:first-child { border-top: 0; }
.audit-event strong, .audit-event small { display: block; }
.audit-event small { margin-top: 4px; color: var(--muted); }
.audit-event p { margin: 0; color: var(--muted); text-align: right; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .account-grid { grid-template-columns: 1fr; }
  .fleet-breakdown { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
  .brand { margin-bottom: 16px; }
  nav { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  nav a { padding: 10px 6px; font-size: .82rem; text-align: center; }
  nav a small { display: none; }
  .logout-form { margin-top: 16px; }
  main { padding: 26px 16px 44px; }
  .page-header { align-items: flex-end; }
  .live-indicator { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .fleet-breakdown { grid-template-columns: repeat(2, 1fr); }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .service-toggles { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 460px) {
  .metrics { grid-template-columns: 1fr; }
  .account-facts { grid-template-columns: 1fr; }
  .account-footer { align-items: flex-start; flex-direction: column; }
  .login-card { padding: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .review-bar { align-items: stretch; flex-direction: column; }
}
