/* ==========================================================================
   Cartis — app stylesheet
   "Nairobi Corporate Modern": clean, data-dense, no shadows/gradients.
   Tokens and components follow docs/design_system.md. Never hardcode colours
   outside the token list here.
   ========================================================================== */

:root {
  /* ── Brand palette — teal-forward "Location Hub" rebrand ──────────────────
     Source of truth: the Location Hub prototype. The Material-style names below
     (--surface*, --primary-container, …) are kept as compatibility ALIASES
     mapped onto this palette, so every existing component re-skins with no
     markup change. They'll be retired as templates move to the brand tokens
     during the Location Hub phase. */
  --deep:  #0B2F33;   /* darkest teal — solid buttons, headings, hovers */
  --teal:  #0F9F8F;   /* primary — links, active states, accents, data bars */
  --mint:  #5EEAD4;   /* bright accent — text on dark, selection */
  --bg:    #F5FAF9;   /* page background */
  --ink:   #183236;   /* body text */
  --gold:  #E9A23B;   /* secondary accent — active nav, highlights */
  --coral: #E05A67;   /* negative / chart-down / decorative red */
  --line:  #DEEAE7;   /* borders */
  --line2: #EDF4F2;   /* lighter dividers */
  --thead: #F1F7F5;   /* table header fill */
  --muted: #5E736F;   /* secondary text */
  --faint: #93A7A3;   /* tertiary text / icons */
  --tint:  #EAF7F4;   /* subtle teal fill */

  /* ── Compatibility aliases (old name → brand token) ─────────────────────── */
  /* Surfaces */
  --surface:           var(--bg);
  --surface-lowest:    #ffffff;
  --surface-low:       #eef6f3;      /* subtle row/hover tint */
  --surface-container: var(--tint);
  --surface-high:      #dceeea;      /* focus ring, bar track, tint badge */
  --surface-highest:   #cde8e1;

  /* Text */
  --on-surface:        var(--ink);
  --on-variant:        var(--muted);
  --outline:           var(--muted);   /* used for small label text — keep legible */
  --outline-variant:   var(--line);

  /* Primary — teal (solid buttons use --deep for AA contrast; see .btn-primary) */
  --primary-container:    var(--teal);
  --on-primary:           #ffffff;
  --on-primary-container: var(--deep);

  /* Secondary — gold */
  --secondary-container:    var(--gold);
  --on-secondary-container: #5a3d00;

  /* Tertiary — deep teal / mint */
  --tertiary-container:    var(--deep);
  --on-tertiary-container: var(--mint);

  /* Semantic — error kept readable on light; brand coral lives at --coral */
  --error:              #c62f3b;
  --error-container:    #fbe0e2;
  --on-error-container: #7a1620;

  /* Navigation (sidebar) — deep-teal shell with pale-mint text */
  --nav-bg:     var(--deep);
  --nav-fg:     #eafbf7;                 /* rgb(234,251,247) — sidebar text */
  --nav-muted:  rgba(234,251,247,0.55);  /* dimmed section labels */
  --nav-accent: rgba(94,234,212,0.15);   /* mint 15% — hover / selected */
  --nav-border: rgba(94,234,212,0.12);   /* subtle right divider */

  /* Radius */
  --r:      4px;
  --r-md:   6px;
  --r-lg:   8px;
  --r-xl:   12px;
  --r-full: 9999px;
  --r-card: 14px;   /* cards, KPI tiles, slot cards (Location Hub redesign) */
  --r-btn:  10px;   /* buttons, nav items */

  /* Elevation — a single whisper-soft shadow; the design is otherwise flat. */
  --shadow-card: 0 1px 2px rgba(11, 47, 51, 0.04);

  /* Type — Instrument Sans (body) + Space Grotesk (display/headings/numbers) */
  --font:         "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Space Grotesk", "Instrument Sans", system-ui, sans-serif;
  --fd:           var(--font-display);   /* prototype alias */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--deep); }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

