/* Smart Pilot: mobile first, cockpit-grounded.
   Type: B612 / B612 Mono (Airbus cockpit display face).
   Colour follows avionics semantics, not decoration:
     magenta  = the active route (ND / FMS), used only for the route line and profile
     red / amber / cyan = warning / caution / advisory (EICAS), green = done
   Day: chart paper. Night (device dark mode): dim navy for the cockpit at night. */

:root {
  --paper: #f3f5f6; --surface: #ffffff; --sunk: #eaeef1;
  --ink: #13203a; --ink-2: #4b5870; --ink-3: #7d889b; --rule: #d9dfe6;
  --magenta: #b8166f; --cyan: #0a7895; --amber: #a85a00; --red: #bb2a1e; --green: #1d7a4b;
  --cyan-bg: #e2f2f6; --amber-bg: #fdf1dc; --red-bg: #fbe8e5; --green-bg: #e3f3ea;
  --on-ink: #ffffff;
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --gutter: 16px; --shell: 480px;
  --font: "B612", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "B612 Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #09111f; --surface: #101b2e; --sunk: #0c1626;
    --ink: #e6edf7; --ink-2: #a3b0c5; --ink-3: #6f7d95; --rule: #213049;
    --magenta: #f160bb; --cyan: #56cbe9; --amber: #f3b443; --red: #ff6f61; --green: #52d08d;
    --cyan-bg: rgba(86, 203, 233, .12); --amber-bg: rgba(243, 180, 67, .12);
    --red-bg: rgba(255, 111, 97, .13); --green-bg: rgba(82, 208, 141, .12);
    --on-ink: #09111f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --paper: #09111f; --surface: #101b2e; --sunk: #0c1626;
    --ink: #e6edf7; --ink-2: #a3b0c5; --ink-3: #6f7d95; --rule: #213049;
    --magenta: #f160bb; --cyan: #56cbe9; --amber: #f3b443; --red: #ff6f61; --green: #52d08d;
    --cyan-bg: rgba(86, 203, 233, .12); --amber-bg: rgba(243, 180, 67, .12);
    --red-bg: rgba(255, 111, 97, .13); --green-bg: rgba(82, 208, 141, .12);
    --on-ink: #09111f;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
.shell { max-width: var(--shell); margin: 0 auto; background: var(--paper); min-height: 100vh; }
.shell.wide { max-width: 1240px; }
@media (min-width: 560px) {
  /* Desktop shows the phone column, so what is tested is what a pilot gets */
  body { background: var(--sunk); }
  .shell { border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
}
main { padding: 16px var(--gutter) 24px; }
a { color: var(--cyan); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
h1, h2, h3 { font-weight: 700; letter-spacing: -.01em; }

/* --- Top bar + account menu ------------------------------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: env(safe-area-inset-top) 8px 0 var(--gutter);
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
header.top h1 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
header.top h1 picture { display: flex; }
header.top h1 img.brand { height: 26px; width: auto; }
header.top .back {
  border: 0; background: none; color: var(--ink); min-height: 44px; min-width: 44px; padding: 0;
  font: 700 22px/1 var(--font); cursor: pointer; margin-left: -10px;
}
.account { margin-left: auto; position: relative; }
.account summary {
  list-style: none; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font: 700 14px var(--mono); text-transform: uppercase;
}
.account summary::-webkit-details-marker { display: none; }
.account .menu {
  position: absolute; right: 0; top: 48px; min-width: 210px; padding: 6px; z-index: 20;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(9, 17, 31, .18);
}
.account .menu .who-name { padding: 10px 12px 8px; font-size: 13px; color: var(--ink-2); border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
.account .menu .who-name strong { display: block; color: var(--ink); font-size: 15px; }
.account .menu a, .account .menu button {
  display: flex; width: 100%; align-items: center; min-height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--ink); font: 15px var(--font); text-decoration: none; cursor: pointer; text-align: left;
}
.account .menu a:hover, .account .menu button:hover { background: var(--sunk); }

/* --- Theme switcher (next to the account) ------------------------------------------------- */
.theme {
  margin-left: auto; flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--rule); color: var(--ink); background: var(--surface); cursor: pointer;
}
.theme:hover { background: var(--sunk); }
.theme + .account { margin-left: 6px; }

/* --- The route line: the one signature element ----------------------------------------- */
.leg { position: relative; flex: 1; height: 18px; min-width: 40px; }
.leg::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2.5px; margin-top: -1.25px;
  background: var(--magenta); border-radius: 2px;
}
.leg i { /* a waypoint: the ND's triangle */
  position: absolute; top: 50%; width: 0; height: 0; transform: translate(-50%, -62%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--magenta);
}
.leg.reading i { left: 0; animation: fly 2.4s cubic-bezier(.45, 0, .25, 1) infinite; border-bottom-width: 10px; border-left-width: 6px; border-right-width: 6px; }
@keyframes fly { from { left: 0; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .leg.reading i { animation: none; left: 50%; } }

.route { display: flex; align-items: center; gap: 12px; }
.route .apt { font: 700 30px/1 var(--mono); letter-spacing: .02em; }

/* --- Surfaces ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px 16px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--ink); }
.card h2 .count { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 18px 0 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.facts dd { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* --- Buttons and the thumb bar ---------------------------------------------------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px;
  border: 0; border-radius: 14px; background: var(--ink); color: var(--on-ink);
  font: 700 16px/1 var(--font); text-decoration: none; cursor: pointer; transition: transform .08s ease;
}
.btn:active { transform: scale(.985); }
.btn.secondary { background: var(--sunk); color: var(--ink); border: 1px solid var(--rule); }
.btn:disabled { background: var(--sunk); color: var(--ink-3); cursor: not-allowed; transform: none; }
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--rule);
}
.actionbar .inner { max-width: calc(var(--shell) - 2 * var(--gutter)); margin: 0 auto; }
.actionbar .hint { font-size: 12px; color: var(--ink-3); text-align: center; margin: 0 0 8px; }

/* --- Home ---------------------------------------------------------------------- */
.hero h2 { font-size: 26px; line-height: 1.2; margin: 8px 0 8px; }
.hero p { margin: 0 0 18px; color: var(--ink-2); }
.drop {
  display: flex; flex-direction: column; gap: 14px; padding: 22px 18px; cursor: pointer;
  background: var(--surface); border: 1.5px dashed var(--rule); border-radius: var(--r-lg);
}
.drop.over { border-color: var(--magenta); background: color-mix(in srgb, var(--magenta) 6%, var(--surface)); }
.drop .route .apt { font-size: 20px; color: var(--ink-3); }
.drop strong { font-size: 18px; }
.drop span.muted { font-size: 14px; }
.list .row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--rule); }
.list .row:last-child { border-bottom: 0; }
.list .row > a {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 0;
  color: inherit; text-decoration: none;
}
.list .route { flex: 1; gap: 8px; }
.list .route .apt { font-size: 16px; }
.list .route .leg { max-width: 72px; }
.list .meta { font-size: 12px; color: var(--ink-3); }

