/* Einsatz-Assistent: calm, neutral UI; colour only carries status (frei / Anmeldung / kein Flug / offen).
   Spacing scale: 4 / 8 / 12 / 16 / 24 px. Dark mode: :root[data-theme="dark"] (shared/theme.js). */
:root {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px;
  --bg: #ffffff; --surface: #f4f5f7; --fg: #15181d; --muted: #5a6371; --line: #dfe2e7; --line-strong: #bcc2cb;
  --ink: #1b2330; --ink-fg: #ffffff;
  --ok: #17652d; --ok-bg: #e5f4ea;
  --warn: #8a5300; --warn-bg: #fff2d1;
  --danger: #b0261b; --danger-bg: #fcebe9;
  --info: #4a5260; --info-bg: #eceef2;
  --link: #1f4fa8;
  --radius: 10px;
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #181c22; --fg: #e9ecf1; --muted: #9aa3b0; --line: #29303a; --line-strong: #3d4651;
  --ink: #e9ecf1; --ink-fg: #12151a;
  --ok: #6fd58f; --ok-bg: #112a19;
  --warn: #f1bd5c; --warn-bg: #2d2410;
  --danger: #ff8d82; --danger-bg: #331816;
  --info: #aeb6c2; --info-bg: #20252d;
  --link: #8db4ff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.icon { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.2em; }
.map-pin .icon { width: 100%; height: 100%; vertical-align: top; }
.map-pin .pin-svg { color: #b0261b; fill: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.legend .icon, .checklist .icon, .stamp-label .icon { vertical-align: -0.15em; }
.checklist li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stamp-label { display: inline-flex; align-items: center; gap: 6px; }
.tick .icon { width: 14px; height: 14px; vertical-align: -2px; }
.mainnav button b .icon { width: 14px; height: 14px; vertical-align: 0; }
.small .icon { vertical-align: -0.2em; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--link); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
@media print { .no-print { display: none !important; } }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line);
  padding: calc(var(--s2) + env(safe-area-inset-top)) var(--s4) 0;
}
.topbar-row { display: flex; align-items: center; gap: var(--s2); max-width: 1100px; margin: 0 auto var(--s2); }
.topbar h1 { flex: 1; min-width: 0; font-size: 1.05rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 44px; min-height: 44px; padding: 0 var(--s2);
  border: 0; border-radius: var(--radius); background: transparent; text-decoration: none; cursor: pointer; font-size: 1.15rem; color: var(--fg);
}
.icon-btn:hover { background: var(--surface); }
#themeBtn { gap: 6px; font-size: .9rem; font-weight: 600; }
#themeBtn span { display: none; }
@media (min-width: 760px) { #themeBtn span { display: inline; } }
.pill {
  flex: none; min-height: 36px; padding: 0 var(--s3); border: 0; border-radius: 999px; font-weight: 650; font-size: .9rem; cursor: pointer;
  background: var(--info-bg); color: var(--info);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill { display: inline-flex; align-items: center; gap: 6px; }

.mainnav { display: flex; max-width: 1100px; margin: 0 auto; }
.mainnav button {
  flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0 var(--s2); border: 0; border-radius: 0; background: transparent;
  box-shadow: inset 0 -3px 0 transparent; color: var(--muted); font-weight: 500; font-size: .92rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.mainnav button b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--info-bg); color: var(--muted); font-size: .8rem; flex: none; }
.mainnav button span { overflow: hidden; text-overflow: ellipsis; }
.mainnav button.done b { background: var(--ok-bg); color: var(--ok); }
.mainnav button.active { color: var(--fg); font-weight: 700; box-shadow: inset 0 -3px 0 var(--ink); }
.mainnav button.active b { background: var(--ink); color: var(--ink-fg); }
.subnav {
  display: flex; gap: 20px; max-width: 1100px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; padding: 0 var(--s2) 0 var(--s4);
}
.subnav::-webkit-scrollbar { display: none; }
.subnav button {
  position: relative; flex: none; min-height: 44px; padding: 0 var(--s1); border: 0; border-radius: 0; background: transparent; box-shadow: inset 0 -2px 0 transparent;
  color: var(--muted); font-weight: 500; font-size: .95rem; cursor: pointer;
}
.subnav button + button::before { content: '›'; position: absolute; left: -13px; top: 50%; transform: translateY(-52%); color: var(--line-strong); font-size: 1.1rem; }
.subnav button.active { color: var(--fg); font-weight: 700; box-shadow: inset 0 -2px 0 var(--ink); }
.tick { color: var(--ok); font-style: normal; font-weight: 700; }
fieldset.battery-pair { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.battery-pair legend { padding: 0; margin-bottom: var(--s1); }
@media (max-width: 599px) {
  .topbar { padding-inline: var(--s3); }
  .subnav { padding-left: var(--s1); }
  .mainnav button span { display: none; }
  .mainnav button.active span { display: inline; }
  .mainnav button.active b { display: none; }
  .mainnav button.active { flex: 1 1 0; }
  .mainnav button:not(.active) { flex: 0 0 44px; }
  .mainnav button { font-size: .88rem; padding: 0; }
}
@media (max-width: 479px) { .topbar h1 { display: none; } .topbar-row .pill { margin-right: auto; } }

/* ---------- layout ---------- */
.step-root { max-width: 1100px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s6); outline: none; }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: var(--s4); }
.cols { display: grid; gap: var(--s6); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 840px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .cols-map { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
/* one vertical rhythm: flex columns with gap, never margins between blocks */
.sec, .stack, .cols > div, .map-col, .side, .report, .live { display: flex; flex-direction: column; gap: var(--s3); }
.cols > div { gap: var(--s4); }
.cols > div > .sec + .sec { margin-top: var(--s2); }
.sec > h2 { margin-bottom: 0; }
.sec .sec { margin: 0; }
[data-out] { display: flex; flex-direction: column; gap: var(--s3); }
[data-out]:empty { display: none; }
.script[data-out] { display: block; }
p, ul, ol { margin: 0; }
.sec > h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.sec.box { background: var(--surface); border-radius: var(--radius); padding: var(--s4); }
.cols > div > h2, h3 { font-size: 1rem; font-weight: 650; }
.small { font-size: .85rem; color: var(--muted); }
.help { margin-top: var(--s6); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.row-actions > * { flex: 1 1 auto; }

/* ---------- controls ---------- */
:where(button, .btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); width: 100%; min-height: 48px; padding: 0 var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); color: var(--fg); font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation;
}
button:active, .btn:active { transform: scale(.985); }
button:disabled { opacity: .45; cursor: default; }
.icon-btn, .pill, .subnav button { width: auto; }
.btn-primary { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); }
.btn-secondary { background: var(--bg); }
.btn-small { width: auto; min-height: 44px; padding: 0 var(--s4); font-size: .92rem; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-stamp { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); }
.file-btn { cursor: pointer; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: var(--s1); }
.label { font-size: .82rem; color: var(--muted); font-weight: 600; display: block; }
.static { min-height: 44px; display: flex; align-items: center; font-weight: 600; }
input[type=text], input[type=tel], input[type=time], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: var(--s2) var(--s3); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 8px;
}
textarea { resize: vertical; }
input[type=range] { width: 100%; min-height: 44px; accent-color: var(--ink); }
.check { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s1) 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { flex: 1 1 0; min-width: 0; border: 0; border-radius: 0; min-height: 48px; padding: 0 var(--s2); background: var(--bg); font-size: .95rem; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ink-fg); }

