/* © 2026 Andy217Ace */
/* Tabela Gara de Nord — afișaj de gară modern („UI2").
   Sistemul de design e descris în design-system/tabela-gara-de-nord/MASTER.md.
   Trei straturi de tokeni: primitive (--ref-*) → semantice (--bg, --text, --ok…) → componente
   (--btn-*, --card-*, --board-*…). Componentele folosesc doar tokeni semantici/de componentă,
   niciodată culori brute. Întunecat implicit, luminos prin prefers-color-scheme;
   [data-theme] pe <html> le suprascrie pe amândouă.
   Fără stiluri inline (CSP: style-src fără 'unsafe-inline'). */

/* ---------- fonturi auto-găzduite (OFL, web/fonts/OFL-*.txt) ----------
   Subset latin + latin-ext (ă â î ș ț), font-display: swap. Fira Code = cifre, ore, numere
   de tren; Fira Sans = text. */

@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/fira-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/fira-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/fira-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/fira-sans-700.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Code";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/fira-code.woff2") format("woff2-variations"), url("fonts/fira-code.woff2") format("woff2");
}

/* ---------- 1. primitive (valori brute; NU se folosesc direct în componente) ---------- */

html {
  --ref-slate-0: #ffffff;
  --ref-slate-50: #f8fafc;
  --ref-slate-100: #f1f5f9;
  --ref-slate-150: #eef2f7;
  --ref-slate-200: #e2e8f0;
  --ref-slate-300: #cbd5e1;
  --ref-slate-400: #94a3b8;
  --ref-slate-450: #7a889e;
  --ref-slate-500: #5b6779;
  --ref-slate-600: #475569;
  --ref-slate-650: #364559;
  --ref-slate-700: #263348;
  --ref-slate-750: #1e293b;
  --ref-slate-775: #1a2539;
  --ref-slate-800: #151f33;
  --ref-slate-850: #111a2d;
  --ref-slate-875: #0e1628;
  --ref-slate-900: #0f172a;
  --ref-slate-925: #0b1222;
  --ref-amber-400: #ffb547;
  --ref-amber-800: #92400e;
  --ref-amber-950: #1a1204;
  --ref-yellow-100: #fef3c7;
  --ref-yellow-300: #fde047;
  --ref-yellow-800: #8a5300;
  --ref-orange-400: #fb923c;
  --ref-orange-750: #ad3f0a;
  --ref-olive-800: #7a5d00;
  --ref-green-100: #dcfce7;
  --ref-green-400: #4ade80;
  --ref-green-800: #166534;
  --ref-red-100: #fee2e2;
  --ref-red-400: #f87171;
  --ref-red-700: #b91c1c;
  --ref-blue-300: #7cc4ff;
  --ref-blue-400: #60a5fa;
  --ref-blue-700: #1d4ed8;
  --ref-violet-400: #b69cff;
  --ref-violet-700: #6d28d9;
  --ref-teal-400: #3fd4c0;
  --ref-teal-700: #0f766e;
  --ref-lime-400: #9fd86b;
  --ref-lime-700: #4d7c0f;
  --ref-chart-arr-d: #4a96e6;
  --ref-chart-dep-d: #c97d12;
  --ref-chart-seq-d: #9a7ff0;
  --ref-chart-arr-l: #1f5fb8;
  --ref-chart-dep-l: #965200;
  --ref-chart-seq-l: #5b3bb8;
  /* Beta 1.26: categorical slots for donut / pie charts (web/ui2.js), validated with the dataviz
     palette checker (CVD + contrast) against each surface; fixed order, never cycled */
  --ref-cat-d-1: #3987e5;
  --ref-cat-d-2: #d95926;
  --ref-cat-d-3: #199e70;
  --ref-cat-d-4: #9085e9;
  --ref-cat-d-5: #c98500;
  --ref-cat-d-6: #d96a96;
  --ref-cat-l-1: #2a78d6;
  --ref-cat-l-2: #c4501f;
  --ref-cat-l-3: #14876a;
  --ref-cat-l-4: #6250d6;
  --ref-cat-l-5: #b87800;
  --ref-cat-l-6: #c8507f;
  --ref-black: #000000;
  --ref-black-a40: rgba(2, 6, 23, 0.4);
  --ref-black-a60: rgba(2, 6, 23, 0.6);
  --ref-black-a70: rgba(2, 6, 23, 0.7);
  --ref-ink-a06: rgba(15, 23, 42, 0.06);
  --ref-ink-a18: rgba(15, 23, 42, 0.18);
  --ref-nav-dark: rgba(11, 18, 34, 0.92);
  --ref-nav-light: rgba(255, 255, 255, 0.94);
}

/* ---------- 2. semantice: tema întunecată (implicită) ---------- */

