/*
  RouteCenter v6 — Operations Console
  Design tokens, sidebar shell, full-width layout, and aggressive overrides
  for the legacy inline-color soup in va-app.js. KLM blue is the system
  accent; AF red appears contextually. Mixed corner radii: 2px on data rows,
  8px on cards/modals/buttons. 180ms cubic-bezier easings.
*/

/* ── 1. TOKENS ──────────────────────────────────────────────────────────── */

:root {
  /* Surfaces — dark */
  --bg-0:      #07090f;          /* base / outside */
  --bg-1:      #0a0d14;          /* app body */
  --bg-2:      #10141c;          /* cards / sidebar */
  --bg-3:      #161b25;          /* hover / elevated */
  --bg-4:      #1d2331;          /* pressed / strong elevated */
  --bg-input:  #0c1019;
  --bg-thead:  #0c1019;

  /* Borders */
  --bdr-1:     #1a2030;
  --bdr-2:     #232b3c;
  --bdr-3:     #2f3a51;          /* prominent / focus rest */

  /* Text */
  --txt-1:     #e6ecf5;          /* high emphasis */
  --txt-2:     #aab6c8;          /* secondary */
  --txt-3:     #6f7d95;          /* tertiary / labels */
  --txt-4:     #4a576d;          /* muted */
  --txt-ph:    #3a4458;          /* placeholder */

  /* Brand */
  --klm:       #4a9eff;          /* KLM blue (system accent) */
  --klm-hi:    #7bc0ff;
  --klm-lo:    #2b7fde;
  --klm-soft:  #4a9eff1f;
  --klm-ring:  #4a9eff66;
  --klm-glow:  #4a9eff40;
  --af:        #ff5d6c;          /* AF red (contextual) */
  --af-hi:     #ff7e8a;
  --af-soft:   #ff5d6c1f;
  --af-ring:   #ff5d6c66;

  /* Accent aliases (so we can swap later) */
  --acc:       var(--klm);
  --acc-hi:    var(--klm-hi);
  --acc-lo:    var(--klm-lo);
  --acc-soft:  var(--klm-soft);
  --acc-ring:  var(--klm-ring);
  --acc-glow:  var(--klm-glow);
  --airline-spot: #7bc0ff2e;

  /* Legacy aliases used by inline styles in va-app.js */
  --txt:       var(--txt-1);
  --txt1:      var(--txt-1);
  --txt2:      var(--txt-2);
  --txt3:      var(--txt-3);
  --txt4:      var(--txt-4);
  --bg:        var(--bg-1);
  --bg2:       var(--bg-2);
  --bg3:       var(--bg-3);
  --bdr:       var(--bdr-1);
  --input-bg:  var(--bg-input);
  --input-bdr: var(--bdr-1);
  --card-bg:   var(--bg-2);
  --accent:    var(--acc);

  /* Semantic */
  --ok:        #3dd68c;
  --ok-soft:   #3dd68c14;
  --ok-ring:   #3dd68c55;
  --warn:      #f0b85a;
  --warn-soft: #f0b85a14;
  --err:       #ff6b6b;
  --err-soft:  #ff6b6b14;

  /* Effects */
  --shadow-1:  0 1px 2px #00000055;
  --shadow-2:  0 4px 14px #00000066, 0 1px 3px #00000055;
  --shadow-3:  0 18px 48px #000000aa, 0 4px 14px #00000088;
  --shadow-ring: 0 0 0 3px var(--acc-ring);
  --scroll-th: #2a3346;

  /* Motion */
  --ease:      cubic-bezier(.4, 0, .2, 1);
  --ease-out:  cubic-bezier(.16, 1, .3, 1);
  --t-fast:    120ms;
  --t-base:    180ms;
  --t-slow:    280ms;

  /* Radii */
  --r-sm:      2px;
  --r-md:      6px;
  --r-lg:      8px;
  --r-xl:      12px;
  --r-pill:    999px;

  /* Layout */
  --sb-w:      232px;
  --sb-w-col:  68px;
  --topbar-h:  60px;

  color-scheme: dark;
}

body.light {
  --bg-0:      #eef1f6;
  --bg-1:      #f5f7fa;
  --bg-2:      #ffffff;
  --bg-3:      #f1f4f8;
  --bg-4:      #e6ebf2;
  --bg-input:  #ffffff;
  --bg-thead:  #f1f4f8;

  --bdr-1:     #e2e7ef;
  --bdr-2:     #d3dae4;
  --bdr-3:     #b6c0cf;

  --txt-1:     #0d1623;
  --txt-2:     #38465c;
  --txt-3:     #5d6b82;
  --txt-4:     #8893a5;
  --txt-ph:    #abb4c2;

  --klm:       #1d6fde;
  --klm-hi:    #2b7feb;
  --klm-lo:    #0f54b4;
  --klm-soft:  #1d6fde14;
  --klm-ring:  #1d6fde55;
  --klm-glow:  #1d6fde2e;
  --af:        #d23b3b;
  --af-hi:     #b82d2d;
  --af-soft:   #d23b3b14;
  --af-ring:   #d23b3b55;

  --ok:        #1b9d62;
  --ok-soft:   #1b9d6210;
  --ok-ring:   #1b9d6244;
  --warn:      #c47a07;
  --warn-soft: #c47a0710;
  --err:       #d23b3b;
  --err-soft:  #d23b3b10;

  --shadow-1:  0 1px 2px #0d162311;
  --shadow-2:  0 4px 14px #0d16231a, 0 1px 3px #0d162311;
  --shadow-3:  0 18px 48px #0d162322, 0 4px 14px #0d162311;
  --scroll-th: #b6c0cf;
  --airline-spot: #2b87ff20;

  color-scheme: light;
}

body[data-airline-accent="klm"] {
  --acc: #4a9eff;
  --acc-hi: #79c0ff;
  --acc-lo: #2b7fde;
  --acc-soft: #4a9eff20;
  --acc-ring: #4a9eff66;
  --acc-glow: #4a9eff40;
  --airline-spot: #89c5ff34;
}
body[data-airline-accent="klm-cityhopper"] {
  --acc: #00a3b5;
  --acc-hi: #26cbdd;
  --acc-lo: #0c7f8b;
  --acc-soft: #00a3b520;
  --acc-ring: #00a3b566;
  --acc-glow: #00a3b540;
  --airline-spot: #5ce0ed32;
}
body[data-airline-accent="air-france"] {
  --acc: #df3f4f;
  --acc-hi: #ff7080;
  --acc-lo: #b92d3c;
  --acc-soft: #df3f4f20;
  --acc-ring: #df3f4f66;
  --acc-glow: #df3f4f40;
  --airline-spot: #ff9cb032;
}
body[data-airline-accent="af-cargo"] {
  --acc: #7e4bcc;
  --acc-hi: #a878ef;
  --acc-lo: #6639aa;
  --acc-soft: #7e4bcc20;
  --acc-ring: #7e4bcc66;
  --acc-glow: #7e4bcc40;
  --airline-spot: #c2a5f934;
}
body[data-airline-accent="hop"] {
  --acc: #f39d26;
  --acc-hi: #ffc05f;
  --acc-lo: #cb7f10;
  --acc-soft: #f39d2620;
  --acc-ring: #f39d2666;
  --acc-glow: #f39d2640;
  --airline-spot: #ffd48e32;
}
body[data-airline-accent="klm-cargo"] {
  --acc: #2da56b;
  --acc-hi: #61d79b;
  --acc-lo: #1f8353;
  --acc-soft: #2da56b20;
  --acc-ring: #2da56b66;
  --acc-glow: #2da56b40;
  --airline-spot: #8ff0bf32;
}
body[data-airline-accent="transavia"] {
  --acc: #16bb7a;
  --acc-hi: #45e7a3;
  --acc-lo: #0d955f;
  --acc-soft: #16bb7a20;
  --acc-ring: #16bb7a66;
  --acc-glow: #16bb7a40;
  --airline-spot: #76efba34;
}

