/* ==========================================================================
   MTO Planning — the UI
   Vertical, phone-first. Light and dark (bluish) themes.
   ========================================================================== */

*,*::before,*::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html,body { margin: 0; padding: 0; }

/* --- design tokens ------------------------------------------------------- */

:root {
  --surface:        #F4F6F8;
  --surface-quiet:  #E8ECF0;
  --card:           #FFFFFF;
  --card-mad:       #EEF1F5;
  --card-sub:       #F8FAFC;
  --ink:            #0F172A;
  --ink-dim:        #334155;
  --ink-mute:       #64748B;
  --ink-faint:      #94A3B8;
  --line:           #E2E8F0;
  --line-strong:    #CBD5E1;
  --brand:          #0F3A62;
  --brand-ink:      #FFFFFF;

  --arr:            #D64545;
  --dep:            #2FA36B;
  --out:            #3B7DD8;
  --amber:          #B45309;

  /* blob tints — reads at 2m in a hangar, still not Excel-block loud */
  --tint-red:       rgba(214,  69,  69, 0.42);
  --tint-green:     rgba( 47, 163, 107, 0.42);
  --tint-blue:      rgba( 59, 125, 216, 0.36);

  /* MAD-code blob: pure white body + pure white edge strips */
  --mad-body:       #FFFFFF;
  --mad-strip:      #FFFFFF;

  --shadow-card:    0 1px 2px rgba(15, 23, 42, .06),
                    0 3px 10px rgba(15, 23, 42, .04);
  --radius-card:    14px;
  --radius-pill:    999px;
  --topbar-h:       58px;
  --botnav-h:       64px;
  --safe-top:       env(safe-area-inset-top);
  --safe-bot:       env(safe-area-inset-bottom);
}

html[data-theme="dark"] {
  --surface:        #0B1220;
  --surface-quiet:  #101a2c;
  --card:           #131C2E;
  --card-mad:       #1A2540;
  --card-sub:       #182238;
  --ink:            #E8EEF7;
  --ink-dim:        #CBD5E1;
  --ink-mute:       #94A3B8;
  --ink-faint:      #64748B;
  --line:           #223047;
  --line-strong:    #2E4361;
  --brand:          #0F1B2F;
  --brand-ink:      #E8EEF7;

  --arr:            #F0776E;
  --dep:            #5AC48A;
  --out:            #6EA6E8;
  --amber:          #E7A63C;

  /* Dark theme needs even more punch — the surface competes with the tint. */
  --tint-red:       rgba(240, 119, 110, 0.55);
  --tint-green:     rgba( 90, 196, 138, 0.55);
  --tint-blue:      rgba(110, 166, 232, 0.48);

  /* MAD-code blob on dark: distinctly greyer than the card, grey strips */
  --mad-body:       #2A3547;
  --mad-strip:      #4A576D;

  --shadow-card:    0 1px 2px rgba(0,0,0,.35), 0 6px 22px rgba(0,0,0,.28);
}

/* --- typography ---------------------------------------------------------- */

body {
  font: 400 15px/1.4 -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--surface);
  overscroll-behavior-y: none;
  font-feature-settings: "ss01" on;
}
.mono { font-family: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;
        font-variant-numeric: tabular-nums; }
.num  { font-variant-numeric: tabular-nums; }
button, input { font-family: inherit; }

/* --- layout scaffold ---------------------------------------------------- */

.app-shell {
  display: flex; flex-direction: column;
  min-height: 100dvh;
}
.page {
  flex: 1;
  padding: calc(var(--topbar-h) + var(--safe-top) + 8px) 0
           calc(var(--botnav-h) + var(--safe-bot) + 16px);
}
.container { padding: 0 14px; max-width: 620px; margin: 0 auto; }

/* --- top bar ------------------------------------------------------------ */

