/* =====================================================================
   Stärkster Segler – Gestaltung
   Variablen (Tokens) zuerst; Ansichten: hell (Standard), dunkel, Sonnenlicht.
   --brand wird aus Einstellungen → Darstellung gesetzt (Verbandsfarbe).
   ===================================================================== */
:root {
  --brand: #0b6e4f;
  --on-brand: #ffffff;
  --bg: #f4f6f8;
  --card: #ffffff;
  --sunken: #eef1f4;
  --text: #17202a;
  --muted: #566372;
  --line: #d5dce3;
  --line-strong: #b4bfca;
  --accent: var(--brand);
  --accent-bg: var(--brand);       /* Hintergrund für Knöpfe/Kacheln mit --on-brand-Schrift */
  --accent-text: var(--brand);
  --accent-soft: color-mix(in srgb, var(--brand) 12%, var(--card));
  --ok: #0b7a43;  --ok-bg: #e3f4ec;
  --warn: #8a5a00; --warn-bg: #fff3d6;
  --error: #b42318; --error-bg: #fde8e7;
  --hl: #fff7c2;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 45%, transparent);
  --tap: 44px;            /* Mindestgröße für Tippflächen (Handy) */
  --side-w: 236px;
  --top-h: 56px;
  color-scheme: light;
}
/* dunkel: automatisch nach Gerät oder fest gewählt */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f141a; --card: #18202a; --sunken: #121820; --text: #e7edf3; --muted: #9eabb8;
    --line: #2b3643; --line-strong: #3d4a59;
    --accent: color-mix(in srgb, var(--brand) 65%, #ffffff); --accent-text: var(--accent);
    --accent-soft: color-mix(in srgb, var(--brand) 25%, var(--card));
    --ok: #4ccb8a; --ok-bg: #12301f; --warn: #f0c050; --warn-bg: #33270b; --error: #ff8a80; --error-bg: #3a1714;
    --hl: #3a3410; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --card: #18202a; --sunken: #121820; --text: #e7edf3; --muted: #9eabb8;
  --line: #2b3643; --line-strong: #3d4a59;
  --accent: color-mix(in srgb, var(--brand) 65%, #ffffff); --accent-text: var(--accent);
  --accent-soft: color-mix(in srgb, var(--brand) 25%, var(--card));
  --ok: #4ccb8a; --ok-bg: #12301f; --warn: #f0c050; --warn-bg: #33270b; --error: #ff8a80; --error-bg: #3a1714;
  --hl: #3a3410; --shadow: none; color-scheme: dark;
}
/* Sonnenlicht: maximaler Kontrast für helle Hallen und draußen */
:root[data-theme="sun"] {
  --bg: #ffffff; --card: #ffffff; --sunken: #f2f2f2; --text: #000000; --muted: #222222;
  --line: #000000; --line-strong: #000000;
  --accent: color-mix(in srgb, var(--brand) 70%, #000000); --accent-text: var(--accent); --accent-bg: var(--accent);
  --accent-soft: #ffffff; --ok: #005a2b; --ok-bg: #d6f5e3; --warn: #5c3c00; --warn-bg: #ffe9a8;
  --error: #8f0f05; --error-bg: #ffd9d4; --hl: #ffe94d; --shadow: none;
}
:root[data-theme="sun"] body { font-weight: 500; }
:root[data-theme="sun"] .card, :root[data-theme="sun"] table { border-width: 2px; }

/* ---------------------------------------------------------------- Grundlagen */
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top-h) + 24px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent-text); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none; box-shadow: var(--focus);
}
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 .7em; }
h2 { font-size: 1.15rem; margin: 1.5em 0 .55em; }
code { font-size: .9em; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
[hidden] { display: none !important; }  /* hidden-Attribut gilt auch für Elemente mit eigenem display */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--top-h);
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand img { height: 36px; width: auto; border-radius: 4px; }
.brand .t { font-weight: 700; white-space: nowrap; }
.brand .e { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplinks { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.toplinks a, .toplinks button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .93rem; background: transparent; border: 0; cursor: pointer; font-weight: 500;
}
.toplinks a:hover, .toplinks button:hover { background: var(--sunken); filter: none; }
.toplinks a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

/* ---------------------------------------------------------------- Seitenleiste (Wettkampfleitung, PC) */
.layout { display: block; }
.sidebar { display: none; }
.has-sidebar .layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
.has-sidebar .sidebar {
  display: block; position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: 12px 10px 24px; background: var(--card); border-right: 1px solid var(--line);
}
.navgroup + .navgroup { margin-top: 14px; }
.navgroup .gl { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
                padding: 4px 10px; }
.navlink {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .95rem;
}
.navlink .ico { color: var(--muted); }
.navlink:hover { background: var(--sunken); }
.navlink[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600;
                                box-shadow: inset 3px 0 0 var(--accent); }
.navlink[aria-current="page"] .ico { color: var(--accent-text); }

/* ---------------------------------------------------------------- Inhalt */
main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 20px 40px; min-width: 0; }
main.wide { max-width: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
        margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 0; }
