/* cOBD design system ("G"): light ground, cobalt for navigation, selection, primary
   actions and the main data series; amber only for "needs attention"; red only
   for a serious fault or a destructive action. Figtree, served from /vendor.
   Every app page loads this file and nav.js; nav.js draws the sidebar. */

@font-face {
  font-family: 'Figtree'; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(/vendor/figtree/figtree-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Figtree'; font-style: normal; font-weight: 300 900; font-display: swap;
  src: url(/vendor/figtree/figtree-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #172033;        /* body text */
  --ink-2: #2B3446;      /* secondary headings, nav text */
  --muted: #556074;      /* labels, meta (4.5:1 on white and on --side) */
  --faint: #8A94A6;      /* axis ticks only, never body text */
  --line: #E2E6EE;       /* panel borders, dividers */
  --line-2: #DCE1EA;     /* control borders */
  --line-soft: #ECEFF4;  /* rows inside a list */
  --bg: #fff;
  --side: #F4F6FA;       /* sidebar and quiet surfaces */
  --hover: #F2F4F8;
  --accent: #2457D6;     /* brand: nav, selection, primary, main series */
  --accent-hover: #1B44AD;
  --accent-ink: #1D49B8; /* links and text in the brand colour */
  --accent-soft: #E2E9FB;/* selected row */
  --accent-2: #6F8FD8;   /* second series */
  --warn: #E39A00;       /* needs attention: dots, marks */
  --warn-bg: #FFF4D6;
  --warn-bg-2: #FFF1CC;
  --warn-line: #F2D27A;
  --warn-ink: #8A5300;   /* text on warn backgrounds */
  --warn-ink-2: #3D2600;
  --ok: #1E8E4F;
  --ok-bg: #E7F6EC;
  --bad: #B42318;
  --bad-bg: #FDECEA;
  --radius: 10px;
  --radius-sm: 8px;
  --side-w: clamp(188px, 17.8vw, 256px);
  /* Route speed bands, as the map legend names them. */
  --spd-slow: #22c55e; --spd-mid: #fbbf24; --spd-fast: #f97316; --spd-top: #ef4444; --spd-none: #6b7280;
  /* Route temperature bands, coldest first: blue darkening below 15 °C (60 °F), red
     darkening above it. Rain on the route: rain and snow stand out, dry recedes.
     app.js THEME holds the same values for the map. */
  --tmp-0: #104281; --tmp-1: #1c5cab; --tmp-2: #3987e5; --tmp-3: #86b6ef;
  --tmp-4: #fa9088; --tmp-5: #d75853; --tmp-6: #9e3432; --tmp-7: #7a1b1d;
  --wet-rain: #2a78d6; --wet-snow: #d55181; --wet-dry: #9ca3af;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Figtree, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
a { color: var(--accent-ink); }
a:hover { color: var(--accent-hover); }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── App shell: sidebar + scrolling main ─────────────────────────────────────── */
body.g { height: 100vh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); overflow: hidden; }
body.g > main { min-width: 0; height: 100vh; overflow: auto; }
body.g.has-banner { grid-template-rows: auto 1fr; }
body.g.has-banner > .imp-banner { grid-column: 1 / -1; }
body.g.has-banner > main, body.g.has-banner > .side { height: auto; min-height: 0; }

.page { padding: 26px 32px 56px; max-width: 1280px; }
.page-wide { max-width: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -0.01em; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lede { margin-top: 6px; font-size: 15px; line-height: 22px; color: var(--ink-2); max-width: 75ch; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2, .h2 { font-size: 18px; line-height: 24px; font-weight: 600; }
h3, .h3 { font-size: 15px; line-height: 20px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 18px; }
.tiny { font-size: 12px; line-height: 16px; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.flex { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ── Sidebar (drawn by nav.js) ───────────────────────────────────────────────── */
.side { display: flex; flex-direction: column; min-height: 0; height: 100vh; overflow: auto; background: var(--side); border-right: 1px solid var(--line); padding: 16px 10px 14px; }
.side-logo { font-size: 19px; font-weight: 800; color: var(--accent); padding: 0 10px 14px; letter-spacing: -0.01em; text-decoration: none; }
.side-logo:hover { color: var(--accent); }
.side-car { position: relative; }
.side-car-row { display: flex; gap: 6px; }
.car-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; text-align: left; }
.car-btn:hover { background: #F9FAFC; border-color: #C5CDDA; }
.car-btn .car-name { display: block; font-size: 14px; font-weight: 600; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-btn .car-sub { display: block; font-size: 12px; line-height: 16px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lamp-btn { flex: none; position: relative; display: grid; place-items: center; width: 38px; padding: 0; border: 1px solid #EFCF7C; border-radius: var(--radius); background: var(--warn-bg-2); }
.lamp-btn:hover { background: #FFE7A8; }
.lamp-btn[aria-expanded="true"] { background: #FFDD8A; }
.lamp-btn.pending { background: #fff; border-color: var(--line-2); }
.lamp-btn.urgent { background: var(--bad-bg); border-color: #F1B5AE; }
.lamp-count { position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--warn); color: #2A1A00; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--side); }
.lamp-btn.urgent .lamp-count { background: var(--bad); color: #fff; }
.side-pop { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 4px; box-shadow: 0 6px 20px rgba(23, 32, 51, .08); }
.side-pop.wide { width: min(290px, calc(100vw - 24px)); right: auto; }
.side-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 4px 10px; }
.side-pop-head h2 { font-size: 15px; line-height: 20px; }
.mi { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 7px; background: #fff; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none; }
.mi:hover { background: #F1F4F9; color: var(--ink); }
.mi.mi-strong { font-weight: 600; }
.mi-code { display: block; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); }
.mi-code:hover { background: #F1F4F9; color: var(--ink); }
.mi-sep { height: 1px; margin: 4px 6px; background: var(--line-soft); }
.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.nav-item { display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.nav-item:hover { background: #E4E8F0; color: var(--ink-2); }
.nav-item[aria-current="page"], .nav-item[aria-current="page"]:hover { background: var(--accent); color: #fff; }
.nav-item svg { flex: none; }
.nav-item .nav-label { flex: 1; }
.nav-item.quiet { height: 32px; font-size: 13px; color: var(--muted); }
.nav-item.quiet[aria-current="page"] { color: #fff; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.nav-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.nav-item[aria-current="page"] .nav-count { background: #fff; color: var(--accent); }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.side-last { margin: 0 10px 10px; font-size: 12px; line-height: 16px; color: var(--muted); }
.side-menu-btn { display: none; }

.imp-banner { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); color: var(--warn-ink-2); font-size: 14px; }

/* Phone and narrow windows: the sidebar becomes a top bar with a menu. */
@media (max-width: 860px) {
  body.g { display: block; height: auto; overflow: visible; }
  body.g > main { height: auto; overflow: visible; }
  .side { position: sticky; top: 0; z-index: 40; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-logo { padding: 0 4px; }
  .side-car { flex: 1; min-width: 0; }
  .side-menu-btn { display: grid; position: relative; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: var(--radius); background: #fff; }
  .side-menu-btn.has-mark::after { content: ''; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--side); }
  .side-nav, .side-foot { display: none; width: 100%; margin: 0; }
  .side.open .side-nav, .side.open .side-foot { display: flex; }
  .side-foot { padding-top: 6px; border-top: 1px solid var(--line); }
  .side-last { margin: 6px 10px; }
  .page { padding: 18px 16px 40px; }
  .page-head h1 { font-size: 22px; line-height: 28px; }
}

/* ── Controls ────────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: #F1F4F9; color: var(--ink); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }
.btn-danger-ghost { background: #fff; color: var(--bad); border-color: var(--line-2); }
.btn-danger-ghost:hover { background: var(--bad-bg); color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.ibtn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); }
.ibtn:hover { background: #E9EDF3; }
.ibtn:disabled { opacity: .35; cursor: default; background: transparent; }
.lnk { padding: 0; border: 0; background: none; color: var(--accent-ink); font-weight: 600; text-decoration: none; }
.lnk:hover { text-decoration: underline; color: var(--accent-hover); }
.updated { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Segmented control; app.js range chips (.range-chip) take the same look. */
.seg-group { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 9px; background: #EEF1F6; }
.seg, .range-chip { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: #38445A; font-size: 13px; font-weight: 600; white-space: nowrap; }
.seg:hover, .range-chip:hover { background: #E2E7EF; }
.seg[aria-pressed="true"], .seg.on, .range-chip.active, .seg[aria-selected="true"] { background: var(--accent); color: #fff; }

.tabs { display: flex; gap: 20px; box-shadow: inset 0 -1px 0 var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.tab { position: relative; height: 38px; padding: 0 2px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--ink); }
.tab[aria-selected="true"]::after, .tab[aria-current="page"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); border-radius: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; color: var(--ink); font-size: 14px; }
.textarea { height: auto; min-height: 96px; padding: 9px 11px; line-height: 1.45; resize: vertical; }
.select { padding-right: 30px; }
.input:hover, .select:hover, .textarea:hover { border-color: #C5CDDA; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.field-err { font-size: 13px; color: var(--bad); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 10px; background: #C5CDDA; transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Surfaces ────────────────────────────────────────────────────────────────── */
.panel { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: #fff; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.quiet-box { border-radius: 12px; padding: 14px 16px; background: var(--side); }

.notice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--side); color: var(--ink-2); font-size: 14px; }
.notice-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink-2); }
.notice-bad { background: var(--bad-bg); border-color: #F1B5AE; color: #5C120B; }
.notice-ok { background: var(--ok-bg); border-color: #B5E2C4; color: #0F4A28; }
.notice .notice-icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--warn-bg-2); color: var(--warn-ink); }
.notice-title { font-weight: 600; }
.not-logged p { margin: 0 0 4px; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; background: #EEF1F6; color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-warn { background: var(--warn-bg-2); color: var(--warn-ink); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dot-cold { background: #fff; box-shadow: inset 0 0 0 2px var(--accent-2); }
.dot-warn { background: var(--warn); }
.dot-ok { background: var(--ok); }
.dot-bad { background: var(--bad); }
.dot-off { background: #C5CDDA; }

/* Label / value list ("figures"). */
.figs { display: flex; flex-direction: column; }
.figs > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.figs > div:last-child { border-bottom: 0; }
.figs dt, .figs .k { font-size: 13px; color: var(--muted); }
.figs dd, .figs .v { font-size: 14px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.figs .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* Lists of rows (drives, cars, conversations). */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); text-align: left; text-decoration: none; width: 100%; }
.row:hover { background: var(--hover); color: var(--ink); }
.row[aria-selected="true"], .row.on, .row[aria-current="true"] { background: var(--accent-soft); }
.list-group { padding: 12px 12px 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; }

.tbl-wrap { position: relative; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tbody tr:hover td { background: #FAFBFD; }
.tbl th button.sort { border: 0; background: none; padding: 0; color: inherit; font-weight: 600; }

details.raw { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 12px; }
details.raw > summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.raw > summary::-webkit-details-marker { display: none; }
details.raw > summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.raw[open] > summary::before { transform: rotate(45deg); }
details.raw > div { margin-top: 12px; }
pre.code, code.code { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 12.5px; }
pre.code { padding: 12px; border-radius: var(--radius-sm); background: var(--side); overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-all; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty strong { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

#error-banner { display: none; margin: 0 0 16px; padding: 10px 14px; border: 1px solid #F1B5AE; border-radius: var(--radius-sm); background: var(--bad-bg); color: #5C120B; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(23, 32, 51, .2); }

/* Dialog: <dialog class="dlg"> with showModal(). */
dialog.dlg { width: min(440px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line-2); border-radius: 12px; color: var(--ink); box-shadow: 0 20px 50px rgba(23, 32, 51, .18); }
dialog.dlg::backdrop { background: rgba(23, 32, 51, .35); }
dialog.dlg h2 { font-size: 18px; margin-bottom: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* A News post or message as a popup: the text scrolls, Close stays in view. */
dialog.dlg.dlg-post { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; overflow: hidden; }
dialog.dlg.dlg-post[open] { display: flex; flex-direction: column; }
.dlg-post-scroll { min-height: 0; overflow: auto; padding: 20px 20px 6px; }
dialog.dlg-post h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 10px; }
.dlg-post .dlg-actions { margin: 0; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* News post text (public/news-format.js): four sizes, lists, ticked boxes, images. */
/* position: the screen-reader labels on checkboxes (.sr-only, absolute) stay
   inside the post, so they never make the popup itself scroll. */
.post { position: relative; font-size: 15px; line-height: 23px; color: var(--ink); overflow-wrap: anywhere; }
.post > * + * { margin-top: 10px; }
/* A post's own title (22 px) stays its largest text. */
.post .post-xl { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; margin-top: 18px; }
.post .post-lg { font-size: 17px; line-height: 23px; font-weight: 600; margin-top: 16px; }
.post > .post-xl:first-child, .post > .post-lg:first-child { margin-top: 0; }
.post .post-sm { font-size: 13px; line-height: 18px; color: var(--muted); }
.post ul { padding-left: 20px; list-style: disc; }
.post li + li { margin-top: 4px; }
.post li.post-check { list-style: none; margin-left: -20px; display: flex; align-items: flex-start; gap: 9px; }
.post .post-box { flex: none; position: relative; width: 17px; height: 17px; margin-top: 3px; padding: 0; border: 1.5px solid var(--line-2); border-radius: 5px; background: #fff; }
.post .post-box[data-on], .post .post-box[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); }
.post .post-box[data-on]::after, .post .post-box[aria-pressed="true"]::after { content: ''; position: absolute; left: 4.5px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.post button.post-box { cursor: pointer; }
.post .post-check-text { min-width: 0; }
.post img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.post a { text-underline-offset: 2px; }
.post s { color: var(--muted); }

/* Charts: a sized box around the canvas. */
.chart { position: relative; height: 220px; }
.chart-sm { height: 140px; }
.chart-lg { height: 300px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Maps (Leaflet). Muted tiles so the route carries the colour. */
.map { position: relative; height: 320px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #EEF1F5; }
.map .leaflet-container { height: 100%; font-family: inherit; background: #EEF1F5; }
.map .leaflet-tile-pane { filter: saturate(.45) brightness(1.03); }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; padding: 16px; z-index: 500; background: #F4F6FA; }
.map-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.leaflet-control-zoom a { color: var(--ink) !important; }
.leaflet-control-attribution { font-size: 11px; }

/* Reading rows: a name, its value and unit, a bar across its scale and a plain note (Live, playback on Drives). */
.rd { padding: 10px 0 11px; border-top: 1px solid var(--line-soft); }
.rd-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rd-top dt { font-weight: 600; }
.rd-top dd { white-space: nowrap; }
.rd-val { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; }
.rd-val.none { color: var(--faint); letter-spacing: 0; }
.rd-unit { margin-left: 4px; font-size: 13px; color: var(--muted); }
.rd-bar { margin-top: 6px; }
.rd-track { position: relative; height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.rd-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--accent); }
.rd-fill.warn { background: var(--warn); }
.rd-fill.alert { background: var(--bad); }
.rd-scale { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11px; line-height: 13px; color: var(--muted); }
.rd-note { margin-top: 5px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.rd-note.dim { color: var(--muted); }
.rd-note.missing { color: var(--warn-ink); }
.rd-note.warn { color: var(--warn-ink); font-weight: 600; }
.rd-note.alert { color: var(--bad); font-weight: 600; }
/* More readings: a name and a value, smaller than the gauges above them. */
.rd-more { padding: 7px 0 8px; }
.rd-more .rd-val { font-size: 17px; line-height: 22px; }

/* Public pages (sign in, landing): no sidebar. */
body.pub { min-height: 100vh; }
.pub-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; }
.pub-top .side-logo { padding: 0; }
.auth { width: min(380px, calc(100vw - 32px)); margin: 10vh auto 40px; }
.auth h1 { font-size: 24px; line-height: 30px; font-weight: 700; margin-bottom: 18px; }
.auth form > * + * { margin-top: 14px; }
.auth .btn { width: 100%; height: 40px; }

/* Conversations (Feedback, and Admin's feedback tab). */
.convo { display: grid; grid-template-columns: clamp(260px, 30%, 360px) minmax(0, 1fr); height: 100%; min-height: 0; }
.convo-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.convo-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 16px 12px 20px; }
.convo-list-head h1 { font-size: 22px; line-height: 28px; font-weight: 700; }
.convo-items { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 16px; }
.convo-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; text-align: left; }
.convo-item:hover { background: var(--hover); }
.convo-item[aria-current="true"] { background: var(--accent-soft); }
.convo-item .t { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-item.unread .t { font-weight: 700; }
.convo-item .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-item .w { font-size: 12px; color: var(--muted); white-space: nowrap; }
.convo-item .u { justify-self: end; align-self: center; }
.convo-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.convo-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.convo-head h2 { font-size: 18px; line-height: 28px; }
.convo-back { display: none; }
.chat { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 20px 24px; }
.msg-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.msg-wrap.me { align-items: flex-end; }
.msg { max-width: min(560px, 86%); padding: 9px 12px; border-radius: 12px; background: var(--side); font-size: 14px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-wrap.me .msg { background: var(--accent-soft); }
.msg-meta { margin-top: 3px; font-size: 12px; color: var(--muted); }
.reply-box { display: flex; align-items: flex-end; gap: 8px; padding: 12px 24px 20px; border-top: 1px solid var(--line); }
.reply-box .textarea { min-height: 40px; height: 40px; max-height: 160px; }
.compose { padding: 20px 24px; max-width: 560px; }
.compose > * + * { margin-top: 16px; }
@media (max-width: 860px) {
  .convo { display: block; height: auto; }
  .convo-list { border-right: 0; }
  .convo.reading .convo-list { display: none; }
  .convo:not(.reading) .convo-pane { display: none; }
  .convo-back { display: inline-grid; }
  .chat { overflow: visible; }
}

/* ── Public pages: the homepage's top bar and footer, and public News ──────── */
/* Moved from landing.html as they were; the public News pages share them. */
.land { max-width: 1360px; margin: 0 auto; padding: 0 40px; }
.land-top { display: flex; align-items: center; gap: 28px; height: 64px; }
.land-top .side-logo { padding: 0; }
.land-nav { display: flex; align-items: center; gap: 24px; margin-left: auto; font-size: 14px; font-weight: 600; white-space: nowrap; }
.tlnk { color: var(--ink-2); text-decoration: none; }
.tlnk:hover { color: var(--accent-hover); text-decoration: underline; }
.land-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; margin-top: 64px; padding: 22px 0 28px; border-top: 1px solid var(--line-soft); }
.land-foot .side-logo { padding: 0; font-size: 16px; }
@media (max-width: 760px) {
  .land { padding: 0 16px; }
  .land-nav { gap: 16px; }
}
/* The top bar needs 360 px with all three links; the footer has the guide too. */
@media (max-width: 380px) {
  .land-nav .land-how { display: none; }
}

/* /news and /news/<slug> (lib/public-news.js) */
.pn { max-width: 760px; padding: 36px 0 8px; }
.pn h1 { font-size: 30px; line-height: 38px; font-weight: 700; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.pn-date { margin-top: 6px; font-size: 14px; color: var(--muted); }
.pn-list { margin-top: 20px; }
.pn-item { padding: 26px 0; border-top: 1px solid var(--line-soft); }
.pn-item h2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.pn-item h2 a { color: var(--ink); text-decoration: none; }
.pn-item h2 a:hover { color: var(--accent-hover); text-decoration: underline; }
.pn-banner { display: block; margin-top: 14px; }
.pn-banner img { max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.pn-first { margin-top: 12px; font-size: 15px; line-height: 23px; color: var(--ink-2); }
.pn-back { font-size: 14px; font-weight: 600; }
.pn-back a { text-decoration: none; }
.pn-back a:hover { text-decoration: underline; }
.pn-post h1 { margin-top: 10px; }
.pn-post .post { margin-top: 22px; }
.pn-cta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 20px; margin-top: 40px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--side); }
.pn-cta p { font-size: 16px; line-height: 23px; font-weight: 600; }
.pn-missing { margin-top: 10px; font-size: 15px; color: var(--ink-2); }

/* The homepage's News block */
.nb { max-width: 820px; border-top: 1px solid var(--line-soft); }
.nb-item { display: block; padding: 14px 2px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); text-decoration: none; }
.nb-item strong { display: block; margin-top: 2px; font-size: 16px; line-height: 22px; font-weight: 600; color: var(--ink); }
.nb-item:hover strong { color: var(--accent-hover); text-decoration: underline; }
.nb-date { display: block; font-size: 13px; line-height: 18px; color: var(--muted); }
.nb-first { display: block; margin-top: 3px; font-size: 15px; line-height: 22px; }

/* ── Fault code pages (lib/public-codes.js) ── */
.pn-wide { max-width: none; }
.cp { padding: 0; }
.cp h1 { margin-top: 10px; }
.cp-sev { margin-top: 12px; }
.cp-sys { margin-top: 6px; font-size: 15px; color: var(--muted); }
.cp-which { margin-top: 20px; border-top: 1px solid var(--line-soft); }
.cp-which > div { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; line-height: 22px; color: var(--ink-2); }
.cp-which b { font-weight: 700; color: var(--ink); }
.cp-which .std { display: block; font-size: 13px; line-height: 18px; color: var(--muted); }
.cp h2 { margin-top: 28px; font-size: 18px; line-height: 24px; font-weight: 700; }
.cp .txt { margin-top: 8px; font-size: 15px; line-height: 23px; color: var(--ink-2); }
.cp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.cp ul.causes { margin-top: 6px; }
.cp ul.causes li { position: relative; padding-left: 16px; margin-top: 6px; font-size: 15px; line-height: 22px; color: var(--ink-2); }
.cp ul.causes li::before { content: ''; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); }
.cp-disc { margin-top: 22px; font-size: 13px; color: var(--muted); }
.cp-rel { margin-top: 8px; border-top: 1px solid var(--line-soft); }
.cp-rel a { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); text-decoration: none; font-size: 15px; line-height: 22px; }
.cp-rel a b { color: var(--accent-ink); }
.cp-rel a:hover span { text-decoration: underline; color: var(--accent-hover); }
@media (max-width: 640px) {
  .cp-cols { grid-template-columns: 1fr; }
  .cp h1 { font-size: 25px; line-height: 32px; }
  .cp-rel a { grid-template-columns: 1fr; gap: 0; }
}
.ci-look { margin-top: 18px; max-width: 460px; }
.ci-box { display: flex; gap: 8px; margin-top: 6px; }
.ci-box .btn { flex: none; }
.ci-look .input { text-transform: uppercase; }
.ci-groups { margin-top: 8px; column-count: 2; column-gap: 48px; }
.ci-group { break-inside: avoid; padding-top: 24px; }
.ci-group h2 { margin: 0 0 6px; font-size: 16px; line-height: 22px; font-weight: 700; }
.ci-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line-soft); color: var(--ink-2); text-decoration: none; font-size: 15px; line-height: 21px; }
.ci-row b { color: var(--accent-ink); font-weight: 700; }
.ci-row:hover .t { color: var(--accent-hover); text-decoration: underline; }
.ci-sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 700px) {
  .ci-groups { column-count: 1; }
  .ci h1 { font-size: 25px; line-height: 32px; }
  .ci-row { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .ci-row b { grid-column: 1; }
  .ci-row .t { grid-column: 1; }
  .ci-row .ci-sev { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .ci-row .ci-sev .w { display: none; }
}

/* ── Playback (Drives): one drive played back over the whole window ──────────── */
.pb { position: fixed; inset: 0; z-index: 1200; display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "head head" "main side" "foot foot"; background: var(--bg); overscroll-behavior: contain; }
.pb-head { grid-area: head; display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.pb-title { flex: 1; min-width: 0; }
.pb-title h2 { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; }
.pb-title p { margin-top: 1px; font-size: 14px; color: var(--muted); }
.pb-main { grid-area: main; position: relative; min-height: 0; }
.pb-status { padding: 24px 20px; color: var(--muted); }
.pb-map { position: absolute; inset: 0; }
.pb-map .leaflet-tile-pane { filter: saturate(.45) brightness(1.03); }
.pb-map { overflow: hidden; background: #EEF1F5; }
.pb-tilt, .pb-cam { position: absolute; inset: 0; }
.pb-map .leaflet-container { background: #EEF1F5; font-family: inherit; }
.pb-map .leaflet-interactive:focus { outline: none; }
/* The tilted route cannot read a pointer: its speed tooltip would show another point. */
.pb-persp .pb-tilt .leaflet-interactive { pointer-events: none; }
/* Perspective: the map leans back into a haze, and takes no pointer. */
.pb-map.pb-persp { background: linear-gradient(#E1E6EE, #EEF1F5 40%); }
.pb-map.pb-persp { touch-action: none; cursor: grab; }
.pb-persp .pb-tilt { overflow: hidden; pointer-events: none; -webkit-mask-image: linear-gradient(transparent, #000 22%); mask-image: linear-gradient(transparent, #000 22%); }
.pb-tools { position: absolute; z-index: 1000; top: 10px; left: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pb-views { box-shadow: 0 1px 4px rgba(23, 32, 51, .14); }
/* The map's buttons, top right: zoom, then the Follow car and Radar toggles. */
.pb-ctrls { position: absolute; z-index: 1000; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 8px; }
.pb-btns { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; }
.pb-btns button { width: 34px; height: 34px; padding: 0; border: 0; background: var(--bg); font-size: 20px; line-height: 1; color: var(--ink); }
.pb-btns button + button { border-top: 1px solid var(--line-2); }
.pb-btns button:hover { background: var(--hover); }
.pb-btns button:focus-visible { outline-offset: -3px; }   /* the group clips anything outside it */
.pb-btns button[aria-disabled="true"] { color: var(--faint); background: var(--bg); cursor: default; }
.pb-tog { display: grid; place-items: center; }
.pb-tog svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pb-btns .pb-tog { color: var(--ink-2); }
.pb-btns .pb-tog[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.pb-btns .pb-tog[aria-pressed="true"]:hover { background: color-mix(in srgb, var(--accent-soft) 82%, var(--accent)); }
.pb-tog[aria-pressed="true"] .pb-fill { fill: currentColor; }
.pb-credit { position: absolute; z-index: 1000; right: 0; bottom: 0; padding: 1px 6px; background: rgba(255, 255, 255, .8); font-size: 12px; line-height: 16px; color: var(--ink-2); }
.pb-credit a { color: #0078A8; text-decoration: none; }
.pb-arrow { position: absolute; z-index: 999; width: 34px; height: 34px; pointer-events: none; filter: drop-shadow(0 1px 2px rgba(23, 32, 51, .35)); }
.pb-arrow path { fill: var(--accent); stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; }
.pb-arrow.pb-frozen path { fill: #fff; stroke: #8A94A6; stroke-width: 2.2; }
.pb-side { grid-area: side; min-height: 0; overflow: auto; padding: 4px 20px; border-left: 1px solid var(--line); }
.pb-side .rd:first-child { border-top: 0; }
.pb-more-h, .pb-wx-h { margin-top: 18px; }
.pb-wx-none { padding: 7px 0 8px; color: var(--muted); }
.pb-tiles, .pb-gps-map, .pb-more-box { display: none; }
.pb-wx-box { display: none; }
.pb-foot { grid-area: foot; display: flex; flex-direction: column; padding: 8px 20px 12px; border-top: 1px solid var(--line); }
.pb-bar { display: flex; align-items: center; gap: 12px; }
.pb-play { flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0 0 0 1px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; }
.pb-play:hover { background: var(--accent-hover); }
.pb-time { flex: none; min-width: 74px; font-size: 16px; font-weight: 700; }
.pb-skip { font-size: 13px; font-weight: 600; color: var(--muted); }
.pb-gap { flex: 1; }
.pb-chart { position: relative; height: 120px; margin-top: 6px; cursor: pointer; touch-action: none; }
.pb-chart:focus-visible { outline-offset: 0; }
.pb-playhead { position: absolute; left: 0; top: 0; pointer-events: none; }

/* No route: the readings take the space, in two columns. */
.pb.pb-none { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "foot"; }
.pb-none .pb-main { overflow: auto; padding: 18px 28px; }
.pb-noroute { font-size: 14px; line-height: 20px; color: var(--ink-2); }
.pb-noroute strong { font-weight: 600; }
.pb-none .pb-side { max-width: 880px; margin-top: 14px; padding: 0; border-left: 0; overflow: visible; }
.pb-none .pb-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
.pb-none .pb-side .rd:nth-child(2) { border-top: 0; }
.pb-none .pb-rows:first-child .rd-val { font-size: 30px; line-height: 36px; }

@media (max-width: 860px) {
  .pb { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto auto auto; grid-template-areas: "head" "main" "tiles" "wx" "more" "foot"; }
  .pb-head { padding: 10px 14px; }
  .pb-title h2 { font-size: 17px; line-height: 22px; }
  .pb-title p { font-size: 13px; }
  .pb-btns button { width: 30px; height: 30px; }
  .pb-views .seg { height: 28px; padding: 0 9px; font-size: 12px; }
  .pb-route .pb-side { display: none; }
  .pb-route .pb-tiles { grid-area: tiles; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); border-top: 1px solid var(--line); }
  .pb-tile { min-width: 0; padding: 7px 10px 8px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
  .pb-tile.end { border-right: 0; }
  .pb-tile.q { padding: 7px 8px 8px; }
  .pb-tile.q .n { font-size: 18px; }
  .pb-gps-map { display: inline-flex; position: absolute; left: 10px; bottom: 22px; z-index: 1000; }
  .pb-bar .pill { display: none; }
  .pb-rates { flex-wrap: nowrap; }
  .pb-tile .k { font-size: 11px; line-height: 14px; color: var(--muted); }
  .pb-tile .n { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.01em; }
  .pb-tile .u { margin-left: 3px; font-size: 12px; color: var(--muted); }
  .pb-route .pb-more-box { grid-area: more; display: block; margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); }
  .pb-more-box .pb-rows { max-height: 32vh; overflow: auto; margin-top: 4px; }
  .pb-more-box .rd:first-child { border-top: 0; }
  .pb-route .pb-wx-box { grid-area: wx; display: block; margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); }
  .pb-wx-box .pb-rows { margin-top: 4px; }
  .pb-wx-box .rd:first-child { border-top: 0; }
  .pb-foot { padding: 4px 12px 10px; }
  .pb-chart { order: -1; height: 76px; margin: 0 0 4px; }
  .pb-bar { gap: 8px; }
  .pb-rates .seg { padding: 0 9px; }
  .pb-none .pb-main { padding: 12px 16px; }
  .pb-none .pb-rows { display: block; }
  .pb-none .pb-side .rd:nth-child(2) { border-top: 1px solid var(--line-soft); }
  .pb-none .pb-rows:first-child .rd-val { font-size: 22px; line-height: 28px; }
}
