/* ============================================================
   Logbook — Japan-inspired theme (dark + light variants)
   All colors are CSS variables: :root = dark, body.light-mode = light.
   The navbar stays dark in both modes (torii-gate frame), so it uses
   its own fixed --navbar-* variables.
   ============================================================ */

:root {
  /* ---- Surfaces ---- */
  --bg-0: #0d0d0d;        /* deepest sumi-ink black (page) */
  --bg-1: #111111;        /* panel base */
  --bg-2: #161616;        /* raised panel — faint warm tint */
  --bg-3: #1a1a1a;        /* inputs / hover */
  --card-grad-top: rgba(24, 22, 22, 0.7);
  --card-grad-bottom: rgba(17, 17, 17, 0.7);
  --card-shadow: none;
  --tile-bg: rgba(17, 17, 17, 0.6);
  --map-bg: #0a0a0a;
  --backdrop: rgba(8, 8, 8, 0.7);
  --overlay-bg: rgba(20, 16, 16, 0.82);  /* map overlays (replay) */

  /* ---- Borders ---- */
  --border: #2a1515;      /* subtle dark red tint */
  --border-soft: #1f1212;
  --border-hover: #3a1f1f;
  --swatch-border: rgba(255, 255, 255, 0.15);
  --navbar-btn-border: rgba(255, 255, 255, 0.14);

  /* ---- Text ---- */
  --text: #f0ece4;        /* warm off-white */
  --text-dim: #8a8580;    /* warm grey */
  --text-faint: #6b6560;
  --text-strong: #c0b8b0; /* table headers / day date */
  --text-label: #807870;  /* stat labels / day meta */
  --text-soft: #a09890;   /* callsign / model / ZRH time */
  --reg-text: #f0b0c4;    /* registration (bright sakura) */

  /* ---- Accents ---- */
  --accent-rgb: 230, 57, 70;     /* torii red #e63946 */
  --sakura-rgb: 244, 167, 185;   /* sakura pink */
  --green-rgb: 34, 197, 94;      /* success */
  --amber: #e63946;       /* primary accent — torii red */
  --amber-deep: #c0392b;
  --accent-hover: #ef5a66;
  --green: #22c55e;
  --red: #e63946;         /* danger / landing */
  --sakura: #f4a7b9;      /* secondary accent */
  --cyan: #f4a7b9;        /* alias → sakura */
  --on-accent: #fbeae8;        /* text on primary buttons */
  --on-accent-strong: #ffffff; /* discovery Add button text */

  /* ---- Rows / tables ---- */
  --flight-row-bg: #181414;
  --flight-row-hover: #221c1c;
  --disc-row-bg: #1e1a1a;
  --disc-row-hover: #2a2020;
  --disc-match-bg: #2a1f1a;
  --disabled-bg: #2a2a2a;
  --disabled-text: #707070;

  /* ---- Lines ---- */
  --day-border: rgba(230, 57, 70, 0.22);
  --connector: rgba(230, 57, 70, 0.6);

  /* ---- Effects ---- */
  --glow-amber: 0 0 0 1px rgba(var(--accent-rgb), 0.4),
                0 0 18px -4px rgba(var(--accent-rgb), 0.55);
  --row-shadow: 0 6px 22px -12px rgba(0, 0, 0, 0.8);
  --toast-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.9);
  --chart-grid: rgba(42, 21, 21, 0.6);

  /* ---- Navbar (fixed in both modes) ---- */
  --navbar-bg: rgba(26, 18, 18, 0.85);   /* #1a1212 */
  --navbar-border: #2a1515;
  --navbar-text: #f0ece4;
  --navbar-text-dim: #8a8580;
  --navbar-text-faint: #6b6560;
  --navbar-hover-bg: #241a1a;

  /* ---- Typography ---- */
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;

  --radius: 12px;
}

/* ============================================================
   LIGHT MODE — only color variables change (navbar excluded)
   ============================================================ */
