:root {
  --paper: #F1F4F8;
  --ink: #0A1A33;
  --euro-blue: #0B4DA2;
  --chart-line: #C2CEDC;
  --surface: #FFFFFF;
  --calm: #7E9BBF;
  --warm: #E8A23D;
  --hot: #C8362B;
  --muted: #5A6B85;
  --shadow: 0 8px 30px rgba(10,26,51,.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
.mono { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }

/* Masthead */
#masthead {
  background: var(--surface); border-bottom: 1px solid var(--chart-line);
  padding: 10px 20px; display: grid;
  grid-template-columns: auto 1fr auto; align-items: center; gap: 20px;
}
.brand h1 {
  font-family: "Archivo Expanded", sans-serif; font-weight: 700;
  font-size: 20px; letter-spacing: .02em; margin: 0; color: var(--euro-blue);
}
.eyebrow {
  font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); display: block;
}
.controls { display: flex; align-items: center; gap: 24px; justify-self: center; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.daynav { gap: 4px; }
.daydate { font-size: 14px; color: var(--ink); min-width: 96px; text-align: center; }
.daybtn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--chart-line);
  background: var(--surface); color: var(--euro-blue); cursor: pointer; font-size: 12px;
  line-height: 1; display: grid; place-items: center; transition: background .12s, color .12s;
}
.daybtn:hover:not(:disabled) { background: var(--euro-blue); color: #fff; }
.daybtn:disabled { opacity: .35; cursor: default; }
#operator { font: inherit; padding: 4px 8px; border: 1px solid var(--chart-line); border-radius: 6px; background: var(--surface); color: var(--ink); }
.stat { display: flex; flex-direction: column; align-items: flex-end; }
.stat-num { font-size: 22px; font-weight: 600; color: var(--ink); }
.stat-lbl { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.honesty { grid-column: 1 / -1; font-size: 11px; color: var(--muted); font-style: italic; }

/* Stage */
#stage { position: relative; flex: 1; display: flex; min-height: 0; }
#hotspots {
  width: 240px; background: var(--surface); border-right: 1px solid var(--chart-line);
  padding: 14px; overflow-y: auto; z-index: 2;
}
.panel-h {
  font-family: "Archivo Expanded", sans-serif; font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 10px;
}
.leaderboard { list-style: none; margin: 0; padding: 0; }
.hs-row {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 6px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.hs-row:hover { background: var(--paper); border-color: var(--chart-line); }
.hs-rank { color: var(--muted); font-size: 11px; }
.hs-icao { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.hs-val { font-family: "IBM Plex Mono", monospace; font-size: 12px; }
.hs-bar { grid-column: 1 / -1; height: 3px; border-radius: 2px; }

#map { flex: 1; position: relative; }
.map-hint {
  position: absolute; left: 14px; top: 14px; z-index: 4; max-width: 320px;
  background: rgba(255,255,255,.92); border: 1px solid var(--chart-line);
  border-radius: 8px; padding: 9px 12px; box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
}
.hint-text { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.hint-text strong { color: var(--ink); font-weight: 600; }
.hint-controls { margin-top: 8px; }
.hint-ctl { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#routeCount {
  font: inherit; font-size: 11px; padding: 2px 6px; border: 1px solid var(--chart-line);
  border-radius: 5px; background: var(--surface); color: var(--ink);
}
.legend { margin-top: 10px; }
.legend-cap { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 4px; }
.legend-scale { display: flex; align-items: center; gap: 8px; }
.legend-lbl { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.legend-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--calm), var(--warm), var(--hot));
}
.map-zoom {
  position: absolute; left: 14px; bottom: 14px; z-index: 4;
  display: flex; flex-direction: column; box-shadow: var(--shadow); border-radius: 8px;
}
.map-zoom button {
  width: 34px; height: 34px; border: 1px solid var(--chart-line); background: var(--surface);
  color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
}
.map-zoom button:first-child { border-radius: 8px 8px 0 0; }
.map-zoom button:last-child { border-radius: 0 0 8px 8px; border-top: none; }
.map-zoom button:hover { background: var(--paper); color: var(--euro-blue); }
.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff;
  padding: 6px 9px; border-radius: 6px; font-size: 12px; z-index: 5; box-shadow: var(--shadow);
}
.hidden { display: none !important; }

/* Dossier — a non-modal side panel; the map stays live beside it. */
#dossier {
  position: absolute; top: 0; right: 0; width: 460px; max-width: 92vw; height: 100%;
  background: var(--surface); border-left: 1px solid var(--chart-line);
  box-shadow: var(--shadow); z-index: 7; overflow: hidden auto; padding: 20px;
}
#cascadeMount svg { max-width: 100%; display: block; }
.dossier-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dossier-head h2 { font-family: "Archivo Expanded", sans-serif; font-size: 22px; margin: 0; }
.dossier-sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.close-btn {
  border: 1px solid var(--chart-line); background: var(--surface); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 16px; color: var(--ink); line-height: 1;
}
.close-btn:hover { background: var(--paper); }
.section-h {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); margin: 22px 0 8px;
}
.tail-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 9px 10px; border: 1px solid var(--chart-line); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; background: var(--surface);
}
.tail-row:hover { border-color: var(--euro-blue); }
.tail-row.selected { border-color: var(--euro-blue); background: var(--paper); box-shadow: inset 3px 0 0 var(--euro-blue); }
.tail-reg { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.tail-meta { font-size: 11px; color: var(--muted); }
.tail-delay { font-family: "IBM Plex Mono", monospace; font-size: 13px; }

/* Cascade (D3) */
.cascade-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 12px;
  font-size: 11px; color: var(--muted);
}
.cl-item { display: inline-flex; align-items: center; gap: 6px; }
.cl-strip { width: 22px; height: 9px; border-radius: 2px; background: #E3E9F1; border: 1px solid var(--chart-line); }
.cl-tail { width: 14px; height: 9px; border-radius: 2px; background: linear-gradient(90deg, var(--warm), var(--hot)); }
.cl-dash {
  width: 22px; height: 0; border-top: 2px dashed var(--warm); align-self: center;
}
.cause-slots { margin-top: 8px; }
.leg-cause {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted);
  border: 1px dashed var(--chart-line); border-radius: 4px; padding: 3px 7px;
  display: block; margin-top: 4px;
}
.ask {
  margin-top: 18px; padding: 14px; background: var(--paper);
  border-left: 4px solid var(--euro-blue); font-size: 13px; line-height: 1.55;
}

/* Notice shown when a clicked tail's rotation can't be drawn on the basemap */
.map-notice {
  margin-top: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.45;
  color: var(--muted); background: var(--paper);
  border-left: 3px solid var(--chart-line); border-radius: 4px;
}

/* Scheduled-vs-actual table shown under a selected cascade leg */
.leg-times { font-family: "IBM Plex Mono", monospace; }
.leg-times-tbl { border-collapse: collapse; font-size: 11px; color: #0A1A33; }
.leg-times-tbl th { font-weight: 600; text-align: right; padding: 1px 8px 1px 0; color: #5A6B85; }
.leg-times-tbl td { text-align: right; padding: 1px 8px 1px 0; }
.leg-times-tbl tr th:first-child { text-align: left; }

/* Quality floor */
:focus-visible { outline: 2px solid var(--euro-blue); outline-offset: 2px; }
@media (max-width: 1100px) { #hotspots { width: 190px; } #day { width: 150px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