/* --- Product headers: title, built time (UTC), rebuild ----------------------------------------- */
.part-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.part-title { display: grid; gap: 2px; min-width: 0; }
.part-title h2 { margin: 0; }
.rebuild-all { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; padding: 0 4px; }
.rebuild-all.busy { flex-wrap: wrap; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.steps li {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink-3); font: 700 12px var(--font);
}
.steps .mark { display: inline-grid; place-items: center; min-width: 16px; font: 700 13px var(--mono); }
.steps li.running { color: var(--ink); border-color: var(--cyan); }
.steps li.done { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, var(--rule)); }
.steps li.failed { color: var(--red); border-color: var(--red); }
.xs-head { margin-bottom: 8px; }
.xs-head .part-head { margin-bottom: 0; }
.xs-head .sb-busy { margin: 12px 0 0; }

/* --- Cross section (EFB viewer): the card gives it the full width of the column ------------- */
.xs-card { padding: 4px; overflow: hidden; min-width: 0; }
/* the viewer scrolls its own chart sideways on a phone: it must not widen the column */
#xs-mount, #xs-mount .cross-section-viewer-root, #xs-mount .cross-section-viewer { min-width: 0; max-width: 100%; }
/* Wider than a phone (desktop, tablet, later the app in landscape): the chart leaves the phone column and
   takes the width of the screen, centred under it; the rest of the page stays in the column */