/* Keep accent-driven text (pilot names, badges) readable in light mode. */
body.light[data-airline-accent="klm"] {
  --acc: #1d6fde;
  --acc-hi: #2b7feb;
  --acc-lo: #0f54b4;
  --acc-soft: #1d6fde14;
  --acc-ring: #1d6fde55;
  --acc-glow: #1d6fde2e;
  --airline-spot: #2b87ff20;
}
body.light[data-airline-accent="klm-cityhopper"] {
  --acc: #0b7480;
  --acc-hi: #1594a3;
  --acc-lo: #075d66;
  --acc-soft: #0b748014;
  --acc-ring: #0b748055;
  --acc-glow: #0b74802e;
  --airline-spot: #1594a320;
}
body.light[data-airline-accent="air-france"] {
  --acc: #b92d3c;
  --acc-hi: #cf3f4f;
  --acc-lo: #982230;
  --acc-soft: #b92d3c14;
  --acc-ring: #b92d3c55;
  --acc-glow: #b92d3c2e;
  --airline-spot: #cf3f4f20;
}
body.light[data-airline-accent="af-cargo"] {
  --acc: #5f3aa2;
  --acc-hi: #764ec0;
  --acc-lo: #4d2f83;
  --acc-soft: #5f3aa214;
  --acc-ring: #5f3aa255;
  --acc-glow: #5f3aa22e;
  --airline-spot: #764ec020;
}
body.light[data-airline-accent="hop"] {
  --acc: #b36e08;
  --acc-hi: #c78316;
  --acc-lo: #8f5806;
  --acc-soft: #b36e0814;
  --acc-ring: #b36e0855;
  --acc-glow: #b36e082e;
  --airline-spot: #c7831620;
}
body.light[data-airline-accent="klm-cargo"] {
  --acc: #1f8353;
  --acc-hi: #2f9a66;
  --acc-lo: #186844;
  --acc-soft: #1f835314;
  --acc-ring: #1f835355;
  --acc-glow: #1f83532e;
  --airline-spot: #2f9a6620;
}
body.light[data-airline-accent="transavia"] {
  --acc: #0e8f5f;
  --acc-hi: #17a56f;
  --acc-lo: #0b724c;
  --acc-soft: #0e8f5f14;
  --acc-ring: #0e8f5f55;
  --acc-glow: #0e8f5f2e;
  --airline-spot: #17a56f20;
}

/* ── 2. BASE / RESET ────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(1200px circle at -10% -20%, var(--acc-glow), transparent 55%),
    radial-gradient(980px circle at 110% 20%, var(--airline-spot), transparent 60%),
    linear-gradient(165deg, var(--acc-soft), transparent 35%),
    var(--bg-1);
  color: var(--txt-1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-th);
  border-radius: var(--r-pill);
  border: 3px solid var(--bg-1);
}
::-webkit-scrollbar-thumb:hover { background: var(--acc); }

::selection { background: var(--acc-glow); color: var(--txt-1); }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
  border-radius: var(--r-md);
}

a { color: var(--acc); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--acc-hi); }

.mono {
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-feature-settings: 'zero', 'ss01';
}
.mono-muted { font-size: 10px; color: var(--txt-3); letter-spacing: 0.06em; text-transform: uppercase; }

/* .bebas — repurposed to heavy Inter. Inline font-size from the original HTML still applies. */
.bebas {
  font-family: 'Inter', -apple-system, sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: -0.025em !important;
  text-transform: none !important;
  line-height: 1.1 !important;
}

/* ── 3. APP SHELL ────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: var(--sb-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--t-slow) var(--ease);
}
.app-shell.sidebar-collapsed { grid-template-columns: var(--sb-w-col) 1fr; }

/* When auth section is active, hide the chrome AND apply background to body */
.app-shell:has(#sec-auth.active) .sidebar,
.app-shell:has(#sec-auth.active) .topbar,
.app-shell:has(#sec-auth.active) .app-footer { display: none; }
.app-shell:has(#sec-auth.active) { grid-template-columns: 1fr; }

/* Body-level auth backdrop — fills viewport edge-to-edge */
body:has(#sec-auth.active) {
  background:
    radial-gradient(1200px circle at 20% -10%, var(--klm-glow), transparent 52%),
    radial-gradient(900px circle at 80% 110%, var(--af-soft), transparent 52%),
    radial-gradient(700px circle at 50% 45%, var(--airline-spot), transparent 62%),
    var(--bg-1);
  background-attachment: fixed;
}

/* ── 4. SIDEBAR ──────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--bdr-1);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  overflow: hidden;
  transition: width var(--t-slow) var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--bdr-1);
  flex-shrink: 0;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--klm), var(--klm-lo));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 0 #ffffff20 inset, 0 2px 8px var(--klm-glow);
}
.brand-mark.big { width: 56px; height: 56px; border-radius: 14px; }
.brand-mark.big svg { width: 30px; height: 30px; }

.brand-text {
  display: flex;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--t-base) var(--ease);
}
.brand-route { color: var(--klm); }
.brand-center { color: var(--txt-1); }

.app-shell.sidebar-collapsed .brand-text { opacity: 0; pointer-events: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 10px;
}
.nav-list { display: flex; flex-direction: column; gap: 2px; }

/* Sidebar nav buttons (rendered by va-app.js renderNav into #nav-tabs).
   Original code uses class="tab-btn" so we restyle them as sidebar items. */
.sidebar .tab-btn,
#nav-tabs .tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--txt-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
#nav-tabs .tab-btn::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--txt-4);
  flex-shrink: 0;
  transition: background var(--t-fast) var(--ease), transform var(--t-base) var(--ease);
}
#nav-tabs .tab-btn:hover { background: var(--bg-3); color: var(--txt-1); }
#nav-tabs .tab-btn:hover::before { background: var(--txt-2); }
#nav-tabs .tab-btn.active {
  background: var(--acc-soft);
  color: var(--acc);
}
#nav-tabs .tab-btn.active::before {
  background: var(--acc);
  transform: scale(1.4);
  box-shadow: 0 0 8px var(--acc);
}

/* Active underline from old design — kill it in sidebar mode */
#nav-tabs .tab-btn::after { display: none; }

.app-shell.sidebar-collapsed #nav-tabs .tab-btn {
  padding: 0;
  justify-content: center;
}
.app-shell.sidebar-collapsed #nav-tabs .tab-btn {
  font-size: 0;
}
.app-shell.sidebar-collapsed #nav-tabs .tab-btn::before {
  width: 10px;
  height: 10px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--bdr-1);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}
