/* DTDC RF174 BI — chart chrome & ink from the validated reference palette */
:root {
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* blue */
  --series-2: #1baf7a;   /* aqua */
  --series-3: #eda100;   /* yellow */
  --deemph: #c3c2b7;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --delta-good: #006300;
  --delta-bad: #d03b3b;
  --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --series-3: #c98500;
    --deemph: #52514e;
    --delta-good: #0ca30c;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.shell { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.sidebar {
  width: 210px; flex: 0 0 210px;
  padding: 20px 12px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 4px 10px 18px; }
.brand-mark { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.nav-link {
  display: block; padding: 8px 10px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--surface-1); }
.nav-link.active { background: var(--surface-1); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border); }
.sidebar-foot { margin-top: auto; padding: 10px; color: var(--text-muted); font-size: 11.5px; }

/* ---- main ---- */
.main { flex: 1; padding: 20px 26px 48px; min-width: 0; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h1 { font-size: 20px; margin: 0; }
.freshness { color: var(--text-muted); font-size: 12px; text-align: right; }
.page { display: none; }
.page.active { display: block; }

/* ---- KPI row ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px;
}
.tile .label { color: var(--text-secondary); font-size: 12.5px; }
.tile .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .delta { font-size: 12px; margin-top: 2px; }
.tile .delta.up   { color: var(--delta-good); }
.tile .delta.down { color: var(--delta-bad); }
.tile .delta.flat { color: var(--text-muted); }
.tile .note { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.tile.alert { border-color: var(--status-critical); }
.tile .spark { margin-top: 6px; }

/* ---- cards & grid ---- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 10px; grid-column: span 12; min-width: 0;
}
.card.half { grid-column: span 6; }
.card.third { grid-column: span 4; }
@media (max-width: 1100px) { .card.half, .card.third { grid-column: span 12; } }
.card h3 { margin: 0 0 2px; font-size: 14.5px; }
.card .sub { color: var(--text-muted); font-size: 12px; margin: 0 0 8px; }
.card figure { margin: 0; }
.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 2px 0 6px; font-size: 12px; color: var(--text-secondary); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .linekey { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

/* data table view (relief channel for every chart) */
details.data-table { margin: 4px 0 6px; }
details.data-table summary { cursor: pointer; color: var(--text-muted); font-size: 12px; user-select: none; }
details.data-table table { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: 12.5px; }
details.data-table th, details.data-table td {
  text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
details.data-table th:first-child, details.data-table td:first-child { text-align: left; }
details.data-table th { color: var(--text-secondary); font-weight: 600; }

/* tooltip */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  max-width: 280px;
}
.tooltip .tt-title { color: var(--text-muted); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.tooltip .tt-key { width: 12px; height: 2.5px; border-radius: 1px; flex: 0 0 12px; }
.tooltip .tt-val { font-weight: 600; }
.tooltip .tt-name { color: var(--text-secondary); }

/* status pills (icon + label, never color alone) */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border);
}
.pill.critical { color: var(--status-critical); }
.pill.serious  { color: var(--status-serious); }
.pill.warning  { color: var(--status-warning); }
.pill.good     { color: var(--status-good); }
@media (prefers-color-scheme: light) {
  .pill.warning { color: #8a6100; }
  .pill.serious { color: #b4552e; }
}

/* health checks */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.check:last-child { border-bottom: none; }
.check .body { flex: 1; min-width: 0; }
.check .name { font-weight: 600; overflow-wrap: break-word; }
.check .detail { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; overflow-wrap: break-word; }

/* callout */
.callout {
  border-left: 3px solid var(--status-critical);
  background: var(--surface-1); border-radius: 8px; border-top: 1px solid var(--border);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
.callout b { font-weight: 600; }
.callout.info { border-left-color: var(--accent); }

.small-note { color: var(--text-muted); font-size: 11.5px; margin-top: 6px; }
.err { color: var(--status-critical); padding: 20px; }

/* ---- mobile top bar + nav drawer ---- */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close { display: none; }

@media (max-width: 760px) {
  .mobile-topbar {
    display: flex; align-items: center; gap: 6px;
    position: sticky; top: 0; z-index: 55; height: 52px; padding: 0 8px 0 4px;
    background: var(--surface-1); border-bottom: 1px solid var(--border);
  }
  .hamburger {
    width: 44px; height: 44px; border: none; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    flex: 0 0 44px;
  }
  .hamburger span { width: 20px; height: 2px; background: var(--text-primary); border-radius: 1px; }
  .mobile-title { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 64;
  }
  .sidebar-backdrop[hidden] { display: none; }

  .shell { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 65;
    width: min(82vw, 300px); height: 100vh; height: 100dvh;
    background: var(--surface-1); box-shadow: 4px 0 28px rgba(0,0,0,0.35);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    transform: translateX(-100%); transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  body.drawer-open { overflow: hidden; }

  .brand { position: relative; padding-right: 40px; }
  .sidebar-close {
    display: block; position: absolute; top: 2px; right: 2px;
    width: 34px; height: 34px; border: none; background: none; color: var(--text-muted);
    font-size: 22px; line-height: 1; cursor: pointer;
  }
  .nav-link { padding: 11px 10px; }
  .nav-sub .nav-link { padding: 10px 10px 10px 18px; }
  .sidebar-foot { display: block; }

  /* page chrome */
  .page-head h1 { display: none; }
  .page-head { margin-bottom: 10px; }
  .freshness { text-align: left; font-size: 11px; }
  .main { padding: 12px 12px 40px; }

  .kpi-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .tile { padding: 10px 11px; }
  .tile .value { font-size: 22px; }
  .card { padding: 12px 12px 8px; }
  .grid { gap: 10px; }

  .lb-name { min-width: 92px; font-size: 12.5px; }
  .lb-val { min-width: 48px; }

  .route-compare { grid-template-columns: 1fr !important; }

  .chat-fab span { display: none; }
  .chat-fab { width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 50%; }
  .chat-panel { right: 12px; bottom: 12px; }
}

/* ---- driver management module ---- */
.nav-group { margin-top: 10px; }
.nav-group-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-muted); cursor: pointer; user-select: none;
}
.nav-group-label .chev { transition: transform 0.15s; font-size: 10px; }
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-sub { display: none; }
.nav-sub .nav-link { padding: 6px 10px 6px 18px; font-size: 13px; }

.demo-badge {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; vertical-align: 2px;
  color: var(--status-warning); border: 1px solid currentColor;
}
@media (prefers-color-scheme: light) { .demo-badge { color: #8a6100; } }

/* status chips for drivers/shipments */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip.on-delivery::before, .chip.en-route::before, .chip.out-for-delivery::before, .chip.in-use::before { background: var(--series-1); }
.chip.available::before, .chip.completed::before, .chip.delivered::before, .chip.present::before { background: var(--status-good); }
.chip.offline::before, .chip.cancelled::before, .chip.failed::before, .chip.absent::before { background: var(--status-critical); }
.chip.on-break::before, .chip.pending::before, .chip.scheduled::before, .chip.reattempt::before, .chip.late::before, .chip.parked::before, .chip.leave::before { background: var(--status-warning); }
.chip.returned::before, .chip.assigned::before { background: var(--series-3); }
/* Depot presence. Deliberately louder than the status chips beside it: "at the
   depot right now" is the signal that decides who dispatch plans over. */
.chip.live {
  color: var(--status-good); border-color: color-mix(in srgb, var(--status-good) 45%, transparent);
  background: color-mix(in srgb, var(--status-good) 12%, transparent); letter-spacing: .04em;
}
.chip.live::before { background: var(--status-good); animation: chip-live-pulse 2s ease-in-out infinite; }
@keyframes chip-live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .chip.live::before { animation: none; } }

/* data tables (fleet) */
table.fleet { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.fleet th, table.fleet td { padding: 7px 9px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
table.fleet td.num, table.fleet th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.fleet th { color: var(--text-secondary); font-weight: 600; font-size: 12px; }
table.fleet tr:hover td { background: var(--page); }
.table-scroll { overflow-x: auto; }
.row-actions { display: flex; gap: 6px; }
.btn-sm {
  border: 1px solid var(--border); background: var(--page); color: var(--text-secondary);
  border-radius: 7px; padding: 3px 9px; font-size: 11.5px; cursor: pointer;
}
.btn-sm:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-primary {
  border: none; background: var(--accent); color: #fff; border-radius: 9px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.06); }

/* view switcher + filter row */
.view-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.view-row .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--surface-1); color: var(--text-secondary); padding: 6px 13px; font-size: 12.5px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }
select.fleet-select, input.fleet-input {
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 9px; padding: 6px 10px; font-size: 12.5px;
}

/* map placeholder */
.map-panel { position: relative; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--page); }
.map-panel svg { display: block; width: 100%; height: auto; }
.map-note {
  position: absolute; left: 10px; bottom: 10px; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-1); border: 1px solid var(--border);
  font-size: 10.5px; color: var(--text-muted);
}
.map-layers { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.kanban .kcol { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 120px; }
.kanban .kcol h4 { margin: 2px 4px 8px; font-size: 12px; color: var(--text-secondary); display: flex; justify-content: space-between; }
.kcard { background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; margin-bottom: 8px; font-size: 12px; }
.kcard b { display: block; font-size: 12.5px; }
.kcard .meta { color: var(--text-muted); margin-top: 2px; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .cal-cell { border: 1px solid var(--border); border-radius: 9px; min-height: 64px; padding: 6px 8px; font-size: 11.5px; background: var(--surface-1); }
.cal .cal-cell .d { color: var(--text-muted); font-size: 10.5px; }
.cal .cal-cell.empty { background: transparent; border-style: dashed; }
.cal-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; }

/* route optimization: before/after map comparison */
.route-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* attendance grid */
.att-grid { display: grid; gap: 3px; }
.att-cell {
  width: 100%; aspect-ratio: 1; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 700; color: #fff;
}

/* heat grid */
.heat-wrap { overflow-x: auto; }
.heat { display: grid; gap: 3px; align-items: center; font-size: 11px; }
.heat .h-label { color: var(--text-secondary); padding-right: 8px; white-space: nowrap; }
.heat .h-cell { border-radius: 4px; min-width: 26px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 10px; }

/* leaderboard */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--grid); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 26px; height: 26px; border-radius: 50%; background: var(--page); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: 0 0 26px; }
.lb-row.top .lb-rank { background: var(--accent); color: #fff; border-color: var(--accent); }
.lb-name { font-weight: 600; min-width: 130px; }
.lb-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--page); overflow: hidden; }
.lb-bar > div { height: 100%; border-radius: 4px; background: var(--series-1); }
.lb-val { font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 60px; text-align: right; }