:root {
  color-scheme: dark;
  --bg: var(--ref-slate-900);
  --bg-glow: transparent;
  --surface: var(--ref-slate-800);
  --surface-2: var(--ref-slate-750);
  --surface-hover: var(--ref-slate-775);
  --border: var(--ref-slate-700);
  --border-strong: var(--ref-slate-650);
  --field-border: var(--ref-slate-500);
  --text: var(--ref-slate-100);
  --text-2: var(--ref-slate-300);
  --text-3: var(--ref-slate-400);
  --accent: var(--ref-amber-400);
  --accent-ink: var(--ref-amber-950);
  --time: var(--ref-amber-400);
  --focus: var(--ref-blue-300);

  --ok: var(--ref-green-400);
  --ok-bg: color-mix(in srgb, var(--ref-green-400) 12%, var(--ref-slate-800));
  --warn: var(--ref-yellow-300);
  --warn-bg: color-mix(in srgb, var(--ref-yellow-300) 12%, var(--ref-slate-800));
  --bad: var(--ref-red-400);
  --bad-bg: color-mix(in srgb, var(--ref-red-400) 14%, var(--ref-slate-800));
  --info: var(--ref-blue-400);
  --unknown: var(--ref-slate-400);

  --board-bg: var(--ref-slate-925);
  --board-surface: var(--ref-slate-850);
  --board-row: var(--ref-slate-850);
  --board-row-alt: var(--ref-slate-875);
  --board-row-hover: var(--ref-slate-775);
  --board-line: var(--ref-slate-700);
  --board-line-strong: var(--ref-slate-650);
  --lvl-ok: var(--ref-green-400);
  --lvl-low: var(--ref-yellow-300);
  --lvl-mid: var(--ref-orange-400);
  --lvl-high: var(--ref-red-400);
  --lvl-tint: 16%;

  --t-ir: var(--ref-blue-400);
  --t-irn: var(--ref-violet-400);
  --t-re: var(--ref-teal-400);
  --t-r: var(--ref-slate-300);
  --t-rm: var(--ref-lime-400);
  --t-other: var(--ref-slate-300);
  /* chart series (Statistici): arrivals blue, departures amber, one sequential hue;
     validated with the dataviz palette checker (CVD/contrast) on each surface */
  --c-arr: var(--ref-chart-arr-d);
  --c-dep: var(--ref-chart-dep-d);
  --c-seq: var(--ref-chart-seq-d);

  --shadow: none;
  --shadow-overlay: 0 20px 48px -12px var(--ref-black-a60);
  --scrim: var(--ref-black-a70);
  --nav-bg: var(--ref-nav-dark);
}

/* ---------- 2b. semantice: tema luminoasă (urmează sistemul) ---------- */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: var(--ref-slate-100);
    --bg-glow: transparent;
    --surface: var(--ref-slate-0);
    --surface-2: var(--ref-slate-150);
    --surface-hover: var(--ref-slate-50);
    --border: var(--ref-slate-200);
    --border-strong: var(--ref-slate-300);
    --field-border: var(--ref-slate-450);
    --text: var(--ref-slate-900);
    --text-2: var(--ref-slate-600);
    --text-3: var(--ref-slate-500);
    --accent: var(--ref-amber-800);
    --accent-ink: var(--ref-slate-0);
    --time: var(--ref-amber-800);
    --focus: var(--ref-blue-700);
    --ok: var(--ref-green-800);
    --ok-bg: var(--ref-green-100);
    --warn: var(--ref-yellow-800);
    --warn-bg: var(--ref-yellow-100);
    --bad: var(--ref-red-700);
    --bad-bg: var(--ref-red-100);
    --info: var(--ref-blue-700);
    --unknown: var(--ref-slate-500);
    --board-bg: var(--ref-slate-50);
    --board-surface: var(--ref-slate-0);
    --board-row: var(--ref-slate-0);
    --board-row-alt: var(--ref-slate-50);
    --board-row-hover: var(--ref-slate-150);
    --board-line: var(--ref-slate-200);
    --board-line-strong: var(--ref-slate-300);
    --lvl-ok: var(--ref-green-800);
    --lvl-low: var(--ref-olive-800);
    --lvl-mid: var(--ref-orange-750);
    --lvl-high: var(--ref-red-700);
    --lvl-tint: 14%;
    --t-ir: var(--ref-blue-700);
    --t-irn: var(--ref-violet-700);
    --t-re: var(--ref-teal-700);
    --t-r: var(--ref-slate-600);
    --t-rm: var(--ref-lime-700);
    --t-other: var(--ref-slate-600);
    --c-arr: var(--ref-chart-arr-l);
    --c-dep: var(--ref-chart-dep-l);
    --c-seq: var(--ref-chart-seq-l);
    --shadow: 0 1px 2px var(--ref-ink-a06);
    --shadow-overlay: 0 20px 48px -16px var(--ref-ink-a18);
    --scrim: var(--ref-black-a40);
    --nav-bg: var(--ref-nav-light);
  }
}

:root[data-theme="dark"] { color-scheme: dark; }

/* ---------- 2c. semantice: tema luminoasă forțată (identică cu 2b) ---------- */

:root[data-theme="light"] {
  color-scheme: light;
  --bg: var(--ref-slate-100);
  --bg-glow: transparent;
  --surface: var(--ref-slate-0);
  --surface-2: var(--ref-slate-150);
  --surface-hover: var(--ref-slate-50);
  --border: var(--ref-slate-200);
  --border-strong: var(--ref-slate-300);
  --field-border: var(--ref-slate-450);
  --text: var(--ref-slate-900);
  --text-2: var(--ref-slate-600);
  --text-3: var(--ref-slate-500);
  --accent: var(--ref-amber-800);
  --accent-ink: var(--ref-slate-0);
  --time: var(--ref-amber-800);
  --focus: var(--ref-blue-700);
  --ok: var(--ref-green-800);
  --ok-bg: var(--ref-green-100);
  --warn: var(--ref-yellow-800);
  --warn-bg: var(--ref-yellow-100);
  --bad: var(--ref-red-700);
  --bad-bg: var(--ref-red-100);
  --info: var(--ref-blue-700);
  --unknown: var(--ref-slate-500);
  --board-bg: var(--ref-slate-50);
  --board-surface: var(--ref-slate-0);
  --board-row: var(--ref-slate-0);
  --board-row-alt: var(--ref-slate-50);
  --board-row-hover: var(--ref-slate-150);
  --board-line: var(--ref-slate-200);
  --board-line-strong: var(--ref-slate-300);
  --lvl-ok: var(--ref-green-800);
  --lvl-low: var(--ref-olive-800);
  --lvl-mid: var(--ref-orange-750);
  --lvl-high: var(--ref-red-700);
  --lvl-tint: 14%;
  --t-ir: var(--ref-blue-700);
  --t-irn: var(--ref-violet-700);
  --t-re: var(--ref-teal-700);
  --t-r: var(--ref-slate-600);
  --t-rm: var(--ref-lime-700);
  --t-other: var(--ref-slate-600);
  --c-arr: var(--ref-chart-arr-l);
  --c-dep: var(--ref-chart-dep-l);
  --c-seq: var(--ref-chart-seq-l);
  --shadow: 0 1px 2px var(--ref-ink-a06);
  --shadow-overlay: 0 20px 48px -16px var(--ref-ink-a18);
  --scrim: var(--ref-black-a40);
  --nav-bg: var(--ref-nav-light);
}