.card { overflow-x: auto; }   /* breite Tabellen in Karten scrollen statt über den Rand zu ragen */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.stat { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: .88em; color: var(--muted); }
.row label > input, .row label > select, .row label > textarea { color: var(--text); }

/* Formulare in Abschnitten (z. B. Teilnehmerseite) */
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.form-grid > .card { margin-bottom: 0; }
.form-grid + .card, .form-grid + section { margin-top: 14px; }
.fields { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fields > label, .fields > .seg { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.fields > label > input, .fields > label > select, .fields > label > .inline { width: 100%; font-weight: 400; color: var(--text); font-size: 1rem; }
.fields .inline input { flex: 1; min-width: 0; }
.fields .wide { grid-column: 1 / -1; }
label.check { flex-direction: row !important; align-items: center; gap: 10px !important; min-height: 38px; align-self: end;
              color: var(--text) !important; font-weight: 500 !important; font-size: .95rem !important; cursor: pointer; }
fieldset.seg { border: 0; padding: 0; margin: 0; }
fieldset.seg legend { padding: 0; margin-bottom: 5px; }
.seg { display: flex; }
.seg > label { display: inline-flex; }
fieldset.seg { flex-direction: row !important; flex-wrap: wrap; gap: 0 !important; }
fieldset.seg legend { width: 100%; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong);
            background: var(--card); color: var(--text); font-weight: 500; font-size: .95rem; cursor: pointer; margin-left: -1px; }
.seg label:first-of-type span { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.seg label:last-of-type span { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.seg input:checked + span { background: var(--accent-bg); color: var(--on-brand); border-color: var(--accent-bg); position: relative; }
.seg input:focus-visible + span { box-shadow: var(--focus); position: relative; }
table.sum { margin-top: 14px; background: transparent; }
table.sum td { padding: 5px 2px; border-bottom: 1px dashed var(--line); }
table.sum tr:hover > td { background: transparent; }
table.sum tr.total td { font-weight: 700; border-bottom: 1px solid var(--line-strong); }
table.sum tr.open td { font-weight: 700; font-size: 1.1rem; border-bottom: 0; color: var(--ok); }
table.sum tr.open.due td { color: var(--error); }
.savebar { position: sticky; bottom: 0; z-index: 30; display: flex; gap: 10px; justify-content: flex-end; align-items: center;
           padding: 12px 0; margin-top: 6px; background: linear-gradient(to top, var(--bg) 75%, transparent); }
.savebar #dirty { margin-right: auto; color: var(--warn); display: inline-flex; align-items: center; gap: 6px; }
.savebar #dirty[hidden] { display: none; }
@media (max-width: 999px) { .has-bottombar .savebar { bottom: calc(58px + env(safe-area-inset-bottom)); } }

/* Meldungen */
.flash { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px;
         background: var(--ok-bg); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.error { background: var(--error-bg); color: var(--error); border-color: color-mix(in srgb, var(--error) 25%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash-stack { position: fixed; top: calc(var(--top-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 60; width: min(680px, calc(100vw - 24px)); }
.flash-stack .flash { margin-bottom: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .22); }
.flash-stack .flash > span { flex: 1; }
.tx { margin-bottom: 10px; }
.tx-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tx-line { flex-wrap: nowrap; margin-top: 6px; align-items: center; }
.tx-name { flex: 1; min-width: 0; }
tr[id] { scroll-margin-top: calc(var(--top-h) + 8px); }
.flash-x { min-height: 0; padding: 2px; flex: none; background: transparent; border: 0; color: inherit; cursor: pointer; line-height: 0; }

/* Tabellen */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; background: var(--sunken); }
table tr:hover > td { background: color-mix(in srgb, var(--sunken) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.hl td { background: var(--hl) !important; }          /* nur für „gerade gescannt/gesucht“ */
tr.sel td { background: var(--accent-soft); }             /* ausgewählte Zeile, z. B. aktiver Betreuer */
tr.done td:first-child { box-shadow: inset 4px 0 0 var(--ok); }   /* erledigt, z. B. eingecheckt */
.ok-mark { color: var(--ok); margin-left: 4px; }
tr.absent td { color: var(--muted); background: var(--sunken); }
tr.absent td:first-child a { text-decoration: line-through; color: var(--muted); }
td.num, .nowrap { white-space: nowrap; }
.inline { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
/* Zeilen „nur lesen“ mit Bearbeiten-Knopf: .view sichtbar, .edit versteckt – und umgekehrt */
tr.ro .edit, tr:not(.ro) .view { display: none !important; }
/* Tabelle bearbeiten (Sammelbearbeitung): Knöpfe je Modus, geänderte Zeilen markiert */
.bulk:not(.editing) .bulk-on, .bulk.editing .bulk-off { display: none !important; }
.savebar [data-bulk-count] { margin-right: auto; }
.bulk-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.bulk.editing tr[data-row] td { background: var(--accent-soft); }
.bulk.editing tr.changed td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
th.wrap { white-space: normal; hyphens: auto; -webkit-hyphens: auto; max-width: 7.5em; }
/* Stationsplan-Übersicht: alle Stationen nebeneinander, erst auf schmalen Bildschirmen scrollen */
.plan-fit table.plan { table-layout: fixed; width: 100%; min-width: calc(var(--cols) * 4.3rem + 4.5rem); font-size: 0.8rem; }
.plan-fit th, .plan-fit td { padding: 6px 5px; white-space: normal; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; line-height: 1.25; }
.plan-fit th:first-child, .plan-fit td.time { width: 4.5rem; position: sticky; left: 0; z-index: 1; }
.plan-fit td.time { background: var(--card); }

/* Formulare und Knöpfe */
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 10px; min-height: 38px;
}
textarea { min-height: auto; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input[type=color] { padding: 2px; width: 52px; }
input.short { width: 7em; }
input.tiny { width: 4.8em; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent-bg); color: var(--on-brand); border: 1px solid transparent; cursor: pointer;
  padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; min-height: 38px;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button.secondary, .btn.secondary { background: var(--card); color: var(--accent-text); border-color: var(--line-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--accent-soft); filter: none; }
button.danger { background: var(--error); color: #fff; }
button:disabled { opacity: .55; cursor: default; }

/* Marken, Fortschritt, Kennzahlen */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78em; font-weight: 600;
         background: var(--sunken); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.place { font-weight: 700; font-size: 1.1em; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.kpi:hover { border-color: var(--accent); }
.kpi .l { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.kpi .v { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { font-size: .8rem; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist a { display: flex; align-items: center; gap: 10px; padding: 10px 4px; color: var(--text); text-decoration: none; min-height: var(--tap); }
.checklist a:hover { background: var(--sunken); }
.checklist .st { width: 22px; height: 22px; flex: none; }
.checklist .st.ok { color: var(--ok); } .checklist .st.warn { color: var(--warn); } .checklist .st.todo { color: var(--muted); }
.checklist .txt { display: flex; flex-direction: column; min-width: 0; }
.checklist .txt small { color: var(--muted); font-size: .82rem; }
.checklist .go { margin-left: auto; color: var(--muted); }

/* Startseite */
.hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.hero img { height: 72px; width: auto; }
.hero h1 { margin: 0; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tile { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: var(--radius); text-decoration: none;
        background: var(--card); border: 1px solid var(--line); color: var(--text); box-shadow: var(--shadow); min-height: 76px; }
.tile:hover { border-color: var(--accent); }
.tile .ico { width: 30px; height: 30px; color: var(--accent-text); }
.tile b { display: block; font-size: 1.05rem; }
.tile span { color: var(--muted); font-size: .88rem; }
.tile.primary { background: var(--accent-bg); color: var(--on-brand); border-color: transparent; }
.tile.primary .ico, .tile.primary span { color: var(--on-brand); }
.program { list-style: none; padding: 0; margin: 0; }
.program li { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.program li:last-child { border-bottom: 0; }
.program .time { font-weight: 700; min-width: 5.5em; font-variant-numeric: tabular-nums; }

/* Fußzeile */
.foot { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; padding: 18px 16px 28px; font-size: .85rem; color: var(--muted); }
.foot a { color: var(--muted); }
.foot select { min-height: 32px; padding: 2px 8px; font-size: .85rem; }

/* ---------------------------------------------------------------- Handy: Leiste unten + „Mehr“ */
.bottombar { display: none; }
.more { position: fixed; inset: 0 0 0 auto; border: 0; padding: 0; margin: 0; height: 100%; max-height: 100%;
        width: min(340px, 88vw); background: var(--card); color: var(--text); border-left: 1px solid var(--line); }
.more[open] { display: flex; flex-direction: column; }
.more::backdrop { background: rgba(0, 0, 0, .45); }
.more .mhead { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.more .mhead button { background: transparent; color: var(--text); border: 0; }
.more .mbody { padding: 8px 10px 30px; overflow-y: auto; }
.more .navlink { min-height: var(--tap); }

@media (max-width: 999px) {
  .has-sidebar .layout { display: block; }
  .has-sidebar .sidebar { display: none; }
  .toplinks .hide-m { display: none; }
  .bottombar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottombar a, .bottombar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px;
    font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none; background: transparent; border: 0;
    border-radius: 0; padding: 4px 2px;
  }
  .bottombar .ico { width: 24px; height: 24px; }
  .bottombar [aria-current="page"] { color: var(--accent-text); }
  .bottombar [aria-current="page"] .ico { stroke-width: 2.4; }
  body.has-bottombar { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
  :root { --top-h: 52px; }
  main { padding: 14px 12px 28px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand img { height: 30px; }
  .brand .e { display: none; }
  h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 1.4rem; }
  /* Helfer-Seiten: große Tippflächen */
  .big-actions button, .big-actions .btn, .capture-row button { min-height: 48px; }
}

/* ---------------------------------------------------------------- Scanner und Erfassung */
.scan-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px;
}
.scan-overlay video { width: min(92vw, 480px); border-radius: 12px; }
.scan-overlay .hint { color: #fff; }
.scan-overlay button { background: #fff; color: #111; }
.big-actions { display: flex; flex-direction: column; gap: 10px; }
.big-actions button, .big-actions .btn { font-size: 1.12rem; padding: 14px; min-height: 52px; text-align: center; }
.capture-row { border-bottom: 1px solid var(--line); padding: 10px 4px; }
.capture-row.hl { background: var(--hl); border-radius: 8px; }
.capture-row .who { display: flex; justify-content: space-between; gap: 8px; }
.capture-row .vals { display: flex; gap: 8px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.capture-row .vals input { width: 6.5em; font-size: 1.15rem; min-height: var(--tap); }
.capture-row .status { min-width: 1.5em; font-weight: 700; }
.sticky-bottom { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
@media (max-width: 999px) { .has-bottombar .sticky-bottom { bottom: calc(58px + env(safe-area-inset-bottom)); } }

/* Stationsplan bearbeiten: kompakt, erste Spalte bleibt beim Scrollen stehen */
.plan-edit th, .plan-edit td { padding: 4px 4px; }
.plan-edit td:first-child, .plan-edit th:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--card); white-space: nowrap; font-weight: 600;
}
.plan-edit select { width: 10.5em; font-size: 0.85rem; padding: 4px 4px; min-height: 34px; }

/* ---------------------------------------------------------------- Druck */
@media print {
  .topbar, .sidebar, .bottombar, .foot, .noprint, .flash { display: none !important; }
  .has-sidebar .layout { display: block; }
  body { background: #fff; color: #000; padding: 0; }
  main { padding: 0; max-width: none; }
  .card { border: none; padding: 0; box-shadow: none; }
}

/* Zurück-Link auf Detailseiten */
.backlink { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: .95rem;
            color: var(--accent-text); text-decoration: none; font-weight: 600; }
.backlink:hover { text-decoration: underline; }

/* Unterschriften (Urkunden → Gestaltung) */
.sig-edit { display: grid; gap: 8px; }

/* ---------------------------------------------------------------- Untermenü (Tabs) */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.subtabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; margin-bottom: -1px; text-decoration: none;
             color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.subtabs a:hover { color: var(--text); background: var(--accent-soft); }
.subtabs a.on { color: var(--accent-text); border-bottom-color: var(--accent-bg); }
.subtabs .count { font-size: .78rem; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); }
@media (max-width: 640px) { .subtabs { flex-wrap: nowrap; overflow-x: auto; } .subtabs a { white-space: nowrap; padding: 10px 10px; } }
.tabpanel[hidden] { display: none !important; }
button.big { font-size: 1.05rem; padding: 12px 20px; }
.print-mode span { flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 16px; line-height: 1.2; }
.print-mode small { font-weight: 400; opacity: .8; font-size: .78rem; }
.hints ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.row .grow { flex: 1 1 240px; }
.row .grow input { width: 100%; }
.reprint-list { max-height: 55vh; overflow: auto; }
.reprint-list thead th { position: sticky; top: 0; z-index: 1; }
.small-seg span { min-height: 34px; padding: 0 11px; font-size: .88rem; }

/* ---------------------------------------------------------------- Urkunden-Gestaltung mit Live-Vorschau */
.designer { display: grid; grid-template-columns: minmax(280px, 460px) minmax(0, 1fr); gap: 18px; align-items: start; }
.designer-preview { position: sticky; top: 76px; }
@media (max-width: 999px) { .designer { grid-template-columns: 1fr; } .designer-preview { position: static; max-width: 460px; } }
.preview-tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.preview-tools label.check { min-height: 0; align-self: center; }
.cert-preview { --mm: 2px; position: relative; width: 100%; aspect-ratio: 210 / 297; background: #fff; overflow: hidden;
                border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.12);
                font-family: "DejaVu Sans", Verdana, "Segoe UI", sans-serif; color: #23419a; user-select: none; touch-action: none; }
.cert-preview.rohling { background: #f7f3e8; }
.cert-preview.rohling .pv-design { display: none; }
.pv-design.hidden-bg .pv-bg { display: none; }
.pv-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pv-panel { position: absolute; border: max(1px, calc(.5 * var(--mm))) solid #c9d1dc; }
.pv-text { position: absolute; line-height: 1; white-space: nowrap; }
/* Elemente: Textbox ist 170 mm breit (wie im Druck); greifen und markieren nur am Text bzw. Bild selbst */
.pv-layer { position: absolute; inset: 0; pointer-events: none; }
.pv-el { position: absolute; }
.pv-text { line-height: 1; white-space: nowrap; }
.pv-text > span, .pv-img { pointer-events: auto; cursor: grab; outline: 1px dashed transparent; outline-offset: 1px; border-radius: 2px; }
.pv-text > span { display: inline-block; }
.pv-text > span:hover, .pv-img:hover { outline-color: var(--accent-bg); }
.pv-el.sel > span, .pv-img.sel { outline: 2px solid var(--accent-bg); background: color-mix(in srgb, var(--accent-bg) 10%, transparent); }
.pv-text > span:focus-visible, .pv-img:focus-visible { outline: 2px solid var(--accent-bg); }
.pv-el.off { opacity: .22; }
.pv-text > span.empty { color: #999; font-style: italic; }
.el-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.el-toolbar select { max-width: 220px; }
.field-ctl .el-kind { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
                      border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; }
.field-ctl .el-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-ctl .badge { opacity: .35; }
.field-ctl .badge.on { opacity: 1; background: var(--accent-soft); color: var(--accent-text); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { min-height: 0; padding: 2px 7px; font-size: .78rem; font-family: ui-monospace, monospace; background: var(--accent-soft);
                color: var(--accent-text); border: 1px solid transparent; font-weight: 500; }
.sliders .row { gap: 12px; align-items: end; }
button.danger, button.secondary.danger { background: var(--card); color: var(--error); border-color: color-mix(in srgb, var(--error) 40%, transparent); }
.pv-sigline { position: absolute; border-top: 1px solid; text-align: center; padding-top: calc(1.5 * var(--mm)); line-height: 1; }
.pv-sigimg { position: absolute; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.pv-sigimg img { flex: none; }
.pv-grid { position: absolute; inset: 0; pointer-events: none; display: none; }
.cert-preview.show-grid .pv-grid { display: block; }
.pv-grid i { position: absolute; background: rgba(220, 40, 40, .25); }
.pv-grid i[data-h] { left: 0; right: 0; height: 1px; }
.pv-grid i[data-v] { top: 0; bottom: 0; width: 1px; }
.pv-grid i[data-h="50"], .pv-grid i[data-h="100"], .pv-grid i[data-h="150"], .pv-grid i[data-h="200"], .pv-grid i[data-h="250"],
.pv-grid i[data-v="50"], .pv-grid i[data-v="100"], .pv-grid i[data-v="150"], .pv-grid i[data-v="200"] { background: rgba(220, 40, 40, .55); }
.field-ctl { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--card); }
.field-ctl[open] { border-color: var(--accent-bg); }
.field-ctl summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; list-style: none; }
.field-ctl summary::-webkit-details-marker { display: none; }
.field-ctl summary label.check { min-height: 0; align-self: center; }
.field-ctl .fname { font-weight: 700; }
.field-ctl .fpos { margin-left: auto; }
.sliders { display: grid; gap: 10px; padding: 4px 12px 12px; }
.field-ctl .sliders { border-top: 1px solid var(--line); padding-top: 10px; }
.sliders > label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.slider { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 400; }
.slider input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent-bg); }
.slider input[type=number] { width: 78px; }
.savebar.static { position: static; background: none; padding-bottom: 0; }
.print-mode { gap: 6px !important; }
.print-mode span { border-radius: var(--radius-sm) !important; margin-left: 0 !important; }
.sig-edit + .sig-edit { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.sig-edit h3 { margin: 0; font-size: 1rem; }
.sig-check { min-height: 70px; display: flex; align-items: center; justify-content: center; padding: 8px;
             border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: #fff; }
.sig-check canvas { max-width: 100%; max-height: 120px; background: repeating-conic-gradient(#e6e6e6 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.sig-edit output { font-weight: 600; min-width: 52px; }
.pv-sigimg canvas { flex: none; }
.keycolor { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.keycolor .kc-label { font-size: .85rem; font-weight: 600; color: var(--muted); width: 100%; }
.keycolor label.check { min-height: 0; }
.keycolor input[type=color] { width: 44px; height: 34px; padding: 2px; }
.keycolor button.on { background: var(--accent-bg); color: var(--on-brand); border-color: var(--accent-bg); }
.sig-check canvas.picking { cursor: crosshair; background: none; outline: 2px dashed var(--accent-bg); outline-offset: 2px; }
/* Unterschriften in der Vorschau verschiebbar */
.pv-sigline { cursor: grab; pointer-events: auto; outline: 1px dashed transparent; outline-offset: 2px; }
.pv-sigline:hover, .pv-sigimg canvas:hover { outline: 1px dashed var(--accent-bg); }
.pv-sigline.sel, .pv-sigimg canvas.sel { outline: 2px solid var(--accent-bg); }
.pv-sigimg canvas { pointer-events: auto; cursor: grab; }
.field-ctl .el-layer { font-size: .72rem; font-weight: 700; min-width: 20px; text-align: center; color: var(--muted); }
.layer-row { flex-wrap: wrap; gap: 6px !important; }
.layer-row button { min-height: 32px; padding: 0 9px; font-size: .85rem; }
.field-ctl .el-drag { cursor: grab; touch-action: none; user-select: none; color: var(--muted); font-size: 1.1rem; line-height: 1;
                      padding: 4px 2px; margin: -4px 0; }
.field-ctl .el-drag:hover { color: var(--accent-text); }
body.sorting, body.sorting * { cursor: grabbing !important; user-select: none; }
.field-ctl.dragging { opacity: .5; border-style: dashed; }
.field-ctl.drop-before { box-shadow: 0 -3px 0 0 var(--accent-bg); }
.field-ctl.drop-after { box-shadow: 0 3px 0 0 var(--accent-bg); }
/* Check-in: Teilnehmertabelle kompakt und einheitlich */
.checkin-table th, .checkin-table td { padding: 7px 6px; vertical-align: middle; }
.checkin-table th { white-space: nowrap; }
.checkin-table .pname { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.checkin-table .pname .ok-mark { margin: 0; display: inline-flex; flex: none; }
.checkin-table .pname .ok-mark.placeholder { color: var(--line-strong); }
.checkin-table .pname-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 3px 0 0 24px; }
.checkin-table .pname-sub .badge { white-space: nowrap; }
.checkin-table input, .checkin-table select, .checkin-table button { min-height: 34px; padding-top: 3px; padding-bottom: 3px; }
.checkin-table input.short { width: 5.4em; }
.checkin-table input.tiny { width: 3.8em; }
.checkin-table select { max-width: 9.5em; }
.checkin-table .inline button { padding-left: 9px; padding-right: 9px; }
.checkin-table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.checkin-table .actions button { white-space: nowrap; }
.checkin-table .actions form { margin: 0; }
.checkin-table .actions button { padding-left: 10px; padding-right: 10px; font-size: .92rem; }
/* Stationsbeschreibung (Erfasser, Verwaltung) */
.station-info summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.station-info summary::-webkit-details-marker { display: none; }
.station-info[open] summary { margin-bottom: 8px; }
.station-info h3 { font-size: 1rem; margin: 12px 0 4px; }
.station-info p { margin: 0 0 8px; line-height: 1.5; }
.st-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.st-facts dt { font-weight: 700; color: var(--muted); }
.st-facts dd { margin: 0; }
table.st-rules th { white-space: nowrap; width: 1%; }
table.st-rules tr.hit td, table.st-rules tr.hit th { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.st-image { display: block; max-width: 100%; height: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.class-rule { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; margin-bottom: 10px; border-radius: var(--radius-sm);
              background: var(--accent-soft); color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent-bg) 30%, transparent); }
.class-rule .ico { flex: none; margin-top: 2px; }
/* Stationen-Tabelle (Veranstaltung) kompakt */
.stations-table th, .stations-table td { padding: 7px 6px; }
.stations-table input.tiny { width: 3.6em; }
.stations-table td:nth-child(3) input.tiny { width: 4.6em; }
.stations-table td:nth-child(2) input { width: 100%; min-width: 10em; }
.stations-table .st-note { margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.stations-table select { max-width: 9.5em; }
/* Benutzer und Protokoll */
.otp { border-color: var(--accent-bg); }
.otp code.pw { font-size: 1.25rem; padding: 2px 8px; background: var(--accent-soft); border-radius: 6px; letter-spacing: .04em; }
.audit-list ul.changes { margin: 4px 0 0; padding-left: 16px; font-size: .88rem; }
.audit-list ul.changes s { color: var(--muted); }
.audit-list .badge.act-neu { background: var(--ok-bg); color: var(--ok); }
.audit-list .badge.act-gelöscht, .audit-list .badge.fehl { background: var(--error-bg); color: var(--error); }
.audit-list .badge.act-druck, .audit-list .badge.act-export { background: var(--accent-soft); color: var(--accent-text); }
.protocol-filter select, .protocol-filter input[type=date] { min-width: 0; }
.pager { gap: 8px; }
.toplinks .whoami { font-weight: 600; }
.history summary { cursor: pointer; }
.history .audit-list { box-shadow: none; border: 0; padding: 0; margin-top: 8px; }
/* Leitstand: gezielte Links */
.checklist small .show { color: var(--accent-text); font-weight: 600; }
.checklist li.has-sub { position: relative; }
.checklist .sub-link { display: inline-block; margin: -6px 0 8px 40px; font-size: .82rem; color: var(--accent-text); }
.station-progress { display: block; margin-bottom: 10px; padding: 6px 8px; border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.station-progress:hover { background: var(--accent-soft); }
.station-progress .row-between { display: flex; justify-content: space-between; gap: 8px; }
.station-progress .bar { display: block; margin-top: 4px; }
/* Offene Beträge, fehlende Ergebnisse */
.open-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.open-head h2 { margin: 0; flex: 1; }
.open-sum { font-size: 1.2rem; font-weight: 700; color: var(--error); }
.missing-station h3 { margin: 14px 0 6px; font-size: 1rem; }
.missing-table input.short { width: 6.5em; }
/* Urkunden-Vorlagen */
.tpl-bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.tpl-bar > label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.tpl-bar select { min-width: 16em; }
.tpl-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-import { width: 100%; }
.tpl-import summary { cursor: pointer; color: var(--accent-text); font-weight: 600; }
.tpl-import > div { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.chk-group { display: flex; flex-wrap: wrap; gap: 2px 14px; align-items: center; margin-top: 10px; }
.chk-group label.check { min-height: 30px; }