body.light-mode {
  --bg-0: #f5f0eb;        /* warm paper / washi */
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #ffffff;
  --card-grad-top: #ffffff;
  --card-grad-bottom: #ffffff;
  --card-shadow: 0 1px 3px rgba(120, 90, 80, 0.10),
                 0 10px 28px -16px rgba(120, 90, 80, 0.22);
  --tile-bg: #ffffff;
  --map-bg: #e8e4df;
  --backdrop: rgba(60, 48, 44, 0.4);
  --overlay-bg: rgba(255, 255, 255, 0.88);

  --border: #e0d4cc;      /* warm light grey */
  --border-soft: #ebe1d9;
  --border-hover: #d4c4ba;
  --swatch-border: rgba(0, 0, 0, 0.15);

  --text: #1a1212;
  --text-dim: #6b5f5f;
  --text-faint: #8a7f7f;
  --text-strong: #3a2e2e;
  --text-label: #8a7f7f;
  --text-soft: #6b5f5f;
  --reg-text: #d4607a;

  --accent-rgb: 192, 57, 43;     /* torii red #c0392b */
  --sakura-rgb: 212, 96, 122;    /* sakura #d4607a */
  --amber: #c0392b;
  --amber-deep: #a93226;
  --accent-hover: #d4493b;
  --red: #c0392b;
  --sakura: #d4607a;
  --cyan: #d4607a;
  --on-accent: #ffffff;
  --on-accent-strong: #ffffff;

  --flight-row-bg: #ffffff;
  --flight-row-hover: #f0e8e0;
  --disc-row-bg: #ffffff;
  --disc-row-hover: #f0e8e0;
  --disc-match-bg: #fde8e0;
  --disabled-bg: #ece4dc;
  --disabled-text: #a59890;

  --day-border: rgba(192, 57, 43, 0.4);
  --connector: rgba(192, 57, 43, 0.5);

  --row-shadow: 0 6px 18px -12px rgba(120, 90, 80, 0.55);
  --toast-shadow: 0 12px 40px -16px rgba(120, 90, 80, 0.4);
  --chart-grid: rgba(224, 212, 204, 0.9);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(var(--accent-rgb), 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(var(--sakura-rgb), 0.05), transparent 60%),
    var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar (always dark) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  height: 60px;
  background: var(--navbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--navbar-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--navbar-text);
}
.brand-mark {
  color: var(--amber);
  font-size: 20px;
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.6));
}
.brand-title { font-size: 16px; }

.nav {
  display: flex;
  gap: 4px;
  margin-left: 12px;
}
.nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--navbar-text-dim);
  font-weight: 500;
  font-size: 14px;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.nav a:hover { color: var(--navbar-text); background: var(--navbar-hover-bg); }
.nav a.active {
  color: var(--amber);
  background: rgba(var(--accent-rgb), 0.08);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.25);
}

.pilot {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--navbar-text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--navbar-btn-border);
  background: transparent;
  color: var(--navbar-text);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  background: var(--navbar-hover-bg);
  border-color: rgba(var(--accent-rgb), 0.5);
}

/* ---------- Mobile nav (hamburger + dropdown) ---------- */
/* Hidden on desktop; revealed in the < 768px media query below. */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--navbar-btn-border);
  background: transparent;
  color: var(--navbar-text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.nav-toggle:hover {
  background: var(--navbar-hover-bg);
  border-color: rgba(var(--accent-rgb), 0.5);
}

.mobile-menu {
  display: none; /* only shown < 768px */
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 999;
  /* Navbar stays dark in both themes. */
  background: var(--navbar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--navbar-border);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.7);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.mobile-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.mobile-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--navbar-text-dim);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.mobile-menu .menu-item:hover {
  background: var(--navbar-hover-bg);
  color: var(--navbar-text);
}
.mobile-menu a.menu-item.active {
  color: var(--amber);
  background: rgba(var(--accent-rgb), 0.10);
}
.mobile-menu .menu-action { color: var(--navbar-text); }
.mobile-menu .menu-divider {
  height: 1px;
  background: var(--navbar-border);
  margin: 6px 8px;
}

/* ---------- Navbar clock (UTC + Zurich) ---------- */
.clock {
  margin-left: auto;
  display: flex;
  gap: 0;
  align-items: center;
}
.clk {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}
/* Red separator between UTC and ZURICH. */
.clk + .clk {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid rgba(var(--accent-rgb), 0.45);
}
.clk .lbl {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--navbar-text-faint);
  text-transform: uppercase;
}
.clk .val {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--navbar-text);
  font-variant-numeric: tabular-nums;
}

