/* Waar's Jy? — "the map is the room".
   One full-bleed night map; everything else floats on it. Big Shoulders Display
   carries the numerals and headings, IBM Plex Sans the text, IBM Plex Mono the
   telemetry. Night is the default; Day is a real second palette. */

:root {
  --bg: #0B1118;
  --bg-2: #0F1721;
  --glass: rgba(14, 21, 29, 0.82);
  --glass-2: rgba(20, 29, 39, 0.9);
  --hair: rgba(255, 255, 255, 0.08);
  --hair-2: rgba(255, 255, 255, 0.14);
  --ink: #E9EEF2;
  --muted: #93A1AD;
  --faint: #5B6B78;
  --hover: rgba(255, 255, 255, 0.05);
  --accent: #F5A524;        /* live / moving; companies set their own */
  --accent-ink: #1A1200;
  --route: #6EA8FE;
  --ok: #35C98A;
  --warn: #F7C948;
  --alert: #FF6B5B;
  --idle: #6EA8FE;
  --parked: #7E8C98;
  --focus: #8FC2FF;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --blur: blur(14px) saturate(1.2);

  --display: "Big Shoulders Display", "Barlow Semi Condensed", Impact, sans-serif;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --spine-w: 72px;
  --strip-h: 56px;
  --r: 14px;
  --r-s: 8px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #E9EDEE;
  --bg-2: #F4F6F6;
  --glass: rgba(255, 255, 255, 0.86);
  --glass-2: rgba(255, 255, 255, 0.96);
  --hair: rgba(16, 24, 32, 0.1);
  --hair-2: rgba(16, 24, 32, 0.18);
  --ink: #101820;
  --muted: #5B6B78;
  --faint: #93A1AD;
  --hover: rgba(16, 24, 32, 0.05);
  --accent-ink: #1A1200;
  --route: #2563A8;
  --ok: #1E8E5A;
  --warn: #B7791F;
  --alert: #D1402F;
  --idle: #2563A8;
  --parked: #6B7A86;
  --focus: #2563A8;
  --shadow: 0 10px 30px -14px rgba(16, 24, 32, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
@supports (height: 100dvh) { html, body, .app-shell, .auth { height: 100dvh; } }
body { background: var(--bg); color: var(--ink); font: 400 14.5px/1.45 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--route); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 20px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.num { font-family: var(--display); font-weight: 700; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--hair-2); border-radius: 999px; padding: 7px 14px; background: var(--glass-2); color: var(--ink); cursor: pointer; font-weight: 500; line-height: 1.2; white-space: nowrap; backdrop-filter: var(--blur); }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: progress; }
a.btn { text-decoration: none; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn-primary:hover { opacity: 0.92; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { color: var(--alert); }
.btn-quiet { border-color: transparent; background: none; color: var(--muted); backdrop-filter: none; }
.btn-quiet:hover { color: var(--ink); background: var(--hover); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: var(--r-s); cursor: pointer; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]), select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--hair-2); border-radius: var(--r-s); background: var(--bg-2); color: var(--ink); min-height: 38px;
}
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea { min-height: 80px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[type="color"] { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--hair-2); border-radius: var(--r-s); background: var(--bg-2); }
label { display: grid; gap: 5px; font-weight: 500; font-size: 13.5px; }
label.check { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; margin: 0; }
.form-error { color: var(--alert); margin: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.form { display: grid; gap: 14px; }
.inline-select { display: inline-flex; align-items: center; gap: 6px; }
.inline-select select, .inline-select input { width: auto; min-height: 34px; padding: 5px 9px; }
.inline-select select { padding-right: 28px; }

/* ---------- Shell: spine + top strip float over the page */
.app-shell { height: 100%; position: relative; }
.page { position: absolute; inset: 0; }
.spine { position: absolute; top: 0; left: 0; bottom: 0; width: var(--spine-w); z-index: 1200; display: flex; flex-direction: column; align-items: stretch; padding: 12px 8px 14px; gap: 2px; background: var(--glass); backdrop-filter: var(--blur); border-right: 1px solid var(--hair); }
.spine a { display: grid; justify-items: center; gap: 4px; padding: 9px 2px 8px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 500; letter-spacing: 0.02em; }
.spine a svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spine a:hover { color: var(--ink); background: var(--hover); }
.spine a.active { color: var(--ink); background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
.spine .nav-label { margin: 10px 0 2px; height: 1px; background: var(--hair); font-size: 0; }
.spine .nav-foot { margin-top: auto; font-size: 10px; color: var(--faint); text-align: center; padding: 0 2px; overflow: hidden; text-overflow: ellipsis; }
.nav-toggle { display: none; }

.topstrip { position: absolute; top: 10px; left: calc(var(--spine-w) + 10px); right: 10px; height: var(--strip-h); z-index: 1150; display: flex; align-items: center; gap: 12px; padding: 0 10px 0 12px; background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; flex: none; overflow: hidden; }
.brand-logo svg { width: 58%; height: 58%; fill: var(--accent-ink); }
.brand-logo.has-logo { display: block; background: none; border-radius: 0; width: auto; max-width: 220px; height: 46px; }
.brand-logo.has-logo img { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope { position: relative; display: flex; align-items: center; margin-left: 6px; min-width: 0; }
.scope-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 420px; min-height: 36px; padding: 4px 10px 4px 10px; border: 1px solid var(--hair-2); border-radius: 999px; background: transparent; color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer; }
.scope-btn:hover, .scope-btn[aria-expanded="true"] { background: var(--hover); border-color: var(--accent); }
.scope-btn .sb-ic svg { width: 17px; height: 17px; color: var(--accent); }
.scope-btn .sb-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-btn .sb-n { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 1px 7px; border-radius: 999px; background: var(--hover); }
.scope-btn .sb-n:empty { display: none; }
.scope-btn > svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.sp-back { position: fixed; inset: 0; z-index: 1140; }
.sp-pop { position: absolute; left: 0; top: calc(100% + 10px); width: min(460px, calc(100vw - 40px)); max-height: min(70vh, 620px); display: flex; flex-direction: column; background: color-mix(in srgb, var(--bg) 97%, transparent); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: 14px; box-shadow: var(--shadow); z-index: 1170; overflow: hidden; animation: deck 0.18s ease-out both; }
.sp-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--hair); }
.sp-search svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.sp-search input { border: 0; background: none; padding: 6px 0; min-height: 0; font-size: 15px; }
.sp-search input:focus-visible { outline: none; }
.sp-list { overflow: auto; padding: 6px; flex: 1; min-height: 0; overscroll-behavior: contain; }
.sp-head { padding: 10px 10px 4px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.sp-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.sp-row.indent { padding-left: 34px; }
.sp-row.group { margin-top: 4px; }
.sp-row.group b { font-weight: 600; }
.sp-row.cur, .sp-row:hover { background: var(--hover); }
.sp-row.on b { color: var(--accent); }
.sp-row .sp-ic svg { width: 18px; height: 18px; color: var(--muted); }
.sp-row.group .sp-ic svg { color: var(--ink); }
.sp-row .sp-txt { display: grid; min-width: 0; }
.sp-row .sp-txt b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row .sp-txt small { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.sp-row .sp-check svg { width: 18px; height: 18px; color: var(--accent); }
.sp-row .sp-tog { display: grid; place-items: center; width: 30px; height: 30px; margin: -6px -8px -6px 0; border-radius: 8px; color: var(--muted); }
.sp-row .sp-tog:hover { background: var(--hair-2); color: var(--ink); }
.sp-row .sp-tog svg { width: 18px; height: 18px; transition: transform 0.15s; }
.sp-row .sp-tog.open svg { transform: rotate(180deg); }
.sp-more { padding: 10px 12px; font-size: 12.5px; color: var(--muted); text-align: center; font-family: var(--mono); }
.sp-foot { display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--hair); font-family: var(--mono); font-size: 11px; color: var(--faint); }
.topstrip-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.feed { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); flex: none; }
.feed.stale::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.feed.down::before { background: var(--alert); box-shadow: 0 0 10px var(--alert); }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 6px 4px 4px; border-radius: 999px; cursor: pointer; }
.user-btn:hover { background: var(--hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 15px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; background: var(--glass-2); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; z-index: 30; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 8px; color: var(--ink); text-decoration: none; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--hover); }