.sidebar-collapse {
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--bdr-2);
  color: var(--txt-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.sidebar-collapse:hover { border-color: var(--acc); color: var(--acc); background: var(--acc-soft); }
.app-shell.sidebar-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.app-shell.sidebar-collapsed .sidebar-footer { justify-content: center; }

/* ── 5. TOPBAR ───────────────────────────────────────────────────────────── */

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  background:
    linear-gradient(90deg, var(--acc-soft), transparent 25%),
    var(--bg-1);
  border-bottom: 1px solid var(--bdr-1);
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.topbar-inner {
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.hamburger {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--bdr-2);
  color: var(--txt-2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast) var(--ease);
}
.hamburger:hover { border-color: var(--acc); color: var(--acc); }

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--txt-1);
  letter-spacing: -0.01em;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

#hdr-user-area > div,
#hdr-user-area > div > div {
  min-width: 0;
}

/* Active flight pill — visibility controlled by JS via inline style.display.
   Styling only applies when JS shows it (display:flex), so no !important on display. */
.hdr-active-pill {
  background: var(--ok-soft) !important;
  border: 1px solid var(--ok) !important;
  border-radius: var(--r-pill) !important;
  padding: 0 14px 0 12px !important;
  height: 32px;
  align-items: center;
  gap: 10px !important;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.hdr-active-pill:hover {
  background: var(--ok) !important;
  color: #052816 !important;
  box-shadow: 0 4px 14px var(--ok-ring);
}
.hdr-active-pill:hover .hdr-active-label,
.hdr-active-pill:hover #hdr-timer,
.hdr-active-pill:hover .mono { color: #052816 !important; }
.hdr-active-pill:hover .pulse-dot { background: #052816; box-shadow: 0 0 6px #052816; }
.hdr-active-pill:active { transform: translateY(1px); }
.hdr-active-label { font-size: 11px; font-weight: 500; color: var(--ok); letter-spacing: 0; }
#hdr-active.hdr-active-pill .mono,
#hdr-timer {
  color: var(--ok) !important;
  font-weight: 700;
  font-size: 12px !important;
  font-variant-numeric: tabular-nums;
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: .55; transform: scale(.78); }
}

/* Theme toggle */
#theme-btn {
  background: transparent;
  border: 1px solid var(--bdr-2);
  color: var(--txt-2);
  border-radius: var(--r-pill);
  padding: 0 14px;
  height: 32px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  transition: all var(--t-fast) var(--ease);
}
#theme-btn:hover { border-color: var(--acc); color: var(--acc); background: var(--acc-soft); }

/* ── 6. MAIN CONTENT ────────────────────────────────────────────────────── */

#main-content {
  flex: 1;
  padding: 32px 36px 48px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  animation: fadeUp var(--t-slow) var(--ease-out) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.app-footer {
  padding: 18px 36px;
  border-top: 1px solid var(--bdr-1);
  text-align: center;
}

/* ── 7. AUTH SCREEN ─────────────────────────────────────────────────────── */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: transparent;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .brand-mark.big { margin: 0 auto 16px; }
.auth-wordmark {
  display: inline-flex;
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -0.025em;
  margin-bottom: 8px;
}
.auth-wordmark .brand-route { color: var(--klm); }
.auth-wordmark .brand-center { color: var(--txt-1); }
.auth-subtitle {
  font-size: 12px;
  color: var(--txt-2);
  letter-spacing: 0;
}
.auth-form-card {
  padding: 28px !important;
  border-color: var(--acc-ring) !important;
  background:
    linear-gradient(155deg, var(--acc-soft), transparent 42%),
    var(--bg-2) !important;
  box-shadow: var(--shadow-2), 0 0 0 1px var(--acc-soft) inset;
}
.auth-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--bdr-1);
  margin: -28px -28px 22px;
  padding: 0 14px;
}
.auth-tabs .tab-btn {
  background: transparent !important;
  border: none !important;
  height: 48px;
  width: auto !important;
  padding: 0 18px !important;
  font-size: 12px;
  font-weight: 500;
  color: var(--txt-3) !important;
  position: relative;
  border-radius: 0 !important;
}
.auth-tabs .tab-btn::before { display: none !important; }
.auth-tabs .tab-btn::after {
  content: '';
  display: block !important;
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: var(--acc);
  transform: scaleX(0);
  transition: transform var(--t-base) var(--ease-out);
}
.auth-tabs .tab-btn:hover { color: var(--txt-1) !important; background: transparent !important; }
.auth-tabs .tab-btn.active { color: var(--acc) !important; background: transparent !important; }
.auth-tabs .tab-btn.active::after { transform: scaleX(1); }

.auth-hint {
  background: var(--klm-soft);
  border: 1px solid var(--klm-ring);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 11px;
  color: var(--txt-2);
  line-height: 1.7;
}

.auth-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--txt-2);
}
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--acc); cursor: pointer; }
.input-wrap { position: relative; }
.input-trail {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  color: var(--txt-3) !important;
  font-size: 14px;
  padding: 4px 6px;
  line-height: 1;
  min-height: auto !important;
  height: auto !important;
  width: auto !important;
  border-radius: var(--r-md);
}
.input-trail:hover { color: var(--acc) !important; background: var(--acc-soft) !important; }
.has-trail { padding-right: 40px !important; }
.btn-block { width: 100%; }

/* ── 8. BUTTONS ─────────────────────────────────────────────────────────── */