/* ---------- 3. scale (independente de temă) + tokeni de componentă ---------- */

html {
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Fira Code", ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;

  /* tipografie (rem; 1rem = 16px) — text nu sub 12px */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.75rem;
  --lh-tight: 1.15;
  --lh-base: 1.5;
  --tracking-label: 0.08em;

  /* spațiere (bază 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* raze */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;
  --radius: var(--radius-lg);

  /* mișcare: discretă (150–300 ms), doar transform/opacity/culori;
     anulată la prefers-reduced-motion */
  --dur-fast: 150ms;
  --dur: 200ms;
  --dur-slow: 300ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* ținte tactile */
  --tap: 44px;
  --control-h: 40px;

  /* componente */
  --btn-bg: var(--surface);
  --btn-border: var(--border-strong);
  --btn-hover: var(--surface-2);
  --card-bg: var(--surface);
  --card-border: var(--border);
  --chip-bg: var(--surface-2);
  --field-bg: var(--surface-2);

  --gutter: 16px;
  --nav-h: 0px; /* no bottom bar any more (menu is the sticky top bar) */
  --topnav-h: 57px; /* sticky .navbar height: 44 + 2×6 padding + 1 border */
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-x: hidden;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ore, numere de tren, cifre: Fira Code cu cifre tabulare */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

main:focus { outline: none; }

[hidden] { display: none !important; }

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

/* nume canonic dintr-o citire OCR nesigură (câmpul `uncertain` din API) */
.is-uncertain {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  cursor: help;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* conținutul randat pe server pentru motoarele de căutare (app/seo.py): ascuns cât rulează
   aplicația (theme-init.js pune mereu data-view pe <html>), vizibil fără JavaScript */
html[data-view] .ssr { display: none; }
.ssr { padding: 16px; }
.ssr th, .ssr td { padding: 2px 8px; text-align: left; }

svg { flex: none; }

/* ---------- header ---------- */

.topbar {
  padding: calc(10px + env(safe-area-inset-top, 0px)) var(--gutter) 8px;
  background: var(--bg);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

/* sigla (web/icons/logo.png: plăcuța rotunjită are deja margine transparentă) */
.logo { display: block; flex: none; }
#logo { width: 40px; height: 40px; }

/* comutator temă: Auto → Luminoasă → Întunecată (theme-init.js + app.js) */
.theme-btn {
  order: 1;
  margin-left: auto;
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.theme-btn:hover { background: var(--btn-hover); border-color: var(--field-border); }
.theme-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-icon {
  display: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon .theme-fill { fill: currentColor; stroke: none; }
.theme-btn[data-mode="auto"] .theme-icon-auto,
.theme-btn[data-mode="light"] .theme-icon-light,
.theme-btn[data-mode="dark"] .theme-icon-dark,
.theme-btn:not([data-mode]) .theme-icon-auto { display: block; }

/* ecran de încărcare (până la primele date) */
.boot {
  position: absolute;   /* over the skeleton rows (#boards), out of the flow: hiding it moves nothing */
  top: 52px;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
  font-size: 0.875rem;
}
.logo-boot { width: 40px; height: 40px; animation: boot-pulse 1.6s ease-in-out infinite; }
@keyframes boot-pulse { 50% { opacity: 0.55; } }

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}

.brand-sub {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: 500;
}

/* weather slot (weather.css / weather.js): until the widget is built, its size, so the header row does not
   wrap or grow later (CLS). Here, not in weather.css: that file belongs to the board's own round. */
.wx-slot:empty { min-width: 5.5rem; min-height: 44px; }

/* live indicator */

.live {
  order: 2;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.live-text, .live-src { white-space: nowrap; }
.live-text { color: var(--text); font-weight: 500; }
.live-sep { color: var(--text-3); }
.live-src a { color: var(--text-2); text-underline-offset: 2px; }
.live-src a:hover { color: var(--text); }

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}

.live[data-state="live"] .live-dot { background: var(--ok); }
.live[data-state="live"] .live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse 2s ease-out infinite;
}
.live[data-state="stale"],
.live[data-state="offline"] {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  background: var(--warn-bg);
}
.live[data-state="stale"] .live-dot,
.live[data-state="offline"] .live-dot { background: var(--warn); border-radius: 2px; }
.live[data-state="stale"] .live-text,
.live[data-state="offline"] .live-text { color: var(--warn); }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.7; }
  80%, 100% { transform: scale(3); opacity: 0; }
}

/* main nav: its own bar, sticky at the top at EVERY width (no bottom bar, no width
   breakpoint that moves it: with „Site pentru desktop” phones lay the page out at ~980 px and
   the old bottom bar became tiny/hidden). Items that don't fit scroll inside the bar, never
   the page; the active item is scrolled into view by app.js. */

.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

.navbar { display: flex; align-items: center; }
.navbar .mainnav { flex: 1 1 auto; min-width: 0; }
.lang-toggle {
  flex: 0 0 auto;
  min-width: var(--tap);
  min-height: var(--tap);
  margin-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.lang-toggle:hover { color: var(--text); background: var(--surface); }

.mainnav {
  display: flex;
  gap: 4px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 6px max(var(--gutter), env(safe-area-inset-right, 0px)) 6px max(var(--gutter), env(safe-area-inset-left, 0px));
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-padding-inline: var(--gutter);
  -webkit-overflow-scrolling: touch;
}

.mainnav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  text-decoration: none;
  white-space: nowrap;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.01em;
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.nav-icon,
.board-icon,
.soon-icon,
.banner-icon,
.btn-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-icon { width: 18px; height: 18px; }

.nav-item[aria-current="page"] {
  color: var(--accent);
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-sm);
}
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item[aria-current="page"]:hover { color: var(--accent); background: var(--surface-2); }

/* touch screens: a bit more room per item (target ≥ 44 px already) */
@media (pointer: coarse) {
  :root { --topnav-h: 59px; }
  .nav-item { min-height: 46px; padding: 0 14px; font-size: 0.9375rem; }
  .nav-icon { width: 20px; height: 20px; }
}

/* phone in „Site pentru desktop” (page laid out much wider than the screen and shown zoomed
   out; class set by theme-init.js): bigger bar so it stays readable and tappable */
html.zoomed-out { --topnav-h: 109px; }
html.zoomed-out .mainnav { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
html.zoomed-out .nav-item { min-height: 88px; padding: 0 24px; gap: 12px; font-size: 1.75rem; border-radius: 18px; }
html.zoomed-out .nav-icon { width: 36px; height: 36px; }

/* ==== Beta 1.67 (F) — phones (≤ 700 px): bottom navigation ==== */
/* The bar moves to the bottom: Tabelă/Istoric/Trenuri/Statistici + „Mai mult” (menu filled by
   app.js from the other .mainnav links). Pure CSS from the first paint: no layout shift.
   Not for „Site pentru desktop” (laid out ~980 px wide: the top bar stays). */
.nav-more { display: none; }
@media (max-width: 700px) {
  :root { --topnav-h: 0px; --nav-h: 58px; }
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }
  /* WCAG 2.4.11: keyboard focus scrolls above the fixed bottom bar, never under it */
  html { scroll-padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); }
  .navbar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    border-bottom: 0;
    border-top: 1px solid var(--border);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }
  .navbar .mainnav { flex: 4 1 0; gap: 0; margin: 0; padding: 0; overflow: visible; }
  .navbar > .lang-toggle { display: none; }
  .mainnav .nav-item:not([data-route="tabela"]):not([data-route="istoric"]):not([data-route="trenuri"]):not([data-route="statistici"]) { display: none; }
  .mainnav .nav-item,
  .nav-more-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--nav-h);
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    border: 0;
    border-radius: 0;
    font-size: 0.6875rem;
    letter-spacing: 0;
  }
  .mainnav .nav-item span,
  .nav-more-btn span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .mainnav .nav-item[aria-current="page"] { background: transparent; box-shadow: inset 0 2px 0 var(--accent); border-radius: 0; }
  .nav-more { display: flex; flex: 1 1 0; min-width: 0; }
  .nav-more-btn {
    display: flex;
    align-items: center;
    background: transparent;
    color: var(--text-2);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
  }
  .nav-more-btn[aria-expanded="true"],
  .nav-more:has(.nav-more-link[aria-current="page"]) .nav-more-btn { color: var(--accent); }
  .nav-more-menu {
    position: absolute;
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: calc(100% + 8px);
    width: min(16rem, calc(100vw - 16px));
    max-height: calc(100dvh - var(--nav-h) - 96px);
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-overlay);
  }
  .nav-more-menu[hidden] { display: none; }
  .nav-more-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
  }
  .nav-more-link:hover { background: var(--surface-hover); }
  .nav-more-link[aria-current="page"] { color: var(--accent); background: var(--surface-2); }
  .nav-more-lang { padding: 6px 4px 2px; border-top: 1px solid var(--border); margin-top: 4px; }
  .nav-more-lang .lang-toggle { width: 100%; margin: 0; }
}
/* ==== end Beta 1.67 (F) bottom navigation ==== */