/* ---------- Deck: non-map pages float over the dimmed map */
.page-pad { position: absolute; inset: 0; overflow: auto; padding: calc(var(--strip-h) + 24px) 24px 40px calc(var(--spine-w) + 24px); background: radial-gradient(1200px 600px at 20% -10%, rgba(110, 168, 254, 0.08), transparent 60%), var(--bg); animation: deck 0.35s ease-out both; }
@keyframes deck { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-pad > * { max-width: 1380px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.findbox { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 10px; border: 1px solid var(--hair-2); border-radius: 999px; background: var(--bg-2); }
.findbox svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.findbox input { border: 0; background: none; min-height: 0; padding: 4px 0; width: 180px; }
.findbox input:focus-visible { outline: none; }
.findbox #find-n { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }
.findbox #find-n:empty { display: none; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar input[type="search"] { max-width: 280px; }

/* ---------- Cards, tables */
.card { background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--hair); }
.card-head h3 { white-space: nowrap; }
.card-head .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) { .span-2 { grid-column: auto; } }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--hair); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; font-family: var(--mono); }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl td.r, .tbl th.r { text-align: right; white-space: nowrap; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.active { background: var(--hover); box-shadow: inset 3px 0 0 var(--route); }
.tbl tr.fresh { animation: fresh 2s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--hair-2); }
.tbl .actions { white-space: nowrap; text-align: right; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--hover); border: 1px solid var(--hair-2); color: var(--muted); white-space: nowrap; font-family: var(--mono); }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.tag.alert { color: var(--alert); border-color: color-mix(in srgb, var(--alert) 45%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.tag.accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--hover); border: 1px solid var(--hair-2); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--parked); }
.chip.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.chip.alert .dot { background: var(--alert); box-shadow: 0 0 8px var(--alert); }
.chip.accent .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.usage { display: grid; gap: 4px; min-width: 120px; }
.usage .bar { height: 5px; border-radius: 3px; background: var(--hair-2); overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: var(--route); border-radius: 3px; }
.usage .bar i.full { background: var(--alert); }
.usage .bar i.near { background: var(--warn); }