/* alerts + insights */
.alert-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 12.5px; }
.alert-row:last-child { border-bottom: none; }
.alert-row > div { flex: 1 1 160px; min-width: 0; overflow-wrap: break-word; }
.alert-row .when { margin-left: auto; color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.insight { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 12.5px; line-height: 1.45; }
.insight:last-child { border-bottom: none; }
.insight .ico { flex: 0 0 auto; }
.insight > div:last-child { flex: 1; min-width: 0; overflow-wrap: break-word; }

/* AI placeholder tiles */
.ai-future { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ai-future .slot {
  border: 1px dashed var(--border); border-radius: 10px; padding: 12px; text-align: center;
  color: var(--text-muted); font-size: 12px;
}
.ai-future .slot .ico { font-size: 18px; display: block; margin-bottom: 4px; }

/* shipment timeline modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 70; display: flex; align-items: center; justify-content: center; }
.modal {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px;
  width: min(480px, calc(100vw - 32px)); max-height: 84vh; overflow-y: auto; padding: 18px 20px;
}
.modal h3 { margin: 0 0 2px; }
.modal .sub { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.tl { position: relative; margin-left: 6px; }
.tl-step { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--grid); }
.tl-step:last-child { border-left-color: transparent; padding-bottom: 2px; }
.tl-step::before {
  content: ''; position: absolute; left: -6px; top: 1px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--deemph); border: 2px solid var(--surface-1);
}
.tl-step.done::before { background: var(--status-good); }
.tl-step.now::before { background: var(--series-1); }
.tl-step b { font-size: 12.5px; }
.tl-step .t { color: var(--text-muted); font-size: 11px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 16px; font-size: 13px; z-index: 80;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* driver detail drawer bits */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv .k { color: var(--text-muted); }

/* ---- chat widget ---- */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  height: 52px; padding: 0 18px 0 16px; border-radius: 26px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  font: 600 14px system-ui, sans-serif; box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}
.chat-fab:hover { filter: brightness(1.05); }
.chat-fab svg { width: 20px; height: 20px; }

.chat-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 61;
  width: min(420px, calc(100vw - 32px)); height: min(620px, calc(100vh - 44px));
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28); display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.chat-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-good); flex: 0 0 8px; }
.chat-head .dot.off { background: var(--status-critical); }
.chat-head .title { font-weight: 600; }
.chat-head .model { color: var(--text-muted); font-size: 11.5px; }
.chat-head .close { margin-left: auto; background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; line-height: 1; }