/* ---------- main ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 6px var(--gutter) 24px;
  min-height: 100vh;   /* the footer starts below the fold: content arriving later never pushes it (CLS) */
}
html[data-deeplink] #view-tabela { display: none; }   /* theme-init.js: another page is coming (app.js route()) */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0 4px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--radius-lg);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: var(--fs-md);
  font-weight: 500;
}
.banner-icon { width: 18px; height: 18px; margin-top: 1px; }

/* segmented tabs (mobile only) */

.tabs {
  position: sticky;
  top: var(--topnav-h); /* under the sticky menu bar */
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 8px calc(-1 * var(--gutter)) 0;
  padding: 8px var(--gutter);
  background: var(--bg);
}

.tabs::before {
  content: "";
  position: absolute;
  inset: 8px var(--gutter);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  z-index: -1;
}

.tab {
  appearance: none;
  border: 0;
  margin: 4px;
  min-height: var(--control-h);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.tab[aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.tab[aria-selected="true"] .tab-count { background: var(--accent-ink); color: var(--accent); }

.tab-count {
  min-width: 1.6em;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}
.tab-count:empty { display: none; }

/* boards */

.boards { position: relative; margin-top: 8px; }

.boards[data-active="arrivals"] .board[data-board="departures"],
.boards[data-active="departures"] .board[data-board="arrivals"] { display: none; }

.board-title {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.board-icon {
  width: 26px;
  height: 26px;
  padding: 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  stroke-width: 2.2;
}

.trains {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- train card ---------- */

.train {
  position: relative;
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  transition: background-color var(--dur-fast) var(--ease);
}

.train::before {
  /* left rail tinted by delay state */
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--rail, transparent);
}
.train[data-delay="minor"] { --rail: var(--warn); }
.train[data-delay="major"] { --rail: var(--bad); }
.train[data-delay="unread"] { --rail: var(--unknown); }

.t-time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: start;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.t-sched {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--time);
}

/* întârziat: ora estimată (programată + întârzierea citită) mare, programata tăiată dedesubt;
   starea o spun bara laterală + eticheta cu iconiță și text, nu culoarea orei */
.train[data-delay="minor"] .t-sched,
.train[data-delay="major"] .t-sched {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-3);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  order: 2;
  margin-top: 4px;
}

.t-est {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--time);
}

.t-main { min-width: 0; }