.btn {
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  border-radius: var(--r-lg);
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
  min-height: 36px;
  user-select: none;
  touch-action: manipulation;
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    filter var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn-blue {
  background: var(--acc);
  color: #fff;
  box-shadow: 0 1px 0 #ffffff20 inset, 0 1px 2px #00000044;
}
.btn-blue:hover {
  background: var(--acc-hi);
  box-shadow: 0 1px 0 #ffffff22 inset, 0 4px 14px var(--acc-glow);
}

.btn-ghost {
  background: transparent;
  border-color: var(--bdr-2);
  color: var(--txt-2);
}
.btn-ghost:hover {
  border-color: var(--acc);
  color: var(--acc);
  background: var(--acc-soft);
}

.btn-green  { background: var(--ok);   color: #fff; }
.btn-green:hover  { filter: brightness(1.08); box-shadow: 0 4px 14px var(--ok-ring); }

.btn-red    { background: var(--err);  color: #fff; }
.btn-red:hover    { filter: brightness(1.08); box-shadow: 0 4px 14px #ff6b6b33; }

.btn-orange { background: var(--warn); color: #fff; }
.btn-orange:hover { filter: brightness(1.08); box-shadow: 0 4px 14px #f0b85a33; }

.btn-purple { background: #7c5cff; color: #fff; }
.btn-purple:hover { filter: brightness(1.08); box-shadow: 0 4px 14px #7c5cff44; }

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  min-height: 26px;
  border-radius: var(--r-md);
}
.icon-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  min-height: 28px;
}

/* ── 9. FORMS ───────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.field label {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--txt-3);
  text-transform: none;
}
.field input,
.field select,
.field textarea,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--bg-input);
  border: 1px solid var(--bdr-1);
  color: var(--txt-1);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  border-radius: var(--r-md);
  width: 100%;
  height: 36px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-base) var(--ease);
}
textarea, .field textarea { height: auto; min-height: 80px; line-height: 1.5; resize: vertical; }
.textarea-mono {
  font-family: 'JetBrains Mono', 'Space Mono', monospace !important;
  font-size: 11px !important;
  line-height: 1.6 !important;
}

.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--bdr-2); }
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-ring);
}
.field input::placeholder, .field textarea::placeholder,
input::placeholder, textarea::placeholder { color: var(--txt-ph); }

/* ── 10. CARDS ──────────────────────────────────────────────────────────── */

.card {
  background:
    linear-gradient(145deg, var(--acc-soft), transparent 40%),
    var(--bg-2);
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
  transition: background var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.card:hover { border-color: var(--bdr-2); }

/* The legacy ::before cyan stripe — kill it everywhere */
.accentcard::before { display: none !important; }

/* ── 11. TABLES (data rows) ─────────────────────────────────────────────── */

.trow {
  display: grid;
  padding: 12px 18px;
  border-bottom: 1px solid var(--bdr-1);
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--txt-1);
  align-items: center;
  border-radius: 0;
  transition: background var(--t-fast) var(--ease);
}
.trow:hover { background: var(--bg-3); }
.trow:last-child { border-bottom: none; }

.thead {
  background: var(--bg-thead) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 10px !important;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--txt-3) !important;
  text-transform: uppercase;
  cursor: default;
  border-bottom: 1px solid var(--bdr-2) !important;
}
.thead:hover { background: var(--bg-thead) !important; }

/* ── 12. BADGES ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
  height: 20px;
  line-height: 1;
}

/* ── 13. STATUS MESSAGES (.ok / .err) ───────────────────────────────────── */

.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok);
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ok::before { content: '✓'; font-weight: 700; }

.err {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid var(--err);
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 14. PROGRESS BAR ───────────────────────────────────────────────────── */

.pbar {
  background: var(--bdr-1);
  border-radius: var(--r-pill);
  height: 6px;
  overflow: hidden;
  position: relative;
}
.pfill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--acc), var(--acc-hi));
  transition: width var(--t-slow) var(--ease-out);
  position: relative;
}
.pfill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, #ffffff22, transparent);
  animation: shimmer 2.4s var(--ease) infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── 15. ACTIVE FLIGHT BANNER ───────────────────────────────────────────── */

.active-flight-banner {
  background: linear-gradient(135deg, var(--ok-soft), transparent 60%), var(--bg-2);
  border: 1px solid var(--ok);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.active-flight-banner::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ok), transparent);
}
.timer-display {
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, monospace !important;
  font-size: 40px !important;
  font-weight: 700 !important;
  color: var(--ok) !important;
  letter-spacing: -0.02em !important;
  line-height: 1 !important;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px #3dd68c33;
}

/* ── 16. DROPDOWNS ──────────────────────────────────────────────────────── */

.dropdown-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--bdr-2);
  border-radius: var(--r-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 999;
  box-shadow: var(--shadow-3);
  display: none;
  transform-origin: top center;
}
.dropdown-list.open {
  display: block;
  animation: dropIn var(--t-base) var(--ease-out);
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--bdr-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--txt-1);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.dropdown-item:hover { background: var(--acc-soft); color: var(--acc); }
.dropdown-item:last-child { border-bottom: none; }

/* ── 17. MODALS ─────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: #000c;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn var(--t-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--bdr-2);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: modalIn var(--t-slow) var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}
.modal-head.bordered {
  padding: 14px 18px;
  margin: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--bdr-1);
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--txt-1);
}
.modal-sub { margin-bottom: 18px; }
.modal-accent-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--ok), transparent);
  margin: -28px -28px 22px;
}
.modal-accent-bar.accent-ok { background: linear-gradient(90deg, var(--ok), transparent); }
.modal-foot {
  padding: 12px 18px;
  background: var(--bg-2);
  border-top: 1px solid var(--bdr-1);
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
}
.map-canvas { height: 460px; width: 100%; }
.map-canvas.tall { height: 520px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--txt-3); }
.legend-sw { width: 14px; height: 14px; border-radius: 3px; }
.legend-sw-acc { background: var(--acc); opacity: .8; }
.legend-sw-bg  { background: var(--bg-3); border: 1px solid var(--bdr-2); }
.legend-dot    { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); }
.legend-line   { width: 24px; height: 2px; border-top: 2px dashed var(--acc); opacity: .7; }
.ml-auto       { margin-left: auto; }
.pilot-name    { color: var(--acc); font-weight: 600; }

.stats-export-btn {
  flex-direction: column !important;
  align-items: flex-start !important;
  padding: 14px 16px !important;
  height: auto !important;
  min-height: 60px !important;
  text-align: left !important;
  width: 100%;
}
.stats-btn-title { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.stats-btn-sub   { font-size: 11px; opacity: .85; margin-top: 2px; font-weight: 400; }

/* ── FLIGHT OPS PAGE (#sec-flight) ──────────────────────────────── */

.flight-empty {
  text-align: center;
  padding: 80px 20px;
}
.flight-empty-icon {
  font-size: 48px;
  color: var(--txt-4);
  margin-bottom: 14px;
}
.flight-empty-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.flight-empty-sub {
  font-size: 13px;
  color: var(--txt-3);
  margin-bottom: 22px;
}

.flight-page { display: flex; flex-direction: column; gap: 18px; }

/* HERO */
.flight-hero {
  position: relative;
  background:
    linear-gradient(135deg, var(--ok-soft), transparent 55%),
    var(--bg-2);
  border: 1px solid var(--ok);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.flight-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ok), transparent);
}
.flight-hero-divert {
  background: linear-gradient(135deg, var(--warn-soft), transparent 55%), var(--bg-2);
  border-color: var(--warn);
}
.flight-hero-divert::before {
  background: linear-gradient(90deg, var(--warn), transparent);
}
.flight-hero-l { flex: 1; min-width: 0; }
.flight-hero-r {
  text-align: right;
  flex-shrink: 0;
}
.flight-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
  letter-spacing: 0.14em;
  margin-bottom: 8px;
}
.flight-hero-divert .flight-eyebrow { color: var(--warn); }
.hero-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 2s var(--ease) infinite;
}
.flight-hero-divert .hero-status-dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.flight-callsign {
  font-family: 'JetBrains Mono', monospace;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--txt-1);
  line-height: 1;
  margin-bottom: 12px;
}
.flight-route {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.route-icao {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--txt-1);
}
.route-icao-strike { color: var(--txt-4); text-decoration: line-through; text-decoration-thickness: 2px; }
.route-icao-warn { color: var(--warn); }
.route-arrow { color: var(--txt-3); }
.route-arrow-warn { color: var(--warn); }

.flight-hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--txt-3);
}
.dot-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--txt-4);
  display: inline-block;
}
.flight-bigtimer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ok);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-top: 6px;
  text-shadow: 0 0 24px var(--ok-ring);
}
.flight-hero-divert .flight-bigtimer { color: var(--warn); text-shadow: 0 0 24px #f0b85a44; }
.flight-eta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--txt-3);
}
.flight-eta-val { color: var(--txt-1); font-weight: 600; margin-left: 4px; }