/* Display type — Space Grotesk on headings, titles and KPI numbers. */
h1, h2, h3,
.page-title, .card-title, .stat .value,
.brand, .auth-brand, .auth-card h1 {
  font-family: var(--font-display);
}

.num { font-variant-numeric: tabular-nums; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--r-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  line-height: 1.2;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
/* Primary is the brand teal (matches the Location Hub CTA); deep on hover.
   Buttons are often <a>, so each hover re-asserts its text colour to beat the
   global `a:hover { color: var(--deep) }` rule (which otherwise hid the label). */
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--deep); color: #fff; }
.btn-ghost {
  background: var(--surface-lowest);
  border-color: var(--line);
  color: var(--deep);
}
.btn-ghost:hover { background: var(--tint); color: var(--deep); }
/* Icons inside ghost/secondary buttons pick up the teal accent. */
.btn-ghost svg { color: var(--teal); }
.btn-gold { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn-gold:hover { background: #d8912b; color: var(--on-secondary-container); }
.btn-block { width: 100%; }

/* --- Forms --------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--on-variant);
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r);
  padding: 9px 11px;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary-container);
  box-shadow: 0 0 0 3px var(--surface-high);
}
.field .helptext { display: block; font-size: 13px; color: var(--on-variant); margin-top: 5px; }
.field .errorlist,
.form-errors {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 13px;
  color: var(--error);
}
.form-nonfield {
  background: var(--error-container);
  color: var(--on-error-container);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 14px;
}

/* --- Cards --------------------------------------------------------------- */

.card {
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.card-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--deep); }
.card-body { padding: 18px; }

/* --- Badges -------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
}
/* Soft brand pills — teal for good, warm-gold for caution, coral for problem. */
.b-green { background: var(--tint); color: var(--teal);  border-color: #c9eae3; }
.b-gold  { background: #fbf3e4;     color: #9a6712;      border-color: #f0deb6; }
.b-red   { background: #fcebec;     color: var(--coral); border-color: #f6d3d6; }
.b-blue  { background: var(--tint); color: var(--deep);  border-color: #c9eae3; }
.b-grey  { background: var(--surface-container); color: var(--muted); border-color: var(--line); }

/* --- App shell: sidebar + main (no top bar; brand + account live in the
       sidebar, matching the Location Hub prototype) ----------------------- */

.app { min-height: 100vh; display: flex; align-items: stretch; }

.sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

/* Brand (sidebar top) — gradient logo tile + two-tone wordmark. */
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: linear-gradient(145deg, var(--teal), var(--mint));
  color: var(--deep); display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
}
.brand .brand-name { font-family: var(--font-display); font-weight: 600; font-size: 15px;
  color: #fff; letter-spacing: 0.005em; }
.brand .brand-name span { color: var(--mint); }

/* Logo image — renders once static/img/cartis-logo.svg exists (replaces the
   text mark). Sidebar sits on the dark shell; if the artwork is dark and doesn't
   read there, supply a light/mono variant and we'll wire it separately. */
.brand-logo { height: 70px; width: auto; max-width: 100%; display: block; }
.auth-brand .brand-logo { height: 100px; width: auto; max-width: 100%; }

.nav-section { font-family: var(--font-display); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--nav-muted);
  padding: 10px 12px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-btn);
  font-family: var(--font-display); font-size: 14px; font-weight: 500; color: var(--nav-fg);
  background: transparent; border: none; margin-bottom: 2px; text-decoration: none;
}
.nav-item:hover:not(.active) { background: var(--nav-accent); color: var(--nav-fg); text-decoration: none; }
/* Selected shares the mint tint with hover; brighter mint text + weight marks it. */
.nav-item.active { background: var(--nav-accent); color: var(--mint); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* Account card + sign out (sidebar bottom). */
.nav-foot { margin-top: auto; padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.nav-account {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--nav-border);
  border-radius: 12px; padding: 10px 11px;
}
.nav-account:hover { text-decoration: none; background: rgba(94, 234, 212, 0.10); }
.nav-account .na-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 8px;
  background: rgba(94, 234, 212, 0.16); color: var(--mint);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
}
.nav-account .na-info { min-width: 0; display: flex; flex-direction: column; }
.nav-account .na-name { font-family: var(--font-display); font-size: 13px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-account .na-plan { font-size: 11px; color: var(--mint); }
.nav-signout { text-align: left; padding: 6px 12px; font-size: 13px; color: #7fa8a2;
  background: transparent; border: none; cursor: pointer; }
.nav-signout:hover { color: var(--nav-fg); }

.main { flex: 1; padding: 24px 32px; min-width: 0; }

/* Mobile menu toggle — fixed top-left (there's no top bar to hold it). */
.nav-toggle { display: none; position: fixed; top: 12px; left: 12px; z-index: 55;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  background: var(--deep); color: var(--mint); border: none;
  border-radius: var(--r-btn); cursor: pointer; box-shadow: var(--shadow-card); }
.nav-toggle svg { width: 22px; height: 22px; }
.nav-backdrop { display: none; }

/* --- Mobile: sidebar becomes an off-canvas drawer ------------------------ */
@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .main { padding: 62px 16px 18px; }   /* clear the fixed toggle */

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; height: 100vh;
    width: 260px; flex-basis: 260px;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .nav-backdrop.show {
    display: block; position: fixed; inset: 0;
    background: rgba(11, 47, 51, 0.45); z-index: 50;
  }

  /* Let wide tables scroll horizontally instead of breaking the layout. */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }

  .stat-row, .slot-row { grid-template-columns: repeat(2, 1fr); }
}

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { font-size: 14px; color: var(--on-variant); margin-top: 3px; }

/* --- Empty state --------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--on-variant);
}
.empty h3 { font-size: 16px; color: var(--on-surface); margin-bottom: 8px; }
.empty p { font-size: 16px; margin: 0 auto 18px; max-width: 380px; }

/* --- Auth layout (centered card) ----------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-xl);
  padding: 32px;
}
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 700; margin-bottom: 22px; }
.auth-brand .mark {
  width: 30px; height: 30px; background: var(--deep); color: var(--mint);
  border-radius: var(--r-md); display: grid; place-items: center;
}
.auth-card h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-card .sub { font-size: 14px; color: var(--on-variant); margin-bottom: 22px; }
.auth-foot { font-size: 14px; color: var(--on-variant); margin-top: 18px; text-align: center; }

/* --- Messages ------------------------------------------------------------ */

.messages { list-style: none; margin: 0 0 18px; padding: 0; }
.messages li {
  padding: 10px 14px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 8px;
  background: var(--surface-low); border: 1px solid var(--outline-variant);
}
.messages li.error { background: var(--error-container); border-color: var(--error); color: var(--on-error-container); }
.messages li.success { background: #d6f5e8; border-color: #4eddbb; color: #1a6641; }

/* --- Data tables --------------------------------------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--faint); padding: 9px 16px;
  border-bottom: 1px solid var(--line); text-align: left;
}
.data-table thead th.right { text-align: right; }
.data-table tbody tr { border-bottom: 1px solid var(--line2); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--tint); }
.data-table td { padding: 11px 16px; }

/* Outside-Nairobi towns: expandable rows with a sub-locality drill-down */
.ot-head, .ot-town > summary {
  display: grid; grid-template-columns: 1fr 90px 150px; align-items: center;
  gap: 8px; padding: 11px 16px; font-size: 14px;
}
.ot-head {
  border-bottom: 1px solid var(--line); color: var(--faint);
  font-family: var(--font-display); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.ot-head .right, .ot-town .right { text-align: right; }
.ot-town { border-bottom: 1px solid var(--line2); }
.ot-town:last-child { border-bottom: none; }
.ot-town > summary { cursor: pointer; list-style: none; }
.ot-town[data-flat] > summary { cursor: default; }
.ot-town > summary::-webkit-details-marker { display: none; }
.ot-town > summary:hover { background: var(--tint); }
.ot-name { display: flex; align-items: center; gap: 7px; }
.ot-caret { color: var(--muted); transition: transform .15s; flex-shrink: 0; }
.ot-town[open] > summary .ot-caret { transform: rotate(90deg); }
.ot-subs { padding: 2px 16px 10px 40px; }
.ot-sub {
  display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px;
  color: var(--muted); border-top: 1px solid var(--line2);
}

/* Clickable rows (e.g. area list → detail view) */
.data-table tr.row-link { cursor: pointer; }
.row-arrow { display: inline-flex; align-items: center; color: var(--outline); }
.row-arrow:hover { color: var(--primary-container); }
.data-table tr.row-link:hover .row-arrow { color: var(--primary-container); }
.data-table td.right { text-align: right; font-variant-numeric: tabular-nums; }
.rank { display:inline-grid; place-items:center; width:22px; height:22px; border-radius:var(--r-full);
  background:var(--surface-container); color:var(--on-variant); font-size:11px; font-weight:700; }
.rank.top { background: var(--secondary-container); color: var(--on-secondary-container); }
.muted { color: var(--on-variant); font-size: 13px; }

/* --- KPI stat cards ------------------------------------------------------ */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface-lowest); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px 18px;
}
.stat .label { font-family: var(--font-display); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.stat .value { font-family: var(--font-display); font-size: 30px; font-weight: 600;
  color: var(--deep); letter-spacing: -0.02em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* --- Context strip ------------------------------------------------------- */

.context-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  background: var(--surface-lowest); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 11px 15px; margin-bottom: 18px; font-size: 13px;
}
.context-strip .cs-item { display: flex; align-items: baseline; gap: 6px; color: var(--muted); }
.context-strip .cs-item b { color: var(--ink); font-weight: 500; }
.context-strip .pills { display: flex; gap: 7px; margin-left: auto; }

/* --- Tabs ---------------------------------------------------------------- */

.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.s-tab {
  font-family: var(--font-display); font-size: 14.5px; font-weight: 500; color: var(--muted);
  background: transparent; border: none; border-bottom: 2.5px solid transparent;
  padding: 0 1px 12px; margin-bottom: -1px; cursor: pointer;
}
.s-tab:hover { color: var(--deep); }
.s-tab.active { color: var(--deep); font-weight: 600; border-bottom-color: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Share bars ---------------------------------------------------------- */

.bar-wrap { display: flex; align-items: center; gap: 9px; }
.bar-track { flex: 1; height: 8px; background: var(--line2); border-radius: var(--r-full);
  overflow: hidden; min-width: 46px; }
.bar-fill { height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--teal), var(--mint)); }

/* --- Hub layout + section headers ---------------------------------------- */

.hub-grid { display: grid; grid-template-columns: 1fr 350px; gap: 18px; align-items: start; }
.section-head { font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--on-variant); margin: 22px 0 10px; }
.mini-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; }
.mini-bar-row .mb-name { width: 92px; flex: 0 0 92px; }
.mini-bar-row .mb-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 900px) { .hub-grid { grid-template-columns: 1fr; } .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* --- Month-over-month comparison overlay --------------------------------- */

/* Compare-to-previous toggle bar (above the KPI row). */
.cmp-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.cmp-title { font-size: 12.5px; color: var(--muted); }
.cmp-sub { font-size: 11.5px; color: var(--faint); }
.cmp-toggle { width: 38px; height: 22px; border-radius: var(--r-full); border: none; padding: 0;
  background: #cbd9d6; position: relative; cursor: pointer; transition: background 0.18s; flex: none; }
.cmp-toggle.on { background: var(--teal); }
.cmp-toggle .cmp-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: left 0.18s; }
.cmp-toggle.on .cmp-knob { left: 19px; }

/* Comparison bits render only while #hub carries .cmp-on (toggled in JS). */
.stat-delta, .movers-card, .cmp-arrow, .cmp-inline { display: none; }
#hub.cmp-on .stat-delta { display: flex; }
#hub.cmp-on .movers-card { display: block; }
#hub.cmp-on .cmp-arrow, #hub.cmp-on .cmp-inline { display: inline; }

/* KPI delta pill. */
.stat-delta { align-items: center; gap: 8px; margin-top: 9px; }
.delta-pill { font-family: var(--font-display); font-size: 12.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 7px; }
.delta-pill.up { background: var(--tint); color: var(--teal); }
.delta-pill.down { background: #fcebec; color: var(--coral); }
.delta-pill.flat { background: var(--surface-container); color: var(--muted); }
.delta-note { font-size: 12px; color: var(--faint); }

/* Area-table direction arrow + "· vs prev" header hint. */
.cmp-arrow { font-size: 11px; margin-left: 2px; }
.cmp-arrow.up { color: var(--teal); }
.cmp-arrow.down { color: var(--coral); }
.cmp-arrow.flat { color: var(--faint); }
.cmp-inline { color: var(--faint); font-weight: 500; }

/* Top movers card. */
.movers-head { font-family: var(--font-display); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; margin: 4px 0 9px; }
.movers-head.up { color: var(--teal); }
.movers-head.down { color: var(--coral); margin-top: 14px; }
.mover-row { display: grid; grid-template-columns: 82px 1fr 46px; gap: 8px;
  align-items: center; margin-bottom: 8px; font-size: 13px; }
.mover-row .mv-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-row .bar-track { height: 7px; }
.mv-fill { height: 100%; border-radius: var(--r-full); }
.mv-fill.up { background: var(--teal); }
.mv-fill.down { background: var(--coral); }
.mv-delta { text-align: right; font-family: var(--font-display); font-size: 12.5px;
  font-weight: 600; font-variant-numeric: tabular-nums; }
.mv-delta.up { color: var(--teal); }
.mv-delta.down { color: var(--coral); }

/* --- Timing tab: slot cards + heat cells --------------------------------- */

.slot-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.slot-card {
  background: var(--surface-lowest); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px;
}
.slot-card .slot-head { display: flex; align-items: center; gap: 8px; font-family: var(--font-display);
  font-weight: 600; font-size: 15px; color: var(--deep); }
.slot-card .slot-range { font-size: 13px; color: var(--muted); margin-top: 2px; }
.slot-card .slot-count { font-family: var(--font-display); font-size: 24px; font-weight: 600;
  color: var(--deep); margin-top: 10px; font-variant-numeric: tabular-nums; }
.slot-card .slot-pct { font-size: 13px; color: var(--muted); }
.slot-card .slot-top { margin-top: 10px; border-top: 1px solid var(--line2); padding-top: 10px; }
.slot-card .slot-top .st { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.slot-card .slot-top .st span:last-child { color: var(--on-variant); font-variant-numeric: tabular-nums; }

.heat-cell {
  display: inline-block; min-width: 44px; text-align: center;
  padding: 5px 8px; border-radius: var(--r); font-size: 13px; font-variant-numeric: tabular-nums;
}
/* Teal intensity ramp — light tint to solid teal (was an off-brand blue ramp). */
.hc-0 { background: var(--line2); color: var(--faint); }
.hc-1 { background: var(--tint);  color: var(--teal); }
.hc-2 { background: #a6e0d6;      color: var(--deep); }
.hc-3 { background: var(--teal);  color: #ffffff; }

.insight {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-xl);
  font-size: 14px; align-items: flex-start; margin-bottom: 18px;
}
.insight.teal { background: var(--tint); border: 1px solid #c9eae3; color: var(--ink); }
.insight.teal svg { color: var(--teal); }
.insight svg { flex: none; margin-top: 1px; }  /* keep the icon from shrinking */
.insight.gold { background: #fbf3e4; border: 1px solid #f0deb6; color: var(--ink); font-size: 13px; }
.insight.gold svg { color: var(--gold); }
/* Banner variant: title/copy left, action button right. */
.insight.between { justify-content: space-between; align-items: center; gap: 12px; }

/* --- Payment tab: stacked split bar + segment colours -------------------- */

.seg-mpesa { background: #1a6641; }   /* M-Pesa green / resolved */
.seg-card  { background: var(--primary-container); }  /* Deep blue */
.seg-cod   { background: var(--secondary-container); } /* Gold / review */
.seg-pos   { background: #7b5ea7; }                    /* Violet / in-store POS */
.seg-other { background: var(--outline); }             /* Grey / outside */
.seg-red   { background: var(--error); }               /* Red / unresolved */
/* Customers: new vs repeat — two-tone teal (matches the prototype). */
.seg-new    { background: var(--deep); }               /* new customers */
.seg-repeat { background: var(--primary-container); }  /* repeat customers (teal) */

/* Payment-method % numbers, tinted by method (readable text variants). */
.pt-mpesa { color: #1a6641; }        /* green */
.pt-card  { color: var(--teal); }    /* teal */
.pt-cod   { color: #9a6712; }        /* gold */
.pt-pos   { color: #6b4f95; }        /* violet */
.pt-other { color: var(--muted); }   /* grey */
.pay-zero { color: var(--faint); }   /* a 0% cell — dimmed to cut noise */

/* Segmented toggle (Orders / Revenue on the overall payment mix). */
.seg-toggle { display: flex; gap: 2px; background: var(--line2); border-radius: 9px; padding: 3px; }
.seg-btn { font-family: var(--font-display); font-size: 12px; font-weight: 500;
  color: var(--muted); background: transparent; border: none; border-radius: 7px;
  padding: 4px 10px; cursor: pointer; }
.seg-btn.active { background: #fff; color: var(--deep); box-shadow: var(--shadow-card); }

.pay-bar { display: flex; height: 8px; border-radius: var(--r-full); overflow: hidden;
  background: var(--line2); min-width: 90px; }
.pay-bar > span { height: 100%; }

.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: var(--r-full);
  margin-right: 6px; vertical-align: middle; }

.mix-row { margin-bottom: 12px; }
.mix-row .mix-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.mix-row .mix-head .num { font-variant-numeric: tabular-nums; color: var(--on-variant); }
.mix-track { height: 8px; border-radius: var(--r-full); background: var(--line2); overflow: hidden; }
.mix-track > span { display: block; height: 100%; }

/* Order-mix legend rendered as a compact, aligned table. */
.mix-table th, .mix-table td { padding: 8px 12px; }
.mix-table td .legend-dot { margin-right: 8px; }
.mix-table tbody tr:hover { background: transparent; }  /* legend, not a row list */
.mix-table .mix-total td { border-top: 1px solid var(--line); font-weight: 600; color: var(--deep); }

/* --- Quality tab: resolution cards + inline review queue ----------------- */
.q-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 16px; }
.q-card {
  background: var(--surface-lowest); border: 1px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px 18px;
}
.q-card .qc-label { display: flex; align-items: center; gap: 8px; font-family: var(--font-display);
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; }
.q-card .qc-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--qc); flex: none; }
.q-card .qc-figs { display: flex; align-items: baseline; gap: 8px; }
.q-card .qc-count { font-family: var(--font-display); font-size: 27px; font-weight: 600;
  color: var(--deep); font-variant-numeric: tabular-nums; }
.q-card .qc-pct { font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--qc); }
.q-card .qc-bar { height: 7px; background: var(--line2); border-radius: var(--r-full);
  overflow: hidden; margin: 10px 0 9px; }
.q-card .qc-bar > span { display: block; height: 100%; border-radius: var(--r-full); background: var(--qc); }
.q-card .qc-note { font-size: 12px; color: var(--muted); line-height: 1.35; }
/* Bucket colour, exposed to the card's children via a custom property. */
.q-card.k-resolved   { --qc: var(--teal); }
.q-card.k-review     { --qc: var(--gold); }
.q-card.k-unresolved { --qc: var(--coral); }
.q-card.k-outside    { --qc: var(--muted); }

/* Assign-area select — inline review queue and the standalone review page. */
.rq-select { flex: 1; font-family: var(--font-display); font-size: 12.5px; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface-lowest);
  color: var(--deep); min-width: 88px; }
.rq-select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--tint); }
.rq-raw { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--ink); }

/* --- Account / settings pages -------------------------------------------- */

/* Stacked cards, comfortable reading width. */
.settings-cols { display: flex; flex-direction: column; gap: 16px; max-width: 620px; }

/* Read-only key/value rows inside a card. */
.info-row { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--outline-variant); }
.info-row:first-child { padding-top: 0; }
.info-row:last-child { border-bottom: none; padding-bottom: 0; }
.info-label { font-size: 14px; color: var(--on-variant); }
.info-value { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-align: right; }

/* Security action rows: description on the left, button on the right. */
.action-row { display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--outline-variant); }
.action-row:first-child { padding-top: 0; }
.action-row:last-child { border-bottom: none; padding-bottom: 0; }
.action-title { font-weight: 600; font-size: 16px; }

/* Form cards (change password, add email, logout confirm). */
.form-card { max-width: 480px; }
.settings-cols .form-card { max-width: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Email list rows. */
.email-row { display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--outline-variant); cursor: pointer; }
.email-row:last-of-type { border-bottom: none; }
.email-row input[type="radio"] { margin: 0; flex: 0 0 auto; }
.email-addr { font-weight: 500; margin-right: auto; }

/* --- County-grouped area table ------------------------------------------- */
.data-table tr.county-head td {
  background: var(--thead);
  border-top: 1px solid var(--line);
  font-family: var(--font-display); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--deep); padding-top: 9px; padding-bottom: 9px;
}
.data-table tr.county-head:first-child td { border-top: none; }
/* Indent the area name under its county header. */
.data-table td.area-cell { padding-left: 20px; }

