@font-face {
  font-family: Outfit;
  src: url(Outfit.ttf) format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #0a0a0a;
  --paper: #fff;
  --muted: #aeb5bd;
  --surface: #131518;
  --line: #ffffff22;
  --signal: #8cf2dc;
  font: 15px Outfit, system-ui, sans-serif;
  color: var(--paper);
  background: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(23px, 3vw, 39px); letter-spacing: -.055em; line-height: 1.08; }
h2 { font-size: 20px; letter-spacing: -.025em; }
h3 { font-size: 14px; }
p { color: var(--muted); }
button, input { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #202327;
  color: var(--paper);
  padding: 8px 12px;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
button:hover { background: #34383d; border-color: #ffffff60; }
button[aria-pressed=true] { background: #223530; border-color: #8cf2dc70; color: var(--signal); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
.masthead {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
  padding: 9px clamp(16px, 3vw, 48px);
}
.brand { color: inherit; text-decoration: none; font-size: 27px; letter-spacing: -.065em; font-weight: 750; }
.masthead-label { border-left: 1px solid var(--line); padding-left: 18px; color: var(--muted); }
#logout { margin-left: auto; }
#status:not(:empty) { padding: 12px clamp(16px, 3vw, 48px); color: #f2c8a8; }
.glass { background: #15181dee; border: 1px solid var(--line); backdrop-filter: blur(18px); }
.eyebrow { text-transform: uppercase; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .14em; margin-bottom: 6px; }
.indicator { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: var(--signal); }
.login { width: min(440px, calc(100% - 32px)); margin: 12vh auto 0; border-radius: 18px; padding: 32px; }
.login h1 { font-size: 42px; }
.login p:not(.eyebrow) { margin: 12px 0 24px; }
form { display: grid; gap: 10px; }
form input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--ink); }
form button { background: var(--paper); color: var(--ink); font-weight: 650; }
form button:hover { background: #d6e0dd; }
.command-strip {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, 2fr);
  align-items: center;
  gap: clamp(12px, 3vw, 48px);
  padding: 16px clamp(16px, 3vw, 48px);
}
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { padding: 0 clamp(9px, 2vw, 26px); border-left: 1px solid var(--line); }
.metric strong, .metric span { display: block; }
.metric strong { font-size: clamp(21px, 3vw, 34px); font-weight: 550; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11px; color: var(--muted); }
.workspace { position: relative; border-top: 1px solid var(--line); }
.map-stage { position: relative; isolation: isolate; }
.trail { height: clamp(460px, calc(100dvh - 286px), 1050px); background: #172025; }
.leaflet-tile-pane { filter: invert(1) grayscale(.84) brightness(.75) contrast(1.14); }
.map-head, .map-stat, .map-key { position: absolute; left: 16px; z-index: 500; border-radius: 9px; padding: 10px 14px; }
.map-head { top: 16px; max-width: calc(100% - 90px); }
.map-head button { margin-top: 8px; }
.map-stat { top: 108px; max-width: 240px; }
.map-stat p { margin-top: 4px; }
.map-tools { position: absolute; right: 16px; top: 16px; z-index: 500; display: grid; gap: 4px; }
.map-tools button { width: 43px; height: 39px; padding: 0; background: #15181def; }
.map-key { left: 16px; bottom: 36px; color: var(--muted); font-size: 11px; }
.map-key span { display: inline-block; width: 16px; height: 2px; margin: 0 5px 3px 0; background: var(--signal); }
.staff-tooltip { background: #15181d; color: var(--paper); border-color: var(--line); border-radius: 8px; padding: 8px 12px; animation: reveal .18s ease-out both; }
.leaflet-container { font-family: Outfit, system-ui, sans-serif; }
.map-tooltip strong, .map-tooltip span { display: block; }
.map-tooltip span { color: var(--muted); }
.inspector {
  position: absolute;
  z-index: 600;
  right: 16px;
  top: 60px;
  width: min(314px, 39%);
  max-height: calc(clamp(460px, calc(100dvh - 286px), 1050px) - 98px);
  overflow: auto;
  border-radius: 10px;
  padding: 16px;
  animation: reveal .2s ease-out both;
}
.inspector h3 { margin: 16px 0 8px; }
.inspector p:not(.eyebrow) { margin: 8px 0; }
.workspace:has(.inspector:not([hidden])) .map-tools { grid-auto-flow: column; }
.trip-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 14px 0; background: var(--line); border: 1px solid var(--line); }
.trip-kpis > div { padding: 9px; background: var(--surface); }
.trip-kpis strong, .trip-kpis span { display: block; }
.trip-kpis span, .row div { color: var(--muted); font-size: 12px; }
.speed-chart, .row { border-top: 1px solid var(--line); padding: 9px 0; }
.speed-row { display: grid; grid-template-columns: 74px 1fr 48px; align-items: center; gap: 6px; margin: 6px 0; font-size: 12px; }
.speed-row meter { width: 100%; }
.event-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.event-filters button { padding: 4px 7px; font-size: 11px; }
.filtered-event { display: none !important; }
.journey-dock { background: var(--surface); border-block: 1px solid var(--line); }
.dock-content {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 2fr) minmax(155px, auto);
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 48px);
}
.dock-heading { padding-right: 16px; border-right: 1px solid var(--line); }
.dock-group h3 { margin-bottom: 6px; }
.choices { display: flex; gap: 6px; overflow: auto; padding: 4px; }
.choices button { flex-shrink: 0; white-space: nowrap; font-size: 12px; }
.garage { font-size: 13px; }
.garage p { margin-top: 6px; }
summary { cursor: pointer; }
.replay { display: flex; align-items: center; gap: 12px; padding: 8px clamp(16px, 3vw, 48px); border-bottom: 1px solid var(--line); font-size: 12px; }
.replay input { flex: 1; min-width: 0; accent-color: var(--signal); }
.replay output { width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
@keyframes reveal { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 680px) {
  .command-strip { grid-template-columns: 1fr; }
  .trail { height: 440px; }
  .dock-content { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .dock-heading { border-right: 0; }
  .inspector { position: static; width: auto; max-height: none; margin: 10px 16px; }
  .map-head { max-width: calc(100% - 160px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.zone-panel {
  position: absolute;
  z-index: 500;
  top: 16px;
  right: 70px;
  width: min(230px, 32%);
  padding: 12px;
  border-radius: 9px;
  animation: rise .26s ease-out both;
}
.zone-panel h3 { font-size: 17px; }
.zone-filters { display: grid; gap: 3px; margin: 9px 0; }
.zone-filters button {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  text-align: left;
  padding: 5px 7px;
  font-size: 12px;
}
.zone-filters button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--zone-color, #d8dde2); }
.zone-filters button[aria-pressed=true] { background: #2a3035; color: white; border-color: var(--zone-color, #d8dde2); }
.zone-filters strong { font-variant-numeric: tabular-nums; }
[data-zone=overspeed] { --zone-color: #ff707a; }
[data-zone=long_idle] { --zone-color: #ffc56e; }
[data-zone=harsh_brake] { --zone-color: #ff9966; }
[data-zone=harsh_accel] { --zone-color: #64caff; }
[data-zone=sharp_turn] { --zone-color: #c5a3ff; }
[data-zone=surface_impact] { --zone-color: #ffe488; }
[data-zone=rough_surface] { --zone-color: #f5a9d4; }
#zone-status { font-size: 11px; }
.zone-shape { animation: reveal .38s ease-out both; }
.metric { animation: rise .3s ease-out both; }
.metric:nth-child(2) { animation-delay: .04s; }
.metric:nth-child(3) { animation-delay: .08s; }
.metric:nth-child(4) { animation-delay: .12s; }
.inspector, .replay { animation: rise .24s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 680px) {
  .zone-panel { position: relative; inset: auto; width: auto; margin: 10px 16px; }
  .zone-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