.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.msg .who { font-size: 11px; color: var(--text-muted); }
.msg .bubble {
  padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--page); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.bot .bubble code { background: rgba(127,127,127,0.15); padding: 1px 4px; border-radius: 4px; font-size: 12.5px; }
.msg.bot.err .bubble { border-color: var(--status-critical); color: var(--status-critical); }
.msg .sources { font-size: 11px; color: var(--text-muted); }
.msg .sources b { color: var(--text-secondary); font-weight: 600; }
.blink::after { content: '▋'; animation: blink 1s steps(2) infinite; color: var(--text-muted); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.chat-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chat-suggest button {
  background: var(--page); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 11px; font-size: 12px; color: var(--text-secondary); cursor: pointer; text-align: left;
}
.chat-suggest button:hover { border-color: var(--accent); color: var(--text-primary); }

.chat-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.chat-input textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; background: var(--page);
  color: var(--text-primary); padding: 9px 11px; font: 13.5px system-ui, sans-serif; max-height: 120px;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }
.chat-input .send {
  flex: 0 0 auto; align-self: flex-end; height: 38px; width: 38px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; cursor: pointer; font-size: 16px;
}
.chat-input .send:disabled { opacity: 0.5; cursor: default; }
.chat-disclaimer { padding: 0 14px 10px; font-size: 10.5px; color: var(--text-muted); }