/* Banners */
.flight-event-banner,
.flight-divert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
}
.flight-event-banner {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
}
.flight-event-icon, .flight-divert-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.flight-event-text { font-size: 13px; color: var(--txt-1); font-weight: 500; margin-top: 2px; }
.flight-divert-banner {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
}

/* GRID */
.flight-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 18px;
  align-items: start;
}
.flight-col-map, .flight-col-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Map card */
.flight-map-card { padding: 0; overflow: hidden; }
.flight-map {
  height: 360px;
  width: 100%;
  background: var(--bg-3);
}
.flight-map-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--txt-3);
  font-size: 12px;
}
.flight-map-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 14px 18px 10px;
}
.map-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.map-stat:not(:last-child) {
  border-right: 1px solid var(--bdr-1);
  padding-right: 14px;
}
.map-stat:not(:first-child) {
  padding-left: 14px;
}
.map-stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--txt-1);
}
.map-stat-sub { font-size: 11px; color: var(--txt-3); font-weight: 400; }
.flight-pbar { margin: 6px 18px 18px; height: 4px; }

/* Route card */
.flight-route-card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.flight-route-text {
  font-size: 12px;
  color: var(--txt-2);
  line-height: 1.6;
  word-break: break-word;
  background: var(--bg-3);
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--bdr-1);
}
.flight-notes-text {
  font-size: 13px;
  color: var(--txt-1);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Airports card */
.flight-airports-card { padding: 18px; }
.airport-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.airport-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.dep-dot { background: var(--acc); box-shadow: 0 0 10px var(--acc-glow); }
.arr-dot { background: var(--ok);  box-shadow: 0 0 10px var(--ok-ring); }
.warn-dot { background: var(--warn) !important; box-shadow: 0 0 10px #f0b85a55 !important; }
.airport-line {
  width: 2px;
  height: 22px;
  background: linear-gradient(180deg, var(--acc), var(--ok));
  margin: 4px 0 4px 5px;
  border-radius: 2px;
  opacity: 0.5;
}
.airport-info { flex: 1; min-width: 0; }
.airport-info .mono-muted { font-size: 9px; margin-bottom: 2px; }
.airport-icao {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--txt-1);
}
.airport-name {
  font-size: 13px;
  color: var(--txt-1);
  margin-top: 2px;
  font-weight: 500;
}
.airport-sub { font-size: 10px; margin-top: 2px; }

/* Aircraft */
.aircraft-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--txt-1);
}
.aircraft-reg {
  font-size: 12px;
  color: var(--txt-3);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

/* Crew */
.crew-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.crew-row:not(:last-child) { border-bottom: 1px solid var(--bdr-1); }
.crew-badge {
  width: 34px;
  height: 22px;
  border-radius: var(--r-sm);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.crew-cpt { background: var(--acc-soft); color: var(--acc); border: 1px solid var(--acc-ring); }
.crew-fo  { background: var(--bg-3); color: var(--txt-2); border: 1px solid var(--bdr-2); }

/* Actions */
.flight-actions-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-tall { padding: 13px 18px; font-size: 13px; min-height: 44px; }
.flight-actions-card .btn {
  justify-content: center;
}
.flight-actions-card .btn span:first-child {
  margin-right: 4px;
}
.flight-cancel-btn { color: var(--err) !important; border-color: var(--err) !important; opacity: 0.7; }
.flight-cancel-btn:hover { background: var(--err-soft) !important; opacity: 1; color: var(--err) !important; }
.flight-cancel-hint {
  text-align: center;
  font-size: 9px;
  margin-top: -2px;
  color: var(--txt-4);
}

/* FO note */
.flight-fo-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--klm-soft) !important;
  border-color: var(--klm-ring) !important;
}
.flight-fo-icon { font-size: 26px; flex-shrink: 0; }
.flight-fo-text { font-size: 12px; color: var(--txt-2); line-height: 1.6; margin-top: 4px; }

/* Divert panel inline */
.flight-divert-panel {
  background: var(--warn-soft);
  border-color: var(--warn);
}
.afm-divert-search {
  width: 100%;
  margin-bottom: 8px;
}
.afm-divert-select {
  width: 100%;
  height: auto;
  padding: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  margin-bottom: 10px;
}
.afm-divert-select option { padding: 4px 8px; }
.afm-divert-buttons {
  display: flex;
  gap: 10px;
}
.afm-divert-buttons .btn:first-child { flex: 1; }

/* Tab "Flight" pulse — gentle hint */
.tab-flight {
  position: relative;
}
.tab-flight::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: pulse 2s var(--ease) infinite;
}
.app-shell.sidebar-collapsed .tab-flight::after { display: none; }

/* Redirect banner on Log Flight when a flight is active */
.logflight-redirect-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background:
    linear-gradient(135deg, var(--ok-soft), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--ok);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-1);
  flex-wrap: wrap;
}
.lrb-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: var(--ok);
  color: #052816;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--ok-ring);
}
.lrb-body { flex: 1; min-width: 220px; }
.lrb-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--txt-1);
  margin: 4px 0 4px;
  letter-spacing: 0.02em;
}
.lrb-divert { color: var(--warn); font-size: 11px; font-weight: 500; }
.lrb-sub { font-size: 10px; }

/* Responsive */
@media (max-width: 900px) {
  .flight-grid { grid-template-columns: 1fr; }
  .flight-hero { padding: 22px; }
  .flight-callsign { font-size: 30px; }
  .flight-bigtimer { font-size: 36px; }
}
@media (max-width: 600px) {
  .flight-hero {
    flex-direction: column;
    gap: 18px;
    align-items: stretch;
  }
  .flight-hero-r { text-align: left; }
  .flight-map { height: 280px; }
  .flight-map-stats { grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; }
  .map-stat:not(:last-child) { border-right: none; padding-right: 0; }
  .map-stat:not(:first-child) { padding-left: 0; }
  .map-stat:nth-child(3) { grid-column: span 2; padding-top: 8px; border-top: 1px solid var(--bdr-1); }
  .flight-pbar { margin: 0 14px 14px; }
  .flight-callsign { font-size: 28px; }
  .flight-bigtimer { font-size: 38px; }
  .logflight-redirect-banner { padding: 16px; }
  .lrb-title { font-size: 14px; }
}

/* ── 18. SECTIONS ───────────────────────────────────────────────────────── */

.section { display: none; }
.section.active {
  display: block;
  animation: sectionIn var(--t-slow) var(--ease-out);
}
@keyframes sectionIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 19. LAYOUT GRIDS ───────────────────────────────────────────────────── */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── 20. HISTORY TAGS ───────────────────────────────────────────────────── */

.hist-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  background: var(--bg-3);
  border: 1px solid var(--bdr-1);
  color: var(--txt-3);
  margin: 2px;
  text-transform: uppercase;
  transition: all var(--t-fast) var(--ease);
}
.hist-tag.klm { border-color: var(--klm-ring); color: var(--klm); background: var(--klm-soft); }
.hist-tag.af  { border-color: var(--af-ring);  color: var(--af);  background: var(--af-soft); }

/* ── 21. LEAFLET LABELS ─────────────────────────────────────────────────── */