.topbar {
  /* z-index 30 so we stay above the sliding detail page (25). */
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 10px; padding-right: 10px;
  background: var(--brand);
  color: var(--brand-ink);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
html[data-theme="dark"] .topbar { border-bottom-color: var(--line); }

.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.tb-center { text-align: center; line-height: 1.05; }

.tb-date { font-size: 10.5px; opacity: .72; letter-spacing: .06em;
           font-weight: 600; text-transform: uppercase; }
.tb-clock { font-size: 19px; font-weight: 600; letter-spacing: .01em;
            font-family: ui-monospace, "SF Mono", monospace;
            font-variant-numeric: tabular-nums; }
.tb-utclab { font-size: 8.5px; letter-spacing: .18em; font-weight: 700;
             opacity: .55; margin-top: 1px; }

.crest {
  width: 36px; height: 36px; border-radius: 8px;
  background: transparent; border: 0;
  padding: 0; overflow: hidden;
  display: grid; place-items: center;
  cursor: pointer; flex-shrink: 0; color: inherit;
}
.crest .crest-img { width: 100%; height: 100%; display: block; object-fit: cover; }
.crest .crest-back { width: 22px; height: 22px; color: var(--brand-ink); }

.identity { line-height: 1.05; min-width: 0; }
.identity .k1 { font-size: 12.5px; font-weight: 700; letter-spacing: .06em;
                white-space: nowrap; }
.identity .k2 { font-size: 9.5px; letter-spacing: .06em; opacity: .72;
                font-weight: 600; white-space: nowrap; margin-top: 1px; }

/* When a plane's detail is open, the identity block shows just the registration. */
.identity.identity-detail {
  font-size: 16px; font-weight: 700; letter-spacing: .05em;
  color: var(--brand-ink); white-space: nowrap;
}

.iconbtn {
  width: 34px; height: 34px; border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  display: grid; place-items: center;
  color: inherit; cursor: pointer;
  position: relative; flex-shrink: 0;
}
.iconbtn svg { width: 18px; height: 18px; stroke: currentColor;
               fill: none; stroke-width: 1.7;
               stroke-linecap: round; stroke-linejoin: round; }

/*
   The bell has two visual states:
     - 0 unseen: a plain circular icon button matching the theme toggle
     - >0 unseen: a solid red pill, wider, with the count baked in
   next to the bell glyph. That way there's only one thing to see instead
   of a badge floating over an icon — more legible on a phone from arm's
   length.
*/
.bellbtn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: inherit; cursor: pointer; flex-shrink: 0;
}
.bellbtn .bell-ico { width: 18px; height: 18px; }
.bellbtn .bell-n {
  display: none;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  line-height: 1;
}
.bellbtn.has-alerts {
  background: var(--arr); border-color: var(--arr); color: #fff;
  padding: 0 10px 0 8px;
}
.bellbtn.has-alerts .bell-ico { fill: #fff; }
.bellbtn.has-alerts .bell-n { display: inline-block; }

.backbtn {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 0; color: inherit;
  padding: 6px 4px; margin-left: -4px; cursor: pointer;
  min-width: 0;
}
.backbtn svg { width: 22px; height: 22px; stroke: currentColor;
               fill: none; stroke-width: 2;
               stroke-linecap: round; stroke-linejoin: round;
               flex-shrink: 0; }
.backbtn .reg { font-size: 17px; font-weight: 700; letter-spacing: .05em;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- bottom nav --------------------------------------------------------- */

.botnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--botnav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.botnav button {
  background: transparent; border: 0; color: var(--ink-mute);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer;
  padding-top: 6px; position: relative;
}
.botnav button svg { width: 22px; height: 22px; stroke: currentColor;
                     fill: none; stroke-width: 1.6;
                     stroke-linecap: round; stroke-linejoin: round; }
.botnav button span { font-size: 11px; font-weight: 600; letter-spacing: .02em; }

.botnav button[aria-current="page"] {
  color: var(--brand);
}
html[data-theme="dark"] .botnav button[aria-current="page"] {
  color: var(--ink);
}
.botnav button[aria-current="page"] svg {
  fill: color-mix(in srgb, currentColor 15%, transparent);
}
.botnav button[aria-current="page"]::after {
  content: ""; position: absolute; bottom: 6px;
  width: 4px; height: 4px; border-radius: 999px;
  background: currentColor;
}

/* --- banners ------------------------------------------------------------ */

.banner {
  border-radius: 12px; padding: 10px 12px; font-size: 13px;
  border: 1px solid var(--line); background: var(--card);
  margin-bottom: 10px; line-height: 1.4;
}
.banner.warn { border-color: color-mix(in srgb, var(--amber) 40%, var(--line));
               background: color-mix(in srgb, var(--amber) 8%, var(--card));
               color: var(--amber); }
.banner.bad  { border-color: color-mix(in srgb, var(--arr) 40%, var(--line));
               background: color-mix(in srgb, var(--arr) 8%, var(--card));
               color: var(--arr); }
.banner.info { border-color: color-mix(in srgb, var(--out) 40%, var(--line));
               background: color-mix(in srgb, var(--out) 8%, var(--card));
               color: var(--out); }

/* --- FLEET — aircraft blobs (the signature) ----------------------------- */

.fleet-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px;                             /* was 10px — more space between */
  padding-top: 6px;                      /* was covered by the meta bar */
}

.blob {
  position: relative;
  /* Slightly softer corners so the blobs read less "boxy". */
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 12px 12px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  /* Shorter than before (was 160px) — a touch less tall as requested. */
  min-height: 148px;
  display: flex; flex-direction: column;
  cursor: pointer;
  text-align: left; font-family: inherit;
  color: var(--ink);
  transition: transform 100ms ease;
  isolation: isolate;
}
.blob:active { transform: scale(.985); }
.blob-inner { position: relative; z-index: 2; display: flex; flex-direction: column;
              flex: 1; min-width: 0; }

/* the two vertical strips + tint fade */
.blob .strip {
  position: absolute; top: 0; bottom: 0; width: 3.5px;
  z-index: 1;
}
.blob .strip.left  { left: 0;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px; }
.blob .strip.right { right: 0;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px; }

.blob .tint {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
}

/* ----- COD variants ----- */

.blob[data-cod="ETA"] .strip { background: var(--arr); }
.blob[data-cod="ETA"] .tint  {
  background: linear-gradient(90deg,
    var(--tint-red) 0%,
    color-mix(in srgb, var(--tint-red) 30%, transparent) 45%,
    transparent 100%),
  linear-gradient(-90deg,
    var(--tint-red) 0%,
    color-mix(in srgb, var(--tint-red) 30%, transparent) 45%,
    transparent 100%);
}

.blob[data-cod="ETD"] .strip { background: var(--dep); }
.blob[data-cod="ETD"] .tint  {
  background: linear-gradient(90deg,
    var(--tint-green) 0%,
    color-mix(in srgb, var(--tint-green) 30%, transparent) 45%,
    transparent 100%),
  linear-gradient(-90deg,
    var(--tint-green) 0%,
    color-mix(in srgb, var(--tint-green) 30%, transparent) 45%,
    transparent 100%);
}

.blob[data-cod="OUT"] .strip { background: var(--out); }
.blob[data-cod="OUT"] .tint  {
  background: linear-gradient(90deg,
    var(--tint-blue) 0%,
    color-mix(in srgb, var(--tint-blue) 30%, transparent) 45%,
    transparent 100%),
  linear-gradient(-90deg,
    var(--tint-blue) 0%,
    color-mix(in srgb, var(--tint-blue) 30%, transparent) 45%,
    transparent 100%);
}

/* MAD = quiet card with its own strips. White strips on light, grey on dark. */
.blob[data-cod="MAD"] { background: var(--mad-body); }
.blob[data-cod="MAD"] .strip { background: var(--mad-strip); }
.blob[data-cod="MAD"] .tint  { display: none; }

/*
   Two-code cross-fade — colours hug in the middle, with a slight oblique.
   We layer:
     - a red gradient from the LEFT that fully dies out by ~62%
     - a green gradient from the RIGHT that fully dies out by ~62%
   The overlap in the middle is where they "hug"; the oblique comes from
   the tint being painted with a small transform: skewX on the ::before pair.
*/
.blob[data-cod="ETA/ETD"] .strip.left  { background: var(--arr); }
.blob[data-cod="ETA/ETD"] .strip.right { background: var(--dep); }
.blob[data-cod="ETA/ETD"] .tint {
  background:
    linear-gradient(100deg,
      var(--tint-red) 0%,
      color-mix(in srgb, var(--tint-red) 60%, transparent) 35%,
      transparent 62%),
    linear-gradient(-100deg,
      var(--tint-green) 0%,
      color-mix(in srgb, var(--tint-green) 60%, transparent) 35%,
      transparent 62%);
}

.blob[data-cod="ETD/ETA"] .strip.left  { background: var(--dep); }
.blob[data-cod="ETD/ETA"] .strip.right { background: var(--arr); }
.blob[data-cod="ETD/ETA"] .tint {
  background:
    linear-gradient(100deg,
      var(--tint-green) 0%,
      color-mix(in srgb, var(--tint-green) 60%, transparent) 35%,
      transparent 62%),
    linear-gradient(-100deg,
      var(--tint-red) 0%,
      color-mix(in srgb, var(--tint-red) 60%, transparent) 35%,
      transparent 62%);
}

/* special-only (no COD but has a special status) → amber quiet */
.blob[data-cod=""] .strip { background: var(--amber); opacity: .8; }
.blob[data-cod=""] .tint  {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--amber) 20%, transparent) 0%, transparent 55%),
  linear-gradient(-90deg,
    color-mix(in srgb, var(--amber) 20%, transparent) 0%, transparent 55%);
}