/* ---- Driver Management redesign ---- */
.ops-hub {
  position: relative; border: 1px solid var(--border); border-radius: 12px;
  background: var(--page); padding: 12px 14px; margin-bottom: 14px;
}
.ops-hub .oh-label { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; color: var(--text-muted); }
.ops-hub .oh-name { font-size: 15px; font-weight: 700; margin-top: 3px; }
.ops-hub .oh-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.ops-hub .btn-sm { position: absolute; right: 14px; top: 14px; text-decoration: none; }

.dm-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.dm-stat {
  flex: 1; min-width: 90px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--page); padding: 9px 12px; display: flex; flex-direction: column;
}
.dm-stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dm-stat .l { font-size: 11px; color: var(--text-muted); }

.dm-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.dm-controls .fleet-input { min-width: 140px; }

.rider-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.rider-card {
  border: 1px solid var(--border); border-radius: 12px; background: var(--page);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.rider-card.dim { opacity: 0.62; }
.rc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rc-name { font-weight: 700; font-size: 14px; }
.rc-body { display: flex; flex-direction: column; gap: 2px; }
.rc-line { font-size: 12.5px; }
.rc-line.sub { color: var(--text-secondary); font-size: 12px; }
.rc-line.warn { color: var(--status-warning); }
.rc-actions { display: flex; align-items: center; gap: 6px; margin-top: 2px; position: relative; }
.rc-actions .rc-more { margin-left: auto; padding: 3px 8px; font-size: 15px; line-height: 1; }

.rider-menu {
  position: absolute; right: 0; top: 30px; z-index: 30; min-width: 150px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.28); display: flex; flex-direction: column;
}
.rider-menu .menu-item {
  text-align: left; background: none; border: none; color: var(--text-secondary);
  padding: 7px 10px; border-radius: 7px; font-size: 12.5px; cursor: pointer;
}
.rider-menu .menu-item:hover { background: var(--page); color: var(--text-primary); }
.rider-menu .menu-item.danger { color: var(--status-critical); }