/* "+N more <county> areas" expander row. */
.data-table tr.more-toggle td { padding: 0; }
.more-btn { display: flex; align-items: center; gap: 7px; width: 100%; text-align: left;
  padding: 10px 16px 10px 20px; font-family: var(--font-display); font-size: 12.5px;
  font-weight: 500; color: var(--teal); background: transparent; border: none; cursor: pointer; }
.more-btn:hover { background: var(--tint); }
.more-btn svg { flex: none; transition: transform .15s ease; }
.more-btn.open svg { transform: rotate(90deg); }

/* --- Inline "?" explainer tooltips --------------------------------------- */
/* Hover on desktop; tabindex=0 makes it tap-to-focus on mobile (no hover). */
.info-tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 5px; border-radius: var(--r-full);
  background: var(--surface-container); color: var(--on-variant);
  font-size: 10px; font-weight: 700; line-height: 1; cursor: help;
  vertical-align: middle; text-transform: none; letter-spacing: 0;
  font-variant-numeric: normal;
}
.info-tip::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: 230px;
  background: var(--on-surface); color: var(--surface-lowest);
  font-size: 13px; font-weight: 400; text-transform: none; letter-spacing: 0;
  text-align: left; line-height: 1.35; padding: 8px 10px; border-radius: var(--r-md);
  opacity: 0; pointer-events: none; transition: opacity .12s ease; z-index: 60;
  box-shadow: 0 4px 14px rgba(11, 47, 51, .18);
}
.info-tip:hover::after, .info-tip:focus::after { opacity: 1; }

/* --- Help / FAQ accordion (native <details>, no JS) ---------------------- */
.faq-wrap { max-width: 720px; }
.faq { border-bottom: 1px solid var(--outline-variant); }
.faq summary {
  padding: 15px 4px; font-weight: 600; font-size: 15px; cursor: pointer;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; color: var(--on-surface);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; color: var(--on-variant); font-weight: 400; font-size: 20px;
  line-height: 1; flex: 0 0 auto;
}
.faq[open] summary::after { content: "\2013"; }  /* en dash */
.faq summary:hover { color: var(--primary-container); }
.faq-body {
  padding: 0 4px 16px; color: var(--on-variant); font-size: 14px; line-height: 1.55;
}