/* ----- blob content ----- */

.blob-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px; margin-bottom: 4px;
}
.blob-reg { font-size: 19px; font-weight: 700; letter-spacing: .04em;
            color: var(--ink); }
.blob-pk  { font-size: 10.5px; font-weight: 600; letter-spacing: .04em;
            color: var(--ink-mute); }

/* status chip — solid but not screaming */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; line-height: 1.15;
  align-self: flex-start; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.status.arr     { background: var(--arr); color: #fff; }
.chip.status.dep     { background: var(--dep); color: #fff; }
.chip.status.out     { background: var(--out); color: #fff; }
.chip.status.mad     { background: var(--ink-faint); color: #fff; }
.chip.status.special { background: var(--amber); color: #fff; }
html[data-theme="dark"] .chip.status.arr,
html[data-theme="dark"] .chip.status.dep,
html[data-theme="dark"] .chip.status.out,
html[data-theme="dark"] .chip.status.special {
  color: #0B1220;
}

.blob-events {
  margin-top: 6px;
  font-size: 12.5px; color: var(--ink-dim);
  line-height: 1.35;
  flex: 1;
}
.blob-events .ev { display: flex; align-items: baseline; gap: 4px; }
.blob-events .ev + .ev { margin-top: 2px; }
.blob-events .ev-k { font-weight: 700; letter-spacing: .06em;
                     font-size: 10.5px; }
.blob-events .ev-k.arr { color: var(--arr); }
.blob-events .ev-k.dep { color: var(--dep); }
.blob-events .ev-body { flex: 1; min-width: 0;
                        white-space: nowrap; overflow: hidden;
                        text-overflow: ellipsis;
                        color: var(--ink-dim); font-size: 12px; }
.blob-events .ev-cnt { font-family: ui-monospace, monospace;
                       font-variant-numeric: tabular-nums;
                       font-size: 11px; color: var(--ink-mute);
                       font-weight: 600; }
.blob-events .ev-none { color: var(--ink-mute); font-size: 12px; }

.blob-foot { display: flex; gap: 6px; margin-top: 8px; }
.chip.count {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  border: 1px solid var(--line-strong);
  color: var(--ink-mute); font-weight: 700; font-size: 10.5px;
  letter-spacing: .04em; text-transform: none;
  padding: 2px 8px;
}
.chip.count.warn { border-color: color-mix(in srgb, var(--amber) 55%, transparent);
                   color: var(--amber);
                   background: color-mix(in srgb, var(--amber) 8%, transparent); }

/* --- AIRCRAFT DETAIL ---------------------------------------------------- */

.detail-page {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface);
  /* Above the bottom nav (z-index 20) so the nav is fully covered while
     detail is open. Below the top bar (z-index 30) which stays put and
     morphs its crest into a back arrow. */
  z-index: 25;
  transform: translateX(100%);
  transition: transform 200ms cubic-bezier(.2,.9,.25,1);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.detail-page.open { transform: translateX(0); }
.detail-page > .container {
  padding-top: calc(var(--topbar-h) + var(--safe-top) + 10px);
  padding-bottom: calc(var(--safe-bot) + 32px);
}

.reg-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 2px 12px;
  font-size: 12.5px; color: var(--ink-mute);
  font-weight: 600; letter-spacing: .04em;
}
.reg-summary .pk { text-transform: uppercase; letter-spacing: .06em; }

/* Next-event hero card */
.next-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius-card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 14px 22px;
  margin-bottom: 8px;
  overflow: hidden;
}
.next-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; border-top-left-radius: var(--radius-card);
  border-bottom-left-radius: var(--radius-card);
  background: currentColor;
}
.next-card.arr { color: var(--arr); }
.next-card.dep { color: var(--dep); }
.next-card .eyebrow {
  font-size: 10px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: currentColor;
  margin-bottom: 4px;
}
.next-card .headline {
  font-size: 15.5px; font-weight: 700; color: var(--ink);
  letter-spacing: .02em; line-height: 1.35;
}
.next-card .headline .kw { color: currentColor; }
.next-card .countdown {
  margin-top: 6px;
  font: 700 20px/1 ui-monospace, "SF Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: .01em;
}
.next-card.secondary { padding-top: 10px; padding-bottom: 10px; }
.next-card.secondary .headline { font-size: 14px; }
.next-card.secondary .countdown { font-size: 15px; margin-top: 4px; }

/* Later flight rows */
.event-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 14px 10px 22px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  margin-bottom: 6px; position: relative;
}
.event-row::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
}
.event-row.arr::before { background: var(--arr); }
.event-row.dep::before { background: var(--dep); }
.event-row .kw { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; }
.event-row .kw.arr { color: var(--arr); }
.event-row .kw.dep { color: var(--dep); }
.event-row .body { flex: 1; font-size: 13.5px; font-weight: 600; }
.event-row .when { font-size: 11.5px; color: var(--ink-mute);
                   font-family: ui-monospace, monospace;
                   font-variant-numeric: tabular-nums; font-weight: 600; }

