/* Pilot Logbook - dark glass by default, light theme on request or by system setting.
   Responsive: sidebar on desktop, icon rail on iPad portrait, bottom tab bar on phones. */
:root {
  color-scheme: dark;
  --bg0: #090b10; --bg1: #10131b;
  --glass: rgba(255, 255, 255, 0.045); --glass-2: rgba(255, 255, 255, 0.08); --glass-3: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.10); --stroke-soft: rgba(255, 255, 255, 0.06);
  --text: #eef1f8; --muted: #98a2b8; --faint: #6b748a;
  --accent: #7ca4ff; --accent-2: #a18cff; --accent-ink: #081022; --accent-soft: rgba(124, 164, 255, 0.16);
  --grad: linear-gradient(135deg, #7ca4ff 0%, #a18cff 100%);
  --ok: #5eddA0; --warn: #fbbf4a; --bad: #ff7a90; --warn-soft: rgba(251, 191, 74, 0.13); --bad-soft: rgba(255, 122, 144, 0.14);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow-a: rgba(124, 164, 255, 0.20); --glow-b: rgba(161, 140, 255, 0.14);
  --panel-solid: #141824;
  --radius: 20px; --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { --theme: light; }
}
:root[data-theme="light"], :root:not([data-theme]) .never { color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg0: #e8ebf2; --bg1: #f5f6fa;
    --glass: rgba(255, 255, 255, 0.72); --glass-2: rgba(255, 255, 255, 0.92); --glass-3: rgba(20, 30, 60, 0.07);
    --stroke: rgba(20, 30, 60, 0.10); --stroke-soft: rgba(20, 30, 60, 0.06);
    --text: #12161f; --muted: #566074; --faint: #8a93a6;
    --accent: #3a62e8; --accent-2: #6d58ea; --accent-ink: #ffffff; --accent-soft: rgba(58, 98, 232, 0.11);
    --grad: linear-gradient(135deg, #3a62e8 0%, #6d58ea 100%);
    --ok: #12804f; --warn: #9a6200; --bad: #c0223c; --warn-soft: rgba(224, 150, 0, 0.14); --bad-soft: rgba(192, 34, 60, 0.10);
    --shadow: 0 14px 40px rgba(30, 40, 80, 0.12);
    --glow-a: rgba(58, 98, 232, 0.14); --glow-b: rgba(109, 88, 234, 0.10);
    --panel-solid: #ffffff;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg0: #e8ebf2; --bg1: #f5f6fa;
  --glass: rgba(255, 255, 255, 0.72); --glass-2: rgba(255, 255, 255, 0.92); --glass-3: rgba(20, 30, 60, 0.07);
  --stroke: rgba(20, 30, 60, 0.10); --stroke-soft: rgba(20, 30, 60, 0.06);
  --text: #12161f; --muted: #566074; --faint: #8a93a6;
  --accent: #3a62e8; --accent-2: #6d58ea; --accent-ink: #ffffff; --accent-soft: rgba(58, 98, 232, 0.11);
  --grad: linear-gradient(135deg, #3a62e8 0%, #6d58ea 100%);
  --ok: #12804f; --warn: #9a6200; --bad: #c0223c; --warn-soft: rgba(224, 150, 0, 0.14); --bad-soft: rgba(192, 34, 60, 0.10);
  --shadow: 0 14px 40px rgba(30, 40, 80, 0.12);
  --glow-a: rgba(58, 98, 232, 0.14); --glow-b: rgba(109, 88, 234, 0.10);
  --panel-solid: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.5 var(--font); color: var(--text); letter-spacing: -0.006em;
  background:
    radial-gradient(1100px 560px at 88% -8%, var(--glow-a), transparent 62%),
    radial-gradient(900px 520px at -8% 108%, var(--glow-b), transparent 58%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 30px; line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px 16px; display: flex; flex-direction: column; gap: 4px;
  background: var(--side-bg, var(--glass)); border-right: 1px solid var(--stroke-soft); box-shadow: var(--side-edge, none); backdrop-filter: blur(24px) saturate(1.3); -webkit-backdrop-filter: blur(24px) saturate(1.3);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.mark { width: 34px; height: 34px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; color: var(--accent-ink); box-shadow: 0 6px 18px rgba(124, 164, 255, 0.35); flex: none; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 14px; color: var(--muted); text-decoration: none; font-weight: 550; min-height: 44px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--glass-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(124, 164, 255, 0.22); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.side-foot .small { color: var(--faint); }
.main { min-width: 0; padding: 30px 36px 80px; max-width: 1360px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .sub { color: var(--muted); margin-top: 6px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--glass-2); color: var(--text); border: 1px solid var(--stroke); text-decoration: none; transition: transform .12s, background .15s, filter .15s; white-space: nowrap;
}
.btn:hover { background: var(--glass-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); color: var(--accent-ink); border-color: transparent; box-shadow: 0 8px 22px rgba(124, 164, 255, 0.28); }
.btn.primary:hover { filter: brightness(1.07); background: var(--grad); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(255, 122, 144, 0.4); background: transparent; }
.btn.icon { width: 42px; padding: 0; }
.btn.sm { min-height: 34px; padding: 0 13px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--text); width: 100%; min-height: 44px; padding: 9px 13px; border-radius: var(--radius-sm); border: 1px solid var(--stroke);
  background: var(--glass); transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--glass-2); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 55%, calc(100% - 14px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select option { background: var(--panel-solid); color: var(--text); }
textarea { min-height: 84px; resize: vertical; }
input[type="date"] { min-height: 44px; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--accent); }
.search { position: relative; flex: 1; min-width: 200px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 42px; border-radius: 999px; }

.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; color: var(--muted); font-weight: 550; }
.f .hint { color: var(--faint); font-weight: 450; }

.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--glass); border: 1px solid var(--stroke); flex-wrap: wrap; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 0 15px; min-height: 36px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--grad); color: var(--accent-ink); box-shadow: 0 4px 14px rgba(124, 164, 255, 0.28); }

