/* ── Entur primitive palette (kept for token fallbacks) ──────────────── */
:root {
  --lavender-10: #f0f1fa; --lavender-30: #c7cdeb; --lavender-40: #aeb7e2;
  --lavender-50: #8794d4; --lavender-60: #5a68c4; --lavender-70: #3b46ab;
  --lavender-80: #262f7d; --lavender-90: #181c56; --lavender-100: #11143c;
  --coral-40: #ff5959; --coral-50: #f73e3b; --coral-60: #d31b1b;
  --mint-40: #5ac39a; --mint-60: #1a8e60;
  --canary-40: #ffe082; --canary-70: #e9b10c;
  --sky-30: #9adfff; --sky-50: #3aa9ff;
  --ebony-100: #08091c; --ebony-90: #212233; --ebony-85: #2d2e3e;
  --ebony-80: #393a49; --ebony-75: #464755; --ebony-50: #81828f;
  --ebony-30: #b3b4bd; --ebony-15: #d8d9df;
}

/* ── Signal Hall tokens ───────────────────────────────────────────────── */
:root {
  /* Fonts */
  --font-display: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Type scale */
  --fs-hero: clamp(3rem, 8vw, 5.5rem);
  --fs-stat: clamp(1.75rem, 4vw, 2.75rem);
  --fs-h2: 0.7rem;
  --fs-body: 0.9375rem;
  --fs-small: 0.75rem;

  /* Font weights — Outfit supports 100–900 */
  --fw-body: 400;
  --fw-med: 500;
  --fw-heading: 600;
  --fw-bold: 700;

  /* Console surface — always dark regardless of theme */
  --console-bg:    #0a0d1f;
  --console-bg-2:  #0f1228;
  --console-edge:  #1e2347;
  --console-edge-2:#2a3160;
  --console-text:  #dde1ff;
  --console-muted: #6b71a0;

  /* Signal semantic colours */
  --signal-green:  #2ecc71;
  --signal-amber:  #f5a623;
  --signal-red:    #ff3b5c;
  --signal-blue:   #4ea7ff;
  --signal-grey:   #4a5080;

  /* Glow shadows */
  --glow-green: 0 0 16px rgba(46, 204, 113, 0.45);
  --glow-amber: 0 0 16px rgba(245, 166, 35, 0.45);
  --glow-red:   0 0 20px rgba(255, 59, 92, 0.55);
  --glow-blue:  0 0 16px rgba(78, 167, 255, 0.55);

  /* Bar-segment glows — off by default (light mode); dark mode restores them */
  --seg-glow-green: none;
  --seg-glow-amber: none;
  --seg-glow-red:   none;


  /* Spacing */
  --space-xs2: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;

  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.875rem;

  /* Page pad (used for bleed calculation) */
  --page-pad: clamp(16px, 4vw, 32px);

  /* Control height */
  --ctrl-h: 2.125rem;

  /* Light theme page surface */
  --bg:         #f4f4f1;
  --bg-2:       #ebebea;
  --surface:    #ffffff;
  --surface-2:  #f3f3f0;
  --surface-3:  #eaeae6;
  --border:     #d8d8d2;
  --text:       #15171f;
  --text-muted: #5a5d6b;
  --accent:     var(--signal-blue);
  --accent-hover: #3390e8;
  --sev-hoy:    var(--signal-red);
  --sev-middels: var(--signal-amber);
  --sev-lav:    #6b8fff;
  --sev-ukjent: #6e7080;
  --shadow-sm:  0 1px 3px rgba(15, 18, 40, 0.07);
  --shadow-md:  0 3px 10px rgba(15, 18, 40, 0.09);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:         #0a0d1f;
  --bg-2:       #0f1228;
  --surface:    #141830;
  --surface-2:  #1a1f3a;
  --surface-3:  #222844;
  --border:     #262d52;
  --text:       #dde1ff;
  --text-muted: #6b71a0;
  --accent:     var(--signal-blue);
  --accent-hover: #6db8ff;
  --sev-hoy:    #ff6680;
  --sev-middels: #ffbd50;
  --sev-lav:    #8aabff;
  --sev-ukjent: #7a7f9a;
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md:  0 3px 10px rgba(0, 0, 0, 0.45);
  --seg-glow-green: var(--glow-green);
  --seg-glow-amber: var(--glow-amber);
  --seg-glow-red:   var(--glow-red);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg:         #0a0d1f;
    --bg-2:       #0f1228;
    --surface:    #141830;
    --surface-2:  #1a1f3a;
    --surface-3:  #222844;
    --border:     #262d52;
    --text:       #dde1ff;
    --text-muted: #6b71a0;
    --accent:     var(--signal-blue);
    --accent-hover: #6db8ff;
    --sev-hoy:    #ff6680;
    --sev-middels: #ffbd50;
    --sev-lav:    #8aabff;
    --sev-ukjent: #7a7f9a;
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md:  0 3px 10px rgba(0, 0, 0, 0.45);
    --seg-glow-green: var(--glow-green);
    --seg-glow-amber: var(--glow-amber);
    --seg-glow-red:   var(--glow-red);
  }
}

