/* ATCMS admin — map-first dispatch board (B5) */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- Sep 30 2026 (operator report) — TEXT SELECTION OFF ----------
 * Same mobile issue as the driver app (v48): tapping any admin text
 * (card titles, school names, audit rows, sheet labels) highlights the
 * word and pops the Android system dictionary / text-selection menu.
 * Global -webkit-user-select:none + -webkit-touch-callout:none kills the
 * long-press selection + the dictionary bubble. Scoped to coarse-pointer
 * (touch-primary) devices ONLY — unlike the driver app (mobile-only,
 * global there), the admin board is desktop-primary and operators
 * legitimately select/copy text (phone numbers, addresses, audit rows)
 * with a mouse; the dictionary popup is a touch-only behaviour.
 * EXEMPT: input/textarea (caret placement, select-all and copy must
 * still work inside form fields — entity modals, login, Mini-Me chat). */
@media (pointer: coarse) {
  * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
  input, textarea {
    -webkit-user-select: auto;
    user-select: auto;
    -webkit-touch-callout: none; /* still no long-press callout inside fields */
  }
}

:root {
  --bg: #101418;
  --panel: #1a2027;
  --panel-2: #212a33;
  --text: #e8eaed;
  --muted: #8a97a3;
  --line: #2c3642;
  --ok: #00c853;
  --watch: #ff9800;
  --alert: #d32f2f;
  --blue: #1976d2;
  --amber: #b0bec5;
}

html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ============ LOGIN ============ */
#login-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(6, 9, 12, 0.96);
  display: flex; align-items: center; justify-content: center;
}
.login-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 36px 32px; width: 320px; text-align: center;
}
.login-box h1 { font-size: 1.8rem; margin-bottom: 4px; letter-spacing: 2px; }
.login-box p { margin-bottom: 24px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; }
.login-box input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 6px; font-size: 1rem;
}
.login-box input:focus { outline: none; border-color: var(--blue); }
.login-box button {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 10px 12px; font-size: 1rem; cursor: pointer; margin-top: 6px;
}
.login-box button:hover { filter: brightness(1.1); }
.login-err { color: var(--alert); margin-top: 12px; min-height: 1em; font-size: 0.9rem; }

/* Sep 22 2026 — taxi Pitfall #90 fork: recovery links + modal on the login overlay */
#login-recover { margin-top: 10px; font-size: 0.85rem; }
#login-recover a, #recover-overlay a { color: var(--muted); text-decoration: none; }
#login-recover a:hover, #recover-overlay a:hover { color: var(--text); text-decoration: underline; }
#recover-overlay {
  position: fixed; inset: 0; z-index: 5001;
  background: rgba(6, 9, 12, 0.96);
  display: flex; align-items: center; justify-content: center;
}

/* ============ LAYOUT ============ */
#main { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 46px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: 1px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ============ Oct 5 2026 — COMPLIANCE BADGE (operator spec) ============
 * Centered in the topbar (absolute center — independent of the brand /
 * nav-block widths). Same icon-btn format as the right-side nav buttons,
 * but the border+icon colour follows the WORST compliance item:
 * green = all ok, amber = something due in 7-31 days, red = <7 days or
 * expired. Bubble = total issue count (topbar-badge shape, docvault
 * precedent). Mobile: the topbar hides the other icon-btns but KEEPS this
 * one (operator: same notification in the center of the mobile bar). */
#btn-compliance {
  position: absolute; left: 50%; transform: translateX(-50%);
}
.comp-btn { position: relative; }
.comp-btn.comp-ok { color: var(--ok); border-color: var(--ok); }
.comp-btn.comp-amber { color: var(--watch); border-color: var(--watch); }
.comp-btn.comp-red { color: var(--alert); border-color: var(--alert); }
#comp-badge { position: absolute; top: -7px; right: -7px; }

/* compliance list popup (Oct 5 2026) — centered modal, same overlay pattern
 * as the audit/docvault modals; severity-coloured rows by urgency */
#comp-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.comp-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: min(480px, 94vw); max-height: 78vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.comp-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.comp-list { overflow-y: auto; padding: 8px; }
.comp-head {
  font-size: 0.78rem; color: var(--muted); padding: 4px 8px 10px;
}
.comp-row {
  display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px;
  align-items: center; padding: 8px 10px; border-radius: 8px;
  border-left: 3px solid transparent; margin-bottom: 4px;
  background: var(--panel-2);
}
.comp-row .comp-drv { font-weight: 600; font-size: 0.85rem; }
.comp-row .comp-item { font-size: 0.85rem; }
.comp-row .comp-when { font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.comp-row.comp-expired { border-left-color: var(--alert); }
.comp-row.comp-critical { border-left-color: var(--alert); }
.comp-row.comp-critical .comp-when { color: var(--alert); }
.comp-row.comp-soon { border-left-color: var(--watch); }
.comp-row.comp-soon .comp-when { color: var(--watch); }
.comp-row.comp-expired .comp-when { color: var(--alert); }
.comp-row.comp-none { display: block; text-align: center; color: var(--ok); font-weight: 600; }
.dot-on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-off { background: #556; }

.icon-btn {
  background: var(--panel-2); color: #ffffff; border: 1px solid var(--line);
  border-radius: 6px; width: 32px; height: 30px; cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--blue); }
.icon-btn svg { display: block; } /* inline SVG icons — pure white via currentColor */

/* ============ Oct 5 2026 — PER-DAY ADDRESS OVERRIDE (operator spec) =====
 * The 📍 chip button opens the per-leg override panel: every child gets
 * Home / authorised / ➕ Different address + a MANDATORY safeguard note.
 * Self-contained (own backdrop/panel ids — no dependency on the drawer
 * or entity-modal selectors). */
#addr-ovr-backdrop {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(6, 9, 12, 0.55);
  display: flex; justify-content: flex-end;
}
#addr-ovr-panel {
  width: 420px; max-width: 100vw; height: 100%;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
}
#addr-ovr-panel .drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
#addr-ovr-panel .drawer-head h2 { font-size: 1.05rem; }
.addr-ovr-body { overflow-y: auto; padding: 14px 16px; }
.addr-ovr-body .small { font-size: 0.85rem; margin-bottom: 12px; display: block; line-height: 1.45; }
.addr-ovr-row {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 12px;
  display: grid; gap: 8px;
}
.aor-kid { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aor-locked { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.aor-current { font-size: 0.8rem; color: var(--ok); font-weight: 600; }
.aor-select, .aor-note, .aor-label, .aor-addr {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 0.9rem; width: 100%;
}
.aor-select:focus, .aor-note:focus, .aor-label:focus, .aor-addr:focus { outline: none; border-color: var(--blue); }
.aor-manual { display: grid; gap: 8px; }
.aor-manual.hidden, .aor-note.hidden { display: none !important; }
.aor-addr-hint { font-size: 0.78rem; margin-top: -2px; }
.aor-save { background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 9px 12px; font-size: 0.9rem; cursor: pointer; justify-self: end; }
.aor-save:hover { filter: brightness(1.1); }
.aor-save:disabled { opacity: 0.5; cursor: not-allowed; }
/* the 📍 chip button — same compact style as the driver +/✕ toggles */
.lc-addr-btn { font-size: 13px; line-height: 1; }

#board { flex: 1 1 auto; display: flex; min-height: 0; }

/* ============ MAP ============ */
#map-wrap { flex: 1 1 auto; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

/* Sep 23 2026 — kill ALL native Google Maps controls. The API options
   (zoomControl/fullscreenControl/rotateControl/tiltControl: false) cover the
   classic controls, but the VECTOR map still renders an internal camera
   control (<gmp-internal-camera-control>, bottom-right compass) that ignores
   them in some library versions. These selectors hide every control surface
   by class + tag, so no version renders native UI on our board. */
#map .gm-style .gm-bundled-control,
#map .gm-style .gm-svpc,
#map .gm-style .gmnoprint,
#map .gm-style .gm-style-mtc,
#map gmp-internal-camera-control,
#map .gm-style div[title^="Map camera"],
#map .gm-style div[title^="Toggle fullscreen"],
#map .gm-style div[title^="Zoom in"],
#map .gm-style div[title^="Show street map"],
#map .gm-style div[title^="Show satellite imagery"] {
  display: none !important;
}
#map-revert-note {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-size: 0.85rem; z-index: 10; pointer-events: none;
}

