:root {
  --bg: #070a12; --bg2: #0d1220; --card: #0f1626; --line: #1c2538; --text: #e6e9f0; --muted: #8b97ad;
  --accent: #38bdf8; --accent2: #a78bfa; --good: #4ade80; --bad: #f43f5e; --warn: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 Inter, system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.mono { font-family: "JetBrains Mono", monospace; }
.muted { color: var(--muted); }
button, select { font: inherit; color: var(--text); }

/* ---------- header */
.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  height: 52px; padding: 0 22px; background: #070a12d9; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 17px; color: var(--text); letter-spacing: -.2px; }
.logo { color: var(--accent); }
.tag { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
nav a { margin-left: 20px; color: var(--muted); font-weight: 500; }
nav a:hover { color: var(--text); }

/* ---------- hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line);
  background: radial-gradient(900px 420px at 15% 0%, #0c4a6e55, transparent 70%),
              radial-gradient(700px 380px at 90% 30%, #4c1d9555, transparent 70%), var(--bg); }
.hero-in { max-width: 1180px; margin: 0 auto; padding: 64px 22px 54px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 11.5px; font-weight: 600; color: var(--accent); margin: 0 0 12px; }
h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.05; margin: 0 0 18px; letter-spacing: -1.5px; font-weight: 800; }
.grad-text { background: linear-gradient(90deg, #38bdf8, #a78bfa 60%, #f472b6); -webkit-background-clip: text;
  background-clip: text; color: transparent; }
.sub { max-width: 660px; color: #b8c1d3; font-size: 16px; margin: 0 0 30px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 920px; margin-bottom: 28px; }
.stat { background: #0f1626b3; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px; }
.stat .n { font-size: 30px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.stat .n.good { color: var(--good); } .stat .n.acc { color: var(--accent); }
.stat .l { font-weight: 600; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 12px; margin-top: 4px; }
.cta { display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--accent); color: #04121c; font-weight: 700; }
.cta:hover { filter: brightness(1.1); }

/* ---------- replay */
.replay { border-bottom: 1px solid var(--line); background: var(--bg2); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ctl, .controls select { background: #0a1020; border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; }
.ctl select { background: transparent; border: 0; padding: 0 0 0 4px; }
.play { width: 38px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: #04121c; font-size: 14px; cursor: pointer; font-weight: 800; }
.scrub { flex: 1; min-width: 160px; }
.scrub input { width: 100%; accent-color: var(--accent); }
.clock { font-size: 22px; font-weight: 700; min-width: 70px; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: #0a1020; border: 0; padding: 6px 11px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #0c4a6e; color: #fff; }
.seg.small button { padding: 4px 10px; font-size: 12.5px; }

.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); height: min(68vh, 720px); min-height: 440px; }
.maps.one { grid-template-columns: 1fr; }
.mapbox { position: relative; background: #000; }
.mapbox .map { position: absolute; inset: 0; }
.card-ov { position: absolute; top: 12px; left: 12px; z-index: 2; width: 236px; background: #0b1120e6; backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.card-ov select { width: 100%; font-size: 13px; background: #0a1020; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-weight: 600; }
.card-ov.rotaist { border-color: #38bdf8aa; box-shadow: 0 0 0 1px #38bdf833, 0 8px 30px #38bdf822; }
.live-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.live-grid .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.live-grid .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.v.bad { color: var(--bad); } .v.good { color: var(--good); }
.bar { height: 5px; border-radius: 3px; background: #1c2538; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #38bdf8, #a78bfa); width: 0; }
.eod { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.eod b { color: var(--text); }

.timeline { height: 150px; padding: 6px 16px 0; }
.timeline canvas { width: 100%; height: 100%; display: block; cursor: ew-resize; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 8px 16px 14px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.dot.ok { background: var(--good); } .dot.late { background: var(--bad); } .dot.wait { border: 2px solid #64748b; }
.lg-traffic b { display: inline-block; width: 90px; height: 6px; border-radius: 3px; vertical-align: middle; margin: 0 6px;
  background: linear-gradient(90deg, #b91c1c, #f97316, #facc15, #22c55e); }

/* ---------- results */
.wrap { max-width: 1180px; margin: 0 auto; padding: 70px 22px; }
h2 { font-size: clamp(24px, 3.4vw, 36px); margin: 0 0 12px; letter-spacing: -.8px; }
.lead { color: var(--muted); max-width: 820px; font-size: 15px; }
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0 22px; }
.ins { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; position: relative; overflow: hidden; }
.ins::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c, var(--accent)); }
.ins .num { font-size: 34px; font-weight: 800; letter-spacing: -1px; color: var(--c, var(--accent)); }
.ins h4 { margin: 4px 0 6px; font-size: 15px; }
.ins p { margin: 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
figure.wide { grid-column: 1 / -1; }
.fig-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.fig-head h3 { margin: 0 0 4px; font-size: 16px; }
.fig-head h3 em { font-style: normal; color: var(--accent); }
.fig-head p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 640px; }
.chart { position: relative; height: 290px; }
.chart.tall { height: 380px; }
.heat-wrap { position: relative; }
#heat { width: 100%; height: 300px; display: block; }
.tip { position: absolute; pointer-events: none; background: #0b1120; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; display: none; white-space: nowrap; }

/* ---------- how */
.pipeline { display: flex; align-items: stretch; gap: 8px; margin: 26px 0; }
.step { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.step .ico { font-size: 26px; }
.step h4 { margin: 8px 0 6px; }
.step p { margin: 0; font-size: 12.5px; color: var(--muted); }
.arrow { align-self: center; color: var(--accent); font-size: 20px; }
.credits { font-size: 12.5px; }

.maplibregl-popup-content { background: #0b1120; color: var(--text); border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; padding: 10px 12px; }
.maplibregl-popup-tip { display: none; }
.maplibregl-ctrl-attrib { font-size: 10px; }

@media (max-width: 1100px) {
  .maps { grid-template-columns: 1fr; height: auto; }
  .maps .mapbox { height: 60vh; min-height: 380px; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights, .grid { grid-template-columns: 1fr; }
  .pipeline { flex-direction: column; } .arrow { transform: rotate(90deg); }
  .maps { grid-template-columns: 1fr; height: auto; }
  .maps .mapbox { height: 58vh; min-height: 380px; }
}
@media (max-width: 600px) {
  .tag, nav a:not(:last-child) { display: none; }
  .hero-in { padding: 40px 16px 36px; }
  .wrap { padding: 46px 16px; }
  .controls { padding: 10px 12px; }
  .scrub { order: 10; flex-basis: 100%; }
  .card-ov { width: auto; right: 12px; padding: 10px 12px; }
  .live-grid { grid-template-columns: repeat(4, 1fr); gap: 4px 8px; }
  .live-grid .v { font-size: 15px; }
  .live-grid .k { font-size: 9.5px; }
  .eod { display: none; }
  .stat .n { font-size: 24px; }
  .fig-head { flex-direction: column; }
}

.legend.flat { padding: 10px 0 0; }

@media (max-width: 600px) { .maplibregl-ctrl-top-right { display: none; } }