/* ---------- Layout ---------- */
main {
  padding: 26px 22px 60px;
  max-width: 1320px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
}
.page-head .sub {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--card-grad-top), var(--card-grad-bottom));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: var(--card-shadow);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-hover); }
.btn-primary {
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  border-color: var(--amber-deep);
  color: var(--on-accent);
}
.btn-primary:hover {
  box-shadow: var(--glow-amber);
  background: linear-gradient(180deg, var(--accent-hover), var(--amber));
}
.btn-danger { color: var(--red); border-color: rgba(var(--accent-rgb), 0.35); }
.btn-danger:hover { background: rgba(var(--accent-rgb), 0.12); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label.field {
  display: block;
  margin-bottom: 14px;
}
label.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
select { cursor: pointer; }
input[type="color"] { padding: 4px; height: 42px; cursor: pointer; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
}

/* Subtle informational note inside a form/panel. */
.form-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
}

/* ---------- Toolbar (filters/sort) ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}
.toolbar .field-inline { min-width: 150px; }
.toolbar .field-inline label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 5px;
}

/* ---------- Flight list ---------- */
.flight-list { display: flex; flex-direction: column; gap: 0; }

/* Day grouping (Europe/Zurich) — lightweight, no heavy boxes. */
.day-group + .day-group { margin-top: 22px; }
.day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--day-border);
}
.day-header .d-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.3px;
}
.day-header .d-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-label);
  white-space: nowrap;
}
.day-rows { display: flex; flex-direction: column; gap: 12px; }
.day-rows .flight-row { position: relative; }
/* Subtle dotted connector bridging the gap to the flight above when the two
   belong to the same session. */
.day-rows .flight-row.linked::before {
  content: "";
  position: absolute;
  left: 22px;
  top: -12px;
  height: 12px;
  border-left: 2px dotted var(--connector);
  pointer-events: none;
}

.flight-row {
  display: grid;
  grid-template-columns: 130px 1fr repeat(4, minmax(80px, 110px)) 30px;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  background: var(--flight-row-bg);
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.flight-row:hover {
  transform: translateY(-1px);
  background: var(--flight-row-hover);
  border-color: var(--border-hover);
  box-shadow: var(--row-shadow),
              0 0 16px -6px rgba(var(--accent-rgb), 0.35);
}
.flight-row .tail {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--reg-text);
}
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 8px -1px currentColor;
}
.flight-row .meta .date {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.flight-row .meta .date .cs { color: var(--text-soft); }
/* "ZRH" timezone label after the row time range — matches the discovery table. */
.flight-row .meta .date .z {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-left: 5px;
}
.flight-row .meta .notes {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.flight-row .meta .model {
  font-size: 12px;
  color: var(--text-soft);
}
.stat-cell {
  text-align: right;
  font-family: var(--mono);
}
.stat-cell .v { font-size: 14px; color: var(--text); }
.stat-cell .u {
  font-size: 10px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.chev { color: var(--text-faint); text-align: right; }

/* ---------- Flight comparison ---------- */
/* Row checkbox: revealed on hover (always visible on touch widths/checked). */
.cmp-check {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  padding: 0;
  accent-color: var(--amber);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.flight-row:hover .cmp-check,
.cmp-check:checked { opacity: 1; }
@media (max-width: 860px) {
  .cmp-check { opacity: 1; }
}

.compare-bar { margin-bottom: 14px; }

.cmp-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.cmp-card {
  background: var(--tile-bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.cmp-card.cmp-a { border-left: 3px solid var(--amber); }
.cmp-card.cmp-b { border-left: 3px solid var(--sakura); }
/* Cards double as track selectors (the only way to highlight on touch). */
.cmp-card { cursor: pointer; transition: box-shadow 0.2s, border-color 0.2s; }
.cmp-card.cmp-active.cmp-a { box-shadow: 0 0 0 2px var(--amber); }
.cmp-card.cmp-active.cmp-b { box-shadow: 0 0 0 2px var(--sakura); }
.cmp-card .cmp-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.cmp-card.cmp-a .cmp-tag { color: var(--amber); }
.cmp-card.cmp-b .cmp-tag { color: var(--sakura); }
.cmp-card .cmp-reg {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  margin-top: 4px;
}
.cmp-card .cmp-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.cmp-legend { position: absolute; top: 12px; left: 56px; z-index: 500; }
.cmp-legend .cl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  padding: 1px 4px;
  margin: 0 -4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.cmp-legend .cl-row.cmp-active { background: rgba(var(--accent-rgb), 0.18); }
.cmp-legend .cl-line {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}
.cmp-legend .cl-hint {
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-faint);
  font-style: italic;
}

/* Track highlighting: subtle by default, the hovered/pinned one pops while the
   other fades. SVG presentation attributes are overridden by these rules, so
   Leaflet's inline opacity is just a no-CSS fallback. */
#cmp-map path.cmp-track,
#cmp-map path.cmp-dot {
  transition: stroke-opacity 0.2s ease, fill-opacity 0.2s ease;
}
#cmp-map path.cmp-track { stroke-opacity: 0.35; }
#cmp-map path.cmp-dot { stroke-opacity: 0.35; fill-opacity: 0.35; }

#cmp-map.hl-a path.cmp-a.cmp-track { stroke-opacity: 1; }
#cmp-map.hl-a path.cmp-a.cmp-dot { stroke-opacity: 1; fill-opacity: 1; }
#cmp-map.hl-a path.cmp-b.cmp-track { stroke-opacity: 0.15; }
#cmp-map.hl-a path.cmp-b.cmp-dot { stroke-opacity: 0.15; fill-opacity: 0.15; }

#cmp-map.hl-b path.cmp-b.cmp-track { stroke-opacity: 1; }
#cmp-map.hl-b path.cmp-b.cmp-dot { stroke-opacity: 1; fill-opacity: 1; }
#cmp-map.hl-b path.cmp-a.cmp-track { stroke-opacity: 0.15; }
#cmp-map.hl-b path.cmp-a.cmp-dot { stroke-opacity: 0.15; fill-opacity: 0.15; }

.cmp-table { width: 100%; border-collapse: collapse; }
.cmp-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-strong);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cmp-table th.cmp-a-h { color: var(--amber); }
.cmp-table th.cmp-b-h { color: var(--sakura); }
.cmp-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}
.cmp-table tbody tr:nth-child(even) td { background: rgba(var(--accent-rgb), 0.04); }
.cmp-table tr:last-child td { border-bottom: none; }
.cmp-table td:first-child {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
}
.cmp-table .cmp-win { color: var(--amber); font-weight: 600; }
.cmp-table .cmp-diff.pos { color: var(--green); }
.cmp-table .cmp-diff.zero { color: var(--text-faint); }

.cmp-weather-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
h3.cmp-a-h { color: var(--amber) !important; }
h3.cmp-b-h { color: var(--sakura) !important; }

@media (max-width: 860px) {
  .cmp-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cmp-weather-grid { grid-template-columns: 1fr; }
}

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.stat-tile {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--tile-bg);
  border: 1px solid var(--border-soft);
}
.stat-tile .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.stat-tile .value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--amber);
}
.stat-tile .value .unit {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: 4px;
}