/* ── Theme icon visibility (CSS-only, no JS textContent swap) ────────── */
/* Default: light mode — show moon button (to switch to dark), hide sun */
.icon-sun { display: none; }

/* Explicit dark theme: show sun button (to switch to light), hide moon */
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline; }

/* System dark preference (no explicit choice): same logic */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-moon { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .icon-sun  { display: inline; }
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: var(--fw-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

h1, h2 { margin: 0; }
h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.muted { color: var(--text-muted); }
.small { font-size: var(--fs-small); }
.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* SVG icons inherit text metrics */
.icon {
  width: 1em; height: 1em;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Page layout ──────────────────────────────────────────────────────── */
#app {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
  padding-top: var(--page-pad);
  padding-inline: var(--page-pad);
}

/* ── Console (top section, adapts to current theme) ──────────────────── */
.console {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ── Header ───────────────────────────────────────────────────────────── */
.hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  padding: 14px var(--space-md) 12px;
  justify-content: space-between;
}

/* Brand: wordmark + meta info */
.hdr-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.brand-icon {
  width: 1.25rem; height: 1.25rem;
  color: var(--signal-blue);
  flex-shrink: 0;
}
.brand-name {
  font-size: 1.0625rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.01em;
  color: var(--text);
}

/* Meta row: live dot, window, updated, badges */
.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}
#window {
  font-size: 0.8125rem;
  font-weight: var(--fw-med);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
#window-dur { color: var(--text-muted); }
#updated { color: var(--text-muted); }
.dot { color: var(--border); }

/* Live indicator */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--signal-blue);
}
.live-ring {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-blue);
  box-shadow: var(--glow-blue);
  flex-shrink: 0;
}
.live-text {
  font-size: 0.625rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
#live-dot.pulse .live-ring {
  animation: live-pulse 0.7s ease-out forwards;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(78,167,255,0.8); }
  60%  { box-shadow: 0 0 0 7px rgba(78,167,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(78,167,255,0); }
}

/* Controls: route picker + lang + theme */
.hdr-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.route {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Shared control base */
.dest-select,
.lang-toggle,
.theme-toggle {
  height: var(--ctrl-h);
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: var(--fw-med);
  padding: 0 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.dest-select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a5d6b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.dest-select:hover,
.lang-toggle:hover,
.theme-toggle:hover {
  border-color: var(--signal-blue);
  background: rgba(78,167,255,0.08);
}
.dest-select:focus-visible,
.lang-toggle:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--signal-blue);
  outline-offset: 1px;
}
.dest-select option {
  background: var(--surface);
  color: var(--text);
}


.route-arrow {
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1;
  user-select: none;
  display: flex;
  align-items: center;
  background: transparent;
  border: 0;
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.route-arrow:hover:not(:disabled) {
  color: var(--signal-blue);
  background: rgba(78,167,255,0.1);
}
.route-arrow:focus-visible {
  outline: 2px solid var(--signal-blue);
  outline-offset: 1px;
}
.route-arrow:disabled {
  cursor: default;
  opacity: 0.45;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 10px;
}
.lang-toggle .icon { width: 0.9em; height: 0.9em; }

.theme-toggle.icon-btn {
  width: var(--ctrl-h);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#theme-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
#theme-toggle-icon .icon { width: 1rem; height: 1rem; }

/* Badges */
.badge {
  background: var(--signal-red);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.5625rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.badge-info { background: var(--signal-blue); }

/* ── Timeline (hero) ──────────────────────────────────────────────────── */
.tl-section {
  padding: 0 var(--space-md) var(--space-xs);
}

.tl-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 108px;
  padding: 6px 4px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.04) 0px,
      rgba(0,0,0,0.04) 1px,
      transparent 1px,
      transparent 24px
    ),
    linear-gradient(180deg, transparent 0%, rgba(78,167,255,0.06) 55%, transparent 100%),
    var(--surface-2);
  border-radius: var(--radius-md);
  overflow: visible;
}