/* ---------- surfaces ---------- */
.glass { background-color: var(--glass); background-image: var(--sheen, none); border: 1px solid var(--stroke); border-radius: var(--radius); box-shadow: var(--edge, none); backdrop-filter: blur(var(--blur, 20px)) saturate(var(--sat, 1)); -webkit-backdrop-filter: blur(var(--blur, 20px)) saturate(var(--sat, 1)); }
.card { padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.stat .v { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--faint); font-size: 12px; margin-top: 4px; }
.stat.hero .v { font-size: 40px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .spark { position: absolute; right: 14px; bottom: 14px; width: 42%; height: 46px; opacity: .95; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .area { fill: var(--accent); opacity: .14; }

/* ---------- flights list ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.list { overflow: hidden; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 14px 16px; border-bottom: 1px solid var(--stroke-soft); white-space: nowrap; }
td { padding: 0 16px; height: 58px; border-bottom: 1px solid var(--stroke-soft); white-space: nowrap; }
td.n, th.n { text-align: right; }
td.wrap { white-space: normal; max-width: 280px; color: var(--muted); font-size: 13px; line-height: 1.35; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover, tr.click:focus-visible { background: var(--glass-2); outline: none; }
tbody tr:last-child td { border-bottom: 0; }
tr.month td { height: 40px; background: var(--glass); color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
tr.month td span { color: var(--faint); font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 10px; }
td .date { font-weight: 650; } td .year { color: var(--faint); font-size: 12px; margin-left: 6px; }
.route { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .01em; }
.route svg { color: var(--faint); }
.ac b { font-weight: 600; } .ac span { color: var(--faint); margin-left: 8px; font-size: 12px; }
td.time { font-weight: 700; font-size: 15px; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--glass-2); color: var(--muted); border: 1px solid var(--stroke-soft); }
.chip[data-cap="PIC"], .chip[data-cap="SPIC"] { background: var(--accent-soft); color: var(--accent); border-color: rgba(124, 164, 255, 0.25); }
.chip[data-cap="PIC U/S"] { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 74, 0.28); }
.chip[data-cap="P2"], .chip[data-cap="P2X"] { background: rgba(161, 140, 255, 0.16); color: var(--accent-2); border-color: rgba(161, 140, 255, 0.28); }
.chip[data-cap="P U/T"] { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 122, 144, 0.28); }
.chip.fstd { background: rgba(94, 221, 160, 0.12); color: var(--ok); border-color: rgba(94, 221, 160, 0.24); }
.chip.test { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.more { display: flex; justify-content: center; padding: 16px; }

/* ---------- sheet (entry form) ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(4, 6, 12, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; justify-content: flex-end; animation: fade .18s ease; }
.sheet {
  width: min(600px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--panel-solid); border-left: 1px solid var(--stroke);
  box-shadow: var(--shadow); animation: slide .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(16px + env(safe-area-inset-top)) 22px 14px; border-bottom: 1px solid var(--stroke-soft); }
.sheet header h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.sheet .body { flex: 1; overflow-y: auto; padding: 20px 22px 28px; -webkit-overflow-scrolling: touch; }
.sheet footer { display: flex; gap: 10px; align-items: center; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--stroke-soft); background: var(--panel-solid); }
.sheet footer .grow { flex: 1; }
.sect { margin-bottom: 26px; }
.sect > h3 { margin: 0 0 12px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.hintline { margin-top: 10px; color: var(--muted); font-size: 12px; min-height: 18px; }
.capgrid { display: grid; grid-template-columns: 56px repeat(4, minmax(0, 1fr)); gap: 8px; align-items: center; }
.capgrid .hd { font-size: 11px; color: var(--faint); font-weight: 650; text-align: center; }
.capgrid .rl { color: var(--muted); font-weight: 600; font-size: 13px; }
@keyframes slide { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- charts ---------- */
.panel { padding: 20px; }
.panel h2 { display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 span { color: var(--faint); font-weight: 450; font-size: 12px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--stroke-soft); stroke-width: 1; }
.chart .bar rect { fill: var(--accent); opacity: .85; transition: opacity .15s; }
.chart .bar:hover rect { opacity: 1; fill: var(--accent-2); }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.donut .ring-bg { stroke: var(--glass-3); }
.donut .s1 { stroke: var(--accent); } .donut .s2 { stroke: var(--warn); } .donut .s3 { stroke: var(--accent-2); } .donut .s4 { stroke: var(--bad); } .donut .s5 { stroke: var(--ok); }
.donut .centre { fill: var(--text); font-size: 20px; font-weight: 700; font-family: var(--font); }
.donut .sub { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.split { display: grid; grid-template-columns: 170px 1fr; gap: 18px; align-items: center; }
.legend { display: grid; gap: 8px; }
.legend div { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .s1 { background: var(--accent); } .legend .s2 { background: var(--warn); } .legend .s3 { background: var(--accent-2); } .legend .s4 { background: var(--bad); } .legend .s5 { background: var(--ok); }
.legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.hbars { display: grid; gap: 12px; }
.hbar .row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.hbar .row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.hbar .track { height: 8px; border-radius: 999px; background: var(--glass-3); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--grad); }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }

/* ---------- print ---------- */
.authority { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 18px; }
.authority button { text-align: left; display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--stroke); color: var(--text); cursor: pointer; font: inherit; transition: transform .12s, border-color .15s, background .15s; min-height: 76px; }
.authority button:hover { background: var(--glass-2); }
.authority button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 8px 26px rgba(124, 164, 255, 0.16); }
.authority .badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 750; font-size: 14px; letter-spacing: .02em; background: var(--grad); color: var(--accent-ink); flex: none; }
.authority .t { font-weight: 650; } .authority .a { color: var(--muted); font-size: 12px; line-height: 1.3; }
.pdfframe { width: 100%; height: min(78vh, 760px); min-height: 420px; border: 1px solid var(--stroke); border-radius: var(--radius); background: var(--panel-solid); }
.notice { display: flex; gap: 12px; padding: 13px 16px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); margin: 12px 0; font-size: 13.5px; }
.notice svg { flex: none; margin-top: 2px; }
.good { display: flex; gap: 10px; align-items: center; color: var(--ok); font-weight: 600; }
.err { color: var(--bad); } .ok { color: var(--ok); }
.issues { list-style: none; margin: 8px 0 0; padding: 0; max-height: 300px; overflow: auto; }
.issues li { padding: 9px 0; border-bottom: 1px solid var(--stroke-soft); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.issues a { color: var(--accent); cursor: pointer; font-weight: 600; text-decoration: none; }
.issues a:hover { text-decoration: underline; }
details.fold summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 10px; min-height: 36px; }
details.fold summary::-webkit-details-marker { display: none; }
.notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- import / settings ---------- */
.drop { display: grid; place-items: center; gap: 8px; text-align: center; padding: 40px 20px; border: 1.5px dashed var(--stroke); border-radius: var(--radius); background: var(--glass); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
.drop .big { font-size: 16px; font-weight: 650; }
.filelist { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 24px); background: var(--panel-solid); color: var(--text); border: 1px solid var(--stroke); box-shadow: var(--shadow); padding: 12px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .22s; z-index: 60; max-width: 90vw; font-weight: 600; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; border-color: transparent; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--glass-3); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- iPad portrait / small laptop: icon rail ---------- */
@media (max-width: 1080px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .side { padding: 18px 10px; align-items: center; }
  .brand span, .nav a span, .side-foot .small { display: none; }
  .brand { padding: 4px 0 18px; }
  .nav a { width: 48px; height: 48px; padding: 0; justify-content: center; }
  .main { padding: 24px 24px 80px; }
  .cols { grid-template-columns: 1fr; }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .col-hide-md { display: none; }
}