.t-station {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  overflow-wrap: anywhere;
  /* nume lungi: cel mult 2 rânduri, apoi „…" (numele complet e în title) */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.t-meta {
  margin: 3px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.t-no {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
}

.t-op {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.t-flag {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 700;
}

.t-row {
  grid-column: 2 / -1;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

/* type badge: outlined */
.type {
  --c: var(--t-other);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.4em;
  padding: 0 6px;
  border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent);
  border-radius: var(--radius-sm);
  color: var(--c);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.type-ir { --c: var(--t-ir); }
.type-irn { --c: var(--t-irn); }
.type-re { --c: var(--t-re); }
.type-r { --c: var(--t-r); }
.type-rm { --c: var(--t-rm); }

/* delay badge: filled tint + icon + text */
.delay {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 9px 2px 7px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.delay svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.delay-ok { color: var(--ok); background: var(--ok-bg); }
.h-truncated { color: var(--warn); font-weight: 600; }
.delay-unread { color: var(--text-2); background: var(--chip-bg); }
.delay.delay-last { font-style: italic; }
.f-sub .delay-unread { padding: 0 6px; border-radius: 6px; font-style: italic; }
.delay-minor { color: var(--warn); background: var(--warn-bg); }
.delay-major { color: var(--bad); background: var(--bad-bg); }

/* follow button */
.follow {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  min-height: 32px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.follow:hover { color: var(--text); border-color: var(--field-border); background: var(--btn-hover); }
.follow svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.follow[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
/* phone: touch target ≥ 44 px; the extra height is taken back with negative margins so the
   card keeps its layout */
@media (max-width: 759px) {
  .follow { min-height: 44px; min-width: 44px; margin-block: -6px; }
}

/* platform */
.t-plat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  align-self: start;
}

/* linia: plăcuță de peron (chenar + cifre ambră); necunoscută = plăcuță stinsă, gri */
.plat {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--accent);
  background: var(--board-bg);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--accent);
}
.plat-unknown {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-3);
  font-size: var(--fs-base);
  font-weight: 500;
}

.plat-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-3);
}

.train:hover { background: var(--surface-hover); }

/* modificare (întârziere/linie): contur ambră care se stinge (doar box-shadow + culoare) */
.train.flash { animation: flash 1.6s var(--ease); }
@keyframes flash {
  0% { box-shadow: 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card-bg)); }
  100% { box-shadow: 0 0 0 0 transparent; background: var(--card-bg); }
}

/* skeleton */
.train.skeleton {
  pointer-events: none;
  box-shadow: none;
}
/* schelet: blocuri statice care pulsează discret (doar opacity) */
.sk {
  display: block;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: sk-pulse 1.4s var(--ease) infinite;
}
.sk-time { width: 4.2rem; height: 1.6rem; align-self: start; }
.sk-lines { height: 2.6rem; width: 80%; }
.sk-plat { width: 2.75rem; height: 2.75rem; border-radius: var(--radius-md); }
@keyframes sk-pulse { 50% { opacity: 0.45; } }

.empty {
  margin: 0;
  padding: 32px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  color: var(--text-2);
  font-weight: 500;
}

/* "în curând" views */
.soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 440px;
  margin: 40px auto;
  padding: 32px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}
.soon h1 { margin: 12px 0 8px; font-size: 1.375rem; letter-spacing: -0.02em; }
.soon p { margin: 0 0 12px; color: var(--text-2); }
.soon-icon { width: 44px; height: 44px; padding: 9px; border-radius: var(--radius-lg); background: var(--surface-2); color: var(--accent); }
.soon-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--warn) !important;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  min-height: var(--control-h);
  padding: 8px 18px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

/* ---------- shared page bits (Istoric / Urmărite) ---------- */

.page-head { margin: var(--space-4) 0 var(--space-4); }
.page-head h1 { margin: 0; font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.01em; line-height: var(--lh-tight); }
.page-sub { margin: 6px 0 0; color: var(--text-2); font-size: 0.9375rem; max-width: 68ch; }

.btn { border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.btn-ghost {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--btn-border);
}
.btn-ghost:hover { background: var(--btn-hover); border-color: var(--field-border); }
.btn-ghost:disabled { opacity: 0.55; cursor: progress; }
.btn-sm { margin-top: 0; min-height: 32px; padding: 5px 12px; font-size: var(--fs-sm); border-radius: var(--radius-md); }

.notice {
  margin: 10px 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: var(--radius-lg);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: var(--fs-md);
  font-weight: 500;
}
.notice-error {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: var(--bad-bg);
  color: var(--bad);
}