/* ---------- Readouts (KPI tiles) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpis.eight { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .kpis.eight { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: var(--r); padding: 14px 16px 12px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 2px; background: var(--accent); border-radius: 0 0 2px 2px; }
.kpi .k { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.kpi .v { font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1; margin-top: 6px; letter-spacing: 0.01em; }
.kpi .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 5px; font-family: var(--mono); }
.kpi.alert::before { background: var(--alert); }
.kpi.ok::before { background: var(--ok); }
.kpi.route::before { background: var(--route); }
.kpi.neutral::before { background: var(--hair-2); }

/* ---------- Charts */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--route); }
.chart .bar.today { fill: var(--accent); }
.chart .bar:hover { opacity: 0.8; }
.chart .axis { stroke: var(--hair-2); stroke-width: 1; }
.chart .lbl { font-family: var(--mono); font-size: 13px; fill: var(--muted); }
.chart .grid { stroke: var(--hair); stroke-dasharray: 2 3; stroke-width: 1; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 1.2fr) 3fr auto; align-items: center; gap: 10px; font-size: 13.5px; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--hair); overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--route); border-radius: 4px; }
.hbar .n { font-family: var(--display); font-weight: 700; font-size: 18px; min-width: 64px; text-align: right; }

/* ---------- Map pages: full-bleed map, floating panel, telemetry ticker */
.live .leaflet-bottom { bottom: 40px; }
.live { position: absolute; inset: 0; }
.live .map { position: absolute; inset: 0; background: var(--bg); }
.live .side { position: absolute; top: calc(var(--strip-h) + 22px); right: 10px; bottom: 52px; width: 380px; display: flex; flex-direction: column; min-height: 0; background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); z-index: 1000; overflow: hidden; }
.live.focus .side { width: 420px; }
.map-tools { position: absolute; top: calc(var(--strip-h) + 22px); left: calc(var(--spine-w) + 12px); z-index: 900; display: flex; gap: 6px; flex-wrap: wrap; }
.map-style { position: absolute; bottom: 52px; left: calc(var(--spine-w) + 12px); z-index: 900; display: flex; gap: 4px; padding: 4px; background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: 999px; }
.map-style button { border: 0; background: none; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 500; }
.map-style button.on { background: var(--ink); color: var(--bg); }
.leaflet-top.leaflet-left { top: calc(var(--strip-h) + 66px); left: calc(var(--spine-w) + 12px); }
.leaflet-bar { border: 1px solid var(--hair) !important; box-shadow: var(--shadow) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-bar a { background: var(--glass) !important; color: var(--ink) !important; border-bottom-color: var(--hair) !important; backdrop-filter: var(--blur); }
.leaflet-bar a:hover { background: var(--glass-2) !important; }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--faint) !important; font-family: var(--mono); font-size: 10px !important; backdrop-filter: var(--blur); }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-container { font: 13.5px/1.4 var(--font); background: var(--bg) !important; }
.leaflet-popup-content-wrapper { background: var(--glass-2); color: var(--ink); border: 1px solid var(--hair); border-radius: 12px; backdrop-filter: var(--blur); box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--glass-2); }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-tooltip { background: var(--glass-2); color: var(--ink); border: 1px solid var(--hair); border-radius: 8px; font-family: var(--mono); font-size: 12px; }
.leaflet-tooltip::before { display: none; }
:root[data-theme="dark"] .tiles-day img { filter: brightness(0.92); }

