:root {
  --red: #b3121a;
  --red-ink: #ffffff;
  --red-soft: #fbe9ea;
  --bg: #e9ebee;
  --panel: #ffffff;
  --ink: #15181c;
  --muted: #5a626b;
  --line: #cfd4da;
  --ok: #1d7a3a;
  --ok-soft: #e4f4e8;
  --err-soft: #fde8e8;
  --focus: #ffb000;
  --shadow: 0 1px 2px rgba(16,24,32,.06), 0 4px 14px rgba(16,24,32,.06);
  color-scheme: light;
  box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Kopf */
.bar {
  background: var(--red);
  color: var(--red-ink);
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 6px solid #ffd000;
}
.bar-in { max-width: 760px; margin: 0 auto; padding: 14px 18px 12px; }
.bar h1 { margin: 0; font-size: 1.5rem; line-height: 1.1; letter-spacing: -0.01em; font-weight: 800; }
.bar p { margin: 2px 0 0; opacity: .9; font-size: .95rem; }

.wrap { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }

.block {
  background: var(--panel);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.block h2 { margin: 0 0 10px; font-size: 1.1rem; font-weight: 700; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.folder { color: var(--ink); font-weight: 600; word-break: break-word; }

/* Löschbezirke */
.lb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.lb { position: relative; display: block; cursor: pointer; }
.lb input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.lb span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 56px; padding: 8px 10px;
  border: 2px solid var(--line); border-radius: 10px;
  font-weight: 600; line-height: 1.2;
  -webkit-user-select: none; user-select: none;
}
.lb input:checked + span { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.lb input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.lb-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.lb-head a, .lb-fixed a { color: var(--muted); font-size: .9rem; }
.lb-fixed { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-left: 6px solid var(--red); }
.lb-current { margin: 2px 0 0; font-size: 1.35rem; font-weight: 800; line-height: 1.2; }

/* Eingaben */
input[type=text], input[type=password], textarea {
  width: 100%; min-height: 54px; padding: 12px 14px;
  font: inherit; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 10px;
}
textarea { resize: vertical; min-height: 110px; line-height: 1.4; }
input[type=text]:focus, input[type=password]:focus, textarea:focus { outline: none; border-color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 18px;
  font: inherit; font-weight: 700; border-radius: 12px; border: 0; cursor: pointer;
  text-decoration: none;
}
.btn:focus-visible, .btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn svg { width: 24px; height: 24px; fill: currentColor; }
.btn-main { width: 100%; background: var(--red); color: var(--red-ink); font-size: 1.1rem; }
.btn-main:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-alt { background: var(--red-soft); color: var(--red); border: 2px solid var(--red); }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* Vorschaubilder */
.thumbs {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px;
}
.thumbs:empty { display: none; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden;
  background: var(--bg); border: 2px solid transparent;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.thumb .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 6px;
  background: rgba(0,0,0,.6); color: #fff; font-size: .75rem;
}
.thumb .rm {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.thumb.is-busy { border-color: var(--focus); }
.thumb.is-done { border-color: var(--ok); }
.thumb.is-done img { opacity: .55; }
.thumb.is-err { border-color: var(--red); }

/* Unterer Bereich */
.dock {
  position: sticky; bottom: 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.msg { padding: 10px 12px; border-radius: 10px; margin: 0 0 8px; font-size: .95rem; }
.msg.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.msg.err { background: var(--err-soft); color: var(--red); font-weight: 600; }
.progress { position: relative; height: 30px; border-radius: 10px; background: var(--panel); overflow: hidden; margin-bottom: 8px; border: 1px solid var(--line); }
.progress-bar { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.progress-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .9rem; font-weight: 600; }

.pin .btn-main { margin-top: 12px; }

.foot { text-align: center; padding: 8px 0 28px; font-size: .85rem; }
.foot a { color: var(--muted); }

/* Warteschlange */
.queue { border-left: 6px solid var(--focus); }
.qlist { list-style: none; margin: 10px 0 0; padding: 0; font-size: .92rem; }
.qlist li { padding: 8px 0; border-top: 1px solid var(--line); word-break: break-word; }
.qlist li:first-child { border-top: 0; }
.queue .acts { display: flex; gap: 14px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.msg.net { background: var(--focus); color: #1a1200; font-weight: 600; }
.lb-links { display: flex; gap: 14px; }
.lb-links a { color: var(--muted); font-size: .9rem; }

.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: .9rem; text-decoration: underline; cursor: pointer; }
.btn-sm { min-height: 42px; font-size: .95rem; padding: 0 14px; }

/* PIN-Verwaltung */
.pin-list { list-style: none; margin: 0; padding: 0; }
.pin-card { border-top: 1px solid var(--line); padding: 12px 0; }
.pin-card:first-child { border-top: 0; }
.pin-card .name { font-weight: 700; }
.pin-card .meta { color: var(--muted); font-size: .88rem; }
.pin-card.is-locked .name { color: var(--red); }
.pin-val { font-weight: 700; color: var(--ink); letter-spacing: .05em; }
.pin-card details { margin-top: 8px; }
.pin-card summary { cursor: pointer; font-weight: 600; font-size: .95rem; }
.pin-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; align-items: end; }
.pin-form label { font-size: .85rem; color: var(--muted); display: grid; gap: 4px; }
.pin-form .btn { grid-column: 1 / -1; }
.pin-card .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Verwaltung */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.folders { list-style: none; margin: 0; padding: 0; }
.folders > li { border-top: 1px solid var(--line); padding: 12px 0; }
.folders > li:first-child { border-top: 0; }
.folders .name { font-weight: 700; word-break: break-word; }
.folders .meta { color: var(--muted); font-size: .88rem; }
.folders .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.folders .acts .btn { min-height: 42px; font-size: .95rem; padding: 0 14px; }
.folders details { margin-top: 6px; font-size: .9rem; }
.folders details ul { margin: 6px 0 0; padding-left: 18px; }
.folders a { color: var(--red); }
.btn-del { background: transparent; color: var(--red); border: 2px solid var(--red); }
.log { max-height: 340px; overflow: auto; font-size: .82rem; white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; margin: 0; }

@media (prefers-reduced-motion: reduce) { .progress-bar { transition: none; } }

/* ===== Feinschliff: Einsatztauglich, immer hell ===== */
:root { color-scheme: light; }
body { font-size: 18px; }
.bar { background: linear-gradient(180deg, #c0151e 0%, var(--red) 100%); border-bottom-width: 5px; }
.bar-in { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.bar-icon { width: 44px; height: 44px; border-radius: 10px; box-shadow: 0 0 0 2px rgba(255,255,255,.35); flex: none; }
.bar h1 { font-size: 1.45rem; }
.block { box-shadow: var(--shadow); border-radius: 16px; padding: 18px; }
.block h2 { display: flex; align-items: center; gap: 10px; font-size: 1.12rem; }
.step { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; font-size: .9rem; font-weight: 800; }
.opt { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 99px; }
.lb-grid { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lb span { min-height: 62px; font-size: 1.02rem; background: var(--panel); transition: background .12s, border-color .12s; }
.lb input:checked + span { box-shadow: 0 2px 8px rgba(179,18,26,.35); }
.lb input:checked + span::before { content: "✓"; margin-right: 8px; font-weight: 900; }
.lb-fixed { border-left-width: 8px; }
.lb-current { font-size: 1.5rem; }
input[type=text], input[type=password], textarea { min-height: 58px; font-size: 1.05rem; background: #f6f7f9; }
.btn { min-height: 62px; border-radius: 14px; }
.btn-main { font-size: 1.15rem; box-shadow: 0 4px 14px rgba(179,18,26,.3); }
.btn-main:disabled { box-shadow: none; }
.btn-alt { background: #fff5f5; }
.pick { gap: 10px; }
.thumbs { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.thumb { border-radius: 10px; }
.thumb .rm { width: 34px; height: 34px; }
.dock { padding-top: 14px; }
.msg.ok { border: 1px solid #b9e2c4; }
.msg.err { border: 1px solid #f3b9bc; }
@media (max-width: 420px) {
  .lb-grid { grid-template-columns: 1fr 1fr; }
  .wrap { padding: 12px 10px 20px; }
}

/* ===== Verwaltung ===== */
.bar-out { color: #fff; font-weight: 700; font-size: .9rem; text-decoration: none; border: 1.5px solid rgba(255,255,255,.6); border-radius: 10px; padding: 7px 12px; }
.bar-out:hover { background: rgba(255,255,255,.12); }
.adm .bar { border-bottom: 0; }
.adm-nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; box-shadow: 0 2px 8px rgba(16,24,32,.06); }
.adm-nav-in { max-width: 960px; margin: 0 auto; display: flex; gap: 4px; padding: 0 10px; overflow-x: auto; scrollbar-width: none; }
.adm-nav a { flex: none; padding: 14px 14px 12px; font-weight: 700; font-size: .95rem; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; }
.adm-nav a:hover { color: var(--ink); }
.adm-nav a[aria-current="page"] { color: var(--red); border-bottom-color: var(--red); }
.adm-wrap { max-width: 960px; }
.adm-title { font-size: 1.35rem; margin: 6px 4px 14px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 12px; }
.card { background: var(--panel); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; align-content: start; }
.card .k { font-size: .82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card .v { font-size: 1.25rem; font-weight: 800; }
.card .s { font-size: .88rem; color: var(--muted); }
.card a { font-size: .9rem; font-weight: 700; color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--focus); } .dot.bad { background: var(--red); }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo li { padding: 10px 12px; border-radius: 10px; background: var(--err-soft); color: var(--red); font-weight: 600; font-size: .93rem; }
.todo li.ok { background: var(--ok-soft); color: var(--ok); }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 9px 0; border-top: 1px solid var(--line); font-size: .92rem; display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.recent li:first-child { border-top: 0; }
.recent .t { color: var(--muted); white-space: nowrap; }
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filter button { font: inherit; font-size: .88rem; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; }
.filter button[aria-pressed="true"] { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.log-list { list-style: none; margin: 0; padding: 0; max-height: 560px; overflow: auto; font-size: .86rem; }
.log-list li { padding: 7px 4px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 128px 1fr; gap: 10px; }
.log-list li:first-child { border-top: 0; }
.log-list .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-list .bad { color: var(--red); font-weight: 600; }
.lb-rows { list-style: none; margin: 0; padding: 0; }
.lb-row { border-top: 1px solid var(--line); }
.lb-row:first-child { border-top: 0; }
.lb-row > details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 4px; flex-wrap: wrap; }
.lb-row > details > summary::-webkit-details-marker { display: none; }
.lb-row > details > summary::after { content: "Bearbeiten ›"; margin-left: auto; font-size: .85rem; font-weight: 700; color: var(--red); }
.lb-row > details[open] > summary::after { content: "Schließen ×"; }
.lb-row .nm { font-weight: 800; min-width: 130px; }
.chip { font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #eef0f3; color: #4b5563; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--err-soft); color: var(--red); }
.lb-edit { padding: 4px 4px 16px; display: grid; gap: 12px; }
.lb-edit section { background: var(--bg); border-radius: 12px; padding: 12px; }
.lb-edit h3 { margin: 0 0 8px; font-size: .95rem; }
.lb-edit .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input[type=email], .inline-form input[type=text] { flex: 1 1 220px; min-height: 46px; padding: 8px 12px; font: inherit; border: 2px solid var(--line); border-radius: 10px; background: #fff; }
.inline-form .btn { min-height: 46px; }

[hidden] { display: none !important; }

.mail-form { display: grid; gap: 10px; }
.mail-form textarea { background: #fff; }
.radio-set { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.radio-set legend { padding: 0; margin-bottom: 4px; }
.radio-set label { display: flex; gap: 8px; align-items: flex-start; font-size: .93rem; line-height: 1.35; cursor: pointer; }
.radio-set input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--red); }

.set-form { display: grid; gap: 12px; }
.set-form label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; color: var(--ink); }
.set-form label.check { display: flex; gap: 10px; align-items: center; }
.set-form label.check input { width: 20px; height: 20px; accent-color: var(--red); }
.set-form input[type=text], .set-form input[type=password], .set-form textarea { min-height: 48px; font-size: 1rem; font-weight: 400; }
.set-form textarea { min-height: 80px; }
.set-form .radio-set label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.set-form .radio-set input { margin-top: 2px; }

/* Ziffernblock */
.pin-field { text-align: center; font-size: 1.8rem !important; letter-spacing: .35em; font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.keypad button { min-height: 72px; border: 0; border-radius: 18px; background: #fff; box-shadow: 0 1px 2px rgba(16,24,32,.12), inset 0 0 0 1.5px var(--line);
  font: 700 1.9rem system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.keypad button:active { background: var(--red-soft); }
.keypad svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.keypad .kp-del { background: transparent; box-shadow: none; color: var(--muted); }
.keypad .kp-ok { background: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(179,18,26,.3); }
.keypad .kp-ok svg { stroke-width: 2.6; }

/* Einsatzart */
.arten { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.art { position: relative; cursor: pointer; }
.art input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.art span { display: inline-flex; align-items: center; min-height: 46px; padding: 0 16px; border-radius: 23px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 1rem; }
.art input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.art input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.sub-label { display: block; font-weight: 700; font-size: .95rem; margin: 2px 0 6px; }

/* Offline-Balken */
.netbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 12px; background: #1f2933; color: #fff; padding: 12px 16px; border-radius: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.netbar svg { width: 28px; height: 28px; flex: none; fill: none; stroke: #ffd000; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.netbar div { display: grid; gap: 2px; }
.netbar b { font-size: 1.02rem; }
.netbar span { font-size: .9rem; color: #d5dae0; }
.btn-main.offline { background: #1f2933; box-shadow: none; }
.queue { border-left: 0; }

/* Erfolgsmeldung */
.done { text-align: center; display: grid; gap: 12px; justify-items: center; padding: 28px 18px; }
.done h2 { justify-content: center; font-size: 1.6rem; margin: 0; }
.done-check { width: 104px; height: 104px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; }
.done-check svg { width: 58px; height: 58px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-list { width: 100%; margin: 4px 0; padding: 12px 14px; background: var(--bg); border-radius: 12px; display: grid; gap: 8px; text-align: left; }
.done-list div { display: flex; justify-content: space-between; gap: 12px; }
.done-list dt { color: var(--muted); }
.done-list dd { margin: 0; font-weight: 700; text-align: right; }
.done-acts { width: 100%; display: grid; gap: 10px; }
.done-acts .btn { width: 100%; }

.set-h3 { font-size: 1rem; margin: 6px 0 6px; }
.arten-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.arten-list li { display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 10px; padding: 4px 4px 4px 14px; }
.arten-list li span { flex: 1; font-weight: 700; }
.arten-list form { margin: 0; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: #fff; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.del { color: var(--red); }

.lock-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lock-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.lock-info { display: grid; gap: 4px; }
.lock-info b { font-variant-numeric: tabular-nums; }
.lock-list form { margin: 0; }
.ok-line { display: block; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.lock-info .chip { justify-self: start; }