/* Bar stagger fade-in */
.tl-bars .bar {
  flex: 1 1 0;
  min-width: 3px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  cursor: default;
  animation: bar-rise 0.28s ease-out backwards;
  animation-delay: calc(var(--i, 0) * 6ms);
}
@keyframes bar-rise {
  from { opacity: 0; transform: scaleY(0.4); transform-origin: bottom; }
  to   { opacity: 1; transform: scaleY(1);   transform-origin: bottom; }
}

.tl-bars .bar .seg { width: 100%; }
.tl-bars .bar .seg-realised {
  background: var(--signal-green);
  border-radius: 2px 2px 0 0;
  box-shadow: var(--seg-glow-green);
}
.tl-bars .bar .seg-cancelled {
  background: var(--signal-red);
  border-radius: 2px 2px 0 0;
  box-shadow: var(--seg-glow-red);
}
.tl-bars .bar .seg-delayed {
  background: var(--signal-amber);
  border-radius: 2px 2px 0 0;
  box-shadow: var(--seg-glow-amber);
}
.tl-bars .bar.empty { background: transparent; }

/* Stub for empty buckets — keeps the rhythm without a hard gap */
.tl-bars .bar.empty .seg-empty {
  height: 4px;
  background: var(--border);
  opacity: 0.6;
  border-radius: 2px;
}


/* Future bars: full brightness (what we care about); past: faded history */
.tl-bars .bar.future .seg { opacity: 1; }
.tl-bars .bar.past .seg { opacity: 0.55; }
.tl-bars .bar.past:hover .seg { opacity: 1; }
.tl-bars .bar:hover .seg-realised { filter: brightness(1.15); }

/* "Now" needle — the centrepiece marker */
.tl-bars .now-marker {
  flex: 0 0 2px;
  align-self: stretch;
  background: var(--signal-blue);
  border-radius: 2px;
  margin: 0 3px;
  box-shadow: var(--glow-blue);
  animation: needle-breathe 2.4s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
.tl-bars .now-marker::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--signal-blue);
  filter: drop-shadow(0 0 4px rgba(78,167,255,0.7));
}
@keyframes needle-breathe {
  0%, 100% { box-shadow: 0 0 6px rgba(78,167,255,0.4); }
  50%       { box-shadow: 0 0 18px rgba(78,167,255,0.9); }
}

/* Timeline tooltip — always dark, floats above the hovered bar */
.tl-tip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
}
.tl-tip.above {
  top: auto;
  bottom: calc(100% + 10px);
}
.tl-tip {
  z-index: 10;
  min-width: 190px;
  max-width: 300px;
  padding: 9px 11px;
  background: var(--console-bg-2);
  border: 1px solid var(--console-edge-2);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  color: var(--console-text);
  pointer-events: none;
  font-size: 0.75rem;
  line-height: 1.45;
}
.tl-tip-head {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-med);
  color: var(--console-text);
}
.tl-tip-counts {
  margin-top: 2px;
  color: var(--console-muted);
}
.tl-tip-red   { color: var(--signal-red); font-weight: var(--fw-med); }
.tl-tip-amber { color: var(--signal-amber); font-weight: var(--fw-med); }
.tl-tip-deps {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--console-edge);
  display: grid;
  gap: 3px;
}
.tl-tip-dep {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}
.tl-tip-dep.cancelled .tl-tip-line,
.tl-tip-dep.cancelled .tl-tip-dest,
.tl-tip-dep.cancelled .tl-tip-time {
  color: var(--signal-red);
  text-decoration: line-through;
}
.tl-tip-line {
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  min-width: 2.6em;
}
.tl-tip-dest {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--console-muted);
}
.tl-tip-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.tl-tip-delay {
  font-family: var(--font-mono);
  color: var(--signal-amber);
  font-weight: var(--fw-med);
}
.tl-tip-delay-minor {
  font-family: var(--font-mono);
  color: var(--console-muted);
}
.tl-tip-more {
  color: var(--console-muted);
  font-size: 0.6875rem;
}