.h-count {
  margin: 12px 0 8px;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.h-count:empty { display: none; }

/* ---------- Istoric: filters ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-date { grid-column: span 2; }
.field-wide { grid-column: 1 / -1; }
.field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-3);
}
.field input,
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
.field input:focus-visible,
.field select:focus-visible { outline-offset: 0; border-color: var(--focus); }
.filters .btn { grid-column: 1 / -1; margin-top: 0; padding: 8px 14px; }
.field input[type="time"] { padding: 8px 6px; }

.view-history.is-loading .h-results { opacity: 0.55; transition: opacity var(--dur) var(--ease); }

/* Istoric — day picker: empty day = „Toate zilele” (default); the button clears the day */
.h-day-pick { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.h-day-pick > input { flex: 1 1 9.5rem; min-width: 0; }
.h-day-pick > .h-alldays { flex: 0 0 auto; min-height: var(--tap); margin-top: 0; padding: 8px 14px; }
.h-alldays[aria-pressed="true"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Istoric — all days of one train: summary, day groups, actions, load more */
.h-summary {
  margin: 4px 0 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
}
.h-summary[hidden] { display: none; }
.h-summary p { margin: 4px 0; overflow-wrap: anywhere; }
.h-sum-board { font-weight: 700; }
.h-sum-states,
.h-sum-note { color: var(--text-2); font-size: 0.8125rem; }
.h-group + .h-group { margin-top: 14px; }
.h-group-title {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}
.h-acts { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.h-act {
  appearance: none;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.h-act:hover { text-decoration-thickness: 2px; }
/* phones: the result cell (badge + "calitate redusă") wraps instead of pushing the page */
.h-group .h-row .h-status { flex-wrap: wrap; row-gap: 4px; }
.lq-badge {
  display: inline-flex;
  padding: 1px 7px;
  border: 1px dashed var(--field-border);
  border-radius: var(--radius-pill);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.h-more { display: block; margin: 14px auto 4px; padding: 8px 18px; }
.h-more[hidden] { display: none; }

/* ---------- Istoric: results (cards on mobile, table on wide screens) ---------- */

.h-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.h-table thead { display: none; }
.h-table tbody { display: flex; flex-direction: column; gap: 8px; }
.h-row {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
  transition: background-color var(--dur-fast) var(--ease);
}
.h-row:hover { background: var(--surface-hover); }
.h-row::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  bottom: -1px;
  width: 4px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--rail, transparent);
}
.h-row[data-delay="minor"] { --rail: var(--warn); }
.h-row[data-delay="major"] { --rail: var(--bad); }
.h-row[data-delay="unread"] { --rail: var(--unknown); }
.h-row td { display: block; padding: 0; min-width: 0; }
.h-time {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--time);
  letter-spacing: -0.02em;
}
.h-board {
  grid-column: 1;
  grid-row: 3;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-3);
}
.h-station {
  grid-column: 2;
  grid-row: 1;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.h-trn { grid-column: 2; grid-row: 2; }
.h-op { grid-column: 2; grid-row: 3; font-size: 0.8125rem; color: var(--text-2); }
.h-plat { grid-column: 3; grid-row: 1 / span 2; justify-self: end; }
.h-row .h-max,
.h-row .h-last,
.h-row .h-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.h-row .h-max::before,
.h-row .h-last::before,
.h-row .h-status::before {
  content: attr(data-label);
  flex: 0 0 12.5em;
  color: var(--text-3);
}
.h-row .h-max { margin-top: 6px; }

.h-train {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 2px 6px 2px 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.h-train:hover { text-decoration-color: var(--accent); }

.plat-sm { width: 2.25rem; height: 2.25rem; font-size: var(--fs-base); }

/* ==== Beta 1.67 (F) — phones (≤ 700 px): collapsible filters + denser Istoric cards ==== */
.filt-toggle { display: none; }
@media (max-width: 700px) {
  .filt-toggle { display: flex; justify-content: center; width: 100%; margin: 0 0 10px; }
  .filt-collapsible:not(.filt-open) { display: none; }
  .filt-collapsible.filt-open { margin-bottom: 10px; }

  /* Istoric card in 3 lines: time · station · platform / panel · train · actions / badges with short
     labels (wrapping flex: each line ends with an item that takes the rest of the width) */
  .h-table tbody { gap: 6px; }
  .h-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 6px 10px 6px 12px; }
  .h-row .h-time { order: 1; flex: 0 0 3.4rem; font-size: 1.125rem; }
  .h-row .h-station { order: 2; flex: 1 1 calc(100% - 5.3rem - 16px); }   /* the rest of line 1 */
  .h-row .h-plat { order: 3; flex: none; }
  .h-row .h-board { order: 4; flex: 0 0 3.4rem; }
  .h-row .h-trn { order: 5; flex: none; }
  .h-row .h-op { order: 6; flex: 1 1 auto; min-width: 45%; display: flex; justify-content: flex-end; }
  .h-row .h-max { order: 7; }
  .h-row .h-last { order: 8; }
  .h-row .h-status { order: 9; }
  .h-train { min-height: 28px; padding-block: 0; }
  .plat-sm { width: 1.875rem; height: 1.875rem; font-size: 0.9375rem; }
  .h-row .h-max,
  .h-row .h-last,
  .h-row .h-status { display: inline-flex; gap: 4px; font-size: 0.75rem; }
  .h-row .h-max { margin-top: 0; }
  .h-row .h-max::before,
  .h-row .h-last::before { content: attr(data-short); flex: none; }
  .h-row .h-status::before { content: none; }
  .h-row .h-status { margin-left: auto; }
  .h-row .delay,
  .h-row .res-badge { padding: 1px 7px; font-size: 0.75rem; }
  .h-row .delay svg { width: 12px; height: 12px; }
}
/* ==== end Beta 1.67 (F) filters + Istoric ==== */

/* ---------- detail sheet ---------- */

.sheet {
  width: min(720px, calc(100vw - 16px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 18px 18px 22px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
  overflow: auto;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: sheet-in var(--dur-slow) var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title { margin: 0; font-size: 1.25rem; font-family: var(--mono); letter-spacing: -0.01em; }
.sheet-sub { margin: 4px 0 8px; color: var(--text-2); font-size: var(--fs-md); }
.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn .btn-icon { width: 20px; height: 20px; }
.detail-block { margin-top: 14px; }
.detail-h {
  margin: 0 0 8px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}
.detail-note { margin: 6px 0 0; color: var(--text-3); font-size: 0.8125rem; }

.chart {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.chart-grid line { stroke: var(--border); stroke-width: 1; }
.chart-grid text { fill: var(--text-3); font-family: var(--mono); font-size: 12px; }
.chart-ylabel { text-anchor: end; }
.chart-xlabel { text-anchor: middle; }
.chart-xstart { text-anchor: start; }
.chart-xend { text-anchor: end; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-gone { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-gone-label { fill: var(--bad); font-family: var(--mono); font-size: 12px; text-anchor: middle; }
.chart-gone-label.chart-xend { text-anchor: end; }

/* rezultatul final al unei călătorii (/api/journeys/{id}) */
.res-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--text-2);
  background: var(--chip-bg);
  border: 1px solid var(--border);
}
.res-confirmed { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.res-unconfirmed { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.res-unknown { color: var(--text-2); background: var(--surface-2); }
.res-progress { color: var(--info); background: var(--chip-bg); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.res {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.res-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.res-label { font-weight: 600; }
.res-reason { margin: 6px 0 0; color: var(--text-2); font-size: 0.875rem; }
.res-facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 12px;
  margin: 10px 0 0;
  font-size: 0.875rem;
}
.res-facts dt { color: var(--text-3); font-size: 0.75rem; margin-top: 6px; }
.res-facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; overflow-wrap: break-word; }
@media (min-width: 560px) {
  .res-facts { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: 4px 12px; }
  .res-facts dt { font-size: inherit; margin-top: 0; }
}
.res-fact-note { color: var(--text-3); font-weight: 400; }
.res-train-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.875rem;
  text-underline-offset: 3px;
}

.timeline { list-style: none; margin: 0 0 0 5px; padding: 0; border-left: 2px solid var(--border); }
.tl-item {
  position: relative;
  display: grid;
  grid-template-columns: 5.2rem minmax(0, 1fr);
  gap: 2px 10px;
  padding: 6px 0 6px 14px;
  font-size: 0.875rem;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-3);
}
.tl-delay::before { border-color: var(--warn); }
.tl-platform::before { border-color: var(--info); }
.tl-appeared::before { border-color: var(--ok); }
.tl-gone::before { border-color: var(--bad); }
.tl-time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); }
.tl-text { font-weight: 600; }
.tl-meta { grid-column: 2; color: var(--text-3); font-size: 0.75rem; text-transform: capitalize; }

/* ---------- Urmărite ---------- */

.panel {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-status { margin: 8px 0 0; color: var(--text-2); font-size: 0.875rem; }
.panel .notice { margin-bottom: 0; }

.switch { position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-track {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--field-border);
  transition: background-color var(--dur) var(--ease);
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.45; }
.switch input:disabled ~ .switch-label { color: var(--text-3); }

.f-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.f-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.f-info { min-width: 0; }
.f-title { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 1.0625rem; }
.f-sub { margin: 2px 0 0; color: var(--text-2); font-size: 0.8125rem; }
.f-actions { display: flex; align-items: center; gap: 12px; }
.f-link { color: var(--text-2); font-size: 0.8125rem; font-weight: 600; text-underline-offset: 3px; }

.follow[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.follow[aria-busy="true"] { cursor: progress; opacity: 0.7; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: 500;
  box-shadow: var(--shadow-overlay);
  animation: toast-in var(--dur) var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* footer */
.footer {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 18px var(--gutter) calc(22px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-2);
  text-align: center;
}
.footer p { margin: 0; }
.footer { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.logo-footer { width: 16px; height: 16px; border-radius: 4px; }
.footer a { color: var(--text); text-underline-offset: 2px; }

/* telefoane înguste: „Sursa: CFR" e și în footer → indicatorul „actualizat" încape pe rândul
   ceasului, iar tabela începe mai sus */
@media (max-width: 429px) {
  .live-sep, .live-src { display: none; }
  .live { padding: 4px 10px; }
}

/* ---------- larger phones / tablets ---------- */

@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .train { grid-template-columns: 5.4rem minmax(0, 1fr) auto; padding: 16px 18px 16px 16px; }
  .t-sched, .t-est { font-size: 1.75rem; }
  .t-station { font-size: 1.125rem; }
}

/* ---------- Istoric on wide screens: real table ---------- */

@media (min-width: 760px) {
  /* 760–1023 px: the one-row filter template (~59rem) doesn't fit → wrapping columns
     (it pushed the page sideways on tablets / phones in landscape) */
  .filters { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); align-items: end; }
  .field-date, .field-wide { grid-column: auto; }
  .h-group-title { margin: 0; padding: 10px 10px 4px; border-top: 1px solid var(--border-strong); }
  .h-group:first-child .h-group-title { border-top: 0; }
  .h-group + .h-group { margin-top: 0; }
  .h-group .h-row .h-time,
  .h-group .h-row .h-trn { white-space: nowrap; }
  .field input[type="time"] { padding: 8px 10px; }
  .filters .btn { grid-column: auto; min-height: 42px; margin-top: 0; }

  .h-results {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow-x: auto;
  }
  .h-results:empty { display: none; }
  .h-table { display: table; }
  .h-table thead { display: table-header-group; }
  .h-table tbody { display: table-row-group; }
  .h-table th {
    padding: 10px 10px 8px;
    border-bottom: 1px solid var(--border-strong);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    vertical-align: bottom;
  }
  .h-row { display: table-row; box-shadow: none; border: 0; border-radius: 0; }
  .h-row::before { display: none; }
  .h-row td,
  .h-row .h-max,
  .h-row .h-last,
  .h-row .h-status {
    display: table-cell;
    margin: 0;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: var(--fs-md);
    color: var(--text);
  }
  .h-row .h-max::before,
  .h-row .h-last::before,
  .h-row .h-status::before { content: none; }
  .h-row:last-child td { border-bottom: 0; }
  .h-time { font-size: 1.0625rem; }
  .h-board { font-size: 0.75rem; letter-spacing: 0.04em; }
  .h-row .h-op,
  .h-row .h-status { color: var(--text-2); }
  .h-row[data-delay="minor"] .h-time { box-shadow: 4px 0 0 var(--warn) inset; }
  .h-row[data-delay="major"] .h-time { box-shadow: 4px 0 0 var(--bad) inset; }
  .h-row[data-delay="unread"] .h-time { box-shadow: 4px 0 0 var(--unknown) inset; }
}

@media (min-width: 1100px) {
  /* one table per day: same column widths in every group */
  .h-group .h-table { table-layout: fixed; }
  .h-group .h-table th:nth-child(1) { width: 7%; }
  .h-group .h-table th:nth-child(2) { width: 9%; }
  .h-group .h-table th:nth-child(3) { width: 10%; }
  .h-group .h-table th:nth-child(5) { width: 12%; }
  .h-group .h-table th:nth-child(6) { width: 13%; }
  .h-group .h-table th:nth-child(7) { width: 15%; }
  .h-group .h-table th:nth-child(8) { width: 6%; }
  .h-group .h-table th:nth-child(9) { width: 11%; }
  .h-group .h-row td { overflow-wrap: anywhere; }
}

/* ---------- desktop: side by side, no tabs ---------- */

@media (min-width: 1024px) {
  .filters { grid-template-columns: 11rem 7rem minmax(9rem, 1fr) 7rem 7rem 8.5rem auto; }

  .topbar { padding-top: 14px; padding-bottom: 10px; }
  .brand-title { font-size: var(--fs-2xl); }
  #logo { width: 44px; height: 44px; }

  .live { order: 3; margin-left: auto; }
  .theme-btn { order: 4; margin-left: 0; width: 40px; height: 40px; }

  .tabs { display: none; }
  .boards {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-6);
    margin-top: var(--space-4);
    align-items: start;
  }
  .boards .board { display: block !important; min-width: 0; }
  /* coloane alăturate: carduri de aceeași înălțime (stația pe un rând, operatorul trunchiat
     pe rândul tipului), ca rândurile din Sosiri și Plecări să rămână aliniate */
  .t-station { -webkit-line-clamp: 1; line-clamp: 1; }
  .t-meta { flex-wrap: nowrap; }
  .t-meta > * { flex: 0 0 auto; }
  .t-meta > .t-op { flex: 0 1 auto; }
  .board-title { display: flex; }

  .toast { bottom: 24px; }
}

@media (min-width: 1200px) {
  .train {
    grid-template-columns: 5.4rem minmax(0, 1fr) auto auto;
    align-items: center;
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .t-time { align-self: center; }
  .t-row {
    grid-column: 3;
    grid-row: 1;
    flex-direction: column;
    align-items: flex-end;
    margin-top: 0;
  }
  .follow { margin-left: 0; }
  .t-plat { grid-column: 4; grid-row: 1; align-self: center; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .train.flash { animation: none; }
  .live[data-state="live"] .live-dot::after { display: none; }
  .sk { animation: none; }
  .logo-boot { animation: none; }
  .sheet[open], .toast { animation: none; }
}

@media (forced-colors: active) {
  .live-dot, .plat, .type, .delay, .follow, .tab[aria-selected="true"] { border: 1px solid CanvasText; }
  .nav-item[aria-current="page"] { border-bottom: 2px solid CanvasText; }
}

/* ---------- pagina offline (web/offline.html, servită de sw.js) ---------- */

.offline-page { padding-bottom: 0; }
.offline {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px var(--gutter);
  text-align: center;
}
.logo-offline { width: 96px; height: 96px; }
.offline-title { margin: 0; font-size: 1.5rem; }
.offline-text { margin: 0; color: var(--text-2); }
.offline-retry { text-decoration: none; }

/* versiunea în footer + ecranul „Versiuni” (web/versions.js) */
.footer-version { color: var(--text-2); font-variant-numeric: tabular-nums; }
.v-list { display: grid; gap: 14px; max-width: 72ch; }
.v-entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.v-entry:first-child { border-left: 4px solid var(--accent); }
.v-title { margin: 0 0 6px; font-size: 1.125rem; }
.v-date { color: var(--text-2); font-size: 0.875rem; font-weight: 500; margin-left: 6px; }
.v-group { margin: 12px 0 4px; font-size: 0.9375rem; color: var(--text-2); }
.v-items { margin: 0; padding-left: 20px; line-height: 1.5; }
.v-items li + li { margin-top: 4px; }

/* un singur panou cu date vechi (citiri respinse), celălalt actualizat */
.tab[data-stale="true"] > span:first-child::after,
.board[data-stale="true"] .board-title::after {
  content: "date vechi";
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px dashed currentColor;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.8;
}
.board[data-stale="true"] .trains { opacity: 0.6; }

/* ---------- comutatorul "Peron estimat" (coloana: peron_est.css, încărcat lazy) ---------- */
.pe-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 0;
  min-height: 44px;
  color: var(--text-2);
  font-size: 0.875rem;
  cursor: pointer;
}
.pe-toggle input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.pe-note { margin: 4px 0 0; color: var(--text-3); font-size: 0.75rem; line-height: 1.4; }
.pe-note[hidden], .pe-cell[hidden] { display: none; }
html[data-view="panou"] .pe-toggle,
html[data-view="panou"] .pe-note { display: none !important; }

/* ---------- station links (board, panel, history, stats; global because stats.css loads lazily) ---------- */
.station-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  text-transform: none;
}
.station-link:hover { text-decoration-color: var(--accent); }
/* Panou / Carduri: the link keeps the look of the name (case, colour, weight); underline on hover only. */
.station-link-plain { text-transform: inherit; text-decoration: none; }
.station-link-plain:hover { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.station-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ===== a11y 2.5.8 (WCAG 2.2 AA): every control is a >= 24x24 CSS px target =====
   Padding grows the hit area, the equal negative margin keeps the layout unchanged.
   `body` prefix outranks the per-page stylesheets that load later. */
body .station-link, body .st-train, body .st-back, body .ss-card-link, body .footer-version, body .footer-how, body .live-src a {
  display: inline-block;
  padding-block: 5px;
  margin-block: -5px;
  min-width: 24px;
}
/* panel cells clip with an ellipsis: inline-block would wrap long names and change the row height */
body .pnl-board .station-link, body .pnl-board .st-train { display: inline; }
body .ss-card-link { min-width: 24px; text-align: center; }
body .pnl-sortbtn, body .st-sort { padding-block: 5px; margin-block: -5px; min-height: 24px; min-width: 24px; }
body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
body .setari-save { min-height: 24px; }
body input[type="checkbox"], body input[type="radio"] { min-width: 24px; min-height: 24px; }
/* ===== end a11y 2.5.8 ===== */

/* ===== a11y: reduced motion (belt and braces over the per-component blocks) ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
/* ===== end a11y reduced motion ===== */

/* a11y: the settings view now has the page h1 (was an h2) */
.setari-title { font-size: 1.5rem; margin: 0 0 12px; }