@media (min-width: 560px) {
  .xs-card { width: min(1600px, calc(100vw - 48px)); position: relative; left: 50%; transform: translateX(-50%); }
}
.xs-card .card.center { border: 0; padding: 30px 0; }

/* --- Smart Briefing -------------------------------------------------------------------------- */
.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sb-head h2 { margin: 0; }
.sb-update {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--rule);
  border-radius: 999px; background: var(--sunk); color: var(--ink); font: 700 14px var(--font); cursor: pointer;
}
.sb-update:disabled { cursor: default; color: var(--ink-2); }
.sb-meta { margin: -6px 0 12px; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; flex: none; }
.sb-busy { display: flex; align-items: center; gap: 10px; }
/* the previous briefing stays readable while the new one is written, dimmed */
.sb.is-busy .sb-headline, .sb.is-busy .sb-points, .sb.is-busy .sb-player { opacity: .45; transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.sb-player { display: flex; align-items: center; gap: 12px; padding: 10px; margin-bottom: 14px; border-radius: var(--r-md); background: var(--sunk); }
.sb-play {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--ink); color: var(--on-ink); font: 700 15px var(--font); cursor: pointer; flex: none;
}
.sb-now { display: grid; min-width: 0; }
.sb-stop { margin-left: auto; flex: none; }
.sb-now strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-headline { font-size: 18px; line-height: 1.4; margin: 0 0 14px; }
.sb-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 6px; font-weight: 700; }
.sb-points { list-style: none; margin: 0; padding: 0; }
.sb-points li {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 10px 0 10px 12px;
  border-bottom: 1px solid var(--rule); box-shadow: inset 3px 0 0 var(--c, var(--rule)); font-size: 15px;
}
.sb-points li:last-child { border-bottom: 0; }
.sb-points li.critical { --c: var(--red); } .sb-points li.warning { --c: var(--amber); } .sb-points li.info { --c: var(--cyan); }
.sb-tag { padding: 2px 8px; border-radius: 4px; font: 700 11px var(--font); text-transform: capitalize; white-space: nowrap; margin-top: 2px; }
.sb-tag.critical { background: var(--red); color: #fff; }
.sb-tag.warning { background: var(--amber-bg); color: var(--amber); }
.sb-tag.info { background: var(--cyan-bg); color: var(--cyan); }
.sb-sources { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sb-sources span, .sb-sources button {
  padding: 2px 8px; border: 1px solid var(--rule); border-radius: 6px; font: 12px/1.35 var(--font); color: var(--ink-2); background: none;
}
.sb-sources button { cursor: pointer; font-weight: 700; color: var(--cyan); min-height: 24px; }
.sb-note { margin: 10px 0 0; }
/* Spoken parts: one row each, opened on tap; the part being read opens and is marked */
.sb-part { border-top: 1px solid var(--rule); }
.sb-part:first-child { border-top: 0; }
.sb-part summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; cursor: pointer; font-weight: 700; font-size: 15px; list-style: none; }
.sb-part summary::-webkit-details-marker { display: none; }
.sb-part summary > span::before { content: "›"; display: inline-block; width: 16px; color: var(--ink-3); transition: transform .15s; }
.sb-part[open] summary > span::before { transform: rotate(90deg); }
.sb-part summary .linkish { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; min-height: 40px; }
.sb-part.reading { box-shadow: inset 3px 0 0 var(--cyan); padding-left: 10px; }
.sb-part p { margin: 0 0 12px 16px; font-size: 15px; line-height: 1.55; }
/* Section bar of the Briefing tab: outside the cards, edge to edge of the page, pinned under the header */
.nb-phases-bar.sb-nav {
  margin: 0 calc(-1 * var(--gutter)) 12px; top: calc(56px + env(safe-area-inset-top));
  /* solid, in the page colour: the text scrolling under it is hidden, not seen through the tabs */
  background: var(--paper); backdrop-filter: none; box-shadow: 0 8px 12px -10px rgba(0, 0, 0, .55);
}
.sb-nav .hs-prev { background: linear-gradient(to right, var(--paper) 55%, transparent); }
.sb-nav .hs-next { background: linear-gradient(to left, var(--paper) 55%, transparent); }
.sb-nav .nb-phases { padding: 8px var(--gutter); }
.sb-sec { min-height: 40vh; }
.sb-sec.is-busy { opacity: .45; transition: opacity .2s; }
.sb-apt { padding: 10px 0; border-top: 1px solid var(--rule); }
.sb-apt:first-of-type { border-top: 0; padding-top: 0; }
.sb-apt-head { display: flex; align-items: center; gap: 8px; }
.sb-apt-head .mono { font-weight: 700; font-size: 15px; }
.sb-cat { margin-left: auto; padding: 1px 8px; border-radius: 4px; font: 700 11px var(--mono); background: var(--green-bg); color: var(--green); }
.sb-cat.MVFR { background: var(--cyan-bg); color: var(--cyan); }
.sb-cat.IFR, .sb-cat.LIFR { background: var(--red-bg); color: var(--red); }
.sb-apt pre { white-space: pre-wrap; font: 12px/1.5 var(--mono); margin: 6px 0 0; color: var(--ink-2); }

/* --- Date picker (inline calendar) --------------------------------------------------------- */
.dp { position: relative; }
.dp-field {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 46px; margin-top: 4px;
  padding: 0 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--sunk); color: var(--ink);
  font: 16px var(--font); font-variant-numeric: tabular-nums; cursor: pointer; text-align: left;
}
.dp-field svg { color: var(--ink-3); flex: none; }
.dp-field[aria-expanded="true"] { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-bg); }
.dp-pop {
  margin-top: 8px; padding: 12px; border: 1px solid var(--rule); border-radius: var(--r-md);
  background: var(--surface); box-shadow: 0 10px 28px rgba(9, 17, 31, .14);
}
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-head strong { font-size: 15px; }
.dp-nav {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--ink);
  font: 400 26px/1 var(--font); cursor: pointer;
}
.dp-nav:hover { background: var(--sunk); }
.dp-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.dp-wd { text-align: center; font-size: 12px; color: var(--ink-3); padding: 4px 0; }
.dp-day {
  height: 44px; border: 0; border-radius: 50%; background: none; color: var(--ink);
  font: 15px var(--mono); cursor: pointer; aspect-ratio: 1; justify-self: center; width: 100%; max-width: 44px;
}
.dp-day:hover { background: var(--sunk); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.dp-day.sel { background: var(--cyan); color: #fff; font-weight: 700; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dp-day.sel { color: var(--on-ink); }
  :root:not([data-theme="light"]) .dp-pop { box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }
}
:root[data-theme="dark"] .dp-day.sel { color: var(--on-ink); }
:root[data-theme="dark"] .dp-pop { box-shadow: 0 10px 28px rgba(0, 0, 0, .45); }
.dp-foot { display: flex; justify-content: space-between; margin-top: 4px; }

/* --- Page choice (step 2) ------------------------------------------------------------------- */
.pages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pg { position: relative; }
.pg-pick {
  position: relative; display: block; width: 100%; aspect-ratio: 210 / 297; padding: 0; overflow: hidden; cursor: pointer;
  border: 2px solid var(--rule); border-radius: var(--r-sm); background: #fff;
}
.pg-pick img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; opacity: .45; transition: opacity .12s; }
.pg-pick[aria-pressed="true"] { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan); }
.pg-pick[aria-pressed="true"] img { opacity: 1; }
.pg-n { position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: 6px; background: var(--ink); color: var(--on-ink); font: 700 12px var(--font); }
.pg-tick {
  position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; display: none; place-items: center;
  background: var(--cyan); color: #fff; font: 700 13px var(--font);
}
.pg-pick[aria-pressed="true"] .pg-tick { display: grid; }
.pg-flag { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 6px; background: var(--amber-bg); color: var(--amber); font: 700 11px var(--font); }
.pg-zoom {
  position: absolute; right: 4px; bottom: 4px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink); box-shadow: 0 1px 4px rgba(9, 17, 31, .25);
}
.linkish { border: 0; background: none; padding: 0; min-height: 40px; color: var(--cyan); font: 700 14px var(--font); cursor: pointer; }

