/* Ventilator
   Zustände nie nur über Farbe: gewählt = Haken + dicker Rahmen + Füllung,
   Fehler = Warnsymbol + gestrichelter Rahmen + Text, wartet = Uhr + Text.
   Kein Rot. Akzent Blau, Warnung Ocker/Braun – auch bei Rot-Grün-Sehschwäche gut unterscheidbar. */

:root {
  color-scheme: light dark;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #14181f;
  --muted: #535d6b;
  --line: #aab3bf;
  --line-strong: #14181f;
  --accent: #1746b3;
  --accent-ink: #ffffff;
  --accent-soft: #e4ebfa;
  --warn-bg: #fff3cc;
  --warn-line: #7a5800;
  --warn-ink: #3b2a00;
  --info-bg: #e8eef9;
  --focus: #0b57d0;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #1a1f26;
    --text: #eef1f5;
    --muted: #a6afbb;
    --line: #4a5461;
    --line-strong: #eef1f5;
    --accent: #8fb2ff;
    --accent-ink: #071331;
    --accent-soft: #1c2944;
    --warn-bg: #362b08;
    --warn-line: #f0c74a;
    --warn-ink: #ffe6a0;
    --info-bg: #17223a;
    --focus: #a9c3ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 var(--font);
}
[hidden] { display: none !important; }
.sprite { display: none; }
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.ic { width: 20px; height: 20px; flex: none; }

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.top { margin: 4px 0 12px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; }
h2 { font-size: 20px; margin: 0 0 8px; }
.sub, .muted { color: var(--muted); margin: 2px 0 0; }
.intro { margin: 0 0 10px; font-size: 15px; }

/* Karten / Felder */
.card, .field {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 12px;
  min-width: 0;
}
fieldset.field { margin-inline: 0; }
legend {
  float: left;            /* Legend innerhalb der Karte statt auf dem Rahmen */
  width: 100%;
  padding: 0;
}
legend + * { clear: both; }
.q { display: block; margin: 0 0 10px; font-size: 17px; }
.hint { color: var(--muted); font-size: 15px; margin: -4px 0 10px; }
.field input + .hint { margin: 10px 0 0; }  /* unter dem Feld, Fokusrahmen darf nicht überdecken */
.opt { color: var(--muted); font-weight: normal; }
.label { display: block; font-weight: 600; margin: 12px 0 6px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  font: inherit;
  font-size: 18px;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 52px;
}
#einsatznummer { font-size: 22px; letter-spacing: .06em; font-weight: 600; }
textarea { resize: vertical; min-height: 110px; line-height: 1.35; }
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input[type="text"]:hover, input[type="password"]:hover, textarea:hover { border-color: var(--line-strong); }

/* Tipp-Flächen */
.tiles { display: grid; gap: 8px; }
.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tile input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.tile:hover { border-color: var(--line-strong); }
.tile:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.tile.on {
  border-color: var(--accent);
  border-width: 3px;
  padding: 9px 11px;       /* Rahmen dicker, Größe gleich */
  background: var(--accent-soft);
}
.tx { display: flex; flex-direction: column; }
.t1 { font-weight: 600; }
.t2 { color: var(--muted); font-size: 14px; }
.or { margin: 2px 0; text-align: center; color: var(--muted); font-size: 14px; }

/* Kästchen (Mehrfachauswahl) und Kreis (Einfachauswahl) */
.box, .dot {
  flex: none;
  width: 26px; height: 26px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  display: grid; place-items: center;
}
.box { border-radius: 6px; }
.dot { border-radius: 50%; }
.tile.on .box { background: var(--accent); border-color: var(--accent); }
.tile.on .box::after {
  content: "";
  width: 7px; height: 13px;
  border: solid var(--accent-ink);
  border-width: 0 3px 3px 0;
  transform: translateY(-2px) rotate(45deg);
}
.tile.on .dot { border-color: var(--accent); border-width: 3px; }
.tile.on .dot::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
}

/* Skala 1–5 */
.scale-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tile.num {
  justify-content: center;
  min-height: 56px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
}
.tile.num.on {
  padding: 0;
  background: var(--accent);
  color: var(--accent-ink);
}
.tile.num .mark {
  display: none;
  position: absolute; top: 3px; right: 4px;
  width: 15px; height: 15px;
}
.tile.num.on .mark { display: block; }
.scale-legend {
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 14px; margin: 6px 2px 8px;
}
.tile.nb { justify-content: center; min-height: 48px; }

/* Hinweise, Fehler */
.err, .note, .summary {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 15px;
}
.err, .summary {
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 2px dashed var(--warn-line);
  font-weight: 600;
}
.note { background: var(--info-bg); border: 2px solid var(--accent); }
.field.has-error { border: 3px dashed var(--warn-line); padding: 12px; }
.field.has-error input, .field.has-error textarea { border-color: var(--warn-line); }
.summary { margin: 4px 0 12px; }

.below { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-top: 6px; }
.privacy { display: flex; gap: 6px; align-items: center; margin: 0; }
.privacy .ic { width: 18px; height: 18px; }
.count { color: var(--muted); font-size: 14px; margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Knöpfe */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  min-height: 54px;
  margin: 4px 0 0;
  padding: 10px 16px;
  font: inherit; font-size: 18px; font-weight: 700;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.small { min-height: 44px; font-size: 16px; width: auto; padding: 6px 14px; margin: 8px 0 0; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::before, .spin {
  content: "";
  width: 18px; height: 18px; flex: none;
  border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::before, .spin { animation-duration: 3s; }
}

/* Statusleiste oben: kein Netz / wartet / nachgesendet */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 15px;
}
.banner .ic { width: 22px; height: 22px; margin-top: 1px; }
.banner strong { display: block; font-size: 16px; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner.wait { background: var(--warn-bg); color: var(--warn-ink); border: 2px dashed var(--warn-line); }
.banner.offline { background: var(--surface); border: 2px dashed var(--line-strong); }
.banner.ok { background: var(--info-bg); border: 2px solid var(--accent); }
.banner.problem { background: var(--warn-bg); color: var(--warn-ink); border: 3px double var(--warn-line); }
.banner .btn.secondary { color: var(--text); }

/* Bestätigung */
.done {
  text-align: center;
  background: var(--surface);
  border: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 16px;
  margin: 0 0 14px;
}
.done:focus { outline: none; }
.done.queued { border: 3px dashed var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.done-ic { width: 52px; height: 52px; color: var(--accent); }
.done.queued .done-ic { color: var(--warn-ink); }
.done h2 { margin: 8px 0 4px; }
.done p { margin: 0; }

/* Nebenlinks: klein, grau, nicht unterstrichen */
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 20px; }
.link {
  background: none; border: 0; padding: 12px 6px; min-height: 44px;
  font: inherit; font-size: 12.5px; color: var(--muted);
  text-decoration: none; cursor: pointer;
}
.link:hover { color: var(--text); text-decoration: underline; }
.foot-note { flex-basis: 100%; text-align: center; margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Auswertung (/admin) ---------- */
.wrap.wide { max-width: 1200px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); gap: 4px; }
.filters input[type="date"] {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 44px;
}
.filters .btn { width: auto; margin: 0; min-height: 44px; font-size: 16px; padding: 6px 14px; }
a.btn { text-decoration: none; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.stats b { font-size: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--surface); font-weight: 700; white-space: nowrap; }
td.num { text-align: center; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }
td.text { min-width: 220px; max-width: 420px; white-space: pre-wrap; }
.tag { display: inline-block; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 5px; font-size: 12px; margin-left: 4px; }
.empty { padding: 18px; color: var(--muted); }