/* ---------- Weather panel ---------- */
.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.weather-tile .wx-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.weather-tile .wx-desc {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
}
.weather-tile .wx-arrow {
  display: inline-block;
  color: var(--amber);
  font-weight: 700;
  transition: transform 0.3s ease;
}
.weather-tile .wx-icon { font-size: 26px; line-height: 1.1; }
.weather-tile .wx-bar {
  margin-top: 8px;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-3);
  overflow: hidden;
}
.weather-tile .wx-bar span {
  display: block;
  height: 100%;
  background: var(--amber);
  border-radius: 3px;
}
.weather-note { font-size: 12px; margin-top: 12px; }
.weather-unavailable { grid-column: 1 / -1; padding: 8px 2px; font-size: 13px; }

/* Skeleton loading tiles */
.weather-tile.skeleton .sk-line {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    rgba(var(--accent-rgb), 0.08), rgba(var(--accent-rgb), 0.16),
    rgba(var(--accent-rgb), 0.08));
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s ease-in-out infinite;
}
.weather-tile.skeleton .sk-label { width: 60%; margin-bottom: 12px; }
.weather-tile.skeleton .sk-value { width: 85%; height: 20px; }
@keyframes sk-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Flight detail ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
#map,
#cmp-map {
  height: 56vh;
  min-height: 420px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
}
.leaflet-container { background: var(--map-bg); }