/* modal form fields (shared modal shell in the "shipment timeline modal" block) */
.form-field { margin-bottom: 12px; }
.form-field > label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 600; }
.field-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.phone-wrap { display: flex; align-items: stretch; }
.phone-wrap .cc {
  display: flex; align-items: center; padding: 0 10px; font-size: 12.5px; color: var(--text-secondary);
  border: 1px solid var(--border); border-right: none; border-radius: 9px 0 0 9px; background: var(--page);
}
.phone-wrap .fleet-input { border-radius: 0 9px 9px 0; }
.shift-row { display: flex; align-items: center; gap: 8px; }
.shift-row .fleet-input { flex: 1; }
.shift-row span { color: var(--text-muted); font-size: 12px; }
.hub-note {
  border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px;
  display: flex; flex-direction: column; gap: 2px; background: var(--page);
}
.hub-note .k { font-size: 11px; color: var(--text-muted); }
.hub-note b { font-size: 13px; }
.hub-note .sub { font-size: 11px; color: var(--text-muted); }
.form-err { color: var(--status-critical); font-size: 12px; margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ============================================================
   Today — operations landing page (ux-redesign/svg/dashboard.svg)
   Six-layer hierarchy: only layer 1 may use red.
   ============================================================ */

/* nav grouping — the flat 7-item list gave no sense of what mattered */
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-muted); font-weight: 700;
  padding: 14px 10px 4px;
}

/* Layer 1 — critical alerts */
.today-alert {
  display: flex; align-items: flex-start; gap: 12px;
  background: color-mix(in srgb, var(--status-critical) 8%, var(--surface-1));
  border: 1px solid var(--status-critical);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.today-alert.clear {
  background: color-mix(in srgb, var(--status-good) 7%, var(--surface-1));
  border-color: color-mix(in srgb, var(--status-good) 45%, transparent);
}
.today-alert-icon {
  flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--status-critical); color: #fff;
}
.today-alert.clear .today-alert-icon { background: var(--status-good); }
.today-alert-body { flex: 1; min-width: 0; }
.today-alert-title { font-size: 15px; font-weight: 650; color: var(--status-critical); }
.today-alert.clear .today-alert-title { color: var(--status-good); }
.today-alert-detail { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; }

/* Layer 2 — action tiles. A tile is a link, not a read-only number. */
.tile--action {
  display: block; text-decoration: none; color: inherit;
  transition: border-color .12s ease, transform .12s ease;
}
.tile--action:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile--action.tone-critical { box-shadow: inset 3px 0 0 var(--status-critical); }
.tile--action.tone-warning  { box-shadow: inset 3px 0 0 var(--status-warning); }