/* Day picker on detail */
.day-tabs { display: flex; gap: 8px; padding: 14px 2px 10px; }
.day-tabs button {
  flex: 1; padding: 10px 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; color: var(--ink-mute);
  font-size: 12.5px; font-weight: 700; letter-spacing: .06em;
  cursor: pointer;
}
.day-tabs button[aria-selected="true"] {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
}
html[data-theme="dark"] .day-tabs button[aria-selected="true"] {
  background: var(--card-sub); color: var(--ink); border-color: var(--line-strong);
}

/* Section headers on detail (& shifts) */
.section-h {
  padding: 14px 2px 6px;
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.section-h .t {
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-mute);
}
.section-h .n {
  font-size: 11px; color: var(--ink-mute);
  font-family: ui-monospace, monospace; font-weight: 700;
}

/* Task / CFD / remark list */
.checklist { list-style: none; padding: 0; margin: 0 0 6px; }
.checklist li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid var(--line);
}
.checklist li:last-child { border-bottom: none; }
.checkbox {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 5px;
  border: 1.6px solid var(--line-strong);
  display: grid; place-items: center;
  margin-top: 1px; background: transparent;
}
.checkbox.unknown { border-style: dashed; border-color: var(--ink-faint); }
.checkbox.done {
  background: var(--dep); border-color: var(--dep);
}
.checkbox.done svg { width: 12px; height: 12px; stroke: #fff; fill: none;
                     stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.item-text { font-size: 14px; color: var(--ink); line-height: 1.35;
             word-break: break-word; flex: 1; min-width: 0; }
.item-text .sub {
  display: block; font-size: 12.5px;
  color: var(--ink-mute); margin-top: 2px; font-weight: 500;
}
.item-text .ref {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--ink-mute); font-weight: 700; margin-right: 6px;
  letter-spacing: .04em; text-transform: uppercase;
}
.checklist li.done .item-text {
  color: var(--ink-mute); text-decoration: line-through;
  text-decoration-color: var(--ink-faint);
  text-decoration-thickness: 1.2px;
}
.checklist li.done .item-text .sub { text-decoration: none; }