.leaflet-va-label {
  background: var(--bg-2) !important;
  border: 1px solid var(--acc) !important;
  color: var(--acc) !important;
  font-family: 'JetBrains Mono', 'Space Mono', ui-monospace, monospace !important;
  font-size: 10px !important;
  font-weight: 500 !important;
  padding: 3px 7px !important;
  border-radius: var(--r-sm) !important;
  box-shadow: var(--shadow-1) !important;
  white-space: nowrap !important;
}
.leaflet-va-label::before { display: none !important; }
.leaflet-container { font-family: 'Inter', sans-serif; }

/* ── 22. SCRIM (mobile sidebar overlay) ─────────────────────────────────── */

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: #000a;
  z-index: 45;
  display: none;
  animation: fadeIn var(--t-base) var(--ease-out);
}
.app-shell.sidebar-open .sidebar-scrim { display: block; }

/* ── 23. RESPONSIVE ─────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sb-w);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform var(--t-slow) var(--ease);
    z-index: 60;
    box-shadow: var(--shadow-3);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .hamburger { display: inline-flex; }
  .app-shell.sidebar-collapsed .sidebar { width: var(--sb-w); }
  .app-shell.sidebar-collapsed .brand-text { opacity: 1; }
  .app-shell.sidebar-collapsed #nav-tabs .tab-btn { padding: 0 12px; justify-content: flex-start; font-size: 13px; }
  .app-shell.sidebar-collapsed #nav-tabs .tab-btn::before { width: 6px; height: 6px; }
  #main-content { padding: 20px 18px 32px; }
  .topbar-inner { padding: 0 16px; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 95vh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}
@media (max-width: 600px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .topbar-title { display: none; }
  .hdr-active-pill .hdr-active-label { display: none; }
  body { padding-bottom: env(safe-area-inset-bottom); }
  .app-footer { display: none; }
  .timer-display { font-size: 32px !important; }
}

/* ── 24. REDUCED MOTION ─────────────────────────────────────────────────── */

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

/* ════════════════════════════════════════════════════════════════
   25. LEGACY INLINE COLOR OVERRIDES
   The JS injects HTML with hardcoded #00b0ea, #00aa66, #ff8833, etc.
   We catch them via attribute selectors so the JS doesn't need touching.
   ════════════════════════════════════════════════════════════════ */

/* The KLM cyan #00b0ea — everywhere it appears as a color */
[style*="#00b0ea"]        { color: var(--klm) !important; }
[style*="color:#00b0ea"]  { color: var(--klm) !important; }
[style*="color: #00b0ea"] { color: var(--klm) !important; }

/* Backgrounds derived from that cyan */
[style*="background:#00b0ea"],
[style*="background: #00b0ea"] { background: var(--klm) !important; }
[style*="background:#001220"],
[style*="background: #001220"] { background: var(--klm-soft) !important; }
[style*="background:#0c1829"],
[style*="background: #0c1829"] { background: var(--bg-3) !important; }
[style*="border-color:#00b0ea"],
[style*="border-color: #00b0ea"],
[style*="border:1px solid #00b0ea"],
[style*="border: 1px solid #00b0ea"] { border-color: var(--klm) !important; }

/* Cyan border variants with alpha */
[style*="#00b0ea44"] { border-color: var(--klm-ring) !important; }
[style*="#00b0ea66"] { border-color: var(--klm-ring) !important; }
[style*="#00b0ea22"] { background-color: var(--klm-soft) !important; }

/* The bright dashboard cyan #00aadd / #0066cc / #003cb3 */
[style*="#00aadd"]  { color: var(--klm) !important; }
[style*="#0066cc"]  { color: var(--klm) !important; }
[style*="#003cb3"]  { color: var(--klm) !important; }

/* Active flight green tones */
[style*="#00ee88"] { color: var(--ok) !important; }
[style*="#00cc66"] { color: var(--ok) !important; }
[style*="#00aa66"] { color: var(--ok) !important; }
[style*="#00aa44"] { color: var(--ok) !important; }
[style*="#00dd66"] { color: var(--ok) !important; }
[style*="background:#001a0a"],
[style*="background: #001a0a"],
[style*="background:#001a10"],
[style*="background: #001a10"] { background: var(--ok-soft) !important; }
[style*="border:1px solid #00aa66"],
[style*="border: 1px solid #00aa66"],
[style*="#00aa6644"],
[style*="#00aa6633"],
[style*="#00dd6644"] { border-color: var(--ok) !important; }

/* Admin orange */
[style*="#ff8833"] { color: var(--warn) !important; }
[style*="#ff883344"] { border-color: var(--warn) !important; }
[style*="background:#1a0800"],
[style*="background: #1a0800"] { background: var(--warn-soft) !important; }

/* Event yellow / amber */
[style*="#f0a500"]  { color: var(--warn) !important; }
[style*="#f0a50022"] { background-color: var(--warn-soft) !important; }
[style*="#f0a50044"] { border-color: var(--warn) !important; }
[style*="background:#1a1200"],
[style*="background: #1a1200"] { background: var(--warn-soft) !important; }

/* AF red references in JS HTML */
[style*="#e2001a"] { color: var(--af) !important; }
[style*="#e08000"] { color: var(--warn) !important; }
[style*="#cc2233"] { color: var(--af) !important; }

/* Cyan/blue text gradients in stat headers */
[style*="color:#00b0ea"][style*="font-size"] { color: var(--acc) !important; }

/* Specific dashboard accents — letter-spacing keys (mostly mono labels) */
.mono[style*="color:#00b0ea"] { color: var(--acc) !important; }
.mono[style*="color:#00cc66"],
.mono[style*="color:#00ee88"],
.mono[style*="color:#00aa66"] { color: var(--ok) !important; }