/* Axis labels */
.tl-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0 4px;
}
.tl-foot {
  display: flex;
  margin-top: 4px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: var(--fs-small);
  padding: 0 4px;
}

/* ── Stat strip with gauge ────────────────────────────────────────────── */
.big {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-sm) var(--space-lg);
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* Gauges span both rows; the scope toggle sits centered below the tiles */
.big .big-stat { grid-row: 1 / span 2; }
.big-toggle {
  grid-column: 2;
  justify-self: center;
  margin-top: 0;
  align-self: start;
}

/* Gauge ring */
.big-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.gauge-wrap {
  position: relative;
  width: 152px; height: 152px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Re-runs whenever the ring re-enters the layout (scope switch) */
  animation: gauge-in 0.28s ease-out backwards;
}
@keyframes gauge-in {
  from { opacity: 0; transform: scale(0.86); }
  to   { opacity: 1; transform: scale(1); }
}

.gauge-ring {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 12;
}
.gauge-arc {
  fill: none;
  stroke: var(--signal-green);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 0.8s ease, stroke 0.4s ease;
}

.gauge-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  pointer-events: none;
}

.big-num {
  font-family: var(--font-mono);
  font-size: clamp(1.125rem, 2.2vw, 1.625rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}
.big-label {
  font-size: 0.6rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Stat counter tiles */
.big-counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: var(--space-xs);
  align-content: center;
}
.big-counters > div {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  transition: opacity 0.2s ease;
}

/* Signal lamp in each tile corner — off (border-grey) until its metric
   has something to signal */
.big-counters > div::after {
  content: "";
  position: absolute;
  top: 9px; right: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.big-counters > div.lamp-green::after {
  background: var(--signal-green);
  box-shadow: var(--seg-glow-green);
}
.big-counters > div.lamp-amber::after {
  background: var(--signal-amber);
  box-shadow: var(--seg-glow-amber);
}
.big-counters > div.lamp-red::after {
  background: var(--signal-red);
  box-shadow: var(--seg-glow-red);
}

/* Not applicable in the current scope (kjørt in future view) */
.big-counters > div.na { opacity: 0.5; }
.num {
  font-family: var(--font-mono);
  font-size: var(--fs-stat);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
}
.cap {
  font-size: 0.6rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

/* Semantic counter colours */
.num.neg       { color: var(--signal-red); }
.num.sig-amber { color: var(--signal-amber); }
.num.sig-green { color: var(--signal-green); }

/* ── Cards (blocks) ───────────────────────────────────────────────────── */
.block {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Summary callout — editorial voice */
.summary {
  border-left: 4px solid var(--signal-blue);
  padding-left: var(--space-lg);
}
.summary-text {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: var(--fw-med);
  line-height: 1.5;
  color: var(--text);
}

/* ── Collapsible cards ────────────────────────────────────────────────── */
.collapsible > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  outline: none;
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary > h2 { display: flex; align-items: center; gap: 7px; }
.collapsible > summary > h2::after {
  content: "";
  display: inline-block;
  width: 0.55em; height: 0.55em;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.18s ease, border-color 0.15s;
}
.collapsible[open] > summary > h2::after { transform: rotate(-135deg); }
.collapsible > summary:hover > h2::after { border-color: var(--accent); }

.collapsible > *:not(summary) { margin-top: var(--space-sm); }
.block-headline {
  line-height: 1.45;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Hide the view toggle when collapsed */
.collapsible:not([open]) > summary .seg-toggle { display: none; }

/* ── Segmented toggle ─────────────────────────────────────────────────── */
.seg-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  align-self: flex-start;
  margin-top: 2px;
  user-select: none;
}
.seg-toggle button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 3px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.625rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  transition: background 0.12s, color 0.12s;
}
.seg-toggle button:hover { color: var(--text); }
.seg-toggle button.active {
  background: var(--accent);
  color: #fff;
}

/* ── Situations list ──────────────────────────────────────────────────── */
.sit-list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid;
  gap: var(--space-xs);
}
.sit-list li {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: var(--space-sm);
  align-items: start;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--sev-ukjent);
  transition: border-left-color 0.2s;
}
.sit-list li.sev-hoy     { border-left-color: var(--sev-hoy); }
.sit-list li.sev-middels { border-left-color: var(--sev-middels); }
.sit-list li.sev-lav     { border-left-color: var(--sev-lav); }

/* Severity pulse on new high situations */
.sit-list li.severity-pulse {
  animation: sev-pulse 1.2s ease-out forwards;
}
@keyframes sev-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,59,92,0); }
  30%  { box-shadow: 0 0 16px 4px rgba(255,59,92,0.5); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,92,0); }
}