.empty-lite {
  padding: 12px 2px; color: var(--ink-mute); font-size: 12.5px;
}

/* --- SCHEDULE ----------------------------------------------------------- */

.sched-day-h {
  padding: 16px 2px 8px;
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  color: var(--ink-mute); text-transform: uppercase;
}

/*
   Row layout, left → right, all one line, no wrapping:
     [ time ] [ ARR/DEP ] [ registration + from/to X ] .... [ countdown ]
   Flexbox is used (not grid) because Safari sometimes auto-flowed grid
   items to a new row when the `1fr` middle column had wrappable text —
   producing the "countdown on line 2" bug seen on iPhone.
*/
.sched-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 22px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  margin-bottom: 6px;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.sched-row::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 2px;
}
.sched-row.arr::before { background: var(--arr); }
.sched-row.dep::before { background: var(--dep); }
.sched-row .t {
  font: 700 15px/1 ui-monospace, "SF Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  flex: 0 0 auto;
}
.sched-row .kw {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid currentColor;
  line-height: 1;
  flex: 0 0 auto;
}
.sched-row .kw.arr { color: var(--arr); }
.sched-row .kw.dep { color: var(--dep); }
.sched-row .who {
  font-size: 13.5px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.sched-row .who small {
  display: block; color: var(--ink-mute); font-weight: 500;
  font-size: 11.5px; letter-spacing: .04em; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sched-row .cnt {
  font: 600 11.5px/1 ui-monospace, "SF Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  white-space: nowrap;
  letter-spacing: .02em;
  flex: 0 0 auto;
  text-align: right;
}
.sched-row .cnt.past { font-style: normal; }

/* past events: faded */
.sched-row.past {
  background: var(--surface-quiet);
  border-color: transparent;
  opacity: .65;
}
.sched-row.past::before { opacity: .5; }
.sched-row.past .t,
.sched-row.past .who { color: var(--ink-mute); }
.sched-row.past .who small { color: var(--ink-faint); }
.sched-row.past .kw { opacity: .8; }

/* the very-next event: gently emphasised */
.sched-row.next {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 12%, transparent);
}
.sched-row.next .who { font-size: 14.5px; }
.sched-row.next .t { font-size: 16px; }

.sched-next-badge {
  display: inline-block;
  font-size: 9px; font-weight: 800; letter-spacing: .12em;
  padding: 2px 6px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink);
  margin-left: 6px; vertical-align: 2px;
}
html[data-theme="dark"] .sched-next-badge {
  background: var(--ink); color: var(--surface);
}