/* Sep 25 2026 (late-3) — floating map control button (traffic toggle).
   Sits top-right INSIDE #map-wrap so it scrolls with the map pane; above
   the map tiles + all native (hidden) controls. The [aria-pressed=true]
   state carries the ACTIVE look (amber ring) — no JS class juggling. */
.map-ctrl-btn {
  position: absolute; top: 12px; right: 12px; z-index: 30;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2, #141a21); color: var(--text, #e8eaed);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  padding: 0;
}
.map-ctrl-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
.map-ctrl-btn:active { transform: translateY(0); }
.map-ctrl-btn[aria-pressed="true"] {
  border-color: #ff9800;
  box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.35), 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* Sep 30 2026 — MAP COLOUR LEGEND. The 🎨 toggle sits BELOW the 🚦
   traffic button (top-right stack); the legend panel slides under it.
   Dark translucent panel matching the map controls; swatches mirror
   the live pin colours; taxi rows use the emoji tinted by status. */
#map-legend-toggle { top: 58px; }
#map-legend {
  position: absolute; top: 106px; right: 12px; z-index: 29;
  min-width: 210px; max-width: 260px; max-height: 60vh; overflow-y: auto;
  background: rgba(15, 20, 26, 0.92); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  font-size: 0.78rem; color: var(--text, #e8eaed);
}
#map-legend-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 6px; font-weight: 600; letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
}
#map-legend-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
#map-legend-body { padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.ml-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-swatch {
  width: 13px; height: 13px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); flex: none; border: 1.5px solid #fff;
  margin-right: 2px;
}
.ml-taxi { font-size: 1rem; flex: none; }
.ml-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* ============ SIDEBAR ============ */
#sidebar {
  /* Oct 4 2026 — widened 340px → 480px to match the entity menu (#ent):
   * one consistent panel width across the board (operator request). The
   * cards stretch to fill; the RAG filter pills center in the header. */
  flex: 0 0 480px; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line); min-height: 0;
}
#cards-header {
  padding: 12px 14px 8px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
#cards-header h2 { font-size: 1.05rem; }
/* Oct 4 2026 (round 5) — operator follow-up: "the padding needs to be the
 * same inbetween the pills and on the left of the green pill, and the
 * right of the all pill". space-between left the OUTER gaps at the
 * header's padding (~20px) while the inner gaps ballooned (~70px).
 * space-evenly makes ALL FIVE gaps equal; the negative side margins
 * cancel #cards-header's 14px so the even distribution spans the FULL
 * panel width edge to edge. gap:0 — any gap would add on top of the
 * evenly-spaced distribution and skew the outer gaps again. */
/* Oct 4 2026 (round 6) — operator request: "move the all filter button to
 * the left and shift the green, orange and red buttons to the right, so
 * in order we have all, green, orange, red". DOM order in admin.html is
 * now all → green → orange → red; the even edge-to-edge distribution
 * from round 5 (space-evenly, gap:0, -14px side margins) is KEPT —
 * only the order changed, so all five gaps stay equal with "all" first
 * at the left edge and red last at the right edge. */
/* Oct 4 2026 (round 7) — operator follow-up: "the filter pills are now
 * not evenly aligned across the width of the panel". Round 6 wrongly
 * switched to a left-anchored "all" + right-packed RAG group (auto
 * margin), which broke the even spread the operator approved in
 * round 5. RESTORED: space-evenly + gap:0 + the -14px side margins —
 * all five gaps (left edge, between pills, right edge) equal again.
 * The pill ORDER change (all first) is the only thing that stays. */
#cards-legend { display: flex; justify-content: space-evenly; gap: 0; margin: 8px -14px 0; padding: 0; align-items: center; }
.pill {
  padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  color: #101418;
}
.pill-ok { background: var(--ok); }
.pill-watch { background: var(--watch); }
.pill-alert { background: var(--alert); color: #fff; }

/* Sep 22 2026 — legend pills are interactive FILTER buttons now. Same colours
   when idle; the active filter gets a ring + slight lift so the operator can
   see at a glance which filter is on. legend-all is the neutral "show all". */
.legend-btn {
  border: 2px solid transparent; cursor: pointer; font-family: inherit;
  transition: transform 0.1s, box-shadow 0.1s;
}
.legend-btn:hover { transform: translateY(-1px); }
.legend-btn.legend-on {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.45);
}
.legend-all { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.legend-all.legend-on { background: var(--blue); color: #fff; }

#cards { flex: 1 1 auto; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.cards-empty {
  color: var(--muted); text-align: center; padding: 26px 10px; font-size: 0.9rem;
  border: 1px dashed var(--line); border-radius: 8px;
}

/* contract card = AM + PM grouped (D4).
   Sep 23 2026 — card body is NOT clickable (only the AM/PM chips are) —
   no pointer cursor; hover tint kept as a subtle affordance of the chips. */
.run-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 4px solid var(--muted); border-radius: 8px; padding: 10px 12px;
  transition: border-color 0.15s;
}
.run-card:hover { border-color: var(--blue); }
.run-card.st-green { border-left-color: var(--ok); }
.run-card.st-orange { border-left-color: var(--watch); }
.run-card.st-red { border-left-color: var(--alert); }

