/* ==========================================================================
   Florian-FunkFuchs – Stylesheet
   Feuerwehrfarben: Dunkelblau, Rot, Schwarz, Weiß · Hell- und Dunkelmodus
   ========================================================================== */

:root {
  --navy: #13294b;
  --navy-2: #1d3a66;
  --red: #c8102e;
  --red-2: #a50d26;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: #e3e8f0;
  --text: #0e1726;
  --muted: #5a667a;
  --border: #d9e0ea;
  --primary: var(--navy);
  --link: #1d4f9c;
  --primary-text: #ffffff;
  --accent: var(--red);
  --ok: #1b7f45;
  --ok-bg: #e3f4ea;
  --warn: #a86500;
  --warn-bg: #fff2d9;
  --danger: #c8102e;
  --danger-bg: #fde6ea;
  --info: #1d5fbf;
  --info-bg: #e5efff;
  --shadow: 0 1px 2px rgba(14, 23, 38, .06), 0 4px 14px rgba(14, 23, 38, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar: var(--navy);
  --topbar-text: #ffffff;
  --focus: 0 0 0 3px rgba(200, 16, 46, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121b2d; --surface-2: #19243a; --surface-3: #22304a;
    --text: #e7ecf4; --muted: #95a2b8; --border: #26344e;
    --primary: #3a6fc4; --link: #8fb4ff; --accent: #ff4d63;
    --ok: #3ccf7a; --ok-bg: #0f2e1f; --warn: #ffb547; --warn-bg: #33260d;
    --danger: #ff5a6e; --danger-bg: #3a1219; --info: #6aa6ff; --info-bg: #122542;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    --topbar: #0d1a33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121b2d; --surface-2: #19243a; --surface-3: #22304a;
  --text: #e7ecf4; --muted: #95a2b8; --border: #26344e;
  --primary: #3a6fc4; --link: #8fb4ff; --accent: #ff4d63;
  --ok: #3ccf7a; --ok-bg: #0f2e1f; --warn: #ffb547; --warn-bg: #33260d;
  --danger: #ff5a6e; --danger-bg: #3a1219; --info: #6aa6ff; --info-bg: #122542;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  --topbar: #0d1a33;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); min-height: 100vh;
}
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.accent { color: var(--accent); }
.pre { white-space: pre-wrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

/* ---------- Layout-Helfer ---------- */
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-main { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Karten ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card + .card { margin-top: 16px; }
.veh-grid > .card + .card, .ex-cards > .card + .card, .grid-2 > .card + .card, .grid > .card + .card { margin-top: 0; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-height: 40px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-red, .btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover, .btn-danger:hover { background: var(--red-2); border-color: var(--red-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.93); background: var(--ok); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-outline-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.btn-lg { padding: 13px 20px; min-height: 52px; font-size: 1.05rem; }
.btn-xl { padding: 16px 22px; min-height: 64px; font-size: 1.2rem; border-radius: var(--radius); }
.btn-block { width: 100%; white-space: normal; text-align: center; }
.icon-btn {
  background: transparent; border: 0; color: inherit; cursor: pointer; font: inherit;
  min-width: 40px; min-height: 40px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.linklike { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- Formulare ---------- */
.field { display: block; }
.field > span, .field-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.field small, .hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--red); vertical-align: middle; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { flex: 0 0 auto; margin-top: 2px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.code-input { font-family: var(--mono); font-size: 1.6rem !important; letter-spacing: .25em; text-align: center; text-transform: uppercase; }
.inline-num { width: 90px !important; }

/* ---------- Hinweise / Badges ---------- */
.alert { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; margin: 10px 0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--surface-3); color: var(--text); white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-navy { background: var(--primary); color: #fff; }
.badge-red { background: var(--red); color: #fff; }
.type-badge { font-family: var(--mono); }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  background: var(--topbar); color: var(--topbar-text); padding: 8px 16px; min-height: 58px;
  border-bottom: 3px solid var(--red);
}
.topbar a { color: inherit; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.1rem; letter-spacing: .01em; }
.brand img { display: block; }
.brand b { color: #ff6b7d; }
.topbar-crumbs { flex: 1 1 auto; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: .92rem; opacity: .9; }
.topbar-crumbs a:hover { text-decoration: underline; }
.topbar-crumbs .sep { opacity: .5; }
.topbar-crumbs span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; z-index: 60;
}
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 6px; background: none; border: 0;
  font: inherit; color: inherit; text-decoration: none; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
@media (max-width: 700px) { .user-name, .app-leitstelle .brand-text { display: none; } }

.app-main { max-width: 1500px; margin: 0 auto; padding: 18px 16px 60px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Anmeldung / Startseite ---------- */
.page-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 24px; }
.auth-brand { margin-bottom: 18px; color: var(--text); }
.auth-brand .brand b { color: var(--red); }
.home { width: 100%; max-width: 820px; }
.home-hero { text-align: center; margin-bottom: 28px; }
.home-hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 10px 0 6px; }
.home-choices { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.choice { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); padding: 26px 22px; border-top: 4px solid var(--red); transition: transform .12s; }
.choice:hover { transform: translateY(-2px); }
.choice-ico { font-size: 2.2rem; }
.choice-title { font-size: 1.25rem; font-weight: 800; }
.choice-sub { color: var(--muted); }
.home-foot { text-align: center; margin-top: 24px; }

/* ---------- Seitentitel / Tabs ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--red); }

/* ---------- Status der Übung ---------- */
.ex-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot-live { background: var(--red); box-shadow: 0 0 0 0 rgba(200, 16, 46, .6); animation: pulse 1.6s infinite; }
.dot-ok { background: var(--ok); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(200, 16, 46, .55); } 70% { box-shadow: 0 0 0 9px rgba(200, 16, 46, 0); } 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0); } }
@media (prefers-reduced-motion: reduce) { .dot-live { animation: none; } }
.clock { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; letter-spacing: .02em; }
.clock-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.clock-box .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: block; }

/* ---------- Dashboard ---------- */
.ex-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ex-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); border-left: 4px solid var(--primary); }
.ex-card:hover { border-color: var(--red); }
.ex-card h3 { margin: 0; font-size: 1.12rem; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), #ff6b3d); border-radius: 99px; }
.progress-ok > i { background: var(--ok); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 1.45rem; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }

/* ---------- Fahrzeugkacheln (Live) ---------- */
.veh-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.veh-tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  border-left: 6px solid var(--muted); padding: 14px; transition: box-shadow .15s, transform .1s;
}
.veh-tile:hover { box-shadow: 0 0 0 2px var(--primary), var(--shadow); }
.veh-tile.st-enroute { border-left-color: var(--info); }
.veh-tile.st-arrived { border-left-color: var(--warn); }
.veh-tile.st-done { border-left-color: var(--ok); }
.veh-tile.st-finished { border-left-color: var(--ok); }
.veh-tile.overdue { border-left-color: var(--red); background: linear-gradient(0deg, var(--danger-bg), var(--danger-bg)) , var(--surface); }
.veh-tile.overdue .veh-state { color: var(--danger); }
.veh-call { font-size: 1.35rem; font-weight: 800; letter-spacing: .01em; font-family: var(--mono); }
.veh-type { color: var(--muted); font-weight: 600; }
.veh-state { font-weight: 700; }
.veh-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.veh-actions { display: flex; gap: 8px; margin-top: auto; }
.veh-actions .btn { flex: 1 1 0; }
.veh-rank { position: absolute; right: 12px; top: 12px; text-align: right; }
.veh-rank b { font-size: 1.2rem; display: block; }
.leg-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.leg-dot {
  width: 26px; height: 26px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; background: var(--surface-3); color: var(--muted); border: 2px solid transparent;
}
.leg-dot.s-enroute { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.leg-dot.s-arrived, .leg-dot.s-submitted { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.leg-dot.s-done { background: var(--ok-bg); color: var(--ok); }
.leg-dot.s-skipped { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.cell-btn { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; padding: 4px 6px; border-radius: 6px; width: 100%; text-align: inherit; }
.cell-btn:hover { background: var(--surface-3); }
.matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.m-cell { display: inline-flex; min-width: 38px; justify-content: center; padding: 3px 6px; border-radius: 6px; font-weight: 700; font-size: .85rem; }
.m-waiting { color: var(--muted); }
.m-name { display: inline-block; font-weight: 500; font-size: .8rem; line-height: 1.25; justify-content: flex-start; text-align: left; min-width: 88px; }
.m-name.m-waiting { background: var(--surface-2); }
.route-matrix td { padding: 5px 4px; vertical-align: top; }
.m-enroute { background: var(--info-bg); color: var(--info); }
.m-arrived, .m-submitted { background: var(--warn-bg); color: var(--warn); }
.m-done { background: var(--ok-bg); color: var(--ok); }
.m-skipped { color: var(--muted); text-decoration: line-through; }
.rank-1 td:first-child::before { content: "🥇 "; }
.rank-2 td:first-child::before { content: "🥈 "; }
.rank-3 td:first-child::before { content: "🥉 "; }

/* ---------- Fahrzeug-Detail ---------- */
.action-card { border: 2px solid var(--primary); }
.action-card.enroute { border-color: var(--info); }
.action-card.arrived { border-color: var(--warn); }
.action-card.finished { border-color: var(--ok); }
.big-coord { font-family: var(--mono); font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; letter-spacing: .03em; }
.expect { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.expect .name { font-size: 1.15rem; font-weight: 800; }
.task-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; border-left: 4px solid var(--red); }
.task-box h4 { margin: 0 0 6px; }
.solution { background: var(--ok-bg); color: var(--ok); border-radius: 6px; padding: 6px 10px; font-weight: 600; }
.answer-box { background: var(--info-bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.answer-box .lbl { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; }
.answer-box .val { font-size: 1.1rem; font-weight: 700; white-space: pre-wrap; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 180px; }
.route-list { list-style: none; margin: 0; padding: 0; }
.route-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: start; }
.route-item:last-child { border-bottom: 0; }
.route-item.is-current { background: linear-gradient(90deg, var(--info-bg), transparent); margin: 0 -16px; padding: 10px 16px; }
.route-item .pos { font-weight: 800; font-size: 1.05rem; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; }
.route-item.s-done .pos, .route-item.s-submitted .pos, .route-item.s-arrived .pos { background: var(--ok); color: #fff; }
.route-item.s-enroute .pos { background: var(--info); color: #fff; }
.route-item.s-skipped .pos { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.route-times { font-size: .82rem; color: var(--muted); }
.score-form .crit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 8px 14px; font-weight: 600; min-width: 44px; text-align: center; border-right: 1px solid var(--border); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--primary); color: #fff; }
.seg input:focus-visible + span { box-shadow: inset var(--focus); }
.stopwatch { font-family: var(--mono); font-size: 2rem; font-weight: 800; }

/* ---------- Einsatztagebuch ---------- */
.log { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.log li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.log li:last-child { border-bottom: 0; }
.log time { font-family: var(--mono); color: var(--muted); font-size: .82rem; padding-top: 1px; }
.log .by { color: var(--muted); font-size: .78rem; }
.log .k-wrong { color: var(--danger); }
.log .k-submit { color: var(--info); }
.log .k-start, .log .k-finish { font-weight: 700; }

/* ---------- Timeline ---------- */
.timeline-wrap { overflow-x: auto; }
.timeline-svg { width: 100%; min-width: 640px; height: auto; display: block; font-family: var(--font); }
.timeline-svg text { fill: var(--text); font-size: 12px; }
.timeline-svg .axis text { fill: var(--muted); font-size: 11px; }
.timeline-svg .grid line { stroke: var(--border); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(8, 14, 26, .55); z-index: 100; display: flex; align-items: flex-start;
  justify-content: center; padding: 5vh 12px; overflow-y: auto;
}
.modal { width: 100%; max-width: 640px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); border-top: 4px solid var(--red); }
.modal-lg { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.app-teilnehmer .toasts { bottom: 84px; left: 16px; right: 16px; max-width: none; }
.toast { background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 600; animation: toast-in .2s ease-out; }
.toast-error { background: var(--danger); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Einstellungen ---------- */
.list-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 700; }
.opt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.route-edit { list-style: none; padding: 0; margin: 0; }
.route-edit li { display: grid; grid-template-columns: 34px minmax(160px, 1.2fr) minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--border); }
@media (max-width: 900px) { .route-edit li { grid-template-columns: 34px minmax(0, 1fr) auto; } .route-edit li .re-var, .route-edit li .re-sol { grid-column: 2 / 3; } }
.route-edit .pos { font-weight: 800; padding-top: 10px; text-align: center; }
.route-edit textarea { min-height: 42px; }
.qr-box { background: #fff; padding: 6px; border-radius: 8px; display: inline-block; line-height: 0; }
.qr-box svg { width: 92px; height: 92px; }
.code-pill { font-family: var(--mono); font-weight: 800; letter-spacing: .15em; background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }
.logo-prev { max-height: 90px; max-width: 220px; background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--border); }

/* ==========================================================================
   Teilnehmer (Smartphone)
   ========================================================================== */
.app-teilnehmer { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.topbar-mobile { padding-top: calc(8px + env(safe-area-inset-top)); }
.p-main { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }
.p-main .card { padding: 14px; }
.p-hero { text-align: center; padding: 20px 14px; background: linear-gradient(135deg, var(--navy), #0b1a33); color: #fff; border: 0; position: relative; overflow: hidden; }
.p-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--red); }
.p-hero .call { font-family: var(--mono); font-size: 2.2rem; font-weight: 800; letter-spacing: .03em; }
.p-hero .type { opacity: .85; font-weight: 600; }
.p-hero img.logo { max-height: 54px; background: #fff; border-radius: 8px; padding: 4px; margin-bottom: 8px; }
.info-list { display: grid; gap: 0; }
.info-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt, .info-list .k { color: var(--muted); font-size: .88rem; }
.info-list .v { font-weight: 700; text-align: right; word-break: break-word; }
.big-progress { font-size: 1.9rem; font-weight: 800; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 14px rgba(0, 0, 0, .06);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 9px; text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 700; }
.tabbar a.active { color: var(--red); }
.tabbar .tab-ico { font-size: 1.35rem; line-height: 1.1; }
.tabbar .tab-badge { background: var(--red); color: #fff; border-radius: 99px; font-size: .68rem; padding: 0 6px; margin-left: 2px; }
.msgbar { position: sticky; top: 58px; z-index: 44; max-width: 640px; margin: 0 auto; padding: 0 14px; }
.msg-card { background: var(--surface); border: 3px solid var(--red); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(200, 16, 46, .35); padding: 12px 14px; margin-top: 12px; animation: toast-in .25s ease-out; }
.msg-head { display: flex; align-items: center; gap: 6px; font-weight: 800; color: var(--red); font-size: .92rem; flex-wrap: wrap; }
.msg-time { margin-left: auto; color: var(--muted); font-weight: 600; font-family: var(--mono); }
.msg-text { font-size: 1.15rem; font-weight: 700; margin: 8px 0 12px; white-space: pre-wrap; }
.offline-bar { background: var(--warn); color: #000; text-align: center; padding: 6px 10px; font-weight: 700; font-size: .85rem; position: sticky; top: 58px; z-index: 45; }
.leg-card { border-left: 5px solid var(--border); scroll-margin-top: 80px; }
.leg-card.current { border-left-color: var(--info); }
.leg-card.reached { border-left-color: var(--ok); }
.leg-card.has-task { border-left-color: var(--red); box-shadow: 0 0 0 2px var(--red), var(--shadow); }
.leg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.leg-head h3 { margin: 0; font-size: 1.1rem; }
.leg-fields { display: grid; gap: 10px; }
.save-state { font-size: .78rem; color: var(--muted); min-height: 1em; }
.task-alert { background: var(--danger-bg); border-radius: var(--radius-sm); padding: 12px; margin-top: 12px; }
.task-alert h4 { color: var(--danger); margin: 0 0 6px; font-size: 1.05rem; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.quiz-q { font-size: 1.2rem; font-weight: 700; margin: 6px 0 16px; line-height: 1.35; }
.quiz-cat { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--red); }
.quiz-opt {
  display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 10px; cursor: pointer; font-weight: 600; background: var(--surface); min-height: 56px;
}
.quiz-opt:has(input:checked) { border-color: var(--primary); background: var(--info-bg); }
.quiz-opt input { flex: 0 0 auto; width: 22px; height: 22px; }
.quiz-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.quiz-dots { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }
.quiz-dots button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; color: var(--muted); }
.quiz-dots button.answered { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.quiz-dots button.current { outline: 2px solid var(--primary); outline-offset: 1px; color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .ico { font-size: 2.4rem; display: block; margin-bottom: 6px; }

@media (max-width: 560px) {
  .app-main { padding: 12px 12px 60px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
}

/* ==========================================================================
   Druck (Zugangskarten, Urkunden, Laufzettel)
   ========================================================================== */
.print-bar { position: sticky; top: 0; z-index: 10; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 16px; background: var(--navy); color: #fff; }
.print-bar .btn { min-height: 36px; }
.print-page { background: #fff; color: #111; margin: 16px auto; box-shadow: 0 4px 20px rgba(0, 0, 0, .15); }
body.print-body { background: #7c8595; }
@media print {
  body.print-body { background: #fff; }
  .print-bar { display: none !important; }
  .print-page { margin: 0; box-shadow: none; page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
}

/* ---------- Zeichenfläche & Fotos ---------- */
.draw-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.draw-tools .btn.active { outline: 2px solid var(--primary); }
.dp-color { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.dp-color.active { box-shadow: 0 0 0 3px var(--primary); }
.dp-sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.draw-wrap { border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; touch-action: none; }
.draw-wrap canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.photo-box { margin-top: 12px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.photo-box img, .thumb { max-width: 100%; max-height: 260px; border-radius: 6px; display: block; background: #fff; }
.thumb-sm { max-height: 120px; max-width: 200px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compare { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 10px; }
.compare figure { margin: 0; }
.compare figcaption { font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.compare img { width: 100%; max-height: 320px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; }
.stars { display: flex; gap: 6px; }
.stars button { font-size: 2rem; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--surface-3); padding: 2px; }
.stars button.on { color: #f5b301; }
.radio-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.radio-row .cnt { font-weight: 800; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #f5b301; }

/* ---------- Fern-Quiz ---------- */
.fq-timer { position: sticky; top: 0; z-index: 20; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; padding: 8px 12px; background: var(--navy); color: #fff; }
.fq-timer-low { background: var(--red); }