/* --- Delete (two taps) ---------------------------------------------------------------- */
.del {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; min-height: 44px;
  padding: 0 10px; border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--ink-3);
  font: 700 13px var(--font); cursor: pointer; flex: none;
}
.del:hover { color: var(--red); }
.del.armed { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.del.wide { width: 100%; border-color: var(--rule); color: var(--red); font-size: 15px; }
.danger-zone { margin-top: 20px; text-align: center; }
.danger-zone p { margin: 6px 0 0; }

/* --- Alerts (EICAS colours) ---------------------------------------------------------- */
.issue { border-radius: var(--r-sm); padding: 10px 12px 10px 14px; margin: 0 0 8px; font-size: 14px; border-left: 4px solid; }
.issue.error { background: var(--red-bg); border-color: var(--red); color: var(--ink); }
.issue.warning { background: var(--amber-bg); border-color: var(--amber); color: var(--ink); }
.notice { background: var(--cyan-bg); border-left: 4px solid var(--cyan); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
details.cautions summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--amber); font-weight: 700; font-size: 14px; }

/* --- Fields ---------------------------------------------------------------------- */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.fields .full { grid-column: 1 / -1; }
.fields label { font-size: 12px; color: var(--ink-3); }
.fields input, .fields select {
  width: 100%; min-height: 46px; margin-top: 4px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--sunk); color: var(--ink); font: 16px var(--font); font-variant-numeric: tabular-nums;
}
.fields input.code { font-family: var(--mono); }
.fields input:focus, .fields select:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 0 3px var(--cyan-bg); }