/* --- SHIFTS ------------------------------------------------------------- */

/*  Shift period header: dominant. Bigger, heavier, in ink colour with
    thicker hairlines so it clearly outranks "SHIFT LEADER" / "TMAS" etc.  */
.shift-h {
  padding: 28px 2px 14px;
  font-size: 20px; font-weight: 900; letter-spacing: .16em;
  color: var(--ink); text-transform: uppercase;
  text-align: center;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 14px;
}
.shift-h::before, .shift-h::after {
  content: ""; height: 2px; background: var(--ink);
  opacity: .18;
}

.shift-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; overflow: hidden;
}
.shift-role {
  padding: 8px 12px 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-mute);
  background: var(--card-sub); border-bottom: 1px solid var(--line);
}
.shift-person {
  display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.shift-person:last-child { border-bottom: none; }
.shift-person .avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--out));
  color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  display: grid; place-items: center;
}
html[data-theme="dark"] .shift-person .avatar {
  background: linear-gradient(135deg, #223047, #385071);
  color: var(--ink);
}
.shift-person .n {
  font-size: 14px; font-weight: 700; letter-spacing: .04em;
  color: var(--ink);
}
.shift-person .d {
  font-size: 11.5px; color: var(--ink-mute); font-weight: 600;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* --- MESSAGES ----------------------------------------------------------- */

.msg-empty {
  text-align: center; padding: 40px 22px;
  color: var(--ink-mute);
}
.msg-empty .art {
  width: 300px; height: 210px; margin: 0 auto 22px;
  color: var(--ink);
  opacity: .7;
}
.msg-empty .art svg { width: 100%; height: 100%; stroke: currentColor; fill: none;
                      stroke-width: 1.4;
                      stroke-linecap: round; stroke-linejoin: round; }

/*
   Raster illustration variant for the messaging placeholder AND the AOG
   error state. Sized to the phone width, aspect ratio preserved. Dark
   mode inverts the image so the near-black strokes read as light strokes
   against the navy background — same file, no second asset needed.
*/
.msg-empty .art-photo {
  display: block; width: 100%; max-width: 320px; height: auto;
  margin: 0 auto 22px;
  opacity: .8;
}
html[data-theme="dark"] .msg-empty .art-photo {
  filter: invert(1) hue-rotate(180deg);
  opacity: .75;
}
.msg-empty h3 {
  font-size: 17px; margin: 0 0 6px;
  color: var(--ink); letter-spacing: .03em; font-weight: 700;
}
.msg-empty p {
  font-size: 13.5px; margin: 0 auto;
  line-height: 1.5; max-width: 300px;
}

/*
   AOG full-page error state. Owns the whole viewport so it works even when
   the app shell hasn't finished booting. `.aog-page` renders the same
   msg-empty structure but vertically centred.
*/
.aog-page {
  position: fixed; inset: 0; z-index: 60;
  background: var(--surface);
  display: flex; flex-direction: column; justify-content: center;
  align-items: center;
  padding: 24px calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bot));
  overflow-y: auto;
}
.aog-page .msg-empty { padding: 0; max-width: 420px; }
.aog-page .aog-retry {
  margin-top: 22px;
  background: var(--brand); color: var(--brand-ink);
  border: 0; border-radius: 12px; padding: 12px 22px;
  font-size: 14px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; cursor: pointer;
}