/* ---------- phone: bottom tab bar ---------- */
@media (max-width: 720px) {
  .app { display: block; }
  .side {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 30; flex-direction: row; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--stroke); background: var(--panel-solid); backdrop-filter: none;
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; width: auto; height: auto; min-width: 56px; padding: 7px 8px; font-size: 10.5px; border-radius: 12px; }
  .nav a span { display: block; }
  .main { padding: calc(18px + env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); }
  h1 { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px 15px; } .stat .v { font-size: 24px; } .stat.hero { grid-column: 1 / -1; } .stat.hero .v { font-size: 34px; }
  .g2, .g3, .g4, .g5, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet { width: 100%; border-left: 0; }
  .col-hide-sm { display: none; }
  td { padding: 0 11px; height: 62px; } th { padding: 12px 11px; }
  input, select, textarea { font-size: 16px; }
  .split { grid-template-columns: 1fr; justify-items: center; }
  .toolbar .search { flex-basis: 100%; }
  .head .actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print { .side, .actions, .toolbar { display: none; } body { background: #fff; color: #000; } }

.toolbar select { width: auto; min-width: 150px; }
.toolbar .f { min-width: 150px; }

/* flights hero card: double width on desktop so the trend chart has room */
@media (min-width: 1081px) {
  .stats.wide { grid-template-columns: 1.7fr repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1080px) and (min-width: 721px) {
  .stats.wide .hero { grid-column: 1 / -1; }
}
.stat.hero .spark { width: 40%; height: 54px; top: 50%; bottom: auto; transform: translateY(-50%); }

/* totals: hero spans two columns; vivid amber for chart slices in both themes */
@media (min-width: 1081px) { .stats.span-hero .hero { grid-column: span 2; } }
.stat.hero .v { font-size: clamp(30px, 3.4vw, 42px); white-space: nowrap; }
:root { --chart-2: #fbbf4a; }
@media (prefers-color-scheme: light) { :root:not([data-theme]) { --chart-2: #e8a020; } }
:root[data-theme="light"] { --chart-2: #e8a020; }
.donut .s2 { stroke: var(--chart-2); } .legend .s2 { background: var(--chart-2); }

details.fold summary .chev { margin-left: auto; color: var(--faint); transition: transform .15s; }
details.fold[open] summary .chev { transform: rotate(90deg); }

.hintline + .grid, .hintline + .seg, .seg + .hintline + .grid { margin-top: 14px; }
.sect .grid + .hintline { margin-top: 12px; }

/* phone: keep Date, Route, Capacity and Time all on screen */
@media (max-width: 720px) {
  td .year { display: none; }
  td { padding: 0 8px; } th { padding: 12px 8px; }
  td:first-child, th:first-child { padding-left: 14px; }
  td:last-child, th:last-child { padding-right: 14px; }
  .route { gap: 6px; }
  .chip { padding: 2px 8px; font-size: 11px; }
  td.time { font-size: 15px; }
  .list .tablewrap { overflow-x: visible; }
  tr.month td span { display: block; margin: 2px 0 0; }
  tr.month td { height: auto; padding-top: 8px; padding-bottom: 8px; }
}

.seg { border-radius: 24px; }

@media (max-width: 1080px) {
  .side-foot { padding: 6px 0; }
  .side-foot .btn { width: 44px; padding: 0; }
  .side-foot .btn span { display: none; }
}

/* ---------- login page ---------- */
.loginpage { min-height: 100vh; display: grid; place-items: center; }
.login { width: min(420px, 100%); padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.logincard { padding: 34px 30px 30px; text-align: center; box-shadow: var(--shadow); }
.logincard h1 { font-size: 26px; margin-top: 14px; }
.logincard p { margin: 6px 0 22px; }
.logincard form { display: grid; gap: 14px; text-align: left; }
.mark.big { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto; }
.btn.wide { width: 100%; min-height: 48px; margin-top: 4px; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 10px; margin-top: 2px; }
.linkbtn:hover { color: var(--text); }
#pk { display: grid; gap: 10px; text-align: center; margin-bottom: 4px; }
#pk[hidden], #form[hidden] { display: none; }
.pkrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--stroke-soft); }
.pkrow:first-of-type { border-top: 0; }
.pkrow .grow { flex: 1; min-width: 0; }
.loginmsg { min-height: 20px; color: var(--bad); font-size: 13px; font-weight: 600; text-align: center; }
[hidden] { display: none !important; }

/* ---------- recency ---------- */
.pill { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 16px; border-radius: 999px; text-decoration: none; font-weight: 650; border: 1px solid var(--stroke); background: var(--glass-2); color: var(--text); }
.pill:hover { background: var(--glass-3); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--faint); flex: none; }
.pill.ok .dot, .recrow.ok .dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(94, 221, 160, 0.16); }
.pill.soon .dot, .recrow.soon .dot { background: var(--chart-2); box-shadow: 0 0 0 4px rgba(251, 191, 74, 0.18); }
.pill.expired .dot, .recrow.expired .dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(255, 122, 144, 0.18); }
.pill.soon { border-color: rgba(251, 191, 74, 0.45); } .pill.expired { border-color: rgba(255, 122, 144, 0.5); }
.recency { margin-bottom: 26px; }
.rechead { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.rechead h2 { margin: 0 0 2px; font-size: 18px; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin: 12px 0; }
.rcard { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.rcard.expired { border-color: rgba(255, 122, 144, 0.4); } .rcard.soon { border-color: rgba(251, 191, 74, 0.35); }
.rhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rhead h3 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.chip.st-ok { background: rgba(94, 221, 160, 0.14); color: var(--ok); border-color: rgba(94, 221, 160, 0.3); }
.chip.st-soon { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 74, 0.3); }
.chip.st-expired { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 122, 144, 0.3); }
.recrow .rl { display: flex; align-items: center; gap: 10px; }
.recrow .rn { font-weight: 600; flex: 1; }
.recrow .rd { font-weight: 700; font-variant-numeric: tabular-nums; }
.recrow.expired .rd { color: var(--bad); } .recrow.soon .rd { color: var(--warn); }
.recrow .track { height: 8px; border-radius: 999px; background: var(--glass-3); overflow: hidden; margin: 9px 0 7px; }
.recrow .fill { height: 100%; border-radius: 999px; background: var(--ok); }
.recrow.soon .fill { background: var(--chart-2); } .recrow.expired .fill { background: var(--bad); }
.recrow .rs { font-size: 12.5px; color: var(--muted); line-height: 1.4; } .recrow .rs.faint { color: var(--faint); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.rulebox { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--stroke-soft); }
.rulebox .check { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.rulebox .grid { margin-top: 4px; }

/* =====================================================================================
   PALETTES. Dark and Light are above; "Match system" picks one of them. Each palette below is a set of the
   same tokens plus optional hooks: --texture (a pattern over the page), --sheen (a highlight over panels),
   --edge (an inner edge), --side-bg, --blur/--sat.
   ===================================================================================== */
body::before { content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; background: var(--texture, none); opacity: var(--texture-opacity, 0); }
.app { position: relative; z-index: 1; }

/* ---------- Carbon: black, woven carbon-fibre, graphite panels, orange accent ---------- */
:root[data-theme="carbon"] {
  color-scheme: dark;
  --bg0: #07080a; --bg1: #101215;
  --glass: rgba(255, 255, 255, 0.04); --glass-2: rgba(255, 255, 255, 0.08); --glass-3: rgba(255, 255, 255, 0.13);
  --stroke: rgba(255, 255, 255, 0.11); --stroke-soft: rgba(255, 255, 255, 0.06);
  --text: #eceef1; --muted: #9ba0a9; --faint: #6a707a;
  --accent: #ff8a3d; --accent-2: #ffb25b; --accent-ink: #1c1004; --accent-soft: rgba(255, 138, 61, 0.16);
  --grad: linear-gradient(135deg, #ff8a3d 0%, #ffb25b 100%);
  --ok: #5ee0a0; --warn: #ffcc4d; --bad: #ff6b7f; --warn-soft: rgba(255, 204, 77, 0.13); --bad-soft: rgba(255, 107, 127, 0.15);
  --chart-2: #ffcc4d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
  --glow-a: rgba(255, 138, 61, 0.10); --glow-b: rgba(255, 255, 255, 0.03);
  --panel-solid: #15171a;
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 45%);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1px 3px rgba(0, 0, 0, 0.5);
  --side-bg: rgba(10, 11, 13, 0.82);
  --texture: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 6px), repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.45) 0 2px, transparent 2px 6px);
  --texture-opacity: 1;
}

/* ---------- Aluminium: brushed metal, light, cool grey, steel-blue accent ---------- */
:root[data-theme="aluminium"] {
  color-scheme: light;
  --bg0: #c6ccd3; --bg1: #eef0f3;
  --glass: rgba(255, 255, 255, 0.58); --glass-2: rgba(255, 255, 255, 0.82); --glass-3: rgba(38, 50, 64, 0.09);
  --stroke: rgba(38, 50, 64, 0.26); --stroke-soft: rgba(38, 50, 64, 0.13);
  --text: #19202a; --muted: #4c5663; --faint: #79838f;
  --accent: #2a5f8e; --accent-2: #4a86b8; --accent-ink: #ffffff; --accent-soft: rgba(42, 95, 142, 0.13);
  --grad: linear-gradient(180deg, #4a86b8 0%, #2a5f8e 100%);
  --ok: #13804f; --warn: #8a5800; --bad: #b8213a; --warn-soft: rgba(217, 140, 16, 0.16); --bad-soft: rgba(184, 33, 58, 0.11);
  --chart-2: #d98c10;
  --shadow: 0 14px 34px rgba(28, 40, 56, 0.2);
  --glow-a: rgba(255, 255, 255, 0.85); --glow-b: rgba(110, 126, 142, 0.18);
  --panel-solid: #f3f5f7;
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 38%, rgba(60, 72, 86, 0.07));
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.95), inset 0 -1px 0 rgba(38, 50, 64, 0.09), 0 1px 3px rgba(28, 40, 56, 0.14);
  --side-bg: linear-gradient(180deg, #e4e8ec 0%, #c3cad2 100%);
  --side-edge: inset -1px 0 0 rgba(255, 255, 255, 0.7);
  --texture: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.34) 0 1px, rgba(30, 42, 56, 0.04) 1px 2px, transparent 2px 3px);
  --texture-opacity: 0.6;
}