.rc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rc-route { font-weight: 600; font-size: 0.98rem; }
.rc-school { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.rc-status {
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700;
  white-space: nowrap; color: #101418;
  display: inline-flex; align-items: center; justify-content: center;
}
/* Sep 23 2026 (late) — operator request: the status TEXT next to the card's
   coloured highlight duplicated the status. The pill is now a pure colour
   DOT (title tooltip still names the status); UNASSIGNED keeps its text
   since it isn't colour-coded anywhere else. */
.rc-status .rc-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
}
/* Sep 23 2026 (late, fix) — the drawer's status pill previously reused
   .rc-status.st-* — the card's "dot-only" restyle made it transparent/broken
   there. The drawer now uses its OWN pill class with proper solid colours. */
.dr-pill {
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 700; white-space: nowrap; color: #101418;
}
.dr-pill.p-green { background: var(--ok); }
.dr-pill.p-orange { background: var(--watch); }
.dr-pill.p-red { background: var(--alert); color: #fff; }
.rc-status.st-green { background: transparent; }
.rc-status.st-green .rc-dot { background: var(--ok); }
.rc-status.st-orange { background: transparent; }
.rc-status.st-orange .rc-dot { background: var(--watch); }
.rc-status.st-red { background: transparent; }
.rc-status.st-red .rc-dot { background: var(--alert); }
.rc-status.st-unassigned { background: #546e7a; color: #fff; }

.rc-legs { display: flex; gap: 8px; margin-top: 8px; }
.leg-chip {
  flex: 1; background: rgba(255, 255, 255, 0.04); border-radius: 6px;
  padding: 6px 8px; font-size: 0.8rem;
  /* Sep 23 2026 — chips are clickable (open that leg's drawer for
     per-leg driver assignment) — show pointer + hover affordance */
  cursor: pointer;
}
.leg-chip:hover { background: rgba(255, 255, 255, 0.09); outline: 1px solid var(--line); }
/* Sep 23 2026 (late) — instant click-ack: drawer opens after its fetches;
   this keeps the chip visibly responsive in the gap */
.leg-chip.lc-loading { outline: 2px solid var(--blue); background: rgba(31, 111, 235, 0.12); }
/* Oct 4 2026 (round 4) — operator request: the AM / PM chip labels in
   WHITE font (were muted grey) and CENTERED in their respective chips. */
.leg-chip .lc-title { font-weight: 700; font-size: 0.72rem; color: #fff; text-align: center; }
.leg-chip .lc-state { margin-top: 2px; }
.leg-chip .lc-driver { font-size: 0.75rem; color: var(--amber); margin-top: 2px;
  display: flex; align-items: center; gap: 6px; min-width: 0; }
/* Sep 23 2026 (late) — "unassigned" reads like a status echo in amber;
   muted grey instead (it's driver info, the chip's white state line above
   already carries the actual status). */
.leg-chip .lc-driver.none { color: var(--muted); }
.leg-chip .lc-driver .lc-drv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
/* Sep 23 2026 (late) — compact assign(+)/unassign(✕) toggle riding the
   driver line (operator request: drawer buttons redundant with the chip) */
.lc-drv-btn {
  flex: 0 0 auto; width: 22px; height: 22px; line-height: 1; border-radius: 6px;
  border: 1px solid var(--line); background: var(--blue); color: #fff;
  font-size: 0.8rem; font-weight: 700; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.lc-drv-btn.secondary { background: transparent; color: var(--alert); }
.lc-drv-btn:hover { filter: brightness(1.15); }
.leg-chip .lc-sched { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.leg-chip.done { opacity: 0.55; }
.leg-chip.done .lc-title::after { content: " ✓"; color: var(--ok); }

.rc-reason { font-size: 0.75rem; color: var(--watch); margin-top: 6px; }
.rc-findbtn {
  margin-top: 8px; width: 100%; background: var(--blue); color: #fff; border: none;
  border-radius: 6px; padding: 7px 10px; font-size: 0.85rem; cursor: pointer;
}
.rc-findbtn:hover { filter: brightness(1.1); }

/* ============ DRAWER (run detail) ============ */
#drawer-backdrop, #cog-backdrop, #ent-backdrop, #audit-backdrop, #docs-backdrop {
  position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, 0.45);
}
#drawer, #cog, #ent, #audit, #docvault {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 3100;
  width: 480px; max-width: 92vw;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
}

/* ATCMS-#61 FIX (Sep 26 2026) — Google Places autocomplete dropdown
 * (.pac-container) is appended to <body> by the Maps API with its own
 * default z-index of 1000, which puts it BEHIND the entity drawers
 * (3100) and their backdrops (3000) — the user typed, predictions
 * loaded, but the list rendered invisibly behind the modal. Pin it
 * above every admin overlay except the trip-replay (10000, which has
 * no address inputs). */
.pac-container {
  /* Oct 5 2026 — raised 3999 → 4999: the address-override overlay
   * (#addr-ovr-backdrop) sits at z-index 4000, which put the Places
   * dropdown BEHIND the very panel that hosts the search field — the
   * classic ATCMS-#61 lesson re-bitten by a new higher-layered modal.
   * 4999 clears every overlay (backdrop 4000, login 5000 family is
   * exclusive to auth screens where no address search exists). */
  z-index: 4999 !important;
  pointer-events: auto !important;
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.drawer-head h2 { font-size: 1.1rem; }

#dr-body, #cog-body, #ent-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }
#audit-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }
#docvault-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px; }

/* Sep 23 2026 — audit log rows (operator rule: comprehensive logging) */
.audit-row {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-size: 0.78rem; line-height: 1.35;
}
.audit-row.audit-crash { background: rgba(179, 38, 30, 0.08); }
.audit-ts { color: var(--muted, #9aa4ad); flex: 0 0 118px; }
.audit-type { font-weight: 600; flex: 0 0 130px; }
.audit-detail { flex: 1 1 60%; word-break: break-word; }
.audit-who { color: var(--muted, #9aa4ad); flex: 0 0 auto; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dr-section { margin-bottom: 18px; }
.dr-section h3 {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 8px;
}
.dr-state { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.dr-state .state-name { font-size: 1.05rem; font-weight: 700; }
.dr-state .state-since { font-size: 0.8rem; color: var(--muted); }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 10px; font-size: 0.88rem; }
.kv dt { color: var(--muted); }
.kv dd { word-break: break-word; }

/* signoff checklist */
.so-gate-title {
  font-size: 0.78rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 10px 0 4px 0;
}
.so-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px;
  border-bottom: 1px solid var(--line);
}
.so-check { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.so-row.signed .so-check { background: var(--ok); border-color: var(--ok); }
.so-row.signed .so-check::after { content: "✓"; color: #101418; font-weight: 900; }
.so-row.no-show .so-check { background: var(--alert); border-color: var(--alert); }
.so-row.no-show .so-check::after { content: "✗"; color: #fff; font-weight: 900; }
.so-name { font-size: 0.9rem; flex: 1; }
.so-name .so-stop { display: block; font-size: 0.75rem; color: var(--muted); }
/* Oct 5 2026 — per-day address override on the drawer signoff row (green) */
.so-name .so-stop.so-stop-ovr { color: var(--ok); font-weight: 600; }
.so-time { font-size: 0.75rem; color: var(--muted); }
/* Sep 26 2026 (ATCMS-#56a) — drawer order badge: the #N ordinal in which
   each child was signed in the leg (pickup order AM / dropoff order PM).
   Amber = no-show position in the sequence. */
.so-order-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 20px; padding: 0 5px; margin-right: 7px;
  border-radius: 999px; font-size: 0.7rem; font-weight: 800;
  background: rgba(46, 125, 50, 0.16); color: var(--ok);
  vertical-align: middle;
}
.so-order-badge.amber { background: rgba(255, 152, 0, 0.16); color: #ffb74d; }

/* ============ ATCMS-#56c (Sep 26 2026) — TRIP REPLAY overlay ============ */
#replay-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: #000;
}
#replay-overlay.hidden { display: none; }
#replay-map { position: absolute; inset: 0; }
#replay-controls {
  position: absolute; top: 14px; left: 14px; z-index: 10;
  background: rgba(20, 26, 33, 0.92); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  max-width: 330px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
}
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.rp-head strong { font-size: 0.95rem; }
#replay-close {
  background: none; border: none; color: #ff5252; font-size: 1.15rem;
  cursor: pointer; line-height: 1; padding: 0 2px;
}
.rp-status { color: var(--muted); font-size: 0.78rem; margin-bottom: 10px; min-height: 1em; }
.rp-key { margin-bottom: 10px; }
.rp-key-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-bottom: 4px; }
.rp-key-grad { height: 11px; border-radius: 6px; background: linear-gradient(to right, hsl(240,90%,50%), hsl(0,90%,50%)); }
.rp-speeds { display: flex; gap: 6px; margin-bottom: 8px; }
.rp-speed {
  flex: 1; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 0; cursor: pointer; font-size: 0.8rem; font-weight: 700;
}
.rp-speed.active { background: #2196F3; border-color: #2196F3; color: #fff; }
.rp-note { font-size: 0.72rem; color: var(--muted); line-height: 1.45; }
/* cog date-picker + trips list (inside #cog-body) */
.cog-replay-section { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.cog-replay-section h3 { font-size: 0.85rem; margin-bottom: 6px; }
/* ATCMS-#65a — users section in the cog drawer (taxi Users tab fork) */
.cog-users-section { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.cog-users-section h3 { font-size: 0.85rem; margin-bottom: 6px; }
.cog-users-section table { background: transparent; }
.cog-users-section td, .cog-users-section th { border-bottom: 1px solid var(--line); }
.cog-users-section select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px;
  color: var(--text); padding: 3px 5px; font: inherit; font-size: 0.8rem;
}
/* Sep 28 2026 — "+ Add a new user" form: match system look/feel (was bare
   browser-default white boxes). Same recipe as .ent-field: panel bg, line
   border, 6px radius; summary styled as a cog button; password input
   inherits color-scheme dark. */
.cog-users-add details { margin-top: 8px; }
.cog-users-add summary {
  cursor: pointer; font-weight: 600; font-size: 0.8rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); padding: 6px 10px; display: inline-block; user-select: none;
  list-style: none;
}
.cog-users-add summary::-webkit-details-marker { display: none; }
.cog-users-add summary::before { content: "+ "; color: var(--blue); }
.cog-users-add summary:hover { border-color: var(--blue); }
.cog-users-add input, .cog-users-add select {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 7px 9px; border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.cog-users-add input:focus, .cog-users-add select:focus { outline: none; border-color: var(--blue); }
.cog-users-add input[type="password"] { color-scheme: dark; }
.cog-users-add .uu-add-field { display: flex; flex-direction: column; gap: 3px; }
.cog-users-add .uu-add-field label { font-size: 0.75rem; color: var(--muted); }
/* ATCMS-#65b — danger zone (factory reset) in the cog drawer */
.cog-reset-section { margin-top: 14px; border-top: 1px solid #D32F2F; padding-top: 10px; }
.cog-reset-section h3 { font-size: 0.85rem; margin-bottom: 6px; color: #D32F2F; }
.rp-date-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.rp-date-row input[type="date"] {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit;
  color-scheme: dark; /* Sep 28 2026 — white calendar picker icon on dark panel */
}
.rp-date-row button {
  background: #2196F3; border: none; color: #fff; border-radius: 6px;
  padding: 6px 12px; cursor: pointer; font: inherit; font-weight: 600;
}
/* Sep 28 2026 — month-end section controls match the cog look+feel */
.rp-date-row input[type="month"] {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit;
  color-scheme: dark; /* white calendar icon, same as the replay date field */
}
#me-driver, .me-driver-select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit;
  margin-bottom: 8px;
}
.rp-trip-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.rp-trip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; text-align: left; width: 100%;
  color: var(--text); font: inherit;
}
.rp-trip:hover { border-color: #2196F3; }
.rp-trip .rp-trip-main { font-size: 0.82rem; font-weight: 600; }
.rp-trip .rp-trip-sub { font-size: 0.72rem; color: var(--muted); }
.rp-trip .rp-trip-pts { font-size: 0.7rem; color: var(--muted); flex: 0 0 auto; }

/* events feed */
.ev-row { padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.82rem; }
.ev-time { color: var(--muted); margin-right: 8px; font-family: monospace; }

/* drawer buttons */
.dr-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.dr-btn {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 0.88rem; cursor: pointer;
}
.dr-btn.danger { background: var(--alert); }
.dr-btn.secondary { background: var(--panel-2); border: 1px solid var(--line); }
.dr-btn:hover { filter: brightness(1.12); }

/* Sep 23 2026 — assign-driver dropdown picker (replaces the raw prompt()).
   Shows only AVAILABLE drivers: active + not already on another run in the
   SAME leg today. */
.dr-assign-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.dr-select {
  flex: 1 1 160px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 0.85rem; font-family: inherit;
}

/* Oct 4 2026 — KPI section dropdowns (operator feedback: match the
   system look/feel — same recipe as .dr-select / .cog-users select,
   was browser-default). color-scheme dark keeps the arrow + popup
   panel dark in every browser. */
.kpi-select {
  flex: 1 1 160px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font-size: 0.85rem; font-family: inherit;
  color-scheme: dark;
}
.kpi-select:focus { outline: none; border-color: var(--blue); }
.kpi-select:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============ COG ============ */
.cog-setting { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.cog-label { font-size: 0.88rem; }
.cog-label .cog-sub { display: block; font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.cog-setting input[type=number], .cog-setting input[type=text] {
  width: 110px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 6px 8px; border-radius: 6px; text-align: right; font-size: 0.9rem;
}
.cog-setting input[type=text] { width: 180px; text-align: left; }
.cog-setting input[type=checkbox] { width: 18px; height: 18px; }
.cog-badges { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.cog-badge { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 0.8rem; }
.cog-badge b { display: block; font-size: 1.05rem; margin-top: 2px; }
#cog-save {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 10px 16px; font-size: 0.95rem; cursor: pointer; margin-top: 12px; width: 100%;
}
#cog-save:disabled { opacity: 0.5; cursor: default; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ MOBILE BOTTOM NAV (Sep 24 2026) ============
 * NOTE: these base styles MUST stay ABOVE the @media (max-width: 900px)
 * mobile-pass block — the media query flips #bottom-nav to display:flex and
 * equal-specificity selectors resolve by SOURCE ORDER. Having the base
 * block after the media block made display:none win everywhere (caught in
 * live browser verification, Sep 24). */
#bottom-nav {
  display: none; /* desktop: none — topbar owns everything */
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  z-index: 100;
}
.nav-btn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 0.68rem; font-family: inherit; cursor: pointer;
  padding: 4px 14px; border-radius: 10px;
  position: relative; min-width: 64px;
}
.nav-btn svg { display: block; }
.nav-btn.nav-on { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-btn:active { transform: scale(0.96); }
/* red/orange count badge on the Jobs tab — surface alerts without opening Jobs */
.nav-badge {
  position: absolute; top: 2px; right: 8px;
  background: var(--alert); color: #fff; border-radius: 999px;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px; line-height: 1.1;
}

/* ============ MOBILE "MORE" SHEET (Sep 24 2026) ============ */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 3200;
  background: rgba(0, 0, 0, 0.45);
}
#more-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3300;
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}
.sheet-grab {
  width: 42px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 2px auto 8px auto;
}
.sheet-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); text-align: center; margin-bottom: 8px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sheet-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: 0.72rem; font-family: inherit;
}
.sheet-btn:active { filter: brightness(1.2); }
.sheet-btn.sheet-logout { color: var(--alert); }
/* narrow phones: 2 rows of 4 → fits 7 items + logout with breathing room */
@media (max-width: 420px) {
  .sheet-grid { gap: 7px; }
  .sheet-btn { padding: 8px 2px; font-size: 0.66rem; }
}

/* ============ SCHOOL PIN POPUP (Sep 25 2026) ============
 * Click a school marker → small themed popup: contact phone/email,
 * contract count, today's completed / in-transit runs, late-driver count.
 * Absolutely positioned over #map (container-pixel coordinates from the
 * Maps projection), closes on × / map click / Jobs view switch. */
#school-popup {
  position: absolute; z-index: 2500;
  min-width: 210px; max-width: 290px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
  padding: 10px 12px; display: none;
  font-size: 0.82rem; color: var(--text);
  /* pointer-events only when open (absolute overlay must never block the
     map when hidden) */
  pointer-events: none;
}
#school-popup.open { display: block; pointer-events: auto; }
.sp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sp-title { font-weight: 700; font-size: 0.92rem; overflow-wrap: anywhere; }
.sp-close {
  background: none; border: none; color: var(--muted); font-size: 1.05rem;
  cursor: pointer; padding: 0 2px; line-height: 1; flex: 0 0 auto;
}
.sp-close:hover { color: #fff; }
.sp-contact { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.sp-contact a { color: #8ab4f8; text-decoration: none; overflow-wrap: anywhere; }
.sp-contact a:hover { text-decoration: underline; }
.sp-contact.sp-none { color: var(--muted); font-size: 0.74rem; font-style: italic; }
/* ATCMS-#56e (Sep 26 2026) — kids-home popup: per-child block with the
   responsible adults (name + relationship + phone) under each name. */
.kh-kid {
  margin-top: 8px; padding: 7px 9px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px;
}
.kh-name { font-weight: 700; font-size: 0.86rem; }
.kh-adults { margin-top: 3px; font-size: 0.78rem; color: var(--text); line-height: 1.45; }
.kh-adults a { color: #8ab4f8; text-decoration: none; }
.kh-adults a:hover { text-decoration: underline; }
.kh-adults.kh-none { color: var(--muted); font-style: italic; }
.sp-stats {
  margin-top: 8px; display: grid; grid-template-columns: repeat(4, auto);
  gap: 6px; justify-content: start; align-items: center;
}
.sp-stat {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 9px; min-width: 46px;
}
.sp-stat b { font-size: 0.95rem; line-height: 1.1; }
.sp-stat span { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
button.sp-stat.sp-late {
  cursor: pointer; color: #fff; font: inherit;
  background: var(--alert); border-color: var(--alert);
  animation: sp-late-pulse 1.2s ease-in-out infinite;
}
button.sp-stat.sp-late b { font-size: 0.95rem; }
button.sp-stat.sp-late:hover { filter: brightness(1.15); }
@keyframes sp-late-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(211, 47, 47, 0); }
}
/* narrow phones: shrink the popup + stat chips */
@media (max-width: 420px) {
  #school-popup { min-width: 190px; max-width: 250px; font-size: 0.78rem; }
  .sp-stats { gap: 4px; }
  .sp-stat { padding: 3px 7px; min-width: 42px; }
}

/* small screens */
@media (max-width: 900px) {
  #sidebar { flex-basis: 300px; }

  /* ============ MOBILE PASS (Sep 24 2026) ============
     Two alternating views on phones: MAP (full-height Google Map) + JOBS
     (full-height cards list), switched by the bottom nav. The 700px split
     map/cards layout is GONE (half of each was useless on a phone). */
  /* dvh: mobile address bar shrinks vh mid-session — dvh tracks the REAL
     viewport; #main uses 100dvh with a 100vh fallback. */
  #main { height: 100vh; height: 100dvh; }

  #bottom-nav { display: flex; }
  #board { flex-direction: column; }
  /* map view: map fills, sidebar hidden (display:none keeps Google Maps
     happy — a 0x0 container renders blank + mis-places labels) */
  body.mview-map #map-wrap { flex: 1 1 auto; }
  body.mview-map #sidebar { display: none; }
  /* jobs view: cards fill, map hidden — Google Maps inside display:none
     holds stale tile sizes; trigger resize on switch (admin.js does). */
  body.mview-jobs #map-wrap { display: none; }
  body.mview-jobs #sidebar { flex: 1 1 auto; border-left: none; border-top: none; }

  /* topbar trims to brand + status dot + logout only; entity buttons live
     in the More sheet (they were 6 cramped 32px targets in a 46px bar) */
  #topbar { padding: 0 10px; }
  .top-right { gap: 6px; }
  #topbar .icon-btn { display: none; }
  #topbar #btn-logout { display: inline-flex; }
  /* Oct 5 2026 — compliance badge stays visible on mobile (centered) */
  #topbar #btn-compliance { display: inline-flex; }
  #top-date { display: none; }

  /* drawers/modals: full-screen sheets on mobile */
  #drawer, #cog, #ent, #audit, #docvault {
    width: 100vw; max-width: 100vw; border-left: none;
  }

  /* toasts clear the bottom nav (44px + safe-area inset) */
  .ui-toast, .toast-run-gen {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* gmaps fallback banner too (inline-styled → needs !important) */
  #gmaps-fallback { padding-bottom: calc(12px + 44px + env(safe-area-inset-bottom, 0px)) !important; }

  .login-box { width: min(320px, 88vw); padding: 28px 20px; }

  /* audit rows: fixed 118px + 130px columns eat 248px of a ~360px screen
     before the detail starts — stack vertically on phones instead */
  .audit-row { flex-direction: column; gap: 2px; padding: 8px 6px; }
  .audit-ts, .audit-type, .audit-who { flex-basis: auto; max-width: 100%; }
  .audit-detail { flex-basis: auto; }

  /* cog rows: number/text inputs 110-180px wide can push past the label on
     narrow screens — let the row wrap + inputs flex */
  .cog-setting { flex-wrap: wrap; }
  .cog-setting input[type=number], .cog-setting input[type=text] { width: 130px; }

  /* cards header legend pills: 4 pills in a row scroll off-screen on narrow
     phones — wrap + shrink. Oct 4 round 7: even edge-to-edge spread
     restored (space-evenly); on wrap the distribution re-flows evenly
     across the wrapped lines. */
  #cards-legend { flex-wrap: wrap; row-gap: 6px; }

  /* drawer key-value grid: 130px label column is over half a narrow phone */
  .kv { grid-template-columns: 100px 1fr; font-size: 0.84rem; }

  /* entity tabs wrap on narrow screens (3 tabs + padding fit at ~360px, but
     320px devices need the wrap) */
  .ent-tabs { gap: 2px; }
  .ent-tab { padding: 6px 8px; font-size: 0.78rem; }

  /* drawer action buttons + assign picker: stack full-width on phones */
  .dr-actions .dr-btn { flex: 1 1 auto; padding: 10px 12px; font-size: 0.9rem; }
  .dr-assign-picker { flex-direction: column; align-items: stretch; }
  .dr-select { flex-basis: auto; width: 100%; }

  /* signoff rows: name + stop + time can cramp — smaller gap, wrap time */
  .so-row { gap: 8px; padding: 9px 6px; }
  .so-time { white-space: nowrap; }

  /* Oct 4 2026 (round 8) — operator report: "in mobile view, the child,
     school and contract cards are not well visible, as the left column,
     which is the name, is condensed to just one character, therefore over
     multiple lines". Classic side-by-side .ent-row: .ent-actions is
     flex:0 0 auto (never shrinks) so 3-4 buttons (~200px+) + the status
     pill eat a ~360px screen, and .ent-main (min-width:0, shrinkable)
     collapses to a sliver — .ent-name wraps one CHARACTER per line
     (overflow-wrap:anywhere). STACK exactly like the driver cards (Sep 25
     later-4 pattern): the renderer now wraps name + status pill in
     .ent-head, so here the row becomes header line (name … pill, full
     width) + action buttons wrapping UNDER it. Driver rows already
     stack (.ent-row-driver) — untouched. */
  .ent-row:not(.ent-row-driver) { flex-direction: column; align-items: stretch; gap: 8px; }
  .ent-row:not(.ent-row-driver) .ent-actions { flex-wrap: wrap; flex: 0 1 auto; }
  /* Oct 4 2026 (round 9) — STALE-JS DEFENSE: a device that loaded mid-deploy
     (Sep 21 pitfall: html no-store but /static/ caches 24h PER URL) can run
     the OLD row template where the status pill is a DIRECT child of the
     stacked row — align-items:stretch then spans its border the whole
     width (operator report 14:01: "the 'active' section border is the
     whole width, instead of just around the word"). Direct-child pills
     hug their content again; the current template's pill lives inside
     .ent-head (not a direct child) and is unaffected. */
  .ent-row > .ent-tag { align-self: flex-start; }
}

/* ============ ENTITY MANAGER (drivers / schools / contracts — Sep 21 2026) ============ */
.ent-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-bottom: 1px solid var(--line); border-radius: 6px;
}
.ent-row:hover { background: var(--panel-2); }
/* Sep 25 2026 (later-4) — driver cards stack: full-width name header line
 * (name + ID + pills) with the action buttons UNDER it, aligned left.
 * Operator report: the classic side-by-side row squeezed the name to a
 * sliver once the Resend invite button joined Edit/Toggle/Password/Docs.
 * Oct 4 2026 (round 8) — schools/contracts/students rows now use the
 * SAME .ent-head wrapper (see admin.js renderEntityList): desktop keeps
 * the classic side-by-side look (name … pill … buttons), mobile stacks
 * via the max-width:900px media query. */
.ent-row-driver { flex-direction: column; align-items: stretch; gap: 8px; }
.ent-row .ent-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; min-width: 0; flex: 1 1 auto;
}
.ent-row-driver .ent-actions { flex-wrap: wrap; }
.ent-main { flex: 1 1 auto; min-width: 0; }
.ent-name { font-size: 0.92rem; font-weight: 600;
  /* Sep 25 2026 — driver rows label with the driver_id: a single unbreakable
     token that painted OVER the green Active pill on mobile (ent-main has
     min-width:0 so the name div shrinks, but overflow:visible let the text
     spill). Wrap mid-token instead — no info lost to ellipsis. */
  overflow-wrap: anywhere; }
.ent-sub { font-size: 0.76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.ent-tag {
  font-size: 0.68rem; border-radius: 4px; padding: 2px 7px; white-space: nowrap;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.ent-tag.off { color: var(--alert); border-color: var(--alert); }
.ent-tag.on { color: var(--ok); border-color: var(--ok); }
/* Sep 25 2026 (onboarding) — amber progress chip on non-onboarded drivers */
.ent-tag.ob-progress { color: var(--warn); border-color: var(--warn); margin-top: 4px; display: inline-block; }
/* Sep 26 2026 (operator request) — driver-app login ID chip inline with the
 * driver name on the Drivers manager cards ("which number is which driver") */
.ent-tag.drv-id-chip {
  color: var(--blue); border-color: var(--blue); font-size: 0.66rem;
  vertical-align: middle; margin-left: 6px;
}
.ent-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.ent-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 5px 10px; font-size: 0.8rem; cursor: pointer;
}
.ent-btn:hover { filter: brightness(1.15); }
.ent-btn.danger { color: var(--alert); border-color: var(--alert); }
#ent-add {
  background: var(--blue); color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 0.88rem; cursor: pointer; margin: 4px 0 12px 0; width: 100%;
}
.ent-form {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.ent-form h4 { margin: 0 0 10px 0; font-size: 0.9rem; }
.ent-field { margin-bottom: 9px; }
.ent-field label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 3px; }
.ent-field input, .ent-field select {
  width: 100%; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 7px 9px; border-radius: 6px; font-size: 0.9rem;
}
.ent-form-buttons { display: flex; gap: 8px; margin-top: 12px; }
.ent-form-buttons .ent-btn { padding: 8px 14px; font-size: 0.88rem; flex: 1; }
.ent-form-buttons .ent-btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.ent-form-buttons .ent-btn.danger:hover { background: var(--alert); color: #fff; }
.ent-empty { color: var(--muted); font-size: 0.85rem; padding: 18px 0; text-align: center; }

/* ---- entity search box (Sep 22 2026): fast lookup in every entity modal ---- */
.ent-search { margin: 2px 0 10px 0; }
.ent-search input {
  width: 100%; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 6px; font-size: 0.9rem;
}
.ent-search input:focus { outline: none; border-color: var(--blue); }

/* ---- contract children manager (Sep 22 2026) ---- */
/* Sep 28 2026 — cover-run badges: a run assigned to anyone other than the
   contract's usual (default) driver. Amber pill on the chip + drawer. */
.lc-cover-tag {
  display: inline-block; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.4px;
  background: #b36b00; color: #fff; border-radius: 4px; padding: 1px 5px;
  vertical-align: middle; margin-left: 2px;
}
.dr-cover-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px;
  background: #b36b00; color: #fff; border-radius: 5px; padding: 2px 7px; margin-left: 6px;
}

.ent-kids-attached { display: flex; flex-direction: column; gap: 5px; }
.ent-kid-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; font-size: 0.88rem;
}

/* ---- driver 3-tab layout (Sep 22 2026): demographics / compliance / vehicle ---- */
.ent-tabs {
  display: flex; gap: 4px; margin: 0 0 12px 0;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; flex-wrap: wrap;
}
.ent-tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 6px 6px 0 0; padding: 6px 10px; font-size: 0.82rem; cursor: pointer;
}
.ent-tab:hover { color: var(--text); }
.ent-tab.active {
  color: var(--text); border-color: var(--line); border-bottom-color: var(--panel-2);
  background: var(--panel); font-weight: 600;
}
.ent-tabpane { padding-top: 2px; }
.ent-field textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 7px 9px; border-radius: 6px; font-size: 0.9rem; font-family: inherit;
}
.ent-field input[type="date"] { color-scheme: dark; }

/* Oct 5 2026 — SCHOOL TERMS date pickers (6×2 grid in the school modal).
   The term rows sit inside .ent-kid-row (var(--panel) background), so the
   inputs use the panel-2 recipe from .rp-date-row: darker inset background,
   --line border, white calendar icon (color-scheme: dark). flex:1 + min-
   width:0 lets both pickers share the row evenly at any modal width. */
.term-date {
  flex: 1; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; color: var(--text); padding: 6px 8px; font: inherit;
  font-size: 0.88rem; color-scheme: dark;
}

/* Sep 28 2026 — CHECKBOX ALIGNMENT FIX: .ent-field input's width:100%
   stretched the Active checkbox to full row width, leaving it floating
   far from its label (looked "misaligned" on child/school/contract/
   driver forms). Checkbox fields now render as a compact row: box
   first, label beside it, both vertically centred. */
.ent-field.ent-check { display: flex; align-items: center; gap: 8px; }
.ent-field.ent-check label {
  display: inline; font-size: 0.85rem; color: var(--text);
  margin-bottom: 0; cursor: pointer; order: 2;
}
.ent-field.ent-check input[type="checkbox"] {
  width: 18px; height: 18px; min-width: 18px; flex: 0 0 auto;
  order: 1; margin: 0; accent-color: var(--blue);
  cursor: pointer;
}
/* parent SMS-consent checkbox (Responsible adults tab) — same recipe */
.consent-check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.consent-check label { font-size: 0.8rem; color: var(--text); cursor: pointer; }
.consent-check input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer;
}

/* ---- ATCMS-#60a (Sep 26 2026): Mon–Sun operating-day toggles ---- */
/* Pill buttons in the contract form. "on" = selected (primary colour);
   off = muted outline. min-1-day is enforced at save. */
.day-btn-row { display: flex; flex-wrap: wrap; gap: 5px; }
.day-btn {
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 0.78rem; font-weight: 600;
  transition: background .12s, color .12s, border-color .12s;
}
.day-btn:hover { border-color: var(--primary); color: var(--text); }
.day-btn.on {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---- driver privacy-agreement record (ATCMS-#57a, Sep 26 2026) ---- */
/* Read-only audit panel in the driver edit modal: typed signature name,
   UK-format timestamp, policy version, IP + re-consent history. */
.drv-agr-latest {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 6px; padding: 10px 12px; font-size: 0.88rem;
}
.drv-agr-latest.stale { border-left-color: var(--warn); }
.drv-agr-lbl {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px;
  margin-right: 8px;
}
.drv-agr-ok { color: var(--ok); font-size: 0.8rem; }
.drv-agr-warn { color: var(--warn); font-size: 0.8rem; }
.drv-agr-histrow {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--muted);
  padding: 4px 2px; border-bottom: 1px dashed var(--line);
}
.drv-agr-histrow:first-of-type { border-top: 1px dashed var(--line); }


/* ============ DRIVER DOCUMENT VAULT (Sep 25 2026 — ATCMS_DOC_VAULT_PLAN §4) ============ */
/* pending-count badge on the topbar folder button (reuses the Jobs-badge pattern) */
#btn-docvault { position: relative; }
.topbar-badge {
  position: absolute; top: -4px; right: -6px;
  background: var(--alert); color: #fff; border-radius: 999px;
  font-size: 0.6rem; font-weight: 700; padding: 1px 5px; line-height: 1.1;
  pointer-events: none;
}
/* filter chips above the review list */
.dv-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.dv-chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 4px 12px; font-size: 0.78rem; cursor: pointer;
}
.dv-chip.active { color: var(--text); border-color: var(--blue); background: rgba(25,118,210,0.15); }
/* one card per uploaded document */
.dv-row {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; margin-bottom: 10px;
}
/* Sep 25 later pass — thumbnail layout: left column (type/driver/meta/
   view btn) + right tile spanning the dead space under the status pill. */
.dv-top { display: flex; gap: 12px; align-items: stretch; }
.dv-main { flex: 1 1 auto; min-width: 0; }
.dv-thumb {
  flex: 0 0 92px; width: 92px; height: 70px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in; overflow: hidden; align-self: flex-start;
}
.dv-thumb span { font-size: 1.5rem; opacity: 0.45; }
.dv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dv-thumb:hover { border-color: var(--blue); }
.dv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dv-type { font-size: 0.92rem; font-weight: 600; }
.dv-driver { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.dv-status { font-size: 0.72rem; font-weight: 700; border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.dv-status.pending_review { color: var(--warn); border: 1px solid var(--warn); }
.dv-status.approved { color: var(--ok); border: 1px solid var(--ok); }
.dv-status.rejected { color: var(--alert); border: 1px solid var(--alert); }
.dv-status.superseded { color: var(--muted); border: 1px solid var(--line); }
.dv-meta { font-size: 0.74rem; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.dv-view-btn {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 4px 10px; font-size: 0.78rem; cursor: pointer; margin-top: 8px;
}
.dv-view-btn:hover { filter: brightness(1.2); }
/* OCR suggestion chip — pre-fills the expiry field on click (human confirms) */
.dv-ocr {
  margin-top: 8px; font-size: 0.78rem; color: #64b5f6;
  background: rgba(25,118,210,0.1); border: 1px dashed rgba(100,181,246,0.5);
  border-radius: 6px; padding: 6px 9px; cursor: pointer;
}
.dv-ocr:hover { background: rgba(25,118,210,0.2); }
/* Sep 25 later pass — OCR lifecycle states (async OCR + re-run button) */
.dv-ocr-running {
  color: var(--muted); background: rgba(255,255,255,0.04);
  border: 1px solid var(--line); cursor: default; position: relative;
  overflow: hidden;
}
/* animated progress stripe — tells the operator OCR is actively working
   (tesseract takes ~2-5s/image; without motion it looks hung) */
.dv-ocr-running::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(100,181,246,0.25), transparent);
  animation: dv-ocr-sweep 1.2s linear infinite;
}
@keyframes dv-ocr-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.dv-ocr-none { color: var(--muted); background: rgba(255,255,255,0.04); border: 1px solid var(--line); cursor: default; }
.dv-ocr-error { color: var(--alert); background: rgba(229,57,53,0.08); border: 1px solid rgba(229,57,53,0.4); cursor: default; }
.dv-ocr-rerun {
  margin-left: 6px; background: transparent; border: 1px solid var(--line);
  color: var(--text); border-radius: 5px; padding: 2px 8px;
  font-size: 0.72rem; cursor: pointer;
}
.dv-ocr-rerun:hover { border-color: var(--ok); color: var(--ok); }
.dv-ocr-rerun:disabled { opacity: 0.5; cursor: not-allowed; }
/* review form (approve/reject) */
.dv-form { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.dv-field { margin-bottom: 8px; }
.dv-field label { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 3px; }
.dv-field input {
  width: 100%; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 7px 9px; border-radius: 6px; font-size: 0.9rem;
}
.dv-field input[type="date"] { color-scheme: dark; }
.dv-actions { display: flex; gap: 8px; margin-top: 10px; }
.dv-actions button { flex: 1; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--line);
  font-size: 0.88rem; font-weight: 600; cursor: pointer; background: var(--panel-2); color: var(--text); }
.dv-approve { background: var(--ok) !important; color: #06130b !important; border-color: var(--ok) !important; }
.dv-reject { background: transparent !important; color: var(--alert) !important; border-color: var(--alert) !important; }
.dv-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.dv-reject-reason { margin-top: 8px; font-size: 0.78rem; color: var(--alert); }

/* ============ Mini-Me AI helper (Sep 25 2026 — taxi fork) ============ */
.mm-chip {
  padding: 6px 12px; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 16px; cursor: pointer;
  font-size: 0.8rem;
}
.mm-chip:hover { color: var(--text); border-color: var(--blue); }
.mm-bubble-user {
  align-self: flex-end; max-width: 85%; padding: 8px 12px;
  background: var(--blue); color: #fff; border-radius: 12px 12px 2px 12px;
  font-size: 0.9rem; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap;
}
.mm-bubble-bot {
  align-self: flex-start; max-width: 85%; padding: 8px 12px;
  background: var(--panel-2); color: var(--text); border-radius: 12px 12px 12px 2px;
  font-size: 0.9rem; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap;
}
.mm-bubble-typing {
  align-self: flex-start; padding: 8px 12px; background: var(--panel-2);
  color: var(--muted); border-radius: 12px 12px 12px 2px; font-size: 0.9rem;
  font-style: italic;
}

