/* ==========================================================================
   ComputerLogbuch – design system
   Mobile-first (Samsung A54 ≈ 412 px CSS width), scales up to MacBook.
   No framework, no build step. Light/dark via prefers-color-scheme + data-theme.
   ========================================================================== */

:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --ring: rgba(11, 11, 11, .10);

  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #cde2fb;
  --night: #6250d6;
  --night-soft: #dcd7f7;

  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --serious: #ec835a;
  --serious-ink: #a8431b;
  --critical: #d03b3b;
  --critical-ink: #b02a2a;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sidebar: 232px;
  --tabbar: 54px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --line: #2c2c2a;
    --line-strong: #383835;
    --ring: rgba(255, 255, 255, .10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #184f95;
    --night: #9085e9;
    --night-soft: #3a3370;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --serious-ink: #ec835a;
    --critical-ink: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --line: #2c2c2a;
  --line-strong: #383835;
  --ring: rgba(255, 255, 255, .10);
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: #184f95;
  --night: #9085e9;
  --night-soft: #3a3370;
  --good-ink: #0ca30c;
  --warning-ink: #fab219;
  --serious-ink: #ec835a;
  --critical-ink: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
button { font: inherit; color: inherit; }
.num, table { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
html { scroll-padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); } /* focused/scrolled-to content clears the tabbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--page) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; font-weight: 650; margin: 0; letter-spacing: -.01em; flex: 1; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand svg { color: var(--accent); }
.topbar .brand { display: none; }

.sidebar { display: none; }
.tabbar {
  /* Always visible: own compositor layer, fixed height, no reflow while scrolling */
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateZ(0); will-change: transform; contain: layout paint;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; color: var(--ink-3); font-size: 11px; font-weight: 550; line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a[aria-current="page"] { color: var(--accent-ink); }
.tabbar a[aria-current="page"] .ico { background: var(--accent-soft); }
.tabbar .ico { display: grid; place-items: center; width: 48px; height: 26px; border-radius: 13px; }

.main { padding: 16px var(--gutter) 32px; max-width: 1280px; margin: 0 auto; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: var(--sidebar) 1fr; padding-bottom: 0; }
  .tabbar { display: none; }
  html { scroll-padding-bottom: 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh;
    padding: 20px 12px; border-right: 1px solid var(--line); background: var(--surface);
  }
  .sidebar .brand { padding: 4px 10px 20px; font-size: 16px; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
    color: var(--ink-2); font-weight: 550;
  }
  .sidebar a.nav:hover { background: var(--surface-2); }
  .sidebar a.nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
  .sidebar .spacer { flex: 1; }
  .topbar { height: 64px; padding: 0 28px; }
  .main { padding: 24px 28px 48px; }
  :root { --gutter: 28px; }
}

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.icon { width: 38px; padding: 0; justify-content: center; }
.btn .label-long { display: none; }
@media (min-width: 600px) { .btn .label-long { display: inline; } }

.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--ring); }

.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit;
}
.input:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Layout ---------- */
.grid { display: grid; gap: 14px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 28px 0 12px; flex-wrap: wrap; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.section-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }

.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px var(--ring);
  padding: 16px;
  min-width: 0;
}
.card h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 10px; letter-spacing: .01em; }

