:root {
  --grund: #f4f4f1; --flaeche: #fff; --text: #1c1c1a; --leise: #66665f; --rand: #d8d8d0;
  --kopf: #14532d; --kopf-text: #fff; --haupt: #14532d; --haupt-text: #fff; --haupt-tief: #14532d;
  --gut: #3a7d12; --warn: #b7791f; --schlecht: #c02626;
  --gut-tint: #e4f2d7; --warn-tint: #fbf0d4; --schlecht-tint: #fbdcdc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #141412; --flaeche: #1f1f1c; --text: #f0f0ea; --leise: #a5a59b; --rand: #3a3a34;
    --gut-tint: #1f3312; --warn-tint: #3a2e10; --schlecht-tint: #451a1a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--grund); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
header {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--kopf); color: var(--kopf-text); font-size: 14px;
}
header .logo { height: 28px; width: auto; display: block; }
.logo-band { background: var(--kopf); margin: -16px -16px 16px; padding: 20px 16px; border-radius: 10px 10px 0 0; }
.logo-band .logo { display: block; width: 100%; max-width: 280px; margin: 0 auto; }
#warteschlange { margin-left: auto; }
.leiste {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 6px 16px;
  font-size: 14px; color: #fff; background: var(--gut);
}
.leiste.warn { background: var(--warn); }
.leiste.schlecht { background: var(--schlecht); }
.leiste button { flex: none; min-height: 32px; padding: 2px 10px; font-size: 14px; }
.marke-netz { padding: 1px 8px; border-radius: 99px; background: rgba(255,255,255,.2); }
.marke-netz.aus { background: var(--schlecht); }
main { flex: 1; overflow-y: auto; padding: 12px 16px 24px; width: 100%; max-width: 760px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 16px 0 8px; }
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.karte h2 { margin-top: 0; }
label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--leise); }
label.haken { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--text); }
input, select {
  width: 100%; padding: 12px; font: inherit; color: var(--text);
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px;
}
input[type=checkbox] { width: auto; }
input[type=file] { padding: 8px; font-size: 14px; }
button {
  flex: 1; min-height: 48px; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--text);
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px; cursor: pointer;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; }
button.haupt { background: var(--haupt); color: var(--haupt-text); border-color: var(--haupt); width: 100%; }
button.gefahr { background: var(--schlecht); color: #fff; border-color: var(--schlecht); width: 100%; }
.zeile { display: flex; gap: 8px; margin-top: 8px; }
.bereich {
  width: 100%; min-height: 56px; font-size: 20px; color: var(--haupt-text);
  background: var(--haupt); border-color: var(--haupt);
}
#scan { margin-top: 8px; text-align: center; font-size: 18px; }
#scan:focus { outline: 2px solid var(--haupt-tief); }
#scan.aus { outline: 2px solid var(--warn); background: var(--warn-tint); }
#knopf-plus.an, #knopf-minus.an { color: #fff; }
#knopf-plus.an { background: var(--gut); border-color: var(--gut); }
#knopf-minus.an { background: var(--schlecht); border-color: var(--schlecht); }
body.minus-an .bereich { background: var(--schlecht); border-color: var(--schlecht); color: #fff; }
body.minus-an #scan::placeholder { color: var(--schlecht); opacity: 1; }
body.minus-an #scan { outline: 2px solid var(--schlecht); background: var(--schlecht-tint); font-weight: 700; }
body.blitz::after {
  content: ""; position: fixed; inset: 0; background: var(--schlecht);
  opacity: 0; pointer-events: none; animation: blitz .6s ease-out;
}
@keyframes blitz { from { opacity: .6; } to { opacity: 0; } }
.treffer { margin-top: 8px; padding: 16px; border-radius: 10px; background: var(--flaeche); border: 2px solid var(--rand); min-height: 120px; }
.treffer.puls { animation: puls .25s ease-out; }
@keyframes puls { from { box-shadow: 0 0 0 4px var(--haupt); } to { box-shadow: none; } }
.treffer.leer { color: var(--leise); display: flex; align-items: center; justify-content: center; }
.treffer.leer p { margin: 0; }
.treffer.gut { border-color: var(--gut); background: var(--gut-tint); }
.treffer.warn { border-color: var(--warn); background: var(--warn-tint); }
.treffer.schlecht { border-color: var(--schlecht); background: var(--schlecht-tint); }
.treffer .name { font-size: 18px; font-weight: 600; }
.treffer .daten { font-size: 13px; color: var(--leise); margin-top: 2px; }
.treffer .auto { font-size: 13px; font-weight: 700; color: var(--haupt-tief); margin-top: 2px; }
.treffer .zahl { font-size: 34px; font-weight: 700; margin-top: 8px; }
.treffer .zahl small { font-size: 15px; font-weight: 500; color: var(--leise); }
video { display: block; width: 100%; height: 220px; margin-bottom: 8px; border-radius: 10px; background: #000; object-fit: cover; }
.liste { list-style: none; margin: 8px 0 0; padding: 0; }
.liste li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px; margin-bottom: 6px;
}
.liste .links { min-width: 0; overflow-wrap: anywhere; }
.liste .unter { font-size: 12.5px; color: var(--leise); }
.liste .rechts { font-weight: 700; white-space: nowrap; }
#verlauf li { padding: 6px 10px; margin-bottom: 4px; border-left-width: 6px; }
#verlauf .links { flex: 1; }
#verlauf .links > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#verlauf li.gut { background: var(--gut-tint); border-color: var(--gut); }
#verlauf li.warn { background: var(--warn-tint); border-color: var(--warn); }
#verlauf li.unbekannt { background: var(--schlecht-tint); border-color: var(--schlecht); }
.liste .knoepfe { display: flex; gap: 6px; flex: none; align-items: center; }
.liste button { flex: none; min-height: 36px; padding: 4px 10px; font-size: 14px; }
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kacheln div { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px; padding: 10px; }
.kacheln b { display: block; font-size: 20px; }
.kacheln span { font-size: 12px; color: var(--leise); }
.reiter { display: flex; gap: 6px; margin: 12px 0 8px; }
.reiter button { min-height: 40px; font-size: 14px; }
.reiter button.aktiv { background: var(--haupt); color: var(--haupt-text); border-color: var(--haupt); }
nav {
  display: flex; gap: 0; background: var(--flaeche); border-top: 1px solid var(--rand);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button { border: 0; border-radius: 0; min-height: 54px; background: none; color: var(--leise); }
nav button.aktiv { color: var(--haupt-tief); box-shadow: inset 0 3px 0 var(--haupt); }
dialog {
  width: calc(100% - 32px); max-width: 440px; border: 1px solid var(--rand); border-radius: 12px;
  background: var(--flaeche); color: var(--text); padding: 16px;
}
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin-top: 0; }
dialog h2:focus { outline: none; }
.auswahl { display: grid; gap: 8px; }
.auswahl button { width: 100%; min-height: 56px; }
.fehler { color: var(--schlecht); min-height: 1.4em; margin: 8px 0 0; }
.klein { font-size: 13.5px; color: var(--leise); margin: 4px 0 8px; }
.breit { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--rand); padding: 6px 8px; text-align: left; white-space: nowrap; }
td.zahl, th.zahl { text-align: right; }
td input { padding: 6px; width: 64px; text-align: right; font-size: 14px; }
progress { width: 100%; height: 12px; }
details summary { cursor: pointer; margin-bottom: 8px; }
.marke-zeile { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; margin-bottom: 6px; font-size: 13.5px; }
.marke-zeile input { padding: 6px 8px; }
@media (min-width: 900px) {
  header .logo { height: 36px; }
  body[data-seite="zaehlen"] main { max-width: 1240px; }
  #s-zaehlen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .zaehl-rechts h2 { margin-top: 0; }
  #verlauf { margin-top: 0; }
}
#kontrolle { margin-top: 12px; }
#kontrolle table { margin-top: 10px; }
#kontrolle .alt { color: var(--schlecht); font-weight: 700; }
@media (max-width: 899px) {
  #kontrolle { display: none; }
  video { height: 30vh; min-height: 180px; max-height: 260px; }
  /* Das Feld verschwindet nur fürs Auge: Es behält den Fokus für einen Bluetooth-Scanner. */
  body.kamera-an #scan { position: absolute; width: 0; height: 0; padding: 0; margin: 0; border: 0; opacity: 0; }
}
