/* AstroRoute mission control. Owner: Ayush.
   A calm instrument panel: dark neutral surfaces, one accent (cyan = the live route),
   status colours used only for status, sans-serif UI text, tabular mono for telemetry. */

/* ------------------------------------------------------------------ tokens */
:root {
  /* surfaces: navy, lightening with elevation */
  --bg: #050A16;
  --surface: #0A1428;
  --surface-2: #0F1C36;
  --surface-3: #152747;
  --line: #1B2C4E;
  --line-strong: #29406B;

  /* text */
  --text: #E6EDF3;
  --text-2: #B6C4D8;
  --muted: #8C9BB3;
  --faint: #6A7A96;

  /* brand + status (task palette) */
  --accent: #7FD1FF;       /* ice blue: live route, active controls */
  --accent-ink: #03121F;
  --accent-soft: rgba(127, 209, 255, .13);
  --accent-line: rgba(127, 209, 255, .48);
  --amber: #FFB547;
  --amber-soft: rgba(255, 181, 71, .12);
  --red: #FF6B6B;
  --red-soft: rgba(255, 107, 107, .12);
  --green: #69D39A;
  --green-soft: rgba(105, 211, 154, .12);
  --observatory: #C9A7FF;

  /* type */
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --fs-2xs: 10.5px;  /* captions, legend */
  --fs-xs: 11.5px;   /* labels, metadata */
  --fs-sm: 12.5px;   /* secondary body, controls */
  --fs-md: 13.5px;   /* body */
  --fs-lg: 15px;     /* card titles */
  --fs-xl: 20px;     /* KPIs */
  --fs-2xl: 26px;    /* verdict */

  /* spacing (4px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;

  /* shape + depth */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .55), 0 0 0 1px var(--line-strong);
  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);

  /* layout */
  --topbar-h: 60px;
  --side-w: 404px;
  --control-h: 34px;

  /* motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms;
  --t-med: 220ms;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: var(--fs-md)/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.icon {
  flex: none; width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

:focus-visible { outline: none; box-shadow: var(--ring); }

.skip-link {
  position: absolute; left: var(--s3); top: -48px; z-index: 50;
  padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s3); }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--control-h); padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: #3A4870; }
.btn:active { transform: translateY(1px); }
.btn .btn-label-short { display: none; }

.btn-primary { min-width: 96px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #A3DEFF; border-color: #A3DEFF; }
.btn-primary[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.btn-primary[aria-pressed="true"]:hover { background: rgba(127, 209, 255, .2); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }

.btn.tool.armed { background: var(--red-soft); border-color: var(--red); color: var(--red); }

.seg {
  display: inline-flex; gap: 2px; height: var(--control-h); padding: 2px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
}
.seg-btn {
  flex: 1 1 auto; min-width: 40px; padding: 0 var(--s3);
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg-btn:hover { background: var(--surface-2); color: var(--text); }
.seg-btn.active { background: var(--surface-3); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
.seg-fill { display: flex; width: 100%; }

.switch {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: var(--control-h); padding: 0 var(--s3) 0 var(--s2);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
  color: var(--muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.switch:hover { color: var(--text); }
.switch .knob { position: relative; width: 28px; height: 16px; border-radius: 8px; background: var(--line-strong); transition: background var(--t-med) var(--ease); }
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); transition: transform var(--t-med) var(--ease), background var(--t-med) var(--ease);
}
.switch.on { border-color: var(--accent-line); color: var(--accent); }
.switch.on .knob { background: rgba(127, 209, 255, .3); }
.switch.on .knob::after { transform: translateX(12px); background: var(--accent); }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: rgba(11, 16, 32, .85); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 500; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chip-btn:hover { border-color: #3A4870; color: var(--text); }
.chip-btn[aria-pressed="true"] { border-color: var(--accent-line); background: rgba(16, 32, 52, .92); color: var(--accent); }
.chip-btn .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: relative; z-index: 20; flex: none;
  display: flex; align-items: center; gap: var(--s4);
  min-height: var(--topbar-h); padding: var(--s2) var(--s5);
  background: linear-gradient(180deg, #0C1830, var(--surface));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(127, 209, 255, .05), 0 6px 18px rgba(0, 0, 0, .35);
}
.brand { display: flex; flex: none; align-items: center; gap: 10px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0 4px, transparent 4.5px),
              radial-gradient(circle, transparent 0 8px, var(--accent-line) 8.5px 9.5px, transparent 10px);
}
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }

.picker { position: relative; flex: 0 1 260px; min-width: 0; }
.picker-btn {
  display: flex; align-items: center; gap: var(--s2); width: 100%;
  height: var(--control-h); padding: 0 var(--s2) 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); text-align: left; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.picker-btn:hover { border-color: #3A4870; background: var(--surface-3); }
.picker-k { color: var(--muted); font-size: var(--fs-xs); }
.picker-v { flex: 1; min-width: 0; overflow: hidden; font-size: var(--fs-sm); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.picker-btn .caret { color: var(--muted); transition: transform var(--t-med) var(--ease); }
.picker-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.picker-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  width: max(100%, 300px); max-height: min(440px, calc(100vh - 90px)); overflow-y: auto;
  padding: var(--s1); border-radius: var(--r-lg);
  background: var(--surface-2); box-shadow: var(--shadow-pop);
}
.picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 38px; padding: 6px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; font-size: var(--fs-sm); text-align: left; cursor: pointer;
}
.picker-item:hover { background: var(--surface-3); }
.picker-item.active { background: var(--accent-soft); color: var(--accent); }
.picker-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.kind-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.picker-item .tag { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }

.toolbar { display: flex; flex: 1; align-items: center; gap: var(--s3); min-width: 0; }
.tool-group { display: flex; align-items: center; gap: var(--s2); }
.tool-group + .tool-group { padding-left: var(--s3); border-left: 1px solid var(--line); }
#reset-btn { margin-left: auto; }

/* ------------------------------------------------------------------ layout */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); }