/* --- Settings sheet + PWA prompt --------------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(15, 23, 42, 0.5);
  display: none;
}
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(20px + var(--safe-bot));
  transform: translateY(100%);
  transition: transform 220ms cubic-bezier(.2,.9,.25,1);
  border-top: 1px solid var(--line);
}
.sheet.open { transform: translateY(0); }
.sheet .grabber {
  width: 44px; height: 4px; background: var(--line-strong);
  border-radius: 4px; margin: 0 auto 12px;
}
.sheet h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: .04em;
            color: var(--ink); }
.sheet .who {
  color: var(--ink-mute); font-size: 12.5px; font-weight: 600;
  margin-bottom: 10px;
}
.sheet button.item {
  display: flex; width: 100%; align-items: center; gap: 12px;
  padding: 12px 6px; border: 0; background: transparent;
  color: var(--ink); font-size: 14.5px; font-weight: 600;
  border-top: 1px solid var(--line); text-align: left;
  cursor: pointer;
}
.sheet button.item:first-of-type { border-top: none; }
.sheet button.item.warn { color: var(--arr); }
.sheet button.item svg {
  width: 20px; height: 20px; stroke: currentColor; fill: none;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

/*  Notification toggle row: label on the left, ON/OFF pill on the right. */
.sheet button.item-toggle .item-label { flex: 1; }
.sheet button.item-toggle .item-state {
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 10px; border-radius: 999px;
  background: var(--ink-faint); color: #fff;
  text-transform: uppercase;
}
.sheet button.item-toggle.on .item-state { background: var(--dep); }
.sheet button.item-toggle.off .item-state { background: var(--ink-faint); }

/* --- Notifications sheet ------------------------------------------------- */

.notif-backdrop {
  position: fixed; inset: 0; z-index: 32;
  background: rgba(15, 23, 42, 0.5);
  display: none;
}
.notif-backdrop.open { display: block; }

.notif-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 33;
  height: 82vh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  transform: translateY(100%);
  transition: transform 220ms cubic-bezier(.2,.9,.25,1);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.notif-sheet.open { transform: translateY(0); }

.notif-h {
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--line);
}
.notif-h .grabber {
  width: 44px; height: 4px; background: var(--line-strong);
  border-radius: 4px; margin: 0 auto 10px;
}
.notif-title {
  display: flex; align-items: center; justify-content: space-between;
}
.notif-title span {
  font-size: 15px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink);
}
.notif-close {
  border: 0; background: transparent; color: var(--ink-mute);
  padding: 6px; cursor: pointer;
}
.notif-close svg { width: 22px; height: 22px; }

.notif-body {
  flex: 1; overflow-y: auto;
  padding: 6px 12px calc(20px + var(--safe-bot));
}

.notif-day-h {
  padding: 14px 4px 6px;
  font-size: 10px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-mute);
}