/* ---------- Glass: frosted translucent panels over a vivid aurora ---------- */
:root[data-theme="glass"] {
  color-scheme: dark;
  --bg0: #0a0e2e; --bg1: #1b1250;
  --glass: rgba(255, 255, 255, 0.13); --glass-2: rgba(255, 255, 255, 0.21); --glass-3: rgba(255, 255, 255, 0.3);
  --stroke: rgba(255, 255, 255, 0.32); --stroke-soft: rgba(255, 255, 255, 0.17);
  --text: #ffffff; --muted: rgba(255, 255, 255, 0.76); --faint: rgba(255, 255, 255, 0.54);
  --accent: #86e6ff; --accent-2: #c9a8ff; --accent-ink: #06152e; --accent-soft: rgba(134, 230, 255, 0.22);
  --grad: linear-gradient(135deg, #86e6ff 0%, #c9a8ff 100%);
  --ok: #7dffc2; --warn: #ffd66e; --bad: #ff8fa6; --warn-soft: rgba(255, 214, 110, 0.18); --bad-soft: rgba(255, 143, 166, 0.2);
  --chart-2: #ffd66e;
  --shadow: 0 20px 60px rgba(8, 4, 40, 0.5);
  --glow-a: rgba(134, 230, 255, 0.3); --glow-b: rgba(255, 130, 200, 0.25);
  --panel-solid: #1d2052;
  --blur: 30px; --sat: 1.8;
  --sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.05) 42%, rgba(255, 255, 255, 0));
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 12px 32px rgba(10, 6, 50, 0.3);
  --side-bg: rgba(255, 255, 255, 0.1);
}
:root[data-theme="glass"] body {
  background:
    radial-gradient(900px 620px at 12% 8%, rgba(255, 98, 190, 0.55), transparent 62%),
    radial-gradient(1000px 700px at 92% 12%, rgba(70, 200, 255, 0.5), transparent 62%),
    radial-gradient(900px 700px at 62% 105%, rgba(140, 90, 255, 0.58), transparent 62%),
    linear-gradient(160deg, #0a0e2e, #1d1252);
  background-attachment: fixed;
}
:root[data-theme="glass"] .sheet { background: rgba(26, 22, 78, 0.6); backdrop-filter: blur(40px) saturate(1.8); -webkit-backdrop-filter: blur(40px) saturate(1.8); }
:root[data-theme="glass"] .stat.hero .v { filter: drop-shadow(0 2px 12px rgba(134, 230, 255, 0.35)); }

/* panels in the metal and carbon palettes read better with a firmer edge on inputs and buttons */
:root[data-theme="aluminium"] input, :root[data-theme="aluminium"] select, :root[data-theme="aluminium"] textarea { background-color: rgba(255, 255, 255, 0.75); box-shadow: inset 0 1px 2px rgba(28, 40, 56, 0.12); }
:root[data-theme="aluminium"] .btn { box-shadow: var(--edge); }
:root[data-theme="carbon"] .btn.primary, :root[data-theme="aluminium"] .btn.primary { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); }

