:root {
  color-scheme: dark;
  --bg: #0c1117;
  --panel: #151c24;
  --line: #2b3642;
  --text: #edf3f8;
  --muted: #94a3b2;
  --accent: #35b8ff;
  --good: #39d98a;
  --warn: #f5a623;
  --bad: #ff5c6c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, sans-serif; }
/* Leaflet core layout fallback: Brave may block or delay the CDN stylesheet. */
.leaflet-pane, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-tile-container,
.leaflet-pane > svg, .leaflet-pane > canvas, .leaflet-zoom-box, .leaflet-image-layer { position: absolute; left: 0; top: 0; }
.leaflet-container { overflow: hidden; -webkit-tap-highlight-color: transparent; background: #d7e2e8; outline-offset: 1px; }
.leaflet-container img.leaflet-tile { max-width: none !important; max-height: none !important; width: 256px; height: 256px; padding: 0; }
.leaflet-tile { visibility: hidden; user-select: none; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-animated { transform-origin: 0 0; }
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-control { position: relative; z-index: 800; pointer-events: auto; }
.leaflet-top, .leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; } .leaflet-right { right: 0; } .leaflet-bottom { bottom: 0; } .leaflet-left { left: 0; }
.leaflet-control-container .leaflet-control { margin: 10px; }
.leaflet-control-attribution { background: rgba(255,255,255,.8); color: #222; padding: 2px 6px; font-size: 11px; }
.leaflet-control-attribution a { color: #0666a3; }
button, select, input { font: inherit; }
button, select { border: 1px solid var(--line); border-radius: 7px; background: #202a35; color: var(--text); padding: .55rem .8rem; }
button { cursor: pointer; background: #0879b5; }
button.secondary { background: #202a35; }
.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 1.25rem; }
h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
h3 { margin: 0; font-size: .95rem; }
.toolbar, .toolbar form { display: flex; align-items: center; gap: .75rem; margin: 0; }
.status { display: inline-block; margin-top: .2rem; font-size: .85rem; }
.status-good { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }
.layout { height: calc(100% - 68px); display: grid; grid-template-columns: minmax(0, 3fr) minmax(420px, 2fr); }
.map-panel { position: relative; min-height: 360px; }
#map { position: absolute; inset: 0; background: #1a222c; }
.map-legend { position: absolute; z-index: 500; left: 12px; bottom: 12px; display: flex; gap: 1rem; background: rgba(12,17,23,.9); border: 1px solid var(--line); border-radius: 7px; padding: .5rem .75rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .3rem; }
.dot.gnss { background: var(--good); }
.dot.cell { background: var(--warn); }
.vehicle-marker { width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid white; border-radius: 50%; box-shadow: 0 1px 5px #000; }
.vehicle-marker.gnss { background: var(--good); }
.vehicle-marker.cell { background: var(--warn); }
.vehicle-arrow { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid #08121b; transform-origin: 50% 65%; }
.data-panel { min-width: 0; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.vehicle-summary { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
#last-seen { color: var(--muted); }
.parameter-groups { overflow: auto; flex: 1; padding: .75rem; display: grid; gap: .85rem; align-content: start; }
.parameter-section { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #121922; }
.standard-section { border-top: 3px solid var(--accent); }
.tpower-section { border-top: 3px solid #b982ff; }
.section-title { display: flex; justify-content: space-between; align-items: center; padding: .65rem .75rem; background: #1b2530; border-bottom: 1px solid var(--line); }
.field-count { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: #1b2530; color: var(--muted); font-size: .78rem; }
th:nth-child(1), td:nth-child(1) { width: 24%; }
th:nth-child(2), td:nth-child(2) { width: 16%; }
th:nth-child(3), td:nth-child(3) { width: 10%; }
th:nth-child(4), td:nth-child(4) { width: 18%; }
th:nth-child(5), td:nth-child(5) { width: 10%; }
th:nth-child(6), td:nth-child(6) { width: 22%; }
td { overflow-wrap: anywhere; }
tr.stale { color: #8d98a3; background: rgba(245,166,35,.05); }
tr.invalid { color: #65717d; }
.quality-good { color: var(--good); }
.quality-stale { color: var(--warn); }
.quality-invalid { color: var(--bad); }
.login-page { display: grid; place-items: center; min-height: 100%; }
.login-card { width: min(92vw, 390px); background: var(--panel); padding: 2rem; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 42px rgba(0,0,0,.35); }
.login-card p { color: var(--muted); }
.login-card form { display: grid; gap: 1rem; }
.login-card label { display: grid; gap: .35rem; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 7px; background: #0e151d; color: var(--text); padding: .7rem; }
.login-error { color: var(--bad) !important; }
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; flex-wrap: wrap; }
  .layout { height: auto; min-height: calc(100% - 110px); grid-template-columns: 1fr; grid-template-rows: 52vh auto; }
  .data-panel { border-left: 0; border-top: 1px solid var(--line); min-height: 48vh; }
  .toggle { font-size: .9rem; }
}