/* ---------- 3D viewer (Cesium) ---------- */
.cesium-container {
  height: 56vh;
  min-height: 420px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--bg-1);
}
.cesium-overlays {
  position: absolute;
  inset: 0;
  z-index: 600;
  pointer-events: none;
}
.cesium-overlays > * { pointer-events: auto; }
.cesium-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 24px;
  color: var(--text);
  background: var(--bg-1);
  font-size: 14px;
}
.cesium-msg a { color: var(--amber); }
.cz-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.cz-cam {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.cz-cam:hover { border-color: rgba(var(--accent-rgb), 0.5); }
.cz-stats { top: auto; bottom: 12px; right: 12px; }
.fade-in { animation: cz-fade 0.3s ease; }
@keyframes cz-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Flight replay ---------- */
.map-wrap { position: relative; }

/* The class rules below set display:flex, which would otherwise beat the UA
   [hidden] rule — keep the overlays hidden until replay starts. */
.replay-bar[hidden],
.replay-stats[hidden] { display: none !important; }

/* Aircraft marker (custom DivIcon). */
.aircraft-icon { background: transparent; border: 0; }
.aircraft-icon .ac-inner {
  width: 26px;
  height: 26px;
  transform-origin: center;
  transition: transform 0.15s linear;
  will-change: transform;
}
.aircraft-icon svg { display: block; width: 26px; height: 26px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.aircraft-icon svg path { fill: var(--amber); stroke: #fff; stroke-width: 0.7; }

/* Live stats panel (top-right overlay). */
.replay-stats {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.6);
}
.replay-stats .rs-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-width: 120px;
}
.replay-stats .rs-l {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}
.replay-stats .rs-v {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Controls bar (bottom overlay). */
.replay-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}
.rp-btn {
  flex: none;
  min-width: 38px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rp-btn:hover {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.5);
}
.rp-time {
  flex: none;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rp-speed {
  flex: none;
  width: auto;
  padding: 6px 8px;
  font-size: 12px;
}
.rp-status {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  white-space: nowrap;
}

/* Scrubber: torii red thumb + progress fill. */
.rp-scrub {
  flex: 1 1 auto;
  min-width: 80px;
  width: auto;
  height: 6px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    var(--amber) 0%,
    var(--amber) var(--rp-fill, 0%),
    var(--bg-3) var(--rp-fill, 0%),
    var(--bg-3) 100%
  );
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.rp-scrub:focus { outline: none; box-shadow: none; }
.rp-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #fff;
  cursor: pointer;
}
.rp-scrub::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #fff;
  cursor: pointer;
}
.rp-scrub::-moz-range-track { height: 6px; border-radius: 4px; background: transparent; }

@media (max-width: 560px) {
  .replay-bar { flex-wrap: wrap; }
  .rp-scrub { order: 5; flex-basis: 100%; }
  .replay-stats .rs-item { min-width: 96px; }
}

.chart-wrap {
  padding: 16px 18px;
  height: 240px;
}
.chart-wrap h3, .panel h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
}
.panel { padding: 18px; }

.notes-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

/* ---------- Aircraft table (settings) ---------- */
.ac-table { width: 100%; border-collapse: collapse; }
.ac-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.ac-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 13px;
  vertical-align: middle;
}
.ac-table tr:last-child td { border-bottom: none; }
.swatch {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 4px;
  vertical-align: middle;
  border: 1px solid var(--swatch-border);
}
.badge-missing {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--red);
  background: rgba(var(--accent-rgb), 0.12);
  padding: 2px 7px;
  border-radius: 6px;
}

.settings-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ---------- Flight discovery table ---------- */
.disc-table { width: 100%; border-collapse: collapse; }
.disc-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-strong);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.disc-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
.disc-table tbody tr { background: var(--disc-row-bg); }
.disc-table tbody tr:hover { background: var(--disc-row-hover); }
.disc-table tr:last-child td { border-bottom: none; }
.disc-table td .zrh { color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.disc-table td .z {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin-left: 5px;
}
.disc-table tr.row-match td,
.disc-table tbody tr.row-match:hover td { background: var(--disc-match-bg); }
.disc-table tr.row-match td:first-child {
  box-shadow: inset 3px 0 0 var(--amber);
}
/* Buttons inside the discovery table. */
.disc-table .btn-primary { color: var(--on-accent-strong); }
.disc-table .btn[disabled] {
  background: var(--disabled-bg);
  color: var(--disabled-text);
  border-color: var(--disabled-bg);
  opacity: 1;
}
.match-tag {
  display: inline-block;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--amber);
  background: rgba(var(--accent-rgb), 0.12);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ---------- Misc ---------- */
.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0 0 14px;
  font-weight: 600;
}
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty .big { font-size: 40px; margin-bottom: 12px; }
.muted { color: var(--text-dim); }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(var(--accent-rgb), 0.25);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: -8px;
  margin-bottom: 14px;
  font-family: var(--mono);
}
.row-gap { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-end { justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--toast-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5000;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(var(--accent-rgb), 0.5); }
.toast.success { border-color: rgba(var(--green-rgb), 0.5); }

/* ---------- Airports map ---------- */
#airports-map,
#heatmap-map {
  height: calc(100vh - 150px);
  min-height: 420px;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  z-index: 1;
}