/* ---------- the palette picker (Settings) ---------- */
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.themecard { appearance: none; text-align: left; font: inherit; color: var(--text); cursor: pointer; padding: 10px; border-radius: 16px; background: var(--glass); border: 1.5px solid var(--stroke); display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .12s; }
.themecard:hover { background: var(--glass-2); }
.themecard:active { transform: scale(.98); }
.themecard[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.themecard b { font-weight: 650; display: block; } .themecard span.d { font-size: 12px; color: var(--muted); }
.pv { height: 78px; border-radius: 11px; position: relative; overflow: hidden; border: 1px solid rgba(128, 128, 128, 0.3); }
.pv i { position: absolute; display: block; border-radius: 4px; }
.pv .s { left: 6px; top: 6px; bottom: 6px; width: 22px; }
.pv .c1 { left: 36px; top: 8px; right: 8px; height: 20px; }
.pv .c2 { left: 36px; top: 34px; width: 38px; bottom: 8px; }
.pv .c3 { left: 80px; top: 34px; right: 8px; bottom: 8px; }
.pv-auto { background: linear-gradient(135deg, #eef0f5 50%, #0c0f15 50%); }
.pv-auto i { background: rgba(110, 120, 150, 0.45); }
.pv-dark { background: linear-gradient(160deg, #090b10, #151a26); } .pv-dark i { background: rgba(255, 255, 255, 0.1); } .pv-dark .c1 { background: linear-gradient(135deg, #7ca4ff, #a18cff); }
.pv-light { background: linear-gradient(160deg, #e8ebf2, #f7f8fb); } .pv-light i { background: rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(20, 30, 60, 0.12); } .pv-light .c1 { background: linear-gradient(135deg, #3a62e8, #6d58ea); box-shadow: none; }
.pv-aluminium { background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.4) 0 1px, rgba(30, 42, 56, 0.05) 1px 2px), linear-gradient(180deg, #e6e9ed, #bcc3cb); }
.pv-aluminium i { background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(214, 220, 227, 0.9)); box-shadow: 0 0 0 1px rgba(38, 50, 64, 0.25); } .pv-aluminium .c1 { background: linear-gradient(180deg, #4a86b8, #2a5f8e); box-shadow: none; }
.pv-carbon { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 5px), repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.5) 0 2px, transparent 2px 5px), #0b0c0e; }
.pv-carbon i { background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); } .pv-carbon .c1 { background: linear-gradient(135deg, #ff8a3d, #ffb25b); box-shadow: none; }
.pv-glass { background: radial-gradient(60px 50px at 15% 15%, rgba(255, 98, 190, 0.85), transparent 70%), radial-gradient(70px 55px at 90% 20%, rgba(70, 200, 255, 0.8), transparent 70%), radial-gradient(70px 60px at 60% 105%, rgba(140, 90, 255, 0.85), transparent 70%), #1b1250; }
.pv-glass i { background: rgba(255, 255, 255, 0.22); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5); } .pv-glass .c1 { background: linear-gradient(135deg, #86e6ff, #c9a8ff); box-shadow: none; }