.notif-item {
  display: block; width: 100%; text-align: left;
  padding: 12px 12px 12px 14px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.notif-item .n-body {
  font-size: 14px; font-weight: 600; color: var(--ink);
  line-height: 1.4;
}
.notif-item .n-meta {
  margin-top: 5px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-mute);
  font-family: ui-monospace, "SF Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.notif-item.unread {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand) 4%, var(--card));
}
.notif-item.unread::before {
  content: ""; position: absolute; left: -2px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 2px; background: var(--brand);
}
.notif-item.urgent .n-body { color: var(--arr); font-weight: 700; }
.notif-item.grouped {
  background: color-mix(in srgb, var(--brand) 8%, var(--card));
}

.notif-empty {
  padding: 40px 20px; text-align: center; color: var(--ink-mute);
  font-size: 13px;
}

/* --- Password / confirm dialogs ---------------------------------------- */

.mdlg::backdrop { background: rgba(0,0,0,.4); }
.mdlg {
  border: 0; border-radius: 16px; padding: 20px 20px 16px;
  max-width: 320px; width: 88vw;
  background: var(--card); color: var(--ink);
}
.mdlg h3 { margin: 0 0 6px; font-size: 16px; }
.mdlg p  { margin: 0 0 12px; font-size: 13.5px; color: var(--ink-mute); }
.mdlg input {
  width: 100%; padding: 10px 12px; margin: 6px 0;
  font-size: 15px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
}
.mdlg .err { color: var(--arr); font-size: 12.5px; min-height: 18px; }
.mdlg .row { display: flex; gap: 8px; margin-top: 8px; }
.mdlg button {
  flex: 1; padding: 11px; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card-sub); color: var(--ink);
}
.mdlg button.primary { background: var(--brand); color: var(--brand-ink);
                       border-color: var(--brand); }
.mdlg button.warn    { background: var(--arr); color: #fff;
                       border-color: var(--arr); }

/* --- Install prompt (iOS Add to Home Screen) --------------------------- */

.install-card {
  margin: 12px 0; padding: 14px 14px 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px;
}
.install-card h4 { margin: 0 0 4px; font-size: 14px; letter-spacing: .03em;
                   color: var(--ink); font-weight: 700; }
.install-card p  { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-mute);
                   line-height: 1.5; }
.install-card .row { display: flex; gap: 8px; }
.install-card button {
  flex: 1; padding: 9px 10px; border-radius: 8px; font-size: 13px;
  font-weight: 700; cursor: pointer; border: 1px solid var(--line);
  background: var(--card-sub); color: var(--ink);
}
.install-card button.primary { background: var(--brand); color: var(--brand-ink);
                               border-color: var(--brand); }

/* --- Login page --------------------------------------------------------- */

.login-page {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
}
.login-hero {
  padding: calc(48px + var(--safe-top)) 24px 20px;
  display: grid; place-items: center;
}
.login-hero .art {
  width: 100%; max-width: 340px;
  border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-card);
  display: block;
  background: #1A2540;
  aspect-ratio: 1152 / 896;   /* matches login-hero.jpg proportions */
}
.login-hero .art img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
}
.login-form {
  padding: 4px 24px calc(28px + var(--safe-bot));
  max-width: 380px; width: 100%; margin: 0 auto;
}
.login-form input {
  width: 100%; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-size: 16px; margin-bottom: 10px;
}
.login-form input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}
.login-form .err {
  color: var(--arr); font-size: 13px;
  min-height: 20px; margin-bottom: 4px;
}
.login-form button.primary {
  width: 100%; padding: 13px;
  border: 0; border-radius: 12px;
  background: var(--brand); color: var(--brand-ink);
  font-size: 15px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
}
.login-form button.primary:disabled { opacity: .5; }

.ios-tip {
  margin-top: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--card); border: 1px dashed var(--line-strong);
  font-size: 13px; color: var(--ink-dim); line-height: 1.5;
}

/* --- disclaimer footer -------------------------------------------------- */

.disclaimer {
  padding: 20px 2px 0;
  font-size: 11px; color: var(--ink-faint);
  text-align: center; line-height: 1.5; font-weight: 500;
}

.hidden { display: none !important; }