/* Layers 3 + 4 */
.today-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .today-grid { grid-template-columns: 1fr; } }
.today-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.today-rows { margin-top: 6px; }
.today-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid var(--grid); min-height: 44px;
}
.today-row:last-child { border-bottom: none; }
.today-row-n { width: 20px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.today-row-meta { flex: 1; min-width: 0; }
.today-row-name { font-size: 13.5px; font-weight: 500; }
.today-row-sub {
  font-size: 12px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.today-row-slot { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.today-row-act { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.today-row-act:hover { text-decoration: underline; }

.today-rider { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.today-rider:last-of-type { border-bottom: none; }
.today-rider-dot {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.today-rider-meta { flex: 1; min-width: 0; }
.today-rider-name { font-size: 13px; font-weight: 600; }
.today-rider-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.today-rider-sub.idle { color: var(--status-critical); font-weight: 600; }
.today-bar { height: 5px; border-radius: 3px; background: var(--grid); margin-top: 5px; overflow: hidden; }
.today-bar-fill { height: 100%; background: var(--status-good); border-radius: 3px; }

/* Empty and error states — the platform previously had neither */
.empty-state, .error-state { text-align: center; padding: 28px 16px; }
.empty-state-title { font-size: 14px; font-weight: 600; }
.empty-state-note { font-size: 12.5px; color: var(--text-muted); margin: 4px 0 12px; }

/* Skeletons — never blank the screen while fetching */
.skeleton { background: var(--grid); border-radius: 8px; animation: skeleton-pulse 1.3s ease-in-out infinite; }
@keyframes skeleton-pulse { 0%, 100% { opacity: .55; } 50% { opacity: .95; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.today-skeleton { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.skeleton-tile { height: 88px; }
.today-skeleton-rows { display: grid; gap: 8px; }
.skeleton-row { height: 44px; }

/* Keyboard access. styles.css previously contained ONE focus rule and it
   REMOVED the outline, with no :focus-visible replacement anywhere — the
   whole platform was unusable by keyboard. */
:where(a, button, select, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================
   Operations — merged Today + Pickup Bookings + Driver Assignment
   The counts ARE the tabs (1:1 with panels). An earlier draft had
   tiles AND a segmented control: two navigation systems for the
   same three destinations.
   ============================================================ */
.ops-band { margin-bottom: 10px; }

/* All-clear state is informative on desktop and pure cost on a phone, where
   it spent ~110px saying nothing was wrong. */
.today-alert.compact { padding: 8px 12px; align-items: center; }
.today-alert.compact .today-alert-detail { display: none; }
.today-alert.compact .today-alert-title { font-size: 13px; }
.today-alert.compact .today-alert-icon { width: 18px; height: 18px; flex-basis: 18px; font-size: 11px; }

.ops-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.ops-tab {
  appearance: none; text-align: left; cursor: pointer;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px 12px; position: relative;
  display: flex; flex-direction: column; gap: 1px; min-height: 44px;
  font: inherit; color: inherit;
}
.ops-tab:hover { border-color: var(--accent); }
.ops-tab.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface-1)); }
.ops-tab.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 3px; border-radius: 2px 2px 0 0; background: var(--accent);
}
.ops-tab-value { font-size: 24px; font-weight: 600; line-height: 1.1; }
.ops-tab-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.ops-tab-note { font-size: 11px; color: var(--text-muted); }
.ops-tab.tone-critical { box-shadow: inset 3px 0 0 var(--status-critical); }
.ops-tab.tone-warning { box-shadow: inset 3px 0 0 var(--status-warning); }
.ops-panel[hidden] { display: none; }

/* Who is free, directly above what is waiting — one judgement, one glance. */
.ops-riders-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ops-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
}
.ops-chip b { font-weight: 600; }
.ops-chip.idle { border-color: var(--status-critical); color: var(--status-critical); }
.ops-chip.off { opacity: .55; }
.ops-chip.muted { color: var(--text-muted); }

/* Mobile: the first actionable row used to land ~510px down a ~745px
   viewport — one queue row visible. Compact tabs recover roughly 100px. */
@media (max-width: 480px) {
  .ops-tabs { gap: 6px; }
  .ops-tab { padding: 8px 10px 10px; border-radius: 10px; }
  .ops-tab-value { font-size: 18px; }
  .ops-tab-label { font-size: 11px; }
  .ops-tab-note { display: none; }
  .ops-tab.active::after { left: 10px; right: 10px; }
}

/* Operations: bare minimum.
   The Assign panel was rendering 9 cards, 11 explanatory blurbs and 14 buttons
   for 2 unassigned pickups — including the same rows listed twice, because the
   "unassigned" queue and the assignment-order list are built from overlapping
   sets. One list now, with the secondary work folded away. */
.ops-fold { padding: 0; }
.ops-fold > summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; min-height: 44px;
}
.ops-fold > summary::-webkit-details-marker { display: none; }
.ops-fold > summary::before {
  content: '▸'; color: var(--text-muted); font-size: 11px; transition: transform .12s ease;
}
.ops-fold[open] > summary::before { transform: rotate(90deg); }
.ops-fold[open] > summary { border-bottom: 1px solid var(--grid); }
.ops-fold > *:not(summary) { padding: 0 16px 12px; }
@media (prefers-reduced-motion: reduce) { .ops-fold > summary::before { transition: none; } }

/* Rows, not cards. Card chrome per row was most of the visual weight. */
.assign-row--flat:last-child { border-bottom: none !important; }
.assign-row--flat .sub { font-size: 11.5px; }

/* ---- Today's stops map -------------------------------------------------- */
/* Leaflet ships a light-themed control set; these keep it legible on the dark
   dashboard without restyling Leaflet's internals (which breaks on upgrade). */
.stops-map-wrap { margin-top: 14px; }
.stops-map {
  height: 380px;
  width: 100%;
  border: 1px solid var(--grid);
  border-radius: 10px;
  /* Tiles are light; without this the corners show the page background through
     the rounded edge while tiles load. */
  background: #0d1117;
}
.stops-map .leaflet-control-attribution,
.stops-map .leaflet-control-zoom a {
  background: rgba(13, 17, 23, .85);
  color: var(--text-primary);
  border-color: var(--grid);
}
.stops-map .leaflet-control-attribution a { color: var(--series-1); }
/* Numbered route pins. A divIcon is a real element, so the sequence number is
   selectable text that scales with the browser's font size. */
.stop-pin span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  color: #fff;
  font: 600 12px/1 system-ui, sans-serif;
  border: 2px solid #0d1117;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