/* ------------------------------------------------------------------ map */
.map-panel { position: relative; min-width: 0; min-height: 0; background: #030508; }
.map-panel::after { /* soft vignette so overlays read against the starfield */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 120px rgba(2, 6, 16, .75);
}
.map-wrap { position: absolute; inset: 0; overflow: hidden; }
#map { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
#map:active { cursor: grabbing; }
#map.armed { cursor: crosshair; }
.heat { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; pointer-events: none; }
.heat[hidden] { display: none; }
html, body { overscroll-behavior-x: none; } /* a sideways swipe on the map rotates it; never "go back" */

.map-hud { position: absolute; z-index: 2; }
.map-hud-tl { top: var(--s4); left: var(--s4); pointer-events: none; }
.map-hud-tr { top: var(--s4); right: var(--s4); }
.map-hud-bl { bottom: var(--s4); left: var(--s4); }

.map-title { margin-bottom: var(--s2); font-size: var(--fs-lg); font-weight: 600; text-shadow: 0 1px 8px #000; }
.hud-stats {
  display: flex; gap: var(--s1); padding: 6px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: rgba(11, 16, 32, .82);
}
.hud-stats > div { padding: 2px var(--s2); }
.hud-stats > div + div { border-left: 1px solid var(--line); }
.hud-stats dt { color: var(--muted); font-size: var(--fs-2xs); }
.hud-stats dd { color: var(--text); font-size: var(--fs-sm); white-space: nowrap; }
.dots { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: 1px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.dots i.on { background: var(--observatory); }

.legend {
  display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); max-width: calc(100% - 2 * var(--s4));
  padding: 6px var(--s3); border: 1px solid var(--line); border-radius: var(--r-md);
  background: rgba(11, 16, 32, .82); color: var(--text-2); font-size: var(--fs-2xs);
}
.legend li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.sw-best { border-top-width: 3px; border-color: var(--accent); }
.sw-alt { border-top-style: dashed; border-color: var(--amber); }
.sw-jam { width: 10px; height: 10px; border: 0; border-radius: 50%; background: radial-gradient(var(--red), transparent 72%); }
.sw-ahead { border-top-style: dotted; border-color: var(--red); }
.sw-link { height: 2px; border: 0; background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); }

.map-hint {
  position: absolute; left: 50%; bottom: 64px; z-index: 3; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: var(--s2) var(--s4);
  border: 1px solid var(--red); border-radius: var(--r-pill);
  background: rgba(30, 10, 14, .92); color: #FFC2C2; font-size: var(--fs-sm); text-align: center;
}

/* labels the 3D map overlays on its nodes (map3d.js) */
.node-label {
  margin-bottom: 4px; padding: 1px 6px; border-radius: 4px;
  background: rgba(5, 7, 13, .72); color: var(--text-2);
  font: 500 var(--fs-2xs)/1.5 var(--sans); white-space: nowrap; pointer-events: none;
}
.node-label.active { background: rgba(9, 22, 38, .88); color: var(--accent); }

/* ------------------------------------------------------------------ side panels */
.side {
  display: flex; flex-direction: column; gap: var(--s3);
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s3); background: linear-gradient(180deg, #071022, var(--bg)); border-left: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.side:focus { outline: none; }
.card { flex: none; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.card-head h2 { font-size: var(--fs-lg); font-weight: 600; }
.card-meta { min-width: 0; overflow: hidden; color: var(--muted); font-size: var(--fs-xs); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.count { min-width: 24px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); text-align: center; }

/* sidebar tabs (tabs.js): Network / Detection */
.side-tabs {
  position: sticky; top: calc(-1 * var(--s3)); z-index: 3; flex: none;
  display: flex; gap: 2px; margin: calc(-1 * var(--s3)) calc(-1 * var(--s3)) 0; padding: var(--s3) var(--s3) var(--s2);
  background: linear-gradient(180deg, #071022 75%, rgba(7, 16, 34, 0));
}
.side-tab {
  flex: 1; height: var(--control-h); border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.side-tab:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.side-tab:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.side-tab:hover { background: var(--surface-2); color: var(--text); }
.side-tab[aria-selected="true"] { background: var(--surface-3); border-color: var(--accent-line); color: var(--accent); }
aside.side > section[hidden] { display: none !important; }

/* network intelligence (main.js renderIntelPanel) */
.intel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.intel-grid .stat-v { font-size: var(--fs-xl); }
.intel-sub { color: var(--faint); font-size: var(--fs-2xs); }
.intel-section-label { margin: var(--s4) 0 6px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.intel-relays, .intel-collisions { display: flex; flex-direction: column; gap: 6px; }
.intel-relay-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 34px auto; align-items: center; gap: var(--s2); font-size: var(--fs-xs); }
.intel-relay-name { overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.intel-relay-bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.intel-relay-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--red)); }
.intel-relay-score { color: var(--muted); font-family: var(--mono); text-align: right; }
.intel-relay-flag { color: var(--red); font-size: var(--fs-2xs); font-weight: 600; }
.intel-collision-row, .intel-muted { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.intel-collision-row.close { color: var(--amber); }
.intel-collision-row.merging { color: var(--red); }
.intel-fec { color: var(--green); font-size: var(--fs-sm); }
.intel-fec.warn { color: var(--amber); }
.intel-fec.bad { color: var(--red); }
.intel-relay-hint { color: var(--accent); font-size: var(--fs-xs); line-height: 1.5; }

/* status pill */
.pill {
  display: inline-flex; flex: none; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .06em; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.up { background: var(--green-soft); color: var(--green); }
.pill.rerouted { background: var(--amber-soft); color: var(--amber); }
.pill.down { background: var(--red-soft); color: var(--red); }
.pill.down::before { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* signal link */
.route-path {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  margin-bottom: var(--s3); color: var(--accent); font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere;
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: var(--s2) 10px; border-radius: var(--r-md); background: var(--surface-2); }
.stat-v { font-size: var(--fs-lg); font-weight: 600; line-height: 1.2; }
.stat-lg .stat-v { font-size: var(--fs-xl); }
.stat-v[data-unit]::after { content: " " attr(data-unit); color: var(--muted); font-family: var(--sans); font-size: var(--fs-2xs); font-weight: 500; }
.stat-k { overflow: hidden; color: var(--muted); font-size: var(--fs-2xs); text-overflow: ellipsis; white-space: nowrap; }
.stat-wide { grid-column: span 2; }

.hop-threats { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s3); }
.hop-threats:empty { display: none; }
.hop-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 4px; gap: 3px var(--s2); }
.hop-name { overflow: hidden; color: var(--text-2); font-size: var(--fs-xs); text-overflow: ellipsis; white-space: nowrap; }
.hop-snr { font: 600 var(--fs-xs) var(--mono); text-align: right; }
.hop-snr.ok { color: var(--green); }
.hop-snr.warn { color: var(--amber); }
.hop-snr.critical, .hop-snr.blocked, .hop-snr.forecast { color: var(--red); }
.hop-fill { grid-column: 1 / -1; height: 4px; border-radius: 2px; transition: width var(--t-med) var(--ease); }
.hop-fill.ok { background: var(--green); }
.hop-fill.warn { background: var(--amber); }
.hop-fill.critical, .hop-fill.blocked, .hop-fill.forecast { background: var(--red); }

.alt-line { margin-top: var(--s3); padding-left: 10px; border-left: 2px dashed var(--amber); color: var(--text-2); font-size: var(--fs-xs); line-height: 1.5; overflow-wrap: anywhere; }

.card-controls { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.card-controls .seg { flex: 1 1 100%; }
.ctrl-hint { flex: 1 1 140px; align-self: center; color: var(--muted); font-size: var(--fs-2xs); line-height: 1.4; }

/* detection */
.verdict {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--s3) var(--s4); border: 1px solid var(--line-strong); border-left-width: 4px; border-radius: var(--r-md);
  background: var(--surface-2);
}
.verdict-k { color: var(--muted); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.verdict-v { color: var(--text-2); font-size: var(--fs-2xl); font-weight: 750; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.verdict-sub { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.5; }
.verdict-sub:empty { display: none; }
.verdict.good { border-color: rgba(105, 211, 154, .45); border-left-color: var(--green); background: linear-gradient(90deg, var(--green-soft), transparent 70%), var(--surface-2); }
.verdict.good .verdict-v { color: var(--green); }
.verdict.bad { border-color: rgba(255, 107, 107, .45); border-left-color: var(--red); background: linear-gradient(90deg, var(--red-soft), transparent 70%), var(--surface-2); }
.verdict.bad .verdict-v { color: var(--red); }
.verdict.warn { border-color: rgba(255, 181, 71, .4); border-left-color: var(--amber); }
.verdict.warn .verdict-v { color: var(--amber); }

.progress-row { display: flex; align-items: center; gap: var(--s3); margin: var(--s3) 0; }
.progress { flex: 1; height: 6px; overflow: hidden; border-radius: 3px; background: var(--surface-3); }
.progress-bar { width: 0; height: 100%; border-radius: 3px; background: var(--accent); transition: width var(--t-med) var(--ease); }
.progress-text { flex: none; color: var(--muted); font-size: var(--fs-2xs); }

.chart-fig { min-width: 0; }
.chart-label { margin-bottom: 4px; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; }
.chart { display: block; width: 100%; border: 1px solid var(--line); border-radius: var(--r-md); background: #080C18; }
.chart-lc { height: 104px; }
.chart-sm { height: 96px; }
.chart-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s3); }

.checks { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s4); }
.checks:empty { display: none; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--s2); color: var(--text-2); font-size: var(--fs-xs); line-height: 1.45; }
.checks .mark { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 800; line-height: 1; }
.checks .mark.ok { background: var(--green-soft); color: var(--green); }
.checks .mark.no { background: var(--red-soft); color: var(--red); }
.checks .name { color: var(--text); font-weight: 600; }
.checks .detail { color: var(--muted); }

.subsection { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
.subsection-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.subsection-head h3 { font-size: var(--fs-sm); font-weight: 600; }
.empty { color: var(--muted); font-size: var(--fs-xs); }
.transit-list { display: flex; flex-direction: column; gap: 4px; }
.transit-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  font-size: var(--fs-xs);
}
.transit-ep { min-width: 30px; color: var(--muted); font-family: var(--mono); }
.transit-time { flex: 1; color: var(--text); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.transit-dur { color: var(--muted); }
.transit-row.transit-soon { border-color: rgba(255, 181, 71, .45); background: var(--amber-soft); }
.transit-row.transit-now { border-color: rgba(105, 211, 154, .55); background: var(--green-soft); }
.transit-row.transit-now .transit-time { color: var(--green); font-weight: 700; }

/* event log */
.card-log { display: flex; flex: 1 0 auto; flex-direction: column; min-height: 220px; }
.log { flex: 1; max-height: 280px; margin: 0 calc(-1 * var(--s2)); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.log li {
  display: grid; grid-template-columns: auto 8px minmax(0, 1fr); align-items: start; gap: 0 var(--s2);
  padding: 6px var(--s2); border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--fs-xs); line-height: 1.45;
}
.log li + li { border-top: 1px solid rgba(28, 37, 64, .6); }
.log li:hover { background: var(--surface-2); }
.log li time { color: var(--faint); font: var(--fs-2xs)/1.9 var(--mono); white-space: nowrap; }
.log .lvl { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--faint); }
.log .lvl.info { background: var(--accent); }
.log .lvl.good { background: var(--green); }
.log .lvl.warn { background: var(--amber); }
.log .lvl.bad { background: var(--red); }
.log li.bad { color: var(--text); }
.log li.log-empty { display: block; padding: var(--s3) var(--s2); color: var(--muted); }

/* ------------------------------------------------------------------ laptop */
@media (max-width: 1360px) {
  :root { --side-w: 372px; }
  .topbar { gap: var(--s3); padding: var(--s2) var(--s4); }
  .btn { padding: 0 10px; }
  .tool .btn-label { display: none; }
  .tool .btn-label-short { display: inline; }
}

/* ------------------------------------------------------------------ tablet: stacked, page scrolls */
@media (max-width: 1099px) {
  body { height: auto; min-height: 100%; overflow: auto; }
  .topbar { position: sticky; top: 0; flex-wrap: wrap; row-gap: var(--s2); }
  .picker { flex: 1 1 220px; }
  .toolbar { flex: 1 1 100%; }
  .layout { display: block; }
  .map-panel { height: clamp(360px, 62vh, 640px); }
  .side {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--s4);
    overflow: visible; padding: var(--s4); border-left: 0;
  }
  .side-tabs { grid-column: 1 / -1; position: static; margin: 0; padding: 0; background: none; }
  .card-detect { grid-column: 1 / -1; }
  .card-log { min-height: 0; }
  .log { max-height: 360px; }
}

/* ------------------------------------------------------------------ phone: single column */
@media (max-width: 719px) {
  :root { --control-h: 40px; --fs-xl: 18px; --fs-2xl: 22px; }
  .topbar { gap: var(--s2); padding: var(--s2) var(--s3); }
  .brand-name { font-size: 15px; }
  .picker { flex: 1 1 0; }
  .picker-menu { left: auto; right: 0; width: calc(100vw - 2 * var(--s3)); }
  .toolbar { flex-wrap: wrap; gap: var(--s2); }
  .tool-group + .tool-group { padding-left: 0; border-left: 0; }
  .tool-group:first-child { flex: 1 1 100%; }
  .tool-group:first-child .seg { flex: 1; }
  .tool-group:nth-child(2) { flex: 1; }
  .tool-group:nth-child(2) .btn { flex: 1; }
  #reset-btn { width: var(--control-h); margin-left: 0; padding: 0; }
  #reset-btn .btn-label { display: none; }
  .btn-primary { min-width: 108px; }

  .map-panel { height: auto; min-height: 320px; max-height: 78vh; aspect-ratio: 1 / 1; }
  .map-hud-tl { top: var(--s2); left: var(--s2); }
  .map-hud-tr { top: auto; right: var(--s2); bottom: var(--s2); }
  .map-hud-bl, .map-title { display: none; }
  .hud-stats { padding: 4px; }
  .hud-stats > div { padding: 1px 6px; }
  .map-hint { bottom: 52px; font-size: var(--fs-xs); }

  .side { display: flex; align-items: stretch; gap: var(--s3); padding: var(--s3); }
  .intel-relay-row { grid-template-columns: 84px minmax(0, 1fr) 30px auto; }
  .card { padding: var(--s3) var(--s4) var(--s4); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-lg:first-child { grid-column: span 2; }
  .stat-wide { grid-column: span 1; }
  .switch { flex: none; }
  .chart-row { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