.cols-ftl { grid-template-columns: 1fr; }
.cols-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: 1fr; }
.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .cols-ftl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .cols-ftl { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .cols-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cols-2 { grid-template-columns: 1.6fr 1fr; }
  .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Hero: next duty / status ---------- */
.hero { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .hero { grid-template-columns: 1.6fr 1fr; } }
.next-duty .when { font-size: 13px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.next-duty .legs { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; }
.leg { display: flex; flex-direction: column; min-width: 0; }
.leg .route { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.leg .route .arrow { color: var(--ink-3); font-weight: 400; margin: 0 4px; }
.leg .meta { font-size: 13px; color: var(--ink-2); }
.overall { display: flex; gap: 14px; align-items: center; }
.overall .badge-lg { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.overall strong { display: block; font-size: 17px; }

/* ---------- Status pill (icon + label, never colour alone) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 11px; font-size: 12px; font-weight: 650; white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.s-good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 14%, transparent); }
.s-warning { color: var(--warning-ink); background: color-mix(in srgb, var(--warning) 22%, transparent); }
.s-serious { color: var(--serious-ink); background: color-mix(in srgb, var(--serious) 20%, transparent); }
.s-critical { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 16%, transparent); }

/* ---------- FTL meter card ---------- */
.ftl-card { display: flex; flex-direction: column; gap: 10px; }
.ftl-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.ftl-title { font-size: 13.5px; font-weight: 650; }
.ftl-rule { font-size: 12px; color: var(--ink-3); }
.group-head { font-size: 12.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 10px; }
.section-head + .group-head { margin-top: 0; }
.src-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
.src { font-size: 11.5px; font-weight: 600; color: var(--ink-3); padding: 1px 7px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); cursor: help; }
.src.binding { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.meter-wrap { position: relative; }
.meter-wrap.has-ticks { padding-bottom: 14px; }
.tick-mark { position: absolute; top: -3px; height: 16px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; box-shadow: 0 0 0 1.5px var(--surface); }
.tick-label { position: absolute; top: 14px; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; color: var(--ink-2); }
.ftl-value { display: flex; align-items: baseline; gap: 6px; }
.ftl-value b { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.ftl-value span { color: var(--ink-3); font-size: 14px; }
.meter { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.meter .plan, .meter .act { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.meter .act { background: var(--accent); }
.meter .plan { background: repeating-linear-gradient(135deg, var(--accent) 0 3px, color-mix(in srgb, var(--accent) 35%, transparent) 3px 6px); opacity: .55; }
.meter.warning .act { background: var(--warning); } .meter.warning .plan { background: repeating-linear-gradient(135deg, var(--warning) 0 3px, transparent 3px 6px); }
.meter.serious .act { background: var(--serious); } .meter.serious .plan { background: repeating-linear-gradient(135deg, var(--serious) 0 3px, transparent 3px 6px); }
.meter.critical .act { background: var(--critical); } .meter.critical .plan { background: repeating-linear-gradient(135deg, var(--critical) 0 3px, transparent 3px 6px); }
.ftl-foot { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); gap: 8px; flex-wrap: wrap; }
.ftl-foot b { color: var(--ink); font-weight: 650; }

/* ---------- KPI tiles ---------- */
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.kpi .delta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi .delta.up { color: var(--good-ink); }
.kpi .delta.down { color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .base-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .limit { stroke: var(--critical); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .limit-label { fill: var(--critical-ink); font-size: 11px; font-weight: 650; }
.chart .today { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .today-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series.future { stroke-dasharray: 5 4; }
.chart .area { fill: var(--accent); opacity: .10; }
.chart .bar-day { fill: var(--accent); }
.chart .bar-night { fill: var(--night); }
.chart .hit { fill: transparent; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .marker { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 0 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .sw.line { height: 2px; border-radius: 1px; }
.legend .sw.dash { height: 0; border-top: 2px dashed; border-radius: 0; background: none !important; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14), 0 0 0 1px var(--ring);
  font-size: 12.5px; line-height: 1.4; min-width: 140px; transform: translate(-50%, -100%); white-space: nowrap;
}
.tooltip .t-head { font-weight: 650; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .t-row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }

/* ---------- Ranked bars (top destinations, types) ---------- */
.rank { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 58px 1fr 64px; gap: 10px; align-items: center; font-size: 13.5px; }
.rank-row .k { font-weight: 650; }
.rank-row .bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rank-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.rank-row .v { text-align: right; color: var(--ink-2); }

/* ---------- Facts list ---------- */
.facts { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 14px; margin: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; text-align: right; font-weight: 600; }

/* ---------- Logbook ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { flex: 1; min-width: 180px; }
.month-head {
  position: sticky; top: 56px; z-index: 5; display: flex; justify-content: space-between;
  padding: 10px 4px 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .05em; background: var(--page);
}
.month-head span:first-child { white-space: nowrap; }
.month-head span:last-child { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink-3); text-align: right; }
@media (min-width: 900px) { .month-head { top: 64px; } }
.flight-list { display: grid; gap: 8px; margin-bottom: 8px; }
.flight {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 0 0 1px var(--ring); cursor: pointer; text-align: left; border: 0; width: 100%;
}
.flight:hover { background: var(--surface-2); }
.flight .d { text-align: center; line-height: 1.1; }
.flight .d b { display: block; font-size: 18px; }
.flight .d small { font-size: 11px; color: var(--ink-3); text-transform: uppercase; font-weight: 650; }
.flight .r { min-width: 0; }
.flight .r b { font-size: 16px; }
.flight .r .meta { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flight .t { text-align: right; }
.flight .t b { font-size: 16px; display: block; }
.flight .t .n { font-size: 12px; color: var(--night); font-weight: 650; display: inline-flex; align-items: center; gap: 3px; }

.table-wrap { display: none; }
@media (min-width: 900px) {
  .flight-list.cards { display: none; }
  .table-wrap { display: block; background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); overflow: hidden; margin-bottom: 14px; }
}
table.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.log th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
table.log td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.log tr:last-child td { border-bottom: 0; }
table.log tbody tr { cursor: pointer; }
table.log tbody tr:hover td { background: var(--surface-2); }
table.log .r { text-align: right; }
table.log .night { color: var(--night); font-weight: 600; }

/* ---------- Roster ---------- */
.roster-day { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.roster-day:last-child { border-bottom: 0; }
.roster-day .d { text-align: center; }
.roster-day .d b { display: block; font-size: 20px; line-height: 1.1; }
.roster-day .d small { font-size: 11px; color: var(--ink-3); text-transform: uppercase; font-weight: 650; }
.roster-day .items { display: grid; gap: 6px; min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 5px 10px; border-radius: 9px; background: var(--surface-2); font-size: 13.5px; }
.chip b { font-weight: 650; }
.chip.duty { background: var(--accent-soft); color: var(--accent-ink); }
.chip.off { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); }
.roster-day .sum { font-size: 12.5px; color: var(--ink-3); }
.roster-day.past .d { opacity: .55; }
.roster-day.past .chip.duty { background: var(--surface-2); color: var(--ink); }
.chip.flown { border: 0; cursor: pointer; font: inherit; font-size: 13.5px; }
.chip.flown svg { color: var(--ink-3); }
.chip.flown:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip .role { font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px currentColor; opacity: .7; }
.today-sep { display: flex; align-items: center; gap: 10px; margin: 4px 0; scroll-margin-top: 72px; color: var(--accent-ink); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.today-sep::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--accent); }
.roster-more { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; }

/* ---------- Dialog / bottom sheet ---------- */
dialog.sheet {
  border: 0; padding: 0; width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0;
  background: var(--surface); color: var(--ink); box-shadow: 0 -8px 40px rgba(0,0,0,.25);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.4); }
@media (min-width: 640px) { dialog.sheet { max-width: 520px; margin: auto; border-radius: 18px; } }
.sheet form { padding: 20px; display: grid; gap: 14px; }
.sheet h3 { margin: 0; font-size: 18px; }
.sheet .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.sheet .actions { display: flex; justify-content: flex-end; gap: 10px; }

.note {
  font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; margin-top: 18px; display: flex; gap: 8px;
}
.note svg { flex: none; margin-top: 2px; color: var(--ink-3); }
.proto-banner {
  font-size: 12.5px; text-align: center; padding: 6px 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600;
}

/* ---------- Feedback: toasts, busy button, form errors ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(92vw, 440px); }
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast { padding: 11px 14px; border-radius: 12px; font-size: 14px; font-weight: 550; background: var(--ink); color: var(--page); box-shadow: 0 8px 28px rgba(0,0,0,.22); animation: toast-in .18s ease-out; }
.toast.error { background: var(--critical); color: #fff; }
.toast.info { background: var(--surface); color: var(--ink); box-shadow: 0 8px 28px rgba(0,0,0,.18), 0 0 0 1px var(--ring); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.btn[aria-busy="true"] svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.form-error { margin: 0; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.btn:disabled { opacity: .6; cursor: default; }
.chip.ics { background: transparent; color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); border-style: dashed; }
.ics-note { margin: 0 0 12px; }
@media (prefers-reduced-motion: reduce) { .toast, .btn[aria-busy="true"] svg { animation: none; } }

/* ---------- Edit dialog: PF switch, augmented crew ---------- */
.sheet .check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); font-weight: 500; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); cursor: pointer; grid-template-columns: none; }
.sheet .check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.sheet fieldset.aug { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; }
.sheet fieldset.aug legend { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 0 4px; }
.sheet .radio { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; font-size: 14px; cursor: pointer; grid-template-columns: none; }
.sheet .radio input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.sheet .radio span { display: flex; justify-content: space-between; flex: 1; gap: 8px; }
.sheet .radio small { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sheet .hint { margin: 0; font-size: 12px; color: var(--ink-3); }
.sheet form { max-height: 88dvh; overflow-y: auto; }
@media (max-width: 639px) { .sheet form { padding-bottom: calc(20px + env(safe-area-inset-bottom)); } }

/* ---------- Duty codes ---------- */
.chip.unknown { border: 0; cursor: pointer; font: inherit; font-size: 13.5px; background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--warning-ink); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 650; }
.code-list { display: grid; gap: 4px; }
.code-row { display: grid; grid-template-columns: minmax(90px, 1fr) 1.4fr auto; gap: 10px; align-items: center; text-align: left; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--ink); }
.code-row:hover { background: var(--surface-2); }
.code-row.is-unknown { background: color-mix(in srgb, var(--warning) 14%, transparent); }
.code-row .muted { font-size: 12px; white-space: nowrap; }
.sheet .suggest { margin: 0; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; background: var(--accent-soft); color: var(--accent-ink); }

.rank.types .rank-row { grid-template-columns: 96px 1fr 64px; }

/* ---------- Crew suggestions (own list; <datalist> is not shown by Firefox for Android) ---------- */
.suggest-list { display: grid; margin-top: 4px; border-radius: 10px; background: var(--surface); box-shadow: 0 6px 22px rgba(0,0,0,.14), 0 0 0 1px var(--ring); overflow: hidden; }
.suggest-list button { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: transparent; font: inherit; font-size: 14px; text-align: left; color: var(--ink); cursor: pointer; min-height: 44px; }
.suggest-list button + button { border-top: 1px solid var(--line); }
.suggest-list button:hover, .suggest-list button.active { background: var(--accent-soft); color: var(--accent-ink); }
.suggest-list small { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.sheet .fields label { align-content: start; }

/* ---------- Edited / not yet edited sectors ---------- */
.flight .crew-line { font-size: 12px; color: var(--good-ink); display: flex; align-items: center; gap: 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flight.todo { box-shadow: inset 3px 0 0 var(--warning), 0 0 0 1px var(--ring); }
.flight.todo .open-tag { color: var(--warning-ink); font-weight: 600; }
.chip.flown.todo { box-shadow: inset 0 0 0 1.5px var(--warning); }
.chip.flown.edited svg { color: var(--good-ink); }

/* ---------- Rest period (next duty card) ---------- */
.rest-row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.rest-row b { color: var(--ink); }
.rest-row .muted { font-size: 12px; }
.rest-bar { flex-basis: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.rest-bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
@media (max-width: 639px) { .sheet .fields label:has(input.crew) { grid-column: 1 / -1; } }

/* ---------- Sectors no longer in the roster (kept by the sync because of manual entries) ---------- */
.chip.flown.stale { background: color-mix(in srgb, var(--serious) 18%, transparent); color: var(--serious-ink); box-shadow: inset 0 0 0 1.5px var(--serious); }
.flight.stale { box-shadow: inset 3px 0 0 var(--serious); }
.stale-tag { font-size: 12px; font-weight: 600; color: var(--serious-ink); }
.stale-box { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; color: var(--serious-ink); background: color-mix(in srgb, var(--serious) 12%, transparent); }
.stale-box svg { flex: none; margin-top: 2px; }
.stale-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn.danger { color: var(--critical-ink); box-shadow: inset 0 0 0 1px var(--critical); }
.stale-note { margin: 0 0 16px; color: var(--serious-ink); background: color-mix(in srgb, var(--serious) 12%, transparent); }
.stale-note svg { color: var(--serious-ink); }
button.link { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* roster source (settings): feed status, ICS link, PDF import */
.feed-note a { color: inherit; font-weight: 600; }
.feed-log { margin: 12px 0 0; font-size: 13px; }
.feed-log summary { cursor: pointer; color: var(--ink-2); }
.feed-log table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.feed-log td { padding: 4px 6px 4px 0; border-top: 1px solid var(--line); vertical-align: top; }
.feed-log .err { color: var(--critical-ink); }
.inline-form { display: grid; gap: 6px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.inline-form label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.inline-form .row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .row .input { flex: 1 1 220px; min-width: 0; }
.inline-form .hint, .sheet .hint { margin: 0; font-size: 12px; color: var(--ink-3); }
.pdf-groups { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pdf-groups details { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pdf-groups summary { cursor: pointer; font-size: 14px; }
.pdf-groups ul { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.pdf-groups small { color: var(--ink-2); }

/* roster: days off, layovers, named duty codes */
.chip.gd { border: 0; cursor: pointer; font: inherit; font-size: 13.5px; color: inherit; }
.chip.gd:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip.gd.off { color: var(--ink-3); }
.chip .code-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; opacity: .7; }
.chip.free { font-size: 13px; }
.chip.layover { background: transparent; color: var(--ink-2); border: 1px dashed var(--ink-3); font-size: 13px; }
.roster-day:has(.chip.free) { padding: 6px 0; }
.roster-day:has(.chip.free) .d b { font-size: 16px; }

/* settings (More) */
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 4px; }
.settings-nav a { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.settings-nav a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.settings-section { scroll-margin-top: 72px; }
.settings-section > .card + .card, .settings-section > .card + div { margin-top: 14px; }
.settings-action { margin: 14px 0 0; border-top: 1px solid var(--line); padding-top: 12px; }
.settings-action > summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.settings-action .inline-form { margin-top: 10px; padding-top: 0; border-top: 0; }
.code-group { border-top: 1px solid var(--line); padding: 8px 0 0; margin-top: 8px; }
.code-group > summary { cursor: pointer; font-size: 14px; font-weight: 600; padding: 2px 0 6px; }
.code-group > summary .muted { font-weight: 400; font-size: 12.5px; margin-left: 6px; }

/* ---------- Settings: family access (assets/js/family-admin.js) ---------- */
.fam-member { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.fam-member .who { flex: 1 1 220px; min-width: 0; }
.fam-member .who .muted { font-size: 12.5px; }
.fam-member .acts { display: flex; gap: 6px; flex-wrap: wrap; }