.ticker { position: absolute; left: var(--spine-w); right: 0; bottom: 0; height: 40px; z-index: 950; display: flex; align-items: center; gap: 0; background: var(--glass); backdrop-filter: var(--blur); border-top: 1px solid var(--hair); font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; }
.ticker .tk-label { flex: none; padding: 0 14px; height: 100%; display: flex; align-items: center; gap: 8px; border-right: 1px solid var(--hair); color: var(--ink); font-weight: 500; }
.ticker .tk-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.ticker.quiet .tk-label i { background: var(--parked); box-shadow: none; animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }
.ticker .tk-track { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.ticker .tk-items { display: flex; gap: 0; white-space: nowrap; animation: ticker var(--tk-dur, 40s) linear infinite; }
.ticker .tk-track:hover .tk-items { animation-play-state: paused; }
.ticker .tk-item { display: inline-flex; align-items: center; gap: 10px; padding: 0 22px; border-right: 1px solid var(--hair); cursor: pointer; color: var(--muted); background: none; border-top: 0; border-bottom: 0; border-left: 0; height: 40px; }
.ticker .tk-item:hover { color: var(--ink); }
.ticker .tk-item b { color: var(--ink); font-weight: 500; }
.ticker .tk-item .spd { color: var(--accent); font-weight: 500; }
.ticker .tk-item .spd.zero { color: var(--muted); }
.ticker .tk-item .st { font-size: 10.5px; letter-spacing: 0.08em; color: var(--faint); }
.ticker .tk-item .ago { color: var(--faint); }
.ticker .tk-item .st:empty { display: none; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* side panel contents */
.side-tools { padding: 12px 14px; display: grid; gap: 8px; border-bottom: 1px solid var(--hair); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--hair-2); background: none; border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted); font-family: var(--mono); }
.filters button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.vlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.vrow { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 2px 12px; width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--hair); background: none; text-align: left; cursor: pointer; color: var(--ink); }
.vrow:hover { background: var(--hover); }
.vrow .nm { font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .sub { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); }
.vrow .spd { font-family: var(--display); font-weight: 700; font-size: 24px; }
.vrow .spd small { font-weight: 500; font-size: 11px; color: var(--muted); margin-left: 2px; font-family: var(--mono); }
.vrow .client { color: var(--muted); font-size: 12px; font-family: var(--font); font-weight: 400; }
.glyph { width: 24px; height: 24px; display: grid; place-items: center; }
.glyph svg { width: 22px; height: 22px; }
.alert-text { color: var(--alert); font-weight: 600; }

/* status glyphs */
.g-driving { fill: var(--accent); stroke: var(--accent-ink); }
.g-idle { fill: var(--idle); stroke: var(--bg); }
.g-parked { fill: var(--parked); stroke: var(--bg); }
.g-offline { fill: var(--bg-2); stroke: var(--parked); }
.g-nofix { fill: none; stroke: var(--parked); stroke-dasharray: 3 2; }