/* --- Waypoint list ------------------------------------------------------------------ */
.wps { width: 100%; border-collapse: collapse; font-size: 14px; }
.wps th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 400; padding: 0 4px 8px; }
.wps td { padding: 10px 4px; border-top: 1px solid var(--rule); vertical-align: top; font-variant-numeric: tabular-nums; }
.wps td.num, .wps th.num { text-align: right; white-space: nowrap; }
.wps .id { font: 700 15px var(--mono); }
.wps .co { display: block; font: 11px var(--mono); color: var(--ink-3); margin-top: 2px; }
.est { color: var(--ink-3); font-style: italic; }
.scroll-x { overflow-x: auto; }

/* --- Tabs (segmented) and status -------------------------------------------------------- */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; background: var(--sunk); padding: 4px; border-radius: 14px; border: 1px solid var(--rule); }
.tabs button {
  flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: none; color: var(--ink-2);
  font: 700 14px var(--font); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(9, 17, 31, .12); }
.tabs button:disabled { opacity: .4; cursor: not-allowed; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.running { background: var(--cyan-bg); color: var(--cyan); }
.pill.done { background: var(--green-bg); color: var(--green); }
.pill.failed { background: var(--red-bg); color: var(--red); }
.pill.parsed { background: var(--amber-bg); color: var(--amber); }

/* --- NOTAMs ---------------------------------------------------------------------- */
/* --- NOTAM phases as tabs, pinned under the page header while the list scrolls ------------- */
.nb-phases-bar {
  position: sticky; top: 56px; z-index: 5; margin: 0 -16px 10px;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule);
}
.nb-phases { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 8px 16px; }
.nb-phases::-webkit-scrollbar { display: none; }
/* Horizontal scroller: mouse drag + arrows, shown only on the side that has more tabs */
.hs { position: relative; }
/* a pinned bar stays sticky (sticky also anchors the arrows): relative would shift it down by its top offset */
.hs.nb-phases-bar { position: sticky; }
.hs-row.dragging { cursor: grabbing; user-select: none; }
.hs-row.dragging button { pointer-events: none; }
.hs-btn {
  position: absolute; top: 0; bottom: 0; z-index: 1; width: 44px; display: grid; place-items: center; padding: 0;
  border: 0; color: var(--ink); font: 700 22px/1 var(--font); cursor: pointer;
}
.hs-btn[hidden] { display: none; }
.hs-prev { left: 0; background: linear-gradient(to right, var(--surface) 55%, transparent); justify-items: start; padding-left: 8px; }
.hs-next { right: 0; background: linear-gradient(to left, var(--surface) 55%, transparent); justify-items: end; padding-right: 8px; }
.hs-btn:hover { color: var(--c-brand); }
.nb-phases button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink-2);
  font: 700 13px var(--font); cursor: pointer;
}
.nb-phases button[aria-selected="true"] { border-color: var(--c-brand); color: var(--ink); background: var(--nb-tint); box-shadow: inset 0 0 0 1px var(--c-brand); }
.nb-phases .n { font: 12px var(--mono); color: var(--ink-3); }
.nb-phases .flag { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--c-high); color: #fff; font: 700 11px/18px var(--mono); text-align: center; }
.nb .nb-note { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nb .nb-item.open .nb-note { -webkit-line-clamp: unset; }
.nb .nb-strip { padding-top: 10px; }
.nb .nb-tally { margin-top: 0; }

/* --- NOTAM briefing: the EFB NOTAM Briefing tab, as a phone list ---------------------------------
   Severity colours are the EFB's (critical red, high orange, medium yellow, low grey), so a crew reads
   the same colour for the same NOTAM in both. */
.nb, .sb-nav { --c-crit: #d63031; --c-high: #f08c00; --c-med: #e6b800; --c-low: #7f8fa6; --c-brand: #0f75bc; --nb-tint: #eef5fb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nb, :root:not([data-theme="light"]) .sb-nav { --c-brand: #4ea3e0; --nb-tint: #0f2238; }
}
:root[data-theme="dark"] .nb, :root[data-theme="dark"] .sb-nav { --c-brand: #4ea3e0; --nb-tint: #0f2238; }
.nb-strip { background: var(--nb-tint); border-left: 4px solid var(--c-brand); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 14px 14px 12px; margin: 0 0 12px; }
.card h2.nb-title { margin: 0; font-size: 20px; letter-spacing: -.2px; }
.nb-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.nb-tally { margin: 12px 0 6px; color: var(--ink-2); font-size: 14px; }
.nb-tally strong { font: 700 18px var(--mono); color: var(--ink); }
.nb-tally strong:first-child { color: var(--c-brand); font-size: 24px; }
.nb-mix { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--rule); }
.nb-seg { flex-basis: 0; min-width: 4px; }
.nb-seg.critical { background: var(--c-crit); } .nb-seg.high { background: var(--c-high); }
.nb-seg.medium { background: var(--c-med); } .nb-seg.low { background: var(--c-low); }
.nb-seg.unrated { background: repeating-linear-gradient(45deg, #bfc9d4 0 3px, transparent 3px 6px); }
.nb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.nb-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink);
  font: 700 13px var(--font); cursor: pointer;
}
.nb-chip strong { font-family: var(--mono); color: var(--ink-3); }
.nb-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.nb-chip .area { width: 14px; height: 9px; border: 2px solid var(--c-crit); background: rgba(214, 48, 49, .2); }
.nb-chip.critical, .nb-chip.crossed { --c: var(--c-crit); } .nb-chip.high { --c: var(--c-high); }
.nb-chip.medium { --c: var(--c-med); } .nb-chip.low { --c: var(--c-low); }
.nb-chip[aria-pressed="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); background: var(--nb-tint); }
.nb-chip[aria-pressed="true"] strong { color: var(--ink); }
.nb-chip.dim { opacity: .45; }
.nb-ai { margin: 0 0 12px; padding: 8px 12px; font-size: 13px; background: var(--amber-bg); border-left: 3px solid #ffbb44; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.nb-search { display: block; margin: 0 0 14px; }
.nb-search input {
  width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--sunk); color: var(--ink); font: 16px var(--font);
}
.nb-search input:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--nb-tint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nb-section { margin-bottom: 20px; }
.nb-sec-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; padding: 6px 0; border-bottom: 2px solid var(--c-brand); font-size: 15px; }
.nb-sec-title .codes { font: 700 13px var(--mono); color: var(--c-brand); }
.nb-sec-title .minis { display: inline-flex; gap: 4px; margin-left: auto; }
.nb-sec-title .n { font: 11px var(--mono); color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px; padding: 0 6px; }
.nb-mini { min-width: 22px; padding: 0 5px; border-radius: 3px; text-align: center; font: 700 11px/18px var(--mono); }
.nb-item { --c: #d0d4dc; border-bottom: 1px solid var(--rule); box-shadow: inset 4px 0 0 var(--c); }
.nb-item.critical { --c: var(--c-crit); background: rgba(214, 48, 49, .05); } .nb-item.high { --c: var(--c-high); }
.nb-item.medium { --c: var(--c-med); } .nb-item.low { --c: var(--c-low); }
.nb-item.open { background: var(--nb-tint); }
.nb-row {
  display: grid; gap: 4px; width: 100%; padding: 10px 8px 10px 14px; border: 0; background: none;
  color: var(--ink); font: 14px/1.45 var(--font); text-align: left; cursor: pointer;
}
.nb-top { display: flex; align-items: center; gap: 8px; }
.nb-badge { padding: 2px 8px; border-radius: 4px; font: 700 11px var(--font); white-space: nowrap; }
.nb-badge.critical, .nb-mini.critical { background: var(--c-crit); color: #fff; }
.nb-badge.high, .nb-mini.high { background: var(--c-high); color: #fff; }
.nb-badge.medium, .nb-mini.medium { background: #ffe9a8; color: #6b5300; }
.nb-badge.low, .nb-mini.low { background: #e4e8ef; color: #4b5563; }
.nb-badge.unrated { background: var(--sunk); color: var(--ink-3); border: 1px dashed var(--rule); }
.nb-num { font: 700 13px var(--mono); color: var(--c-brand); white-space: nowrap; }
.nb-icao { font-size: 12px; color: var(--ink-3); }
.nb-eta { margin-left: auto; font: 700 13px var(--mono); }
.nb-where { font-size: 13px; color: var(--ink-2); }
.nb-where.crosses { color: var(--c-crit); font-weight: 700; }
.nb-meta { display: flex; flex-wrap: wrap; gap: 2px 18px; font: 12px var(--mono); }
.nb-meta em { font: 11px var(--font); color: var(--ink-3); margin-right: 4px; font-style: normal; }
.nb-floor { font-size: 12px; font-style: italic; color: var(--ink-3); }
.nb-detail { padding: 0 8px 12px 14px; }
.nb-detail .nb-meta { margin-bottom: 8px; }
.nb-raw {
  margin: 0; padding: 8px 10px; max-height: 260px; overflow-y: auto; white-space: pre-wrap;
  font: 12px/1.5 var(--mono); background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
}
.nb-empty { color: var(--ink-2); text-align: center; padding: 16px 0; margin: 0; }
.nb-excluded { border-top: 1px solid var(--rule); padding-top: 6px; }
.nb-excluded .linkish { text-align: left; }
.nb-excluded ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.nb-excluded li { padding: 8px 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nb-badge.medium, :root:not([data-theme="light"]) .nb-mini.medium { background: rgba(230, 184, 0, .2); color: #f0c674; }
  :root:not([data-theme="light"]) .nb-badge.low, :root:not([data-theme="light"]) .nb-mini.low { background: #1b2e4b; color: #bfc9d4; }
  :root:not([data-theme="light"]) .nb-item.critical { background: rgba(214, 48, 49, .08); }
}
:root[data-theme="dark"] .nb-badge.medium, :root[data-theme="dark"] .nb-mini.medium { background: rgba(230, 184, 0, .2); color: #f0c674; }
:root[data-theme="dark"] .nb-badge.low, :root[data-theme="dark"] .nb-mini.low { background: #1b2e4b; color: #bfc9d4; }
:root[data-theme="dark"] .nb-item.critical { background: rgba(214, 48, 49, .08); }

/* --- Waiting ----------------------------------------------------------------------- */
.center { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 8px; text-align: center; }
.center .route { width: 100%; max-width: 320px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--rule); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* --- Profile chart ------------------------------------------------------------------- */
svg.profile { width: 100%; height: auto; display: block; }
svg.profile .ground { fill: var(--ink-3); }
svg.profile .path { fill: none; stroke: var(--magenta); stroke-width: 2.5; stroke-linejoin: round; }
svg.profile .pt { fill: var(--magenta); }
svg.profile text { fill: var(--ink-3); font-size: 10px; font-family: var(--mono); }
svg.profile .grid { stroke: var(--rule); stroke-width: 1; }

/* --- Login ----------------------------------------------------------------------- */
.login { padding: calc(56px + env(safe-area-inset-top)) var(--gutter) 24px; }
.login img.logo { width: 120px; height: auto; display: block; }
.login h1 { font-size: 30px; margin: 20px 0 10px; }
.login > p { margin: 0 0 24px; color: var(--ink-2); }
.login .route .apt { font-size: 18px; color: var(--ink-3); }

/* --- Provider choice (radio cards) --------------------------------------------------- */
.choice { display: grid; gap: 10px; }
h3.sub { margin: 18px 0 8px; font-size: 13px; color: var(--ink-3); }
.choice label.opt {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; align-items: start; padding: 14px;
  border: 1.5px solid var(--rule); border-radius: var(--r-md); background: var(--sunk); cursor: pointer;
}
.choice label.opt:has(input:checked) { border-color: var(--cyan); background: var(--cyan-bg); }
.choice label.opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.choice input[type=radio] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--cyan); }
.choice .name { font-weight: 700; }
.choice .desc { grid-column: 2 / -1; font-size: 13px; color: var(--ink-2); }
.choice .model { grid-column: 2 / -1; margin-top: 8px; }
.choice .model select, .choice .model input {
  width: 100%; min-height: 44px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 15px var(--font);
}
.choice .model input { font-family: var(--mono); font-size: 14px; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--sunk); color: var(--ink-2); border: 1px solid var(--rule); }

/* --- Admin ------------------------------------------------------------------------ */
/* Two columns always: the page is the phone column, whatever the window width */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 14px; }
.kpi span { display: block; font-size: 12px; color: var(--ink-3); }
.kpi strong { display: block; font: 700 22px/1.3 var(--font); font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 96px; border-bottom: 1px solid var(--rule); }
.bars div { flex: 1; background: var(--cyan); border-radius: 2px 2px 0 0; }
.bars div.zero { background: var(--rule); height: 2px !important; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head h2 { margin: 0; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--rule); border-radius: 999px; background: var(--sunk); }
.seg button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--ink-2); font: 700 13px var(--font); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(9, 17, 31, .15); }
/* Main card switch: flight summary / pages of the uploaded OFP */
.card-switch { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.ofp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ofp-pages { display: grid; gap: 14px; max-height: 75vh; overflow-y: auto; overscroll-behavior: contain; }
.ofp-pages figure { margin: 0; }
.ofp-pages img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--rule); border-radius: 8px; }
.ofp-pages figcaption { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.big { font: 700 26px/1.2 var(--font); font-variant-numeric: tabular-nums; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.data th { color: var(--ink-3); font-weight: 400; font-size: 12px; }
table.data td.num, table.data th.num { text-align: right; }
.bad { color: var(--red); }

/* --- Model filter chips and selectable rows ---------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips button {
  min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink-2); font: 700 13px var(--font); cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
table.data tr.pick { cursor: pointer; }
table.data tr.pick:hover td { background: var(--sunk); }
table.data tr.pick.on td { background: var(--cyan-bg); }

/* --- Admin on a desktop browser: parameters left (stays in view), costs right ------------------------ */
@media (min-width: 900px) {
  .admin.shell { border: 0; background: var(--sunk); }
  .admin header.top { padding-left: 24px; padding-right: 16px; }
  .admin main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; padding: 24px; }
  .admin #params { position: sticky; top: 80px; }
  .admin .kpis { grid-template-columns: repeat(4, 1fr); }
  .admin .bars { height: 140px; }
}
