:root {
    --hintergrund: #f4f5f4;
    --flaeche: #ffffff;
    --text: #1d2321;
    --text-leise: #5d6763;
    --linie: #dde1df;
    --akzent: #0f5f5c;
    --akzent-hell: #e3efee;
    --erfolg: #1e6b3a;
    --erfolg-hell: #e5f2e9;
    --fehler: #a3261f;
    --fehler-hell: #fbeceb;
    --warnung: #8a5a00;
    --warnung-hell: #fdf3dd;
    --radius: 8px;
    --schrift: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: var(--schrift);
    font-size: 15px;
    line-height: 1.45;
    color: var(--text);
    background: var(--hintergrund);
}

a { color: var(--akzent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.leise { color: var(--text-leise); }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.zahl { font-variant-numeric: tabular-nums; text-align: right; }
.nummer { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Testsystem-Band */
.umgebung-band {
    background: repeating-linear-gradient(-45deg, #facc15, #facc15 14px, #fde047 14px, #fde047 28px);
    color: #1d2321; font-weight: 800; text-align: center; padding: .35rem .75rem; font-size: .85rem; letter-spacing: .03em;
}
body.anmeldung .umgebung-band { position: fixed; top: 0; left: 0; right: 0; }

/* Kopfzeile */
.kopf {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    padding: .6rem 1.25rem;
    min-height: 56px;
    background: var(--akzent);
    color: #fff;
}
.marke { color: #fff; font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.marke span { font-weight: 400; opacity: .8; }
.navigation { display: flex; gap: .25rem; }
.navigation a {
    color: #fff; text-decoration: none; padding: .4rem .75rem; border-radius: 6px; opacity: .85;
}
.navigation a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.navigation a.aktiv { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.schnellsuche { margin-left: auto; }
.benutzer:first-of-type { margin-left: auto; }
.schnellsuche + .benutzer { margin-left: 0; }
.schnellsuche input {
    width: 15rem; padding: .4rem .7rem; border: 0; border-radius: 6px; font: inherit;
}
.benutzer { display: flex; gap: 1rem; font-size: .9rem; }
.benutzer a { color: #fff; opacity: .85; }

.inhalt { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* Seitenkopf */
.seitenkopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.seitenkopf .aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Karten und Raster */
.karte {
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}
.raster { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.raster > .karte { margin-bottom: 0; }
.kennzahlen { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 1rem; }
.kennzahl { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 1rem 1.25rem; text-decoration: none; color: inherit; }
.kennzahl .wert { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--akzent); }
.kennzahl .bezeichnung { color: var(--text-leise); }
a.kennzahl:hover { border-color: var(--akzent); }

dl.angaben { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
dl.angaben dt { color: var(--text-leise); }
dl.angaben dd { margin: 0; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-leise); font-weight: 600; }
tbody tr:hover { background: #fafbfa; }
tr.inaktiv td { color: var(--text-leise); text-decoration: line-through; }
.tabelle-leer { color: var(--text-leise); padding: 1rem 0; }

/* Marken */
.marke-status {
    display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem;
    background: var(--akzent-hell); color: var(--akzent); white-space: nowrap;
}
.marke-status.warnung { background: var(--warnung-hell); color: var(--warnung); }
.marke-status.fehler { background: var(--fehler-hell); color: var(--fehler); }
.marke-status.leise { background: #eef0ef; color: var(--text-leise); }

/* Meldungen */
.meldung { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.meldung-erfolg { background: var(--erfolg-hell); color: var(--erfolg); border-color: #bfdcc8; }
.meldung-fehler { background: var(--fehler-hell); color: var(--fehler); border-color: #efc2bf; }

/* Formulare */
form .feld, form > div > div { margin-bottom: .9rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=date], input[type=search],
input:not([type]), select, textarea {
    width: 100%; padding: .5rem .65rem; font: inherit; color: inherit;
    border: 1px solid #c4cac7; border-radius: 6px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: 0; border-color: var(--akzent); }
textarea { min-height: 4.5rem; resize: vertical; }
input[type=radio], input[type=checkbox] { margin-right: .35rem; }
input[type=radio] + label, input[type=checkbox] + label { display: inline; font-weight: 400; margin-right: 1rem; }
.help-text, form small { display: block; color: var(--text-leise); font-size: .85rem; margin-top: .2rem; }
ul:has(> li) { padding-left: 1.1rem; }
form ul { color: var(--fehler); margin: .25rem 0; padding-left: 1.1rem; }
.formular-schmal { max-width: 560px; }
.zeile { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.ankreuzen { display: flex; flex-wrap: wrap; gap: .25rem 0; margin-bottom: .75rem; }
.ankreuzen label { font-weight: 400; display: inline-flex; align-items: center; margin-right: 1rem; }
details.einklappen > summary { cursor: pointer; color: var(--akzent); font-weight: 600; margin: .5rem 0; }

.knopf, button {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem 1rem; font: inherit; font-weight: 600; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--akzent); background: var(--akzent); color: #fff; text-decoration: none;
}
.knopf:hover, button:hover { filter: brightness(1.08); }
.knopf.zweitrangig, button.zweitrangig { background: #fff; color: var(--akzent); }
.knopf.gross, button.gross { padding: .8rem 1.4rem; font-size: 1.05rem; }
button.klein { padding: .15rem .5rem; font-size: .8rem; font-weight: 400; background: #fff; color: var(--text-leise); border-color: var(--linie); }

/* Erfassung */
.erfassung-fertig { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.erfassung-fertig img { width: 160px; height: 160px; }
.erfassung-fertig .nummer-gross { font-size: 2.4rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.fotos { display: flex; gap: .75rem; flex-wrap: wrap; }
.fotos a { display: block; }
.fotos img { width: 140px; height: 105px; object-fit: cover; border-radius: 6px; border: 1px solid var(--linie); }

/* Anmeldung */
body.anmeldung { display: grid; place-items: center; min-height: 100vh; background: var(--akzent); }
body.anmeldung .inhalt { width: 100%; max-width: 400px; padding: 1rem; }
body.anmeldung .karte { padding: 2rem; }

/* Reiter (Verwaltung) */
.reiter { display: flex; gap: .25rem; border-bottom: 1px solid var(--linie); margin-bottom: 1.25rem; }
.reiter a { padding: .5rem .9rem; text-decoration: none; color: var(--text-leise); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.reiter a.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }

/* Rollen-Matrix */
.matrix-rollbereich { overflow-x: auto; }
.matrix th.matrix-rolle { text-transform: none; letter-spacing: 0; color: var(--text); text-align: center; min-width: 7.5rem; }
.matrix td.matrix-zelle { text-align: center; vertical-align: middle; }
.matrix td.matrix-zelle input { width: 1.1rem; height: 1.1rem; margin: 0; }
.matrix tr.matrix-bereich td { background: var(--akzent-hell); color: var(--akzent); font-weight: 700; font-size: .85rem; }

code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: #eef0ef; padding: .05rem .3rem; border-radius: 4px; }
code.schluessel { display: inline-block; margin: .4rem 0; padding: .4rem .6rem; font-size: 1rem; background: #fff; user-select: all; word-break: break-all; }

/* Historie */
.historie td { font-size: .85rem; }
.historie .alt { color: var(--fehler); text-decoration: line-through; }
.historie .neu { color: var(--erfolg); }

/* ---------- Handy-Erfassung ---------- */
body.mobil { background: #eef1f0; font-size: 16px; }
.mobil-kopf {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between;
    padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
    background: var(--akzent); color: #fff;
}
.mobil-kopf .marke { color: #fff; }
.mobil-zurueck { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.05rem; }
.mobil-benutzer { font-size: .85rem; opacity: .85; }
.mobil-inhalt { max-width: 560px; margin: 0 auto; padding: .75rem .75rem 2rem; }
.mobil-titel { font-size: 1.35rem; margin: .25rem 0 .75rem; }
.mobil-karte { background: #fff; border: 1px solid var(--linie); border-radius: 12px; padding: 1rem; margin-bottom: .75rem; }
.mobil-karte label, .mobil-karte legend { font-weight: 600; margin-bottom: .35rem; }
.mobil-karte input:not([type=radio]):not([type=checkbox]), .mobil-karte select { font-size: 1.15rem; padding: .7rem .8rem; }
.mobil-kunde { font-weight: 600; margin: .5rem 0 0; }
.mobil-zeile { display: flex; gap: .5rem; }
.mobil-zeile input { flex: 1; }
.mobil-auswahl { border: 0; padding: 0; margin: 1rem 0 0; }
.mobil-auswahl label { display: flex; align-items: center; gap: .5rem; font-weight: 400; padding: .45rem 0; }
.mobil-auswahl input { width: 1.3rem; height: 1.3rem; }
.mobil-breit { display: flex; justify-content: center; width: 100%; margin-bottom: .6rem; padding: 1rem; font-size: 1.1rem; }
.mobil-fuss { font-size: .85rem; text-align: center; margin-top: 1rem; }
.mobil-fotos-kopf { display: flex; justify-content: space-between; margin: .25rem .25rem .5rem; }
.mobil-fertig { text-align: center; }
.mobil-fertig .nummer-gross { font-size: 2.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
button.laedt { opacity: .6; pointer-events: none; }

.kamera {
    position: relative; overflow: hidden; border-radius: 12px; margin-bottom: .75rem;
    background: #111; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%;
}
.kamera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.kamera-rahmen {
    position: absolute; inset: 22% 12%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); transition: border-color .15s;
}
.kamera.erkannt .kamera-rahmen { border-color: #4ade80; }
.kamera.fehlgeschlagen .kamera-rahmen { border-color: #f87171; }
.kamera.fehlgeschlagen .kamera-hinweis { background: rgba(163, 38, 31, .85); }
.fehlertext { color: var(--fehler); }
.kamera-hinweis {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: .6rem .9rem;
    color: #fff; font-size: .9rem; background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.kamera.foto-modus .kamera-hinweis, .kamera[data-kamera=foto].kamera-an .kamera-hinweis { display: none; }
.kamera.ohne-kamera { aspect-ratio: auto; min-height: 7rem; background: #2b3331; }
.kamera.ohne-kamera video, .kamera.ohne-kamera .kamera-rahmen { display: none; }
.kamera.ohne-kamera .kamera-hinweis { position: static; background: none; padding: 1rem; }
.kamera-ausloeser {
    position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%);
    width: 72px; height: 72px; padding: 0; border-radius: 50%;
    background: #fff; border: 5px solid rgba(255,255,255,.5); background-clip: padding-box;
}
.kamera:not(.kamera-an) .kamera-ausloeser { display: none; }
.kamera-ausloeser:active { transform: translateX(-50%) scale(.92); }
.kamera.blitz::after { content: ''; position: absolute; inset: 0; background: #fff; opacity: .7; }
.kamera-lampe {
    position: absolute; top: .6rem; right: .6rem; padding: .35rem .7rem; font-size: .85rem;
    background: rgba(0,0,0,.45); border-color: transparent;
}
.kamera-lampe.aktiv { background: #facc15; color: #111; }
.mobil-schritt { margin: .25rem .25rem .5rem; font-size: .9rem; }
.foto-arten { display: flex; gap: .4rem; margin-bottom: .5rem; overflow-x: auto; }
.foto-arten label {
    flex: 0 0 auto; display: flex; align-items: center; gap: .35rem; margin: 0; font-weight: 600; font-size: .9rem;
    padding: .5rem .8rem; border-radius: 999px; background: #fff; border: 1px solid var(--linie);
}
.foto-arten label:has(input:checked) { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.foto-arten input { margin: 0; }
.foto-art {
    position: absolute; left: 0; right: 0; bottom: 0; padding: .1rem .3rem; font-size: .65rem; color: #fff;
    background: rgba(0,0,0,.55); border-radius: 0 0 8px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.artikel-treffer { display: flex; flex-direction: column; gap: .3rem; margin-top: .4rem; }
.artikel-knopf {
    justify-content: flex-start; text-align: left; font-weight: 400; background: var(--akzent-hell);
    color: var(--text); border-color: transparent; padding: .65rem .8rem;
}
.artikel-gewaehlt { margin: .5rem 0 0; padding: .55rem .8rem; border-radius: 8px; background: var(--erfolg-hell); color: var(--erfolg); font-weight: 600; }
.position-zeile { padding: .8rem 1rem; }
.position-kopf { display: flex; justify-content: space-between; gap: .5rem; }
.position-info { margin: .25rem 0 .5rem; font-size: .9rem; }
button.entfernen { color: var(--fehler); border-color: #efc2bf; }
.fotos-galerie { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .75rem; }
.foto-kachel { position: relative; }
.foto-kachel img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.foto-kachel button {
    position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; padding: 0; justify-content: center;
    border-radius: 50%; background: rgba(0,0,0,.6); border: 0; font-size: 1rem; line-height: 1;
}

@media (max-width: 760px) {
    .kopf { flex-wrap: wrap; height: auto; padding: .6rem 1rem; gap: .5rem 1rem; }
    .schnellsuche { margin-left: 0; order: 5; width: 100%; }
    .schnellsuche input { width: 100%; }
    .seitenkopf { flex-direction: column; }
    .erfassung-fertig { grid-template-columns: 1fr; }
}