/* vehicle focus panel */
.vhead { padding: 10px 16px 12px; border-bottom: 1px solid var(--hair); }
.back { display: inline-flex; align-items: center; gap: 4px; margin-left: -8px; }
.vtitle { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.vtitle h2 { font-size: 30px; overflow-wrap: anywhere; }
.vmeta { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }
.state-line { margin: 6px 0 0; color: var(--muted); }
.state-line .alert-text { display: block; }
.tabs { display: flex; padding: 0 8px; border-bottom: 1px solid var(--hair); }
.tabs button { flex: 1; border: 0; background: none; padding: 11px 4px 9px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; cursor: pointer; font-family: var(--mono); font-size: 12.5px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.day-bar { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--hair); }
.day-bar input { flex: 1; }
.pane { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

/* instrument cluster */
.cluster { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
.gauge { position: relative; width: 100%; max-width: 300px; margin: 0 auto; }
.gauge svg { width: 100%; height: auto; display: block; overflow: visible; }
.gauge .g-track { fill: none; stroke: var(--hair-2); stroke-width: 10; stroke-linecap: round; }
.gauge .g-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease-out; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent)); }
.gauge .g-fill.over { stroke: var(--alert); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--alert) 60%, transparent)); }
.gauge .g-fill.stale { stroke: var(--parked); filter: none; }
.gauge .g-limit { stroke: var(--alert); stroke-width: 3; stroke-linecap: round; }
.gauge .g-tick { stroke: var(--hair-2); stroke-width: 2; }
.gauge .g-lbl { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.gauge .g-num { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-family: var(--display); font-weight: 800; font-size: 76px; line-height: 1; letter-spacing: 0.01em; }
.gauge .g-num small { display: block; font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; letter-spacing: 0.08em; }
.gauge .g-num.over { color: var(--alert); }
.gauge .g-num.stale { color: var(--muted); }
.gauge .g-foot { position: absolute; left: 0; right: 0; bottom: 4px; display: flex; justify-content: space-between; padding: 0 14%; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.gauge .g-foot b { color: var(--alert); font-weight: 500; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; justify-content: center; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.mini-stats > div { background: var(--hover); border: 1px solid var(--hair); border-radius: 10px; padding: 8px 10px; }
.mini-stats .k { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.mini-stats .v { font-family: var(--display); font-weight: 700; font-size: 22px; white-space: nowrap; line-height: 1.1; margin-top: 2px; }
.mini-stats .v small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; font-family: var(--mono); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.facts dd { margin: 1px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.gauge-bar { height: 5px; border-radius: 3px; background: var(--hair-2); overflow: hidden; margin-top: 5px; }
.gauge-bar i { display: block; height: 100%; background: var(--ok); }
.gauge-bar i.low { background: var(--alert); }
.gauge-bar i.mid { background: var(--warn); }
.raw { margin-top: 18px; border-top: 1px solid var(--hair); padding-top: 12px; }
.raw summary { cursor: pointer; font-weight: 500; }
.raw table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; font-family: var(--mono); }
.raw td { padding: 4px 0; border-bottom: 1px solid var(--hair); vertical-align: top; overflow-wrap: anywhere; }
.raw td:first-child { color: var(--muted); padding-right: 10px; width: 50%; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 14px; }
.summary dt { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.summary dd { margin: 0; font-family: var(--display); font-weight: 700; font-size: 26px; }
.summary dd small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; font-family: var(--mono); }
.rows { list-style: none; margin: 0 -16px; padding: 0; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--hair); background: none; text-align: left; cursor: pointer; color: var(--ink); }
.row:hover, .row.active { background: var(--hover); }
.row.active { box-shadow: inset 3px 0 0 var(--route); }
.row-title { font-weight: 600; }
.row-meta { color: var(--muted); font-size: 12.5px; grid-column: 1 / -1; font-family: var(--mono); }
.row-side { color: var(--muted); font-size: 12.5px; text-align: right; font-family: var(--mono); }
.ev-alert .row-title { color: var(--alert); }
.ev-good .row-title { color: var(--ok); }

/* map markers */
.veh-icon { background: none; border: 0; }
.veh .halo { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: halo 2.2s ease-out infinite; pointer-events: none; }
@keyframes halo { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(2.4); opacity: 0; } }
.veh { position: relative; width: 30px; height: 30px; }
.veh svg { width: 30px; height: 30px; overflow: visible; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }
.veh-label { position: absolute; left: 34px; top: 5px; padding: 1px 8px; border-radius: 6px; background: var(--glass-2); color: var(--ink); font: 600 12.5px/18px var(--mono); white-space: nowrap; border: 1px solid var(--hair-2); backdrop-filter: var(--blur); pointer-events: none; }
.veh.selected .veh-label { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.veh.alert svg circle.ring { stroke: var(--alert); }
.pin { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--hair-2); }
.pin.start { background: var(--ok); }
.pin.end { background: var(--alert); }
.pin.event { background: var(--accent); }

/* sheet (phone) controls hidden on desktop */
.sheet-toggle, .sheet-close { display: none; }

/* ---------- Auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 500px at 70% 20%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%), linear-gradient(var(--hair) 1px, transparent 1px), linear-gradient(90deg, var(--hair) 1px, transparent 1px), var(--bg); background-size: auto, 48px 48px, 48px 48px, auto; }
.auth-card { width: min(410px, 100%); display: grid; gap: 16px; padding: 30px; background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--hair); border-radius: 18px; box-shadow: var(--shadow); }
.auth-card .brand-logo { width: 52px; height: 52px; border-radius: 14px; }
.auth-card .brand-logo.has-logo { width: auto; max-width: 300px; height: 72px; }
.auth-card h1 { font-size: 34px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted); }

/* ---------- Modal, toasts */
.modal-back { position: fixed; inset: 0; background: rgba(5, 9, 14, 0.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 2000; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--glass-2); backdrop-filter: var(--blur); color: var(--ink); border: 1px solid var(--hair); border-radius: 18px; box-shadow: var(--shadow); }
.modal.wide { width: min(760px, 100%); }
.modal form, .modal .modal-body { display: grid; gap: 14px; padding: 22px; }
.modal h2 { font-size: 28px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toasts { position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 3000; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 500; }
.toast.err { background: var(--alert); color: #fff; }

/* ---------- Responsive */
@media (max-width: 1100px) {
  .feed { display: none; }
}
@media (max-width: 760px) {
  :root { --spine-w: 0px; }
  .nav-toggle { display: inline-grid; }
  .topstrip { left: 8px; right: 8px; top: 8px; padding-left: 6px; }
  .spine { width: 240px; transform: translateX(-100%); transition: transform 0.2s; border-right: 1px solid var(--hair); }
  .spine.open { transform: none; }
  .spine a { grid-template-columns: 24px 1fr; justify-items: start; align-items: center; gap: 12px; padding: 10px 12px; font-size: 14px; }
  .spine .nav-label { height: auto; font-size: 11px; color: var(--faint); background: none; padding: 12px 12px 2px; }
  .nav-back { position: fixed; inset: 0; background: rgba(5, 9, 14, 0.5); z-index: 1100; }
  .user-name { display: none; }
  .scope { margin-left: 0; flex: 1; min-width: 0; }
  .scope-btn { max-width: 100%; padding: 4px 8px; }
  .scope-btn .sb-n { display: none; }
  .sp-pop { position: fixed; left: 8px; right: 8px; top: calc(var(--strip-h) + 18px); width: auto; max-height: calc(100vh - var(--strip-h) - 30px); }
  .sp-foot { display: none; }
  .brand-logo.has-logo { max-width: 150px; height: 40px; }
  .page-pad { padding: calc(var(--strip-h) + 20px) 14px 40px; }
  .live .side { top: calc(var(--strip-h) + 16px); right: 0; bottom: 40px; width: min(90vw, 400px); border-radius: var(--r) 0 0 var(--r); border-right: 0; transform: translateX(102%); transition: transform 0.22s; }
  .live .side.open { transform: none; }
  .sheet-toggle { display: inline-flex; position: absolute; right: 10px; bottom: 100px; z-index: 900; padding: 10px 18px; font-weight: 600; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .live .side, .live.focus .side { z-index: 1010; width: min(90vw, 400px); }
  .sheet-close { display: inline-grid; position: absolute; top: 8px; right: 8px; z-index: 2; }
  .side-tools, .vhead { padding-right: 48px; }
  .map-tools { top: calc(var(--strip-h) + 18px); left: 10px; }
  .map-style { left: 10px; }
  .leaflet-top.leaflet-left { top: calc(var(--strip-h) + 62px); left: 10px; }
  .ticker { left: 0; }
  .gauge .g-num { font-size: 64px; }
  .kpi .v { font-size: 30px; }
  h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
