/* ClearTrack web dashboard. Colours follow the Android app's theme and status colours. */

:root {
  color-scheme: light;
  --primary: #1d4ed8;
  --on-primary: #ffffff;
  --primary-soft: #dce5ff;
  --on-primary-soft: #0b1b4d;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e9ecf4;
  --line: #dde1ea;
  --line-strong: #b8bfcc;
  --text: #16181d;
  --text-2: #4b5261;
  --text-3: #6b7280;

  /* Status colours: the same in both modes, like the app. Text versions keep contrast. */
  --ok: #16a34a;
  --driving: #2563eb;
  --warn: #f59e0b;
  --alarm: #dc2626;
  --offline: #6b7280;
  --wifi: #0891b2;
  --ok-text: #15803d;
  --driving-text: #1d4ed8;
  --warn-text: #b45309;
  --alarm-text: #b91c1c;
  --offline-text: #4b5563;
  --wifi-text: #0e7490;
  --cell-text: #c2410c;
  --primary-text: #1d4ed8;

  /* Charts (validated per chart: the line with one threshold) */
  --series-1: #2a78d6;
  --guide-warn: #d97706;
  --guide-alarm: #dc2626;
  --grid: #e4e7ee;
  --axis: #6b7280;

  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --radius: 16px;
  --top: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --primary: #9db8ff;
    --on-primary: #0b1b4d;
    --primary-soft: #1e3a8a;
    --on-primary-soft: #dce5ff;
    --bg: #0f1115;
    --surface: #16191f;
    --surface-2: #1b1f27;
    --surface-3: #242a34;
    --line: #2e3440;
    --line-strong: #4b5363;
    --text: #e8eaf0;
    --text-2: #b4bac6;
    --text-3: #8b93a3;
    --ok-text: #4ade80;
    --driving-text: #93b4ff;
    --warn-text: #fbbf24;
    --alarm-text: #f87171;
    --offline-text: #9ca3af;
    --wifi-text: #22d3ee;
    --cell-text: #fb923c;
    --primary-text: #9db8ff;
    --series-1: #3987e5;
    --guide-warn: #d97706;
    --guide-alarm: #ef4444;
    --grid: #2a303b;
    --axis: #8b93a3;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary-text); }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { flex: none; fill: currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.center { display: flex; justify-content: center; }
.stale { opacity: .55; transition: opacity .2s; }
.noscript { padding: 24px; text-align: center; }
[hidden] { display: none !important; }

/* ---- status tones: set --c (marks) and --ct (text) */
.tone-ok { --c: var(--ok); --ct: var(--ok-text); }
.tone-driving { --c: var(--driving); --ct: var(--driving-text); }
.tone-warn { --c: var(--warn); --ct: var(--warn-text); }
.tone-alarm { --c: var(--alarm); --ct: var(--alarm-text); }
.tone-offline { --c: var(--offline); --ct: var(--offline-text); }
.tone-wifi { --c: var(--wifi); --ct: var(--wifi-text); }
.tone-primary { --c: var(--primary); --ct: var(--primary-text); }
.tone-text-ok { color: var(--ok-text); }
.tone-text-driving { color: var(--driving-text); }
.tone-text-warn { color: var(--warn-text); }
.tone-text-cell { color: var(--cell-text); }
/* The LTE estimate (cell tower, not GPS): status line and its label on the map. */
.cell-line { display: flex; gap: 6px; align-items: flex-start; }
.cell-line svg { flex: none; margin-top: 1px; }
.cell-marker {
  position: absolute; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; transform: translate(-50%, -50%);
  border-radius: 999px; background: #ea580c; color: #fff; font: 600 12px/1.2 system-ui, sans-serif; white-space: nowrap;
  box-shadow: 0 1px 4px rgb(0 0 0 / 30%); pointer-events: none;
}
.tone-text-alarm { color: var(--alarm-text); }
.tone-text-offline { color: var(--offline-text); }
.tone-text-wifi { color: var(--wifi-text); }
.tone-text-primary { color: var(--primary-text); }

/* ---- frame */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  height: var(--top); padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.logo { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background: #1d4ed8; color: #fff; }
.topnav { display: flex; gap: 4px; }
.topnav a, .account-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px;
  color: var(--text-2); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.topnav a:hover, .account-link:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current], .account-link[aria-current] { background: var(--primary-soft); color: var(--on-primary-soft); }
.live { display: inline-flex; align-items: center; gap: 6px; margin-right: 6px; font-size: 13px; color: var(--text-2); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); }
.live.up i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
@media (max-width: 700px) {
  .brand > span:not(.logo), .topnav a span, .account-link span, .live span { display: none; }
  .brand { margin-right: 2px; }
}
#view { min-height: calc(100vh - var(--top)); }

.page { max-width: 1200px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 16px; }
.page.narrow { max-width: 760px; }
.page-title { font-size: 22px; font-weight: 650; }
@media (max-width: 640px) { .page { padding: 16px 16px 40px; } }