/* Light-mode hardening for legacy inline colors used in name fields. */
body.light .mono[style*="color:#5599bb"],
body.light .trow [style*="color:#5599bb"],
body.light .card [style*="color:#5599bb"] { color: #1f5f9f !important; }

body.light .mono[style*="color:#00b0ea"],
body.light .trow [style*="color:#00b0ea"],
body.light .card [style*="color:#00b0ea"] { color: #0f6fbf !important; }

body.light .mono[style*="color:#00dd66"],
body.light .mono[style*="color:#00cc66"],
body.light .mono[style*="color:#00ee88"],
body.light .mono[style*="color:#00aa66"],
body.light .trow [style*="color:#00dd66"],
body.light .trow [style*="color:#00cc66"],
body.light .trow [style*="color:#00ee88"],
body.light .trow [style*="color:#00aa66"],
body.light .card [style*="color:#00dd66"],
body.light .card [style*="color:#00cc66"],
body.light .card [style*="color:#00ee88"],
body.light .card [style*="color:#00aa66"] { color: #1b9d62 !important; }

/* Final safeguard: many legacy name labels are rendered with inline color:var(--txt). */
body.light [style*="color:var(--txt)"] { color: var(--txt-1) !important; }

/* Auth-form border that's now redundant */
[style*="border-bottom:1px solid #0c1a28"],
[style*="border-bottom: 1px solid #0c1a28"] { border-bottom-color: var(--bdr-1) !important; }

/* Notice / banner background colors used in JS */
[style*="background:#180000"],
[style*="background: #180000"] { background: var(--err-soft) !important; }
[style*="background:#002a1a"],
[style*="background: #002a1a"] { background: var(--ok-soft) !important; }

/* Replace cyan gradient backgrounds (e.g. Generate Random Flight button) */
[style*="linear-gradient(135deg,#00b0ea"],
[style*="linear-gradient(135deg, #00b0ea"] { background: var(--acc) !important; }

/* ════════════════════════════════════════════════════════════════
   26. AIRLINE-CONTEXTUAL THEMING (KLM/AF split)
   Apply .af-context to a card / section to swap the accent to AF red.
   Useful for badges and route entries when displaying AF-only data.
   ════════════════════════════════════════════════════════════════ */

.af-context {
  --acc: var(--af);
  --acc-hi: var(--af-hi);
  --acc-soft: var(--af-soft);
  --acc-ring: var(--af-ring);
  --acc-glow: var(--af-soft);
}

/* Airline-specific badges (the JS already emits text like "Air France", "AF Cargo", etc.) */
.badge-klm { background: var(--klm-soft); color: var(--klm); border-color: var(--klm-ring); }
.badge-af  { background: var(--af-soft);  color: var(--af);  border-color: var(--af-ring);  }

/* ════════════════════════════════════════════════════════════════
   27. UTILITIES
   ════════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.spread { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--txt-3); }
.mono-num { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

/* Random flight airport explorer */
.fgen-airport-map {
  height: 420px;
  width: 100%;
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-md);
  background: var(--bg-3);
  overflow: hidden;
}

.fgen-airport-routes {
  margin-top: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-md);
  background: var(--bg-input);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fgen-airport-route-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-md);
  padding: 8px;
  background: var(--bg-2);
}

.fgen-airport-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.fgen-airport-dir,
.fgen-airport-pin {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fgen-airport-dir .btn {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 10px;
}

.fgen-airport-dir .btn.is-active {
  background: var(--acc-soft);
  border-color: var(--acc);
  color: var(--acc);
}

.fgen-airport-pin .btn {
  min-height: 28px;
  padding: 5px 10px;
  font-size: 10px;
}

.fgen-route-freq-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  border: 1px solid var(--acc-ring);
  background: var(--acc-soft);
  color: var(--acc);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.fgen-view-switch {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fgen-hub-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
}

.fgen-hub-stats {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  color: var(--txt-3);
  padding: 0 4px;
}

.fgen-hub-stats b {
  color: var(--acc);
  font-weight: 700;
  margin-right: 3px;
}

.fgen-view-switch .btn.is-active {
  background: var(--acc-soft);
  border-color: var(--acc);
  color: var(--acc);
}

.fgen-search-wrap {
  position: relative;
}

.fgen-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 120;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--bdr-2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  box-shadow: var(--shadow-2);
}

.fgen-search-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--bdr-1);
  background: transparent;
  color: var(--txt-1);
  text-align: left;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
  cursor: pointer;
  font-size: 11px;
}

.fgen-search-item:hover {
  background: var(--acc-soft);
  color: var(--acc);
}

.fgen-search-item:last-child {
  border-bottom: 0;
}

.fgen-search-empty {
  padding: 9px 10px;
  color: var(--txt-3);
  font-size: 10px;
}

@media (max-width: 900px) {
  .fgen-hub-grid {
    grid-template-columns: 1fr;
  }

  .fgen-airport-map {
    height: 300px;
  }

  .fgen-airport-routes {
    max-height: 260px;
  }
}

/* ── ADMIN PAGE SCOPED STYLES ─────────────────────────────────────────── */
body[data-page="admin"] .section { display: none; }
body[data-page="admin"] .section.active { display: block; }

body[data-page="admin"] .api-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--bdr-2);
  border-radius: var(--r-pill);
  color: var(--txt-2);
  background: var(--bg-2);
}

body[data-page="admin"] .api-pill.ok {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-soft);
}

body[data-page="admin"] .admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

body[data-page="admin"] .stat-card {
  background: linear-gradient(145deg, var(--acc-soft), transparent 40%), var(--bg-2);
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-lg);
  padding: 16px;
}

body[data-page="admin"] .stat-label {
  font-size: 10px;
  color: var(--txt-3);
  letter-spacing: .1em;
  text-transform: uppercase;
}

body[data-page="admin"] .stat-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  color: var(--txt-1);
  line-height: 1;
}

body[data-page="admin"] .maintenance-card { max-width: 860px; }

body[data-page="admin"] .maintenance-head,
body[data-page="admin"] .data-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

body[data-page="admin"] .maintenance-title {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 700;
}

body[data-page="admin"] .maintenance-desc {
  margin-top: 10px;
  color: var(--txt-2);
  font-size: 13px;
}

body[data-page="admin"] .status-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--bdr-2);
  color: var(--txt-2);
  background: var(--bg-3);
}

body[data-page="admin"] .status-chip.enabled {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-soft);
}

body[data-page="admin"] .status-chip.disabled {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-soft);
}

body[data-page="admin"] .maintenance-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

body[data-page="admin"] #maintenance-msg {
  margin-top: 12px;
}

body[data-page="admin"] .data-toolbar {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

body[data-page="admin"] .data-table-wrap {
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-lg);
}

body[data-page="admin"] .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

body[data-page="admin"] .data-table th,
body[data-page="admin"] .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bdr-1);
  vertical-align: top;
}

body[data-page="admin"] .data-table th {
  background: var(--bg-thead);
  color: var(--txt-3);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

body[data-page="admin"] .data-table tr:last-child td { border-bottom: none; }

body[data-page="admin"] .raw-json {
  margin-top: 14px;
  max-height: 260px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--bdr-1);
  border-radius: var(--r-md);
  padding: 12px;
  font-size: 11px;
  color: var(--txt-2);
}

@media (max-width: 900px) {
  body[data-page="admin"] .maintenance-head,
  body[data-page="admin"] .data-head,
  body[data-page="admin"] .data-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── 26. MOBILE / TABLET HARDENING ───────────────────────────────────── */

.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
}

.topbar-inner { min-height: var(--topbar-h); }

.main-col,
.sidebar {
  min-height: 100dvh;
}

.topbar-right {
  min-width: 0;
  flex-wrap: nowrap;
}

#hdr-user-area {
  min-width: 0;
  max-width: min(42vw, 360px);
}

#hdr-user-area,
#hdr-user-area > * {
  min-width: 0;
}

#hdr-user-area .mono,
#hdr-user-area span,
#hdr-user-area a,
#hdr-user-area button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  #main-content { padding-inline: 24px; }

  .topbar-inner {
    padding: 0 18px;
    gap: 10px;
  }

  .topbar-right { gap: 8px; }

  #theme-btn { padding: 0 11px; }

  #hdr-user-area { max-width: 32vw; }
}