/* Heatmap track hover — smooth opacity/width transition. */
.heat-track { transition: stroke-opacity 0.15s, stroke-width 0.15s; }

/* Heatmap controls panel (extends the airports info card). */
.heat-controls { min-width: 170px; }
.heat-controls .heat-field { display: block; margin: 10px 0 8px; }
.heat-controls .heat-field > span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.heat-controls select { font-size: 13px; padding: 7px 9px; }
.heat-controls .heat-toggle { width: 100%; justify-content: center; }

/* Themed heatmap tooltip (scoped so other Leaflet tooltips are unaffected). */
.leaflet-tooltip.heat-tooltip {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 12px;
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.6);
}
.leaflet-tooltip.heat-tooltip::before { border-top-color: var(--border); }
.heat-tip b { font-family: var(--mono); color: var(--amber); }

.airports-info {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 4px 16px -8px rgba(0, 0, 0, 0.6);
}
.airports-info .ai-val {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--amber);
  font-size: 15px;
  margin-right: 4px;
}

/* Themed Leaflet popups (used by the airports map). */
.leaflet-popup-content-wrapper {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 34px -12px rgba(0, 0, 0, 0.7);
}
.leaflet-popup-tip {
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.leaflet-popup-close-button { color: var(--text-dim) !important; }
.leaflet-popup-content { margin: 12px 14px; }

.ap-pop .ap-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}
.ap-pop .ap-stats { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.ap-pop .ap-num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--amber);
  font-size: 14px;
}
.ap-pop .ap-dates {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 3px;
}
.ap-pop .ap-flights {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 150px;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}
.ap-pop .ap-flight {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.ap-pop .ap-flight:hover { background: rgba(var(--accent-rgb), 0.12); color: var(--amber); }
.ap-pop .ap-flight .ap-dur { color: var(--text-soft); }

/* ---------- Statistics dashboard ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.kpi { padding: 18px; }
.kpi .value {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.5px;
  line-height: 1.1;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-dim);
  margin-top: 8px;
}
.kpi-sub {
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 4px;
}

.stats-h {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 600;
  margin: 8px 0 14px;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.record { padding: 16px 18px; }
.record .r-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.record .r-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.record .r-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 4px;
}
.record.clickable {
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.record.clickable:hover {
  transform: translateY(-1px);
  border-color: var(--border-hover);
  box-shadow: var(--row-shadow), 0 0 16px -6px rgba(var(--accent-rgb), 0.35);
}

.stats-charts {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 26px;
}

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-strong);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.stats-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.stats-table tr:last-child td { border-bottom: none; }
.stats-table td:first-child { color: var(--reg-text); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.login-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 22px;
}
.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 10px;
  font-family: var(--mono);
}
.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 4000;
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 460px;
  padding: 22px;
}
.modal h2 { margin: 0 0 16px; font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .settings-cols { grid-template-columns: 1fr; }
  .flight-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
  }
  .flight-row .tail { grid-column: 1; }
  .flight-row .meta { grid-column: 1 / -1; order: 3; }
  .stat-cell { text-align: left; }
  .chev { display: none; }
  .nav a { padding: 8px 10px; }
  .brand-title { display: none; }
}
@media (max-width: 560px) {
  main { padding: 18px 14px 50px; }
  .pilot { display: none; }
  .topbar { gap: 12px; padding: 0 14px; }
  .clock { gap: 10px; }
  .clk .val { font-size: 12px; }
  .clk .lbl { font-size: 8px; letter-spacing: 1px; }
}

/* ---------- Mobile navbar (< 768px) ---------- */
@media (max-width: 767px) {
  /* Hide the desktop nav + inline buttons; the dropdown takes over. */
  .nav,
  #theme-toggle,
  #logout-btn,
  .pilot { display: none; }

  /* Brand wordmark stays visible on the left. */
  .brand-title { display: inline-block; }

  /* Hamburger on the right, dropdown below the navbar. */
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .mobile-menu { display: block; }

  /* Clock centered, ZURICH only. */
  .clock {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin-left: 0;
    gap: 0;
  }
  .clock .clk:first-child { display: none; }        /* hide UTC */
  .clock .clk + .clk {                              /* drop the separator */
    border-left: none;
    margin-left: 0;
    padding-left: 0;
  }
  .clock .clk { align-items: center; }
}

/* Very narrow: hide the clock if it gets too tight. */
@media (max-width: 340px) {
  .clock { display: none; }
}