.loading { display: flex; justify-content: center; padding: 40px 0; }
.spin { display: inline-block; width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spin.small { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-box { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 520px; margin: 0 auto; padding: 48px 24px; text-align: center; color: var(--text-2); }
.state-box h2 { color: var(--text); font-size: 20px; }
.state-icon { color: var(--primary-text); }

/* ---- cards and lists */
.card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; }
.next-update { display: flex; align-items: baseline; gap: 6px; }
.next-update strong { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
/* Fills slowly from the last check-in to the estimated next one. */
.checkin-bar { display: block; align-self: stretch; height: 3px; overflow: hidden; border-radius: 2px; background: var(--surface-3); }
.checkin-bar[hidden] { display: none; }
.checkin-bar > span { display: block; height: 100%; background: var(--primary); opacity: .5; transform: scaleX(0); transform-origin: left; transition: transform 1s linear; }
.checkin-bar.due > span { animation: checkin-wait 2s ease-in-out infinite; }
@keyframes checkin-wait { 50% { opacity: .2; } }
.car-card-main > .checkin-bar { margin-top: 3px; }
.card-subtitle { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-foot { display: flex; align-items: center; gap: 8px; }
.card-foot > span { flex: 1; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.card > .section-title { margin-top: 0; }
.section-title h3 { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-text); }
.list-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.list-row:first-child { border-top: 0; }
a.list-row:hover, .list-row.clickable:hover { background: var(--surface-2); cursor: pointer; }
.list-row > .icon:last-child { color: var(--text-3); }
.align-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.plain-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.info-rows { display: flex; flex-direction: column; margin: 0; }
.info-rows > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-top: 1px solid var(--line); }
.info-rows > div:first-child { border-top: 0; }
.info-rows dt { color: var(--text-2); }
.info-rows dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2.tight { gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid-3 > :first-child { grid-column: span 2; }
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 4px; }
.stack > .btn:not(.big) { align-self: flex-start; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border: 1px solid transparent; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-size: 14px; font-weight: 600;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.big { width: 100%; min-height: 48px; font-size: 15px; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.tonal { background: var(--primary-soft); color: var(--on-primary-soft); }
.btn.outline { background: transparent; color: var(--primary-text); border-color: var(--line-strong); }
.btn.text { background: transparent; color: var(--primary-text); padding-inline: 10px; }
.btn.outline:hover, .btn.text:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--alarm); color: #fff; }
.btn.danger-text { color: var(--alarm-text); }
.btn.on-alarm { background: #fff; color: #b91c1c; }
.btn.icon-only { width: 40px; padding: 0; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button-row.end { justify-content: flex-end; }
.row-end { display: flex; justify-content: flex-end; }
.link { color: var(--primary-text); font-size: 13px; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Default colours at zero specificity, so a tone-* class on the pill wins. */
:where(.pill) { --c: var(--primary); --ct: var(--primary-text); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--ct);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.plate {
  padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px;
  color: var(--text-2); font-size: 12px; font-weight: 600; letter-spacing: .04em; white-space: nowrap;
}
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.count-badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--c); color: #fff; font-size: 12px; font-weight: 700;
}
.badge-circle {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c);
}
.progress { display: block; height: 4px; margin: 4px 0 2px; overflow: hidden; border-radius: 2px; background: color-mix(in srgb, var(--c) 18%, transparent); }
.progress > span { display: block; height: 100%; border-radius: 2px; background: var(--c); }
.progress.big { height: 8px; border-radius: 4px; }
/* 1NCE data by day (lib.js simQuotaBar): outline = the day's allowance, fill = what it used. */
.sim-days { margin: 6px 0 4px; }
.sim-days-plot { display: flex; align-items: flex-end; gap: 3px; height: 64px; }
.sim-day { position: relative; flex: 1 1 0; min-width: 0; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.sim-day > span { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px 3px 0 0; }
.sim-day-allow { background: color-mix(in srgb, var(--text-2) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-2) 30%, transparent); }
.sim-day-used { background: var(--c); }
.sim-day.estimated .sim-day-used { opacity: .45; }
.sim-day.picked .sim-day-allow { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text-2) 90%, transparent); }
.sim-days-axis { display: flex; justify-content: space-between; margin-top: 2px; }
.signal { color: var(--text-2); }
.signal .on { fill: currentColor; }
.signal .off { fill: currentColor; opacity: .22; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 420px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px;
  border: 0; border-radius: 14px; background: var(--surface-2); text-align: left;
}
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { background: var(--surface-3); }
.tile-label { display: flex; align-items: center; gap: 6px; overflow: hidden; color: var(--text-2); font-size: 12.5px; white-space: nowrap; text-overflow: ellipsis; }
.tile-label .icon { color: var(--c, var(--primary-text)); }
.tile-value { overflow: hidden; font-size: 17px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.tile-detail { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Trip efficiency (leaf) and safety (hazard) scores */
.score-chips { display: flex; gap: 4px; }
.score-chip {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px 1px 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--ct); font-size: 12px; font-weight: 700;
}
.score-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.score-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.score-badge {
  display: grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--ct);
}
.score-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.score-value { color: var(--ct); font-size: 24px; font-weight: 700; }
.score-value small { color: var(--text-2); font-size: 12px; font-weight: 500; }

.avatar {
  --car: #2563eb;
  display: inline-grid; place-items: center; flex: none; overflow: hidden;
  width: 48px; height: 48px; border-radius: 50%; background: var(--car); color: #fff;
}
.avatar.ringed { border: 3px solid var(--ring); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar:has(.default-car), .photo-pick:has(.default-car) { background: var(--surface-2, #e2e8f0); }
.avatar img.default-car, .photo-pick img.default-car { width: 90%; height: 90%; object-fit: contain; }
.avatar:has(.cutout) { background: var(--surface-2, #e2e8f0); }
.avatar img.cutout { width: 92%; height: 92%; object-fit: contain; }
.avatar:has(.car-loading) { background: var(--surface-2, #e2e8f0); }
.avatar img.car-loading { width: 60%; height: 60%; object-fit: contain; }
/* A car picture's low-res copy, blurred, while the full one loads (lists and map markers). */
.avatar img.thumb-blur { filter: blur(2px); }
.car-marker .car-badge .car-top.thumb-blur { filter: blur(2px) !important; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.field-help { color: var(--text-2); font-size: 12.5px; }
:where(input:not([type=checkbox], [type=radio], [type=range], [type=file]), select) {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
:where(input, select):focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input.invalid { border-color: var(--alarm); outline-color: var(--alarm); }
input[type=range] { width: 100%; margin: 4px 0; accent-color: var(--primary); }
input[type=checkbox], input[type=radio] { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.form-error { color: var(--alarm-text); font-size: 14px; }
.input-with { display: flex; align-items: center; gap: 6px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.check-row.top { align-items: flex-start; }
.check-list { display: flex; flex-direction: column; max-height: 300px; overflow: auto; padding: 4px 12px; border: 1px solid var(--line); border-radius: 12px; }
.radio-list { display: flex; flex-direction: column; gap: 2px; }
.radio-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 32px; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { border-color: transparent; background: var(--primary-soft); color: var(--on-primary-soft); }
.chip:disabled { opacity: .5; cursor: default; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch .track { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 30%); transition: transform .15s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .5; }
.switch-label { font-size: 14px; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  display: flex; flex-direction: column; min-width: 260px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
}
.menu-list a, .menu-list button {
  padding: 10px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--text); font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-list .tone-text-alarm { color: var(--alarm-text); }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); }

/* ---- dialogs and messages */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgb(0 0 0 / 30%);
}
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(15 17 21 / 50%); }
.dialog-panel { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 12px 6px 20px; }
.dialog header h2 { font-size: 18px; }
.dialog-body { padding: 8px 20px 18px; overflow: auto; }
.dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.sheet-title { font-size: 20px; }
.toasts {
  position: fixed; inset: auto auto 20px 50%; z-index: 1000; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(560px, calc(100vw - 32px)); margin: 0; padding: 0; overflow: visible;
  border: 0; background: transparent; pointer-events: none;
}
.toast {
  max-width: 100%; padding: 12px 16px; border-radius: 12px; background: #1f2937; color: #fff;
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%); font-size: 14px; pointer-events: auto; animation: toast-in .2s ease-out;
}
.toast.tone-error, .toast.tone-alarm { background: #b91c1c; }
.toast.tone-warn { background: #92400e; }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); background: color-mix(in srgb, var(--c) 12%, var(--surface));
  color: var(--text); text-decoration: none;
}
.banner > .icon:first-child { color: var(--ct); }
.banner > span { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.banner > span > span { color: var(--ct); font-size: 13px; }
.banner > .icon:last-child { color: var(--text-3); }
.banner.static > span { color: var(--text); font-size: 14px; }
.note { display: flex; align-items: flex-start; gap: 8px; color: var(--text-2); font-size: 13px; }
.note .icon { margin-top: 1px; color: var(--primary-text); }

/* ---- sign-in */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  display: flex; flex-direction: column; gap: 14px; width: min(400px, 100%); padding: 32px 28px;
  border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); text-align: center;
}
.login-card .logo { align-self: center; }
.login-card h1 { font-size: 26px; }
.login-card .field { text-align: left; }
.signup-captcha { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.account-card { flex-direction: row; align-items: center; gap: 14px; }
.account-card > div { display: flex; flex-direction: column; }

/* ---- all cars */
.home { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); height: calc(100vh - var(--top)); }
.home-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.side-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.side-head h1 { font-size: 20px; }
.car-list { display: flex; flex: 1; flex-direction: column; gap: 10px; overflow: auto; padding: 8px 12px 24px; }
.home-map-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.home-map { position: relative; flex: 1; min-height: 0; }
@media (max-width: 900px) {
  .home { grid-template-columns: minmax(0, 1fr); height: auto; }
  .home-map-wrap { order: -1; height: 45vh; min-height: 280px; }
  .home-side { border-right: 0; }
  .car-list { overflow: visible; }
}
.car-card {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
}
.car-card:hover { border-color: var(--line-strong); }
.car-card > .icon { color: var(--text-3); }
.car-card-main { display: flex; flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
.car-card-title { display: flex; align-items: baseline; gap: 8px; max-width: 100%; min-width: 0; }
.car-card-title strong { overflow: hidden; font-size: 16px; white-space: nowrap; text-overflow: ellipsis; }
.car-card-title .plate { flex: none; }
.car-card-backup { display: inline-flex; flex: none; align-self: center; align-items: center; gap: 2px; font-size: 12.5px; white-space: nowrap; }
/* One line whatever the next check-in says, so the card keeps its height as the car checks in. */
.car-card-meta { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; max-width: 100%; min-width: 0; color: var(--text-2); font-size: 13px; }
.car-card-meta > span { display: inline-flex; flex: none; align-items: center; gap: 3px; white-space: nowrap; }
.car-card-meta > span[data-next-update] { display: block; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---- maps */
.map { background: var(--surface-3); }
.map-card { position: relative; padding: 0; overflow: hidden; }
/* "Locating car…" while an open map waits for the car to switch to live updates (car.js,
   locatingCar): a floating card low on the map, clear of the controls and the car's last spot. */
.locating { position: absolute; bottom: 96px; left: 50%; z-index: 5; transform: translateX(-50%); width: max-content; max-width: calc(100% - 136px); pointer-events: none; }
.locating[hidden] { display: none; }
.locating-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); animation: toast-in .2s ease-out;
}
.locating-card strong { display: block; font-size: 14px; color: var(--text); }
.locating-when { display: block; font-size: 12.5px; color: var(--text-2); }
.map-missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 100%; min-height: 200px; padding: 24px; color: var(--text-2); font-size: 13px; text-align: center;
}
.map-missing strong { color: var(--text); font-size: 14px; }
.overview-map { height: 460px; }
/* Full-screen map (car overview): the map card over the whole window, an Exit button on top. */
.map-card.map-full { position: fixed; inset: 0; z-index: 1000; margin: 0; border-radius: 0; }
.map-card.map-full .overview-map { height: 100%; }
body.map-full-open { overflow: hidden; }
/* A sticky column would hold the full-screen map in its own stacking context, under the header. */
body.map-full-open .overview-map-col { position: static; }
.map-exit { margin: 10px; box-shadow: rgb(0 0 0 / 30%) 0 1px 4px -1px; }
.trip-map { height: 440px; }
.gps-map { height: 400px; }
.gps-card { gap: 0; margin-bottom: 12px; }
.gps-timeline { display: grid; gap: 2px; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.gps-timeline input[type=range] { width: 100%; margin: 4px 0; accent-color: var(--driving); }
.gps-timeline-row { display: flex; align-items: center; gap: 4px; }
.gps-when { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gps-when strong { font-variant-numeric: tabular-nums; }
tr.gps-row { cursor: pointer; }
tr.gps-row:hover td { background: var(--surface-2); }
tr.gps-row.selected td { background: var(--primary-soft); color: var(--on-primary-soft); }
tr.gps-row.selected a { color: inherit; }
@media (max-width: 600px) { .gps-map { height: 300px; } }
/* GPS log calendar: days with positions are bold with a dot; the rest can't be picked. */
.cal { display: grid; gap: 8px; min-width: min(320px, 100%); }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-size: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { padding: 4px 0; color: var(--text-3); font-size: 12px; font-weight: 600; }
.cal-day {
  position: relative; aspect-ratio: 1; min-height: 36px; border: 0; border-radius: 50%;
  background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
}
.cal-day:hover:not(:disabled) { background: var(--surface-2); }
.cal-day:disabled { color: var(--text-3); opacity: 0.45; cursor: default; }
.cal-day.has { font-weight: 700; }
.cal-day.has::after {
  content: ''; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--driving);
}
.cal-day.today { box-shadow: inset 0 0 0 1px var(--line-strong); }
.cal-day.selected { background: var(--primary); color: var(--on-primary); }
.cal-day.selected::after { background: var(--on-primary); }
.geo-map { height: 540px; }
.map-btn {
  display: grid; place-items: center; width: 40px; height: 40px; margin: 10px;
  border: 0; border-radius: 2px; background: #fff; color: #444; box-shadow: rgb(0 0 0 / 30%) 0 1px 4px -1px; cursor: pointer;
}
.map-btn:hover { color: #000; }
.map-follow {
  display: flex; align-items: center; gap: 6px; margin: 10px; padding: 0 14px 0 10px; height: 36px;
  border: 0; border-radius: 18px; background: #fff; color: #374151; font: 600 13px/1 system-ui, sans-serif;
  box-shadow: rgb(0 0 0 / 30%) 0 1px 4px -1px; cursor: pointer; white-space: nowrap;
}
.map-follow:hover { color: #000; }
.map-follow.paused { background: #1a73e8; color: #fff; }
.map-note {
  margin: 10px; padding: 5px 10px; border-radius: 12px; background: rgb(255 255 255 / 94%);
  color: #1f2937; font: 500 12px/1.3 system-ui, sans-serif; box-shadow: 0 1px 4px rgb(0 0 0 / 20%);
}
.map-note:empty { display: none; }
/* One colour per position source (maps.js SOURCE_COLORS): GPS green, Wi-Fi cyan, LTE orange. */
.source-key { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--source, #9ca3af); box-shadow: 0 0 0 2px color-mix(in srgb, var(--source, #9ca3af) 25%, transparent); }
.source-dot { position: absolute; width: 14px; height: 14px; transform: translate(-50%, -50%); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgb(0 0 0 / 40%); pointer-events: none; }
/* Under a map: the colours' key and the fine details. */
.map-legend { display: grid; gap: 4px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 12.5px; }
.map-legend-keys { display: flex; flex-wrap: wrap; gap: 14px; }
.map-legend-keys span, .map-legend-row { display: inline-flex; align-items: center; gap: 6px; }
.map-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 8px 12px; color: var(--text-2); font-size: 12.5px; }
.map-foot:empty { display: none; }
.map-card.map-full { display: flex; flex-direction: column; }
.map-card.map-full .overview-map { flex: 1; height: auto; min-height: 0; }
.map-sources {
  display: flex; margin: 10px; border-radius: 2px; overflow: hidden; background: #fff; box-shadow: rgb(0 0 0 / 30%) 0 1px 4px -1px;
}
.map-source {
  display: grid; gap: 1px; min-width: 64px; padding: 6px 10px; border: 0; border-right: 1px solid #e5e7eb;
  background: #fff; color: #374151; font: 600 13px/1.2 system-ui, sans-serif; text-align: center; cursor: pointer;
}
.map-source:last-child { border-right: 0; }
.map-source-time { font-weight: 400; font-size: 11px; color: #6b7280; }
.map-source-name { display: inline-flex; align-items: center; gap: 5px; }
.map-source.on { background: var(--source, #1a73e8); color: #fff; }
.map-source.on .source-key { background: #fff; box-shadow: none; }
.map-source.on .map-source-time { color: rgb(255 255 255 / 85%); }
.map-source:disabled { cursor: default; opacity: .45; }
.car-marker {
  /* --car-s / --car-t: picture and type sizes for the map's zoom (maps.js markerScale). */
  position: absolute; display: grid; place-items: center; width: calc(56px * var(--car-s, 1)); height: calc(56px * var(--car-s, 1)); padding: 0;
  border: 0; background: none; transform: translate(-50%, -50%); cursor: pointer;
}
/* Online cars pulse like the homepage's, in Wi-Fi blue (alarm/warning colour when set): one slow ring while parked, two quicker
   ones on the road, brighter under the pointer. An offline car stays still. */
.car-marker:not(.offline)::before, .car-marker.traveling:not(.offline)::after {
  content: ''; position: absolute; left: 50%; top: 50%; z-index: -1;
  width: calc(44px * var(--car-s, 1)); height: calc(44px * var(--car-s, 1)); margin: calc(-22px * var(--car-s, 1)) 0 0 calc(-22px * var(--car-s, 1));
  border: 2px solid var(--halo, var(--wifi)); border-radius: 50%; pointer-events: none; opacity: 0;
  animation: car-halo 6s ease-out infinite;
}
.car-marker.traveling:not(.offline)::before, .car-marker.traveling:not(.offline)::after { animation-duration: 4s; }
.car-marker.traveling:not(.offline)::after { animation-delay: -2s; }
.car-marker:not(.offline):hover::before, .car-marker:not(.offline):focus-visible::before { animation-duration: 2s; border-width: 3px; }
.car-marker.traveling:not(.offline):hover::after, .car-marker.traveling:not(.offline):focus-visible::after { animation-duration: 2s; animation-delay: -1s; border-width: 3px; }
@keyframes car-halo { from { transform: scale(.9); opacity: .6; } to { transform: scale(2.1); opacity: 0; } }
/* Each car on the road, top right: its live speed; a tap centres the map on it. */
.speed-board { display: grid; justify-items: end; gap: 6px; margin: 10px; pointer-events: none; }
.speed-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px 7px 10px; border: 1px solid rgb(255 255 255 / 10%); border-radius: 12px;
  background: rgb(17 24 39 / 88%); color: rgb(255 255 255 / 75%); font: 500 14px/1.2 system-ui, sans-serif; white-space: nowrap;
  box-shadow: 0 2px 8px rgb(0 0 0 / 30%); cursor: pointer; pointer-events: auto; backdrop-filter: blur(6px);
}
.speed-chip b { color: #fff; font-weight: 650; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.speed-chip-kmh { font-variant-numeric: tabular-nums; }
.speed-chip-dot { position: relative; width: 10px; height: 10px; margin-right: 2px; border-radius: 50%; background: var(--paint, #2563eb); box-shadow: 0 0 0 4px color-mix(in srgb, var(--paint, #2563eb) 25%, transparent); }
.speed-chip-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--paint, #2563eb); animation: car-halo 4s ease-out infinite; }
.speed-chip:hover { background: rgb(17 24 39 / 96%); }
@media (prefers-reduced-motion: reduce) {
  .car-marker::before, .car-marker::after, .speed-chip-dot::after { animation: none; opacity: 0; }
}
.map-icon-preview { width: 72px; height: 72px; object-fit: contain; flex: none; }
/* The car at an LTE or Wi-Fi estimate (no newer GPS fix): not a button. */
.car-marker.estimate-car { cursor: default; pointer-events: none; }
.car-marker.estimate-car.clickable { cursor: pointer; pointer-events: auto; }
.car-marker .car-top { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
/* The owner's vehicle photo (no map picture): upright and wider than the top-down car. */
.car-marker .car-top.car-photo { inset: -2px auto auto -22px; width: calc(100% + 44px); height: calc(100% + 4px); max-width: none; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 35%)); }
.car-marker .car-top.car-photo.opaque { inset: 8px auto auto -6px; width: calc(100% + 12px); height: calc(100% - 16px); object-fit: cover; border: 2px solid #fff; border-radius: 10px; filter: none; box-shadow: 0 1px 4px rgb(0 0 0 / 35%); }
/* The round badge: the car (or its photo) in a disc ringed in its paint while online, else the offline/alarm/warning colour. */
.car-marker .car-badge {
  position: relative; width: calc(44px * var(--car-s, 1)); height: calc(44px * var(--car-s, 1)); overflow: hidden;
  border: max(2px, calc(3px * var(--car-s, 1))) solid var(--ring); border-radius: 50%;
  background: var(--surface-2, #e2e8f0); box-shadow: 0 2px 6px rgb(0 0 0 / 35%); pointer-events: none;
}
.car-marker .car-badge .car-top { inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }
/* The default car and map pictures sit on the map with no disc, like the homepage's cars. */
.car-marker .car-badge:not(:has(.car-photo)) { overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
.car-marker .car-badge:not(:has(.car-photo)) .car-top { inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 2px 3px rgb(0 0 0 / 40%)); }
/* Offline: faded and greyed, still readable and tappable. */
.car-marker.offline .car-badge, .car-marker.offline .marker-name, .car-marker.offline .marker-label { opacity: .5; filter: grayscale(.7); }
/* Close cars hide their names and update times, keeping their map positions. */
.car-marker.compact .marker-name, .car-marker.compact .marker-label { visibility: hidden; }
/* While the car's own picture loads: a small spinner where the car will be (never turned to the heading). */
.car-marker .car-badge:not(:has(.car-photo)) .car-top.car-loading { inset: 20%; width: 60%; height: 60%; transform: none !important; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 30%)); }
.car-marker .car-badge .car-top.car-photo,
.car-marker .car-badge .car-top.car-photo.opaque { inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; filter: none; box-shadow: none; }
.marker-label {
  position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center;
  width: max-content; max-width: calc(106px * var(--car-t, 1)); overflow: hidden;
  padding: 1px calc(4px * var(--car-t, 1)); border-radius: 6px; background: #fff; color: #111827;
  font: 600 calc(10px * var(--car-t, 1))/calc(12px * var(--car-t, 1)) system-ui, sans-serif; white-space: nowrap; box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}
.marker-time { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: calc(9px * var(--car-t, 1)); font-weight: 500; line-height: calc(11px * var(--car-t, 1)); color: #4b5563; text-align: center; white-space: pre; }
/* The car's name, always above its picture. */
.marker-name {
  position: absolute; bottom: calc(100% - 4px * var(--car-s, 1)); left: 50%; transform: translateX(-50%);
  max-width: calc(120px * var(--car-t, 1)); overflow: hidden; text-overflow: ellipsis;
  padding: 1px calc(5px * var(--car-t, 1)); border-radius: 6px; background: #111827; color: #fff;
  font: 600 calc(10px * var(--car-t, 1))/calc(13px * var(--car-t, 1)) system-ui, sans-serif; white-space: nowrap; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); pointer-events: none;
}
.pin-marker {
  position: absolute; display: grid; place-items: center; width: 26px; height: 26px; transform: translate(-50%, -50%);
  border: 2px solid #fff; border-radius: 50%; background: #111827; color: #fff; font: 700 12px system-ui, sans-serif;
  box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
}
.car-dot {
  position: absolute; width: 16px; height: 16px; transform: translate(-50%, -50%);
  border: 3px solid #fff; border-radius: 50%; background: #dc2626; box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
}
.speed-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-2); font-size: 12.5px; }
.speed-legend span { display: inline-flex; align-items: center; gap: 6px; }
.speed-legend i { display: inline-block; width: 18px; height: 4px; border-radius: 2px; }
.speed-legend .harsh-dot { width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: #dc2626; box-shadow: 0 0 0 1px #dc2626; }
.route-colour { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
/* A traffic light on a trip map, coloured by the recorded outcome; a stop shows the wait. Tapped,
   what happened there and its record. */
.light-marker {
  position: absolute; display: flex; align-items: center; gap: 3px; transform: translate(-8px, -50%); padding: 0;
  border: 0; background: none; color: #111827; font: 700 11px system-ui, sans-serif; white-space: nowrap; cursor: pointer;
}
.light-marker i { flex: none; width: 16px; height: 16px; border: 2.5px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgb(0 0 0 / 35%), 0 1px 3px rgb(0 0 0 / 35%); }
.light-marker b { padding: 0 6px; border-radius: 999px; background: #fff; line-height: 17px; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); }
.light-marker .light-pop {
  display: none; position: absolute; top: calc(100% + 6px); left: -6px; flex-direction: column; gap: 2px; width: max-content; max-width: 260px;
  padding: 8px 10px; border-radius: 10px; background: #fff; color: #111827; font: 500 12px/1.4 system-ui, sans-serif; text-align: left;
  white-space: normal; box-shadow: 0 2px 8px rgb(0 0 0 / 30%);
}
.light-marker[aria-expanded="true"] { z-index: 3; }
.light-marker[aria-expanded="true"] .light-pop { display: flex; }
.speed-legend .light-legend { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; background: linear-gradient(90deg, #dc2626 50%, #16a34a 50%); box-shadow: 0 0 0 1px rgb(0 0 0 / 35%); }
.light-list { display: flex; flex-direction: column; margin: 4px 0; padding: 0; list-style: none; }
.light-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.light-list li > i { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.light-list li > span:first-of-type { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.light-list .light-odds { flex: none; font-weight: 600; }

/* ---- community lights map */
.lights-side { display: flex; flex: 1; flex-direction: column; gap: 12px; overflow: auto; padding: 4px 16px 24px; }
.lights-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.lights-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lights-legend i, .lights-approach-head i { flex: none; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgb(0 0 0 / 30%); }
.lights-detail { display: flex; flex-direction: column; gap: 10px; }
.lights-name { font-size: 17px; font-weight: 650; }
.lights-approach { display: flex; flex-direction: column; gap: 3px; padding-top: 10px; border-top: 1px solid var(--line); }
.lights-approach-head { display: flex; align-items: center; gap: 8px; }
.lights-approach-head .muted { margin-left: auto; }
.lights-now { font-weight: 600; }
.lights-bands { width: 100%; margin-top: 4px; border-collapse: collapse; }
.lights-bands td { padding: 3px 0; border-top: 1px solid var(--line); }
.lights-bands td:not(:first-child) { text-align: right; white-space: nowrap; padding-left: 10px; }
@media (max-width: 900px) { .lights-side { overflow: visible; } }

/* ---- one car */
.car-page { display: flex; flex-direction: column; }
.car-head { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px 24px 10px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; width: fit-content; color: var(--text-2); font-size: 14px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.car-head-main { display: flex; align-items: center; gap: 14px; }
.car-head-text { display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 0; }
.car-head-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.car-head-title h1 { overflow: hidden; font-size: 24px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.car-head-actions { display: flex; flex: none; flex-wrap: wrap; gap: 8px; }
.tabs {
  position: sticky; top: var(--top); z-index: 10;
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 0 max(16px, calc((100% - 1200px) / 2 + 16px));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.tabs::-webkit-scrollbar { display: none; }
/* Wide screens: every section in view, on a second row when they don't fit. Phones swipe. */
@media (min-width: 641px) { .tabs { flex-wrap: wrap; row-gap: 0; overflow-x: visible; } }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; padding: 12px 10px 10px;
  border-bottom: 2px solid transparent; color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { border-bottom-color: var(--primary); color: var(--primary-text); }
@media (max-width: 640px) {
  .car-head { padding: 12px 16px 8px; }
  .car-head-title h1 { font-size: 20px; }
  .car-head-main { flex-wrap: wrap; }
  .car-head-actions { flex-basis: 100%; }
  .toolbar .btn:not(.icon-only) { padding-inline: 12px; }
}

.overview-alarm { max-width: 1200px; margin: 0 auto; padding: 16px 24px 0; }
.overview-alarm:empty { display: none; }
.alarm-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px; background: var(--alarm); color: #fff; }
.alarm-banner > div { display: flex; flex: 1; flex-direction: column; }
.alarm-banner strong { font-size: 18px; letter-spacing: .04em; }
.overview {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start;
  max-width: 1200px; margin: 0 auto; padding: 16px 24px 48px;
}
.overview-map-col { position: sticky; top: calc(var(--top) + 60px); }
.overview-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 960px) {
  .overview { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 40px; }
  .overview-alarm { padding: 12px 16px 0; }
  .overview-map-col { position: static; }
  .overview-map { height: 340px; }
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-foot { display: flex; align-items: center; gap: 6px; }
.pending-row { display: flex; align-items: center; gap: 8px; }
.pending-row > span:first-child { flex: 1; }
.events { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.events.card { gap: 0; padding: 2px 16px; }
.event { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.event:first-child { border-top: 0; }
.event-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--c); }
.event-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.event.level-warning .event-title, .event.level-alarm .event-title { font-weight: 600; }
.event-body { color: var(--text-2); font-size: 13px; white-space: pre-line; }
.event-meta { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.event-meta a { display: inline-flex; color: var(--text-3); }
.event-meta a:hover { color: var(--primary-text); }

/* ---- charts */
.chart { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.chart-plot { position: relative; width: 100%; }
.chart-plot:focus-visible { outline-offset: 4px; }
.chart-plot svg { display: block; overflow: visible; }
.chart-empty { padding: 28px 0; color: var(--text-2); font-size: 13px; text-align: center; }
.c-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.c-axis { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.c-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.c-area { fill: var(--series-1); opacity: .1; }
.c-guide { stroke-width: 1.5; }
.c-guide.tone-warn { stroke: var(--guide-warn); }
.c-guide.tone-alarm { stroke: var(--guide-alarm); }
.c-guide-label { fill: var(--text-2); font-size: 11px; }
.c-cross { stroke: var(--text-3); stroke-width: 1; }
.c-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.c-bar { fill: var(--series-1); }
.c-bar.hover { opacity: .75; }
.c-hit { fill: transparent; outline: none; }
.c-hit:focus-visible { fill: color-mix(in srgb, var(--series-1) 12%, transparent); }
.c-value { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.chart-tip {
  position: absolute; z-index: 2; display: flex; flex-direction: column; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 4px 14px rgb(0 0 0 / 15%);
  font-size: 12px; white-space: nowrap; pointer-events: none;
}
.chart-tip strong { font-size: 14px; }
.chart-tip span { color: var(--text-2); }
.chart-table summary { width: fit-content; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.table-wrap { max-height: 260px; margin-top: 6px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.table-wrap th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; }
.big-number { font-size: 34px; font-weight: 650; line-height: 1.1; }
.reading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
/* Battery page: the backup cell's estimated life, one slider per phase (battery.js renderLife). */
.battery-life .life-phase { padding: 10px 0 2px; border-top: 1px solid var(--line); margin-top: 10px; }
.battery-life .life-phase p { margin: 2px 0; }
.life-phase-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.life-phase-head strong { white-space: nowrap; }
.life-range { width: 100%; margin: 8px 0 2px; accent-color: var(--primary, currentColor); }
.odometer-card { flex-direction: row; align-items: center; gap: 16px; }

/* ---- battery */
.volts-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.volts-field { display: inline-flex; align-items: center; gap: 6px; }
.volts-input { width: 96px; text-align: right; }

/* ---- maintenance */
.maint { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.toolbar + .maint { margin-top: 16px; }
.maint-main, .maint-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 960px) { .maint { grid-template-columns: minmax(0, 1fr); } }
.maint-row { display: flex; align-items: center; gap: 12px; }
.car-card-maint hr { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--line); }
.conditions { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.recalls { display: flex; flex-direction: column; }
.recall { padding: 10px 0 4px; border-top: 1px solid var(--line); }
.recall:first-child { border-top: 0; }
.recall-head {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 0;
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer;
}
.recall-issue { display: -webkit-box; margin-top: 4px; overflow: hidden; font-size: 14px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.recall.open .recall-issue { display: block; }
.recall-body { display: none; flex-direction: column; gap: 8px; padding: 6px 0 0 48px; }
.recall.open .recall-body { display: flex; }
.recall-body h4 { font-size: 13px; font-weight: 600; }
.recall-body p { font-size: 14px; white-space: pre-line; }
.recall .button-row { padding-left: 40px; }
.visit { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.visit:first-child { border-top: 0; }
.input-with .vin-state { display: inline-flex; min-width: 18px; }

/* ---- settings */
.settings-page { gap: 12px; }
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--top) + 64px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav button {
  padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: var(--text-2);
  font-size: 14px; text-align: left; cursor: pointer;
}
.settings-nav button:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { display: none; }
}
.settings-groups { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.settings-group { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: calc(var(--top) + 64px); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting.changed { background: color-mix(in srgb, var(--warn) 7%, transparent); box-shadow: inset 3px 0 0 var(--warn); }
.setting-text { display: flex; flex-direction: column; gap: 3px; }
.setting-label { font-weight: 500; }
.setting-help { color: var(--text-2); font-size: 13px; }
.setting-control { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.setting-control select { max-width: 340px; }
.setting-input { width: 150px; text-align: right; }
.setting-range { width: 220px; max-width: 100%; accent-color: var(--primary, currentColor); }
.setting-unit { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.setting-hint { color: var(--text-2); font-size: 12.5px; }
.setting-hint:empty { display: none; }
@media (max-width: 640px) {
  .setting { grid-template-columns: minmax(0, 1fr); }
  .setting-control { align-items: flex-start; }
}
.savebar {
  position: sticky; bottom: 0; z-index: 15;
  display: flex; align-items: center; gap: 8px;
  padding: 12px max(24px, calc((100% - 1200px) / 2 + 24px));
  border-top: 1px solid var(--line); background: var(--surface); box-shadow: 0 -4px 16px rgb(0 0 0 / 8%);
}

/* ---- geofences, device, add tracker */
.geo { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.geo-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 960px) {
  .geo { grid-template-columns: minmax(0, 1fr); }
  .geo-map { height: 380px; }
}
.range-row { display: flex; align-items: center; gap: 12px; }
.narrow-input { width: 110px; }
.console {
  display: block; margin: 8px 0; padding: 12px; border-radius: 10px; background: var(--surface-3);
  font-size: 13px; overflow-wrap: anywhere; user-select: all;
}
.steps { gap: 16px; margin: 0; padding: 16px; list-style: none; }
.step { display: flex; gap: 12px; }
.step-n {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-size: 13px; font-weight: 700;
}
.step > div { flex: 1; min-width: 0; padding-top: 2px; }
.diag li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.diag li:first-child { border-top: 0; }
.diag code { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.danger-zone { border-color: color-mix(in srgb, var(--alarm) 40%, var(--line)); }
.photo-row { display: flex; align-items: center; gap: 16px; }
.photo-pick {
  --car: #2563eb;
  display: grid; place-items: center; flex: none; overflow: hidden; width: 84px; height: 84px;
  border: 0; border-radius: 50%; background: var(--car); color: #fff; cursor: pointer;
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 32px; height: 32px; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 15%); cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
/* Edit tracker → Car on the map: the default cars in the car's colour, and the owner's own picture. */
.map-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.map-pick-tile {
  display: grid; justify-items: center; gap: 4px; width: 72px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text-2); font: 500 12px/1.2 system-ui, sans-serif; cursor: pointer;
}
.map-pick-tile img { width: 44px; height: 44px; object-fit: contain; }
.map-pick-tile[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); color: var(--text); }
.plan-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ---- Street addresses (places.js on the server) */
.place-line { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 6px; font-weight: 500; }
.place-line .icon { flex: none; margin-top: 1px; color: var(--primary-text); }
.event-place, .car-card-place { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; }
.car-card-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-places { display: block; color: var(--text-2); overflow-wrap: anywhere; }
p.trip-places { margin: 0 0 12px; }

/* ---- Share links and invitations (people.js) */
.link-box { display: flex; flex-direction: column; gap: 10px; }
.link-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: 13px ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- The public live-location page (share.html) */
.public-shell { display: grid; grid-template-rows: var(--top) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.public-map { position: relative; min-height: 0; }
.public-card {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px)); padding: 14px 16px; z-index: 5;
}
.public-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.public-card-head .pills { margin-top: 4px; }
.public-card p { margin: 0 0 8px; }
.public-card .actions { align-items: center; }
.list-row > select { flex: none; width: auto; max-width: 48%; }

/* ---- photos kept with fill-ups and service records (fuel.js) */
.photo-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.photo-strip:empty { display: none; }
.photo-thumb {
  display: inline-grid; place-items: center; width: 56px; height: 56px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-full { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 8px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.file-btn { cursor: pointer; }

/* ---- Stats tab (stats.js) and summary emails (emails.js) */
:root { --series-2: #7c3aed; --econ: #16a34a; }
@media (prefers-color-scheme: dark) { :root { --series-2: #a78bfa; --econ: #22c55e; } }
.series-econ { --series-1: var(--econ); }
.c-bar.s2 { fill: var(--series-2); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-2); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.sw-fuel { background: var(--series-1); }
.sw-service { background: var(--series-2); }
.stats { display: flex; flex-direction: column; gap: 16px; }
.stats-range { margin-top: -6px; }
.stat-tile { gap: 3px; padding: 12px 14px; }
.stat-tile .tile-value { font-size: 20px; }
.tile-delta { overflow: hidden; font-size: 12px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.tile-delta .muted { font-weight: 400; }
.upcoming li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.upcoming li:first-child { padding-top: 0; border-top: 0; }
.note.tone-warn { color: var(--warn-text); }
.note.tone-warn .icon { color: var(--warn-text); }
.email-promo { flex-direction: row; align-items: center; gap: 14px; }
.promo-icon { display: grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--on-primary-soft); }
.email-form .row { display: flex; flex-wrap: wrap; gap: 12px; }
.email-form .row > .field { flex: 1 1 180px; }
/* Account → SIM data: one row per tracker with its 1NCE bar. */
.sim-account-row { padding: 12px 0; border-top: 1px solid var(--line); gap: 8px; }
.sim-account-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
@media (max-width: 640px) { .check-grid { grid-template-columns: minmax(0, 1fr); } }
.check-row .grow strong { font-weight: 600; }
.email-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.email-preview { width: 100%; height: min(72vh, 900px); border: 1px solid var(--line); border-radius: 12px; background: #f1f5f9; }

/* Lights share the overview map and never replace the cars or move its camera. */
.home-lights { padding: 8px 16px 12px; border-bottom: 1px solid var(--line); }
.home-lights-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.home-lights-head .btn[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.home-lights-body { max-height: 42vh; overflow: auto; }
.home-lights-body[hidden] { display: none; }
.home-lights-body p { margin: 8px 0; }
.lights-legend-help summary { cursor: pointer; color: var(--text-2); margin-bottom: 6px; }
.home-lights .lights-detail { margin: 10px 0 0; padding: 12px; }
/* A rolling day of communication evidence. Every bar represents 15 minutes. */
.lte-monitor { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line, #ffffff20); min-width: 0; }
.lte-monitor-head, .lte-monitor-axis { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lte-monitor-head > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.lte-monitor-badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.lte-monitor-bars { display: grid; grid-template-columns: repeat(96, minmax(0, 1fr)); gap: 2px; margin-top: 14px; height: 36px; }
.lte-monitor-bar { display: block; width: 100%; min-width: 0; min-height: 0; height: 36px; padding: 0; border: 0; border-radius: 3px; cursor: pointer; }
.lte-monitor-bar:hover, .lte-monitor-bar:focus-visible, .lte-monitor-bar.selected { outline: 2px solid currentColor; outline-offset: 2px; z-index: 1; }
.lte-monitor-bar:disabled { opacity: 1; cursor: default; }
.lte-healthy { background: #22c55e; color: #061b0e; }
.lte-issues { background: #fbbf24; color: #241900; }
.lte-failed, .lte-overdue { background: #ef4444; color: #fff; }
.lte-other { background: #38bdf8; color: #05243b; }
.lte-unknown { background: #66708555; color: inherit; }
.lte-monitor-axis { margin-top: 6px; }
.lte-monitor-detail { margin: 10px 0; min-height: 2.5em; overflow-wrap: anywhere; }
.lte-monitor-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lte-monitor-legend span { display: inline-flex; gap: 5px; align-items: center; }
.lte-monitor-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.lte-monitor-note { margin: 8px 0 0; font-size: 11px; line-height: 1.5; }
@media (max-width: 480px) { .lte-monitor-bars { gap: 1px; } }

/* Sign-up code, share codes and the Overview's "Location shared with" card */
.code-input { font: 600 20px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 3px; text-transform: uppercase; max-width: 220px; }
.share-code { font: 700 22px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 3px; }
.list-card.flat { border: 0; box-shadow: none; border-radius: 0; background: none; margin: 0 -4px; }
.health-timeline { list-style: none; padding: 8px 16px; }
.health-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.health-head .page-title { margin: 0; }
.study-candidates { display: flex; flex-wrap: wrap; gap: 8px; max-height: 280px; overflow: auto; }
.study-observation { border-top: 1px solid var(--border); padding: 12px 0; }
.study-observation p { margin: 6px 0; }
.study-reference-map { height: 260px; border-radius: 12px; overflow: hidden; }
.health-entry { position: relative; display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 14px; padding: 16px 0; }
.health-entry:not(:last-child)::after { content: ''; position: absolute; left: 5px; top: 30px; bottom: -16px; width: 2px; background: var(--border); }
.health-dot { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: #38bdf8; z-index: 1; }
.health-warning .health-dot, .health-alarm .health-dot { background: #f59e0b; }
.health-entry-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.health-entry p { margin: 6px 0 0; overflow-wrap: anywhere; }
/* Frame the photo: the round window the avatar shows, the square the map can show around it. */
.frame-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.frame-window { position: relative; width: min(260px, 70vw); aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2, #e2e8f0); }
.frame-window::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgb(0 0 0 / 35%); pointer-events: none; }
.frame-stage { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.frame-stage:active { cursor: grabbing; }
.frame-zoom { display: flex; align-items: center; gap: 8px; width: min(300px, 80vw); font-size: 20px; }
.avatar-btn { padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }

/* Driving insights (insights.js) */
.insight-driver { align-items: flex-start; }
.insight-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 4px; }
.insight-stat { display: inline-flex; flex-direction: column; min-width: 70px; }
.insight-stat b { font-size: 15px; }
.insight-line { display: block; margin-top: 2px; }
.insight-sub { margin: 14px 0 6px; font-size: 14px; }
.insight-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.insight-badge { padding: 1px 6px; border-radius: 999px; border: 1px solid currentColor; letter-spacing: 0; font-weight: 600; }
.road-map { height: 420px; border-radius: 12px; overflow: hidden; margin: 8px 0; }
@media (max-width: 600px) { .road-map { height: 320px; } }

/* Possible crash banner (insights.js): car list and every tab of the car */
.crash-slot:empty { display: none; }
.crash-slot { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.crash-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px;
  border: 2px solid var(--alarm); border-radius: 14px; background: color-mix(in srgb, var(--alarm) 12%, var(--surface)); color: var(--text);
}
.crash-banner .grow { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1; }
.crash-banner strong { color: var(--alarm-text); }
.crash-icon { color: var(--alarm); display: inline-flex; }
.crash-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pin-marker.crash-pin { width: 30px; height: 30px; background: var(--alarm); font-size: 16px; z-index: 5; }
.speed-legend .crash-legend { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; background: #dc2626; color: #fff; font: 700 10px system-ui, sans-serif; }
.speed-legend .jolt-dot { width: 10px; height: 10px; border: 1.5px solid #fff; border-radius: 50%; background: #c084fc; box-shadow: 0 0 0 1px rgb(0 0 0 / 30%); }
.speed-legend .jolt-dot.hard { width: 13px; height: 13px; background: #6b21a8; }
.insight-link { display: flex; align-items: center; gap: 6px; margin: 4px 2px 10px; }
.insight-risk { display: grid; grid-template-columns: minmax(90px, auto) 1fr 1fr; gap: 6px 14px; align-items: center; margin: 6px 0; }
.insight-meter { display: flex; align-items: center; gap: 8px; }
.insight-meter i { display: block; height: 8px; min-width: 2px; border-radius: 4px; background: var(--series-1); }
.insight-meter i.rush { background: var(--warn); }
.insight-meter b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.jolt-pin { position: absolute; width: 12px; height: 12px; transform: translate(-50%, -50%); border: 2px solid #fff; border-radius: 50%; background: #c084fc; box-shadow: 0 1px 3px rgb(0 0 0 / 45%); z-index: 3; }
.jolt-pin.hard { width: 16px; height: 16px; background: #6b21a8; box-shadow: 0 0 0 2px #e9d5ff, 0 1px 3px rgb(0 0 0 / 45%); }

/* Trip overview and progressive details. */
.trip-summary dl { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin:0; }
.trip-summary dt { color:var(--text-2); font-size:13px; }
.trip-summary dd { margin:4px 0 0; font-size:20px; font-weight:650; overflow-wrap:anywhere; }
.trip-light-summary { margin:12px 0 0; font-weight:600; }
.trip-light-controls { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin:8px 0; }
.trip-light-controls [aria-pressed="true"] { background:var(--primary); color:var(--on-primary); border-color:var(--primary); }
.trip-disclosure > summary, .trip-light-history > summary { cursor:pointer; padding:8px 0; }
.trip-disclosure > summary { font-weight:600; }
.trip-disclosure > .card { margin:12px 0 0; padding:0; border:0; box-shadow:none; }
.trip-light-record { display:flex; flex:1; min-width:0; flex-direction:column; gap:4px; }
.light-list li { align-items:flex-start; }
.light-list li > i { margin-top:5px; }
.trip-light-history { color:var(--text-2); }
.trip-light-history p { margin:4px 0 8px; }
.trip-light-group { position:absolute; transform:translate(-50%,-50%); min-width:32px; height:32px; padding:0 6px; border:3px solid white; border-radius:50%; color:white; font:700 12px system-ui; box-shadow:0 1px 5px #0007; cursor:pointer; }
.trip-group-records li { margin:12px 0; }
.trip-group-records p { margin:4px 0; }
@media(max-width:480px) { .trip-summary dl { gap:10px; } .trip-summary dd { font-size:17px; } }

.light-marker::before, .trip-light-group::before { content:""; position:absolute; inset:-8px; }
.light-marker:focus-visible, .trip-light-group:focus-visible { outline:3px solid #2563eb; outline-offset:5px; }

/* Trip page: small charts that open full size, and the details side by side. */
.chart-mini { cursor: pointer; gap: 6px; transition: border-color .15s; }
.chart-mini.empty { cursor: default; }
.chart-mini:not(.empty):hover { border-color: var(--text-3, var(--line)); }
.chart-mini .card-head { align-items: flex-start; flex-wrap: nowrap; }
.chart-mini .card-title + .small { display: block; margin-top: 2px; }
.chart-mini .chart-plot { pointer-events: none; }
.trip-side { gap: 16px; }
.dialog.wide:has(.chart-full) { width: min(1100px, calc(100vw - 32px)); }
@media (min-width: 900px) { .trip-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---- Drivers tab (driver-stats.js): one colour per paired phone on every chart */
:root { --drv-1: #2a78d6; --drv-2: #d9480f; --drv-3: #7c3aed; --drv-4: #0f9f6e; --drv-5: #c2255c; --drv-6: #b7791f; --drv-none: #9aa1ad; }
@media (prefers-color-scheme: dark) { :root { --drv-1: #4c94ef; --drv-2: #ff7a3d; --drv-3: #a78bfa; --drv-4: #34d399; --drv-5: #f06595; --drv-6: #f6c453; --drv-none: #6b7280; } }
.driver-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.driver-card { border-top: 4px solid var(--drv); }
.driver-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.driver-avatar { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--drv); color: #fff; font-weight: 700; font-size: 17px; }
.driver-avatar .icon { fill: #fff; }
.driver-share { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 13.5px; }
.driver-share-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.driver-share-bar i { display: block; height: 100%; background: var(--drv); border-radius: 3px; }
.score-rings { display: flex; gap: 12px; }
.score-ring { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 8px;
  border-radius: 12px; background: linear-gradient(90deg, var(--ring) calc(var(--v) * 1%), var(--surface-3) 0) top / 100% 5px no-repeat, var(--surface-2); }
.tone-ring-ok { --ring: var(--ok); } .tone-ring-warn { --ring: var(--warn); } .tone-ring-alarm { --ring: var(--alarm); } .tone-ring-none { --ring: var(--surface-3); }
.score-ring-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-ring-label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 12.5px; }
.score-ring-label .icon { fill: currentColor; }
.driver-tile .tile-value { font-size: 17px; }
.driver-facts { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--text-2); }
.driver-facts li { display: flex; align-items: flex-start; gap: 8px; }
.driver-facts .icon { flex: none; margin-top: 1px; fill: var(--drv); }
.award-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.award { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); }
.award > div { display: flex; flex-direction: column; min-width: 0; }
.award-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--drv) 18%, transparent); }
.award-icon .icon { fill: var(--drv); }
.drv-key { display: inline-block; flex: none; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; vertical-align: middle; }
.chart-tip span .drv-key { margin-right: 4px; }
.weekday-rows { display: flex; flex-direction: column; gap: 6px; }
.weekday-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.weekday-name { display: inline-flex; align-items: center; width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekday-cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; flex: 1; }
.weekday-cell { display: grid; place-items: center; height: 26px; border-radius: 6px; font-size: 11px; color: var(--text-2);
  background: color-mix(in srgb, var(--drv) calc(var(--a) * 100%), var(--surface-2)); }
.compare-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compare-pick select { flex: 1; min-width: 120px; }
.compare-table { display: flex; flex-direction: column; }
.compare-row { display: grid; grid-template-columns: minmax(110px, 1.2fr) 1fr 1fr; gap: 12px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.compare-head { font-size: 14px; }
.compare-label { color: var(--text-2); }
.compare-val { display: flex; flex-direction: column; gap: 3px; font-variant-numeric: tabular-nums; }
.compare-val.win { font-weight: 700; }
.compare-val.win::after { content: '✓ better'; font-size: 11px; color: var(--ok-text); font-weight: 600; order: 1; }
.compare-bar { display: block; height: 4px; border-radius: 2px; opacity: .8; }
.driver-usual { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-2); }
.driver-usual .icon { fill: var(--ok-text); }
.default-driver { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
.default-driver .grow { flex: 1 1 240px; display: flex; flex-direction: column; gap: 2px; }
.default-driver select { width: auto; min-width: 180px; max-width: 100%; }
.driver-usual .btn .icon { fill: currentColor; }
.skill-block { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.skill-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.skill-now { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.skill-trend { font-weight: 600; font-size: 13px; }
.skill-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); }
.skill-bar i { display: block; height: 100%; border-radius: 5px; background: var(--c); }
.skill-before { position: absolute; top: -3px; width: 2px; height: 16px; margin-left: -1px; border-radius: 1px; background: var(--text); }
.skill-spark { width: 100%; height: 30px; }
.skill-spark path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* ---- Drivers tab charts (driver-motion.js): braking / pulling away / cornering, red lights */
.fx-sub { margin: 10px 0 0; font-size: 14.5px; }
.fb-groups { display: flex; flex-direction: column; gap: 12px; }
.fb-group { display: flex; flex-direction: column; gap: 6px; }
.fb-kind { font-size: 13px; }
.fb-row, .rw-row { display: grid; grid-template-columns: minmax(80px, 130px) minmax(0, 1fr) minmax(120px, auto); align-items: center; gap: 10px; font-size: 13px; }
.fb-name, .rw-name { display: inline-flex; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-track { position: relative; height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.fb-track { display: flex; gap: 1px; }
.fb-track i { display: block; height: 100%; }
.fb-track i:first-child { border-radius: 6px 0 0 6px; }
.fb-track i:last-child { border-radius: 0 6px 6px 0; }
.fb-track i:only-child { border-radius: 6px; }
.fb-gentle { background: color-mix(in srgb, var(--drv, var(--text-3)) 35%, transparent); }
.fb-firm { background: var(--drv, var(--text-3)); }
.fb-harsh { background: repeating-linear-gradient(135deg, var(--drv, var(--text-3)) 0 3px, color-mix(in srgb, var(--drv, var(--text-3)) 30%, var(--text)) 3px 6px); }
.fb-key { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.fb-key span { display: inline-flex; align-items: center; gap: 6px; }
.fb-sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.fb-val, .rw-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rw-range { display: flex; flex-direction: column; gap: 8px; }
.rw-track { position: relative; height: 22px; }
.rw-track i { position: absolute; }
.rw-grid { top: 0; bottom: 0; width: 1px; background: var(--line); }
.rw-whisker { top: 50%; height: 2px; margin-top: -1px; background: color-mix(in srgb, var(--drv) 60%, transparent); }
.rw-box { top: 4px; bottom: 4px; border-radius: 4px; background: color-mix(in srgb, var(--drv) 35%, transparent); border: 1.5px solid var(--drv); }
.rw-median { top: 1px; bottom: 1px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--drv); }
.rw-max { top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--surface); border: 2px solid var(--drv); }
.rw-axis { position: relative; height: 14px; font-size: 11px; color: var(--text-3); }
.rw-axis span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.rw-axis span.first { transform: none; }
.rw-axis span.last { transform: translateX(-100%); }
.rw-hist { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding-top: 4px; }
.rw-bin { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rw-bars { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 120px; padding: 0 2px; border-bottom: 1px solid var(--line); }
.rw-bars i { flex: 1; max-width: 22px; min-height: 1px; border-radius: 3px 3px 0 0; }
.rw-bin-label { font-size: 11px; color: var(--text-3); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gl-bar { position: relative; height: 12px; border-radius: 6px; background: var(--alarm); opacity: .9; overflow: hidden; }
.gl-green { position: absolute; top: 0; bottom: 0; left: 0; background: var(--ok); }
@media (max-width: 560px) {
  .fb-row, .rw-row { grid-template-columns: minmax(0, 1fr) auto; }
  .fb-track, .rw-track, .gl-bar, .rw-axis { grid-column: 1 / -1; grid-row: 2; }
  .rw-row:has(.rw-axis) > span:empty { display: none; }
  .rw-bars { height: 90px; }
}

/* Driver profiles (picture, birth date, contact, licence) on the Drivers tab */
.driver-avatar { overflow: hidden; flex: none; }
.driver-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.driver-profile-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -4px 0 10px; }
.drv-warn { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--ct); background: color-mix(in srgb, var(--c) 14%, transparent); }
.driver-profile-form { display: flex; flex-direction: column; gap: 12px; min-width: min(460px, 100%); }
.driver-profile-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.driver-profile-form textarea.input { resize: vertical; min-height: 64px; font: inherit; }
.driver-profile-photo .driver-avatar { font-size: 26px; }
@media (max-width: 520px) { .driver-profile-form .field-row { grid-template-columns: 1fr; } }

/* ---- notifications bell (notices.js) */
.bell { position: relative; }
.bell-button {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.bell-button:hover, .bell-button[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.bell-badge {
  position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--alarm); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.bell-badge[hidden] { display: none; }
.notice-panel {
  position: absolute; top: calc(100% + 8px); right: -8px; z-index: 40;
  display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - var(--top) - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgb(16 24 40 / 18%); overflow: hidden;
}
.notice-panel[hidden] { display: none; }
.notice-head { display: flex; align-items: center; gap: 2px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notice-head h2 { font-size: 16px; font-weight: 650; }
.notice-list { overflow-y: auto; overscroll-behavior: contain; }
.notice-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px 12px 16px; border-top: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.notice-row:first-child { border-top: 0; }
a.notice-row:hover { background: var(--surface-2); }
.notice-row.unread { background: color-mix(in srgb, var(--primary-soft) 30%, transparent); }
a.notice-row.unread:hover { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notice-icon { display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; margin-top: 2px; border-radius: 50%; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--ct); }
.notice-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.notice-meta { display: flex; gap: 8px; font-size: 12px; color: var(--text-3); }
.notice-meta b { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-title { font-weight: 600; overflow-wrap: anywhere; }
.notice-row.unread .notice-title::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
.notice-body { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.notice-more { display: block; width: 100%; padding: 12px; border-radius: 0; }
.notice-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 24px; text-align: center; color: var(--text-2); }
@media (max-width: 700px) {
  .notice-panel { position: fixed; top: calc(var(--top) + 6px); right: 16px; left: 16px; width: auto; }
}

/* The setting or card a notification pointed at. */
.focus-flash { animation: focus-flash 2.4s ease-out 1; }
@keyframes focus-flash {
  0%, 35% { box-shadow: inset 0 0 0 2px var(--primary); background-color: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
  100% { box-shadow: inset 0 0 0 2px transparent; background-color: transparent; }
}

/* ---- Who is driving now (driver-stats.js driverNow): car card and car page */
.driver-now { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.driver-now > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.driver-now.muted { font-weight: 500; color: var(--text-2); }
.driver-now .driver-avatar { background: var(--primary); font-size: 11px; }
.driver-now .driver-now-none { background: var(--surface-3); }
.driver-now .driver-now-none .icon { fill: var(--text-2); }
.driver-now-line { margin: 0 0 8px; }
.driver-now-line .driver-now { font-size: 15px; }
.driver-now-line .driver-avatar { font-size: 13px; }

/* ---- Several phones in the car: who drove (history.js tripItem) */
.who-drove { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 0 16px 12px; }
.who-drove .chip { padding-block: 3px; font-size: 13px; }