@media (max-width: 900px) {
  .topbar {
    height: auto;
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  .sidebar {
    width: min(86vw, 320px);
    height: 100dvh;
  }

  .topbar-inner {
    min-height: var(--topbar-h);
    height: auto;
    flex-wrap: wrap;
    align-content: center;
    row-gap: 8px;
    column-gap: 8px;
    padding: 8px 12px;
  }

  .topbar-title {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-right {
    margin-left: auto;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 8px;
    column-gap: 8px;
  }

  #hdr-user-area > div {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px !important;
    max-width: 100%;
  }

  #hdr-user-area > div > div {
    flex: 1 1 auto;
  }

  #hdr-user-area [style*="text-align:right"] {
    text-align: left !important;
  }

  #main-content { padding: 16px 14px 24px; }

  .card { padding: 15px; }

  .btn { min-height: 40px; }

  .btn-sm { min-height: 34px; }

  .modal-overlay { padding-bottom: max(0px, env(safe-area-inset-bottom)); }

  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 14px 14px 0 0;
  }

  body[data-page="admin"] .admin-grid { grid-template-columns: 1fr 1fr; }

  body[data-page="admin"] .data-table-wrap { -webkit-overflow-scrolling: touch; }

  body[data-page="admin"] .data-table { min-width: 640px; }
}

@media (max-width: 768px) {
  .topbar-title { display: none; }

  .topbar-inner { padding-inline: 10px; }

  .topbar-right {
    width: calc(100% - 42px);
    justify-content: flex-start;
  }

  #hdr-user-area { max-width: 46vw; }

  .hdr-active-pill { max-width: 100%; }

  #hdr-active.hdr-active-pill .mono,
  #hdr-timer { font-size: 11px !important; }

  .auth-wrap {
    min-height: 100dvh;
    padding: 22px 12px;
  }

  .auth-wordmark { font-size: 26px; }

  .auth-form-card { padding: 18px !important; }

  .auth-tabs {
    margin: -18px -18px 16px;
    padding: 0 8px;
  }

  body[data-page="admin"] .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { --topbar-h: 56px; }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

  #main-content [id$="-content"] > div:first-child[style*="justify-content:space-between"][style*="align-items:flex-end"] {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px !important;
    margin-bottom: 18px !important;
  }

  #main-content [id$="-content"] > div:first-child[style*="justify-content:space-between"][style*="align-items:flex-end"] > div {
    width: 100%;
    min-width: 0;
  }

  #main-content [id$="-content"] > div:first-child[style*="justify-content:space-between"][style*="align-items:flex-end"] .bebas {
    font-size: clamp(24px, 9vw, 32px) !important;
    line-height: 0.95 !important;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  #main-content [id$="-content"] > div:first-child[style*="justify-content:space-between"][style*="align-items:flex-end"] [style*="display:flex"] {
    justify-content: flex-start !important;
    flex-wrap: wrap;
  }

  #hdr-active { order: 1; }

  #theme-btn { order: 2; }

  #hdr-user-area {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
  }

  .hdr-active-pill {
    height: 30px;
    padding: 0 10px !important;
  }

  #main-content { padding: 14px 12px 22px; }

  .card { border-radius: 10px; }

  .map-canvas { height: 360px; }

  .map-canvas.tall { height: 420px; }

  .app-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  body[data-page="admin"] .maintenance-title { font-size: 19px; }

  body[data-page="admin"] .data-table {
    min-width: 560px;
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .topbar-right > * { max-width: 100%; }

  .hdr-active-pill {
    gap: 6px !important;
    padding-inline: 8px !important;
  }

  .hdr-active-pill .hdr-active-label { display: none; }
}

/* Additional device hardening for very small and landscape-constrained viewports */
img,
video,
canvas,
iframe {
  max-width: 100%;
}

/* JS-rendered table cards frequently use inline grid columns and overflow:hidden.
   Let the card scroll horizontally on narrow devices instead of clipping content. */
.card:has(.trow) {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.card:has(.trow) > .trow {
  min-width: max-content;
}

#main-content .section,
#main-content .card,
.modal-box {
  min-width: 0;
}

@media (max-width: 768px) {
  .field input,
  .field select,
  .field textarea,
  .btn,
  .btn-sm {
    max-width: 100%;
  }

  .data-table-wrap,
  .table-wrap {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  [style*="grid-template-columns:360px 1fr"],
  [style*="grid-template-columns:320px 1fr"],
  [style*="grid-template-columns:1.8fr 1fr"],
  [style*="grid-template-columns:1.35fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .card [style*="display:flex"][style*="gap:8px"],
  .card [style*="display:flex"][style*="gap:10px"],
  .card [style*="display:flex"][style*="gap:12px"] {
    flex-wrap: wrap;
  }

  body[data-page="admin"] .data-table {
    min-width: 520px;
  }
}

@media (max-width: 480px) {
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(190px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fit,minmax(140px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fill,minmax(300px,1fr))"],
  [style*="grid-template-columns:repeat(auto-fill,minmax(320px,1fr))"] {
    grid-template-columns: 1fr !important;
  }

  [style*="min-width:220px"],
  [style*="min-width:200px"] {
    min-width: 0 !important;
  }

  [style*="max-width:280px"],
  [style*="max-width:360px"],
  [style*="max-width:500px"] {
    max-width: 100% !important;
  }

  body[data-page="admin"] .data-table {
    min-width: 460px;
    font-size: 10.5px;
  }

  .modal-box {
    padding: 16px !important;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .topbar {
    --topbar-h: 52px;
  }

  .modal-box {
    max-height: 88svh;
  }

  .auth-wrap {
    padding-block: 14px;
  }
}

/* ── LIGHT MODE INLINE-STYLE OVERRIDES ─────────────────────────────────── */

body.light .btn-blue {
  color: #ffffff;
}

/* Admin user list: selected row uses btn-blue which is fine,
   but ensure username text stays readable */
body.light .btn.btn-blue .mono {
  color: #ffffff !important;
}

/* Application status badges */
body.light .badge[style*="background:var(--warn-soft)"] { color: var(--warn) !important; }
body.light .badge[style*="background:var(--ok-soft)"]   { color: var(--ok)   !important; }
body.light .badge[style*="background:var(--err-soft)"]  { color: var(--err)  !important; }
body.light .badge[style*="background:var(--acc-soft)"]  { color: var(--acc)  !important; }

/* Safety net: any inline white text becomes dark in light mode unless explicitly intentional */
body.light [style*="color:#fff"],
body.light [style*="color: #fff"],
body.light [style*="color:#ffffff"],
body.light [style*="color: #ffffff"] {
  color: var(--txt-1) !important;
}

/* Preserve white labels on intentionally colored controls */
body.light .btn-blue,
body.light .btn-green,
body.light .btn-red,
body.light .btn-purple,
body.light .brand-mark,
body.light .brand-mark *,
body.light .btn-blue .mono,
body.light .btn-green .mono,
body.light .btn-red .mono,
body.light .btn-purple .mono {
  color: #ffffff !important;
}

/* Light-mode fixes for inline var(--input-bg) blocks that still render dark */
body.light input[style*="background:var(--input-bg)"],
body.light select[style*="background:var(--input-bg)"],
body.light textarea[style*="background:var(--input-bg)"] {
  background: var(--bg-2) !important;
  color: var(--txt-1) !important;
  border-color: var(--bdr-2) !important;
}

/* Rank/status badges rendered from JS templates */
body.light .badge[style*="background:var(--input-bg)"] {
  background: var(--bg-3) !important;
  border-color: var(--bdr-3) !important;
}