.sit-sev {
  font-size: 0.5625rem;
  text-transform: uppercase;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding-top: 1px;
}
.sit-sev.sev-hoy     { color: var(--sev-hoy); }
.sit-sev.sev-middels { color: var(--sev-middels); }
.sit-sev.sev-lav     { color: var(--sev-lav); }

.sit-body  { display: grid; gap: 3px; }
.sit-text  { color: var(--text); font-size: 0.875rem; line-height: 1.4; }
.sit-lines { color: var(--text-muted); font-size: var(--fs-small); }
.sit-count-badge {
  background: var(--surface-3);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: start;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.plat-tbl, .pax-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.plat-tbl th, .plat-tbl td,
.pax-tbl th,  .pax-tbl td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.plat-tbl th, .pax-tbl th {
  color: var(--text-muted);
  font-size: 0.5625rem;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-bottom-color: var(--surface-3);
}
/* Numeric columns */
.plat-tbl th:nth-child(n+2):nth-child(-n+5),
.plat-tbl td:nth-child(n+2):nth-child(-n+5) {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.plat-tbl td.lines { color: var(--text-muted); font-size: var(--fs-small); }
.pax-tbl th:nth-child(n+2),
.pax-tbl td:nth-child(n+2) {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.pax-tbl td.line-cell { text-align: left; font-weight: var(--fw-heading); }
.pax-tbl { margin-top: var(--space-sm); }

/* Coloured chips on non-zero cancellation/delay cells */
.chip-red  { color: var(--signal-red); font-weight: var(--fw-bold); }
.chip-amber { color: var(--signal-amber); font-weight: var(--fw-bold); }

/* ── Passenger estimate ───────────────────────────────────────────────── */
.pax #pax-headline-main {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.pax-affected {
  margin-top: var(--space-xs);
  border-left: 3px solid var(--signal-amber);
  padding-left: var(--space-sm);
  color: var(--signal-amber);
  font-weight: var(--fw-med);
  font-size: 0.9375rem;
}
.pax-displaced {
  margin-top: var(--space-xs2);
  border-left: 3px solid var(--signal-red);
  padding-left: var(--space-sm);
  color: var(--signal-red);
  font-weight: var(--fw-med);
  font-size: 0.9375rem;
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.ftr {
  text-align: center;
  padding: var(--space-sm) 0 var(--space-xl);
  border-top: 1px solid var(--border);
}

/* ── Responsive: tablet ───────────────────────────────────────────────── */
@media (max-width: 720px) {
  .big {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  .big .big-stat { grid-row: auto; }
  .big-toggle { grid-column: 1; }
  .gauge-wrap { width: 130px; height: 130px; }

  /* Platform & pax tables → card stack */
  .plat-tbl thead { display: none; }
  .plat-tbl tbody tr {
    display: grid;
    grid-template-columns: 3rem 1fr;
    gap: 4px var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
  }
  .plat-tbl tbody tr td {
    border-bottom: none;
    padding: 0;
    text-align: left;
  }
  .plat-tbl tbody tr td:first-child {
    grid-row: 1 / span 3;
    align-self: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
    color: var(--text);
    text-align: center;
  }
  .plat-tbl tbody tr td:not(:first-child)::before {
    content: attr(data-label) " ";
    font-size: 0.5625rem;
    font-weight: var(--fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
  }
  .plat-tbl tbody tr td:last-child {
    grid-column: 2;
  }
}

/* ── Responsive: mobile ───────────────────────────────────────────────── */
@media (max-width: 560px) {
  .hdr { padding: 12px 16px 10px; }
  .hdr-controls { gap: 5px; }
  .route { gap: 5px; }
  .dest-select { max-width: 100px; }
  .tl-bars { height: 80px; }
  .big-counters { grid-template-columns: repeat(3, 1fr); }
  .big { padding: var(--space-sm) var(--space-md); }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