.msg { border-radius: 8px; padding: var(--s3); font-size: .92rem; }
.msg.error { background: var(--danger-bg); color: var(--danger); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.chip { display: inline-flex; align-items: center; padding: 2px var(--s3); border-radius: 999px; font-size: .82rem; font-weight: 650; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }

details.fold { border-top: 1px solid var(--line); padding-top: var(--s1); }
details > summary { min-height: 44px; display: flex; align-items: center; gap: var(--s2); cursor: pointer; font-weight: 600; font-size: .95rem; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '›'; display: inline-block; width: 1em; font-size: 1.2em; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: var(--s2); }
details.fold > :not(summary) + :not(summary) { margin-top: var(--s3); }
details.fold > .stack, details.fold > .manual { padding-bottom: var(--s2); }

ul.plain { list-style: none; padding: 0; margin: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 48px; padding: var(--s1) 0; border-bottom: 1px solid var(--line); }
.list-row a { font-weight: 600; }
.row-end { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2) var(--s4); }
.kv > div > div { font-weight: 600; }
.metar { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-word; white-space: pre-wrap; margin: 0; }
.metar-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); }

/* ---------- Ort ---------- */
.map { height: 360px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
@media (min-width: 840px) { .map { height: 480px; } }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border-radius: 3px; }
.legend i.dash { background: none; border: 2px dashed #777; border-radius: 50%; }
.map-pin { background: none; border: 0; font-size: 28px; line-height: 1; text-align: center; text-shadow: 0 0 3px #fff; }
.map-arp { font-size: 22px; color: #000; }
.map-plain { background: #e8e8e8; }
.gms { font-size: 1.45rem; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums; }
.manual { display: flex; gap: var(--s2); }
.manual input { flex: 1; }
.manual button { width: auto; flex: none; }

/* ---------- Zone ---------- */
.zone-line { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s3) var(--s6); }
.zone-badge {
  width: 56px; height: 56px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.9rem; font-weight: 750;
  background: var(--info-bg); color: var(--info);
}
.zone-badge.ok { background: var(--ok-bg); color: var(--ok); }
.zone-badge.warn { background: var(--warn-bg); color: var(--warn); }
.zone-badge.danger { background: var(--danger-bg); color: var(--danger); }
.fact strong { display: block; font-size: 1.05rem; }

/* ---------- Höhe ---------- */
.report-grid { display: grid; gap: var(--s4); }
@media (min-width: 480px) and (max-width: 839px), (min-width: 1000px) { .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.report { background: var(--surface); border-radius: var(--radius); padding: var(--s3) var(--s4); }
.report .pair { display: flex; gap: var(--s4) var(--s6); flex-wrap: wrap; }
.report .big { font-size: 1.9rem; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.report .unit { font-size: 1rem; color: var(--muted); font-weight: 600; }
.report .what { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.allowed-line .chip { margin-left: auto; }
.allowed-line { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.facts li { margin: var(--s1) 0; }

/* ---------- Entscheidung ---------- */
.verdict { border-radius: var(--radius); padding: var(--s6) var(--s4); text-align: center; background: var(--info-bg); color: var(--info); }
.verdict .v-title { font-size: 2rem; font-weight: 750; line-height: 1.15; }
.verdict .v-sub { margin-top: var(--s2); font-size: .95rem; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- Anmeldung ---------- */
.script { white-space: pre-wrap; background: var(--surface); border-radius: var(--radius); padding: var(--s3) var(--s4); font-size: 1rem; }
.bullets { list-style: none; margin: 0; padding: 0; }
.bullets li { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: 1.15rem; }
.bullets .label { flex: 0 0 8.5em; font-size: .9rem; }
.bullets strong.blank { color: var(--danger); font-weight: 500; }
.checklist li { padding: var(--s1) 0; }
.checklist li.ok { color: var(--ok); }
.checklist li.open { color: var(--muted); }
.stamp-row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; min-height: 48px; }
.stamp-row .stamp-label { font-weight: 650; color: var(--ok); min-width: 8.5em; }
.stamp-row input[type=time] { width: 8.5em; flex: none; }
.stamp-row.done .btn-ghost { margin-left: auto; }

/* ---------- Flugbuch ---------- */
.live { text-align: center; padding: var(--s4); background: var(--surface); border-radius: var(--radius); gap: var(--s1); }
.live .timer { font-size: 2.6rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.live.running { background: var(--warn-bg); color: var(--warn); }
.live.running .small { color: inherit; }
.flight { padding: var(--s4) 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s3); }
.flight h3 { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.flight .btn-small { align-self: flex-start; }

/* ---------- footer nav ---------- */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4) calc(var(--s2) + env(safe-area-inset-bottom));
}
.navbar > * { max-width: none; }
.navbar #prevBtn { width: auto; flex: none; min-width: 110px; }
.navbar #nextBtn { width: auto; flex: 1 1 auto; max-width: 420px; margin-left: auto; min-height: 52px; }
.navbar #saveInfo { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 599px) { .navbar #saveInfo { display: none; } .navbar #nextBtn { max-width: none; } }

/* ---------- dialogs, toast, preview ---------- */
dialog.dlg { width: min(560px, calc(100vw - 32px)); max-height: 90vh; overflow: auto; border: 0; border-radius: 14px; background: var(--bg); color: var(--fg); padding: var(--s4); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog.dlg::backdrop { background: rgba(0,0,0,.55); }
.dlg-body > h2 { font-size: 1.25rem; }
.dlg-body h3 { margin-bottom: var(--s2); }
.dlg-body section { padding-top: var(--s3); border-top: 1px solid var(--line); }
.seg + .small { display: block; margin-top: var(--s1); }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--ink-fg);
  padding: var(--s2) var(--s4); border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; }
.preview { overflow-x: auto; }
.preview-scale { min-width: 0; zoom: .5; }

/* Printing: only the protocol (rendered into #printRoot) is visible */
.print-root { display: none; }
@media print {
  body.printing { padding: 0; background: #fff; }
  body.printing #appRoot, body.printing dialog, body.printing .toast { display: none !important; }
  body.printing .print-root { display: block; }
}

/* cards: grouped blocks with inner padding */
.sec.box { padding: var(--s4); }
.sec.box > h2 { color: var(--fg); text-transform: none; letter-spacing: 0; font-size: 1.02rem; }
.zonehint { display: flex; flex-direction: column; gap: var(--s2); }
.zonehint p { font-size: .92rem; }
.zonehint .msg { font-size: .92rem; }
.map-sm { height: 260px; }
.taf { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.taf li > strong { display: inline; }
.taf .when { color: var(--muted); }
pre.metar { margin: 0; }

.w3w { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.w3w strong { font-size: 1.05rem; }
