:root {
    --bg: #0f1319; --flaeche: #171d26; --flaeche2: #1e2733; --rand: #2a3644;
    --text: #e6ecf3; --dezent: #93a3b5; --primaer: #3b82f6; --primaer-dunkel: #2f6bd0;
    --ok: #22c55e; --warnt: #eab308; --fehler: #ef4444; --radius: 10px;
    --schatten: 0 1px 3px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: light) {
    :root { --bg:#f4f6fa; --flaeche:#fff; --flaeche2:#eef2f7; --rand:#d8e0ea;
        --text:#1a2230; --dezent:#5d6b7d; --schatten:0 1px 3px rgba(20,40,70,.12); }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--primaer); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: .2rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.dezent { color: var(--dezent); font-size: .88rem; }
code, .dezent code { background: var(--flaeche2); padding: 1px 5px; border-radius: 5px; }

/* Kopf */
.kopf { display: flex; align-items: center; gap: .8rem; padding: .5rem 1rem;
    background: var(--flaeche); border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 20; }
.marke { font-weight: 700; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.kopfsuche { flex: 1; display: flex; gap: .4rem; max-width: 620px; }
.kopfsuche input { flex: 1; }
.kopfende { margin-left: auto; display: flex; align-items: center; gap: .8rem; font-size: .9rem; }
.puls { color: var(--warnt); background: var(--flaeche2); padding: 2px 10px; border-radius: 20px; }
.navi-knopf { display: none; background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; }

/* Layout */
.rumpf { display: flex; align-items: flex-start; min-height: calc(100vh - 58px); }
.seitenleiste { width: 220px; flex: none; padding: 1rem .6rem; position: sticky; top: 58px;
    display: flex; flex-direction: column; gap: 2px; }
.seitenleiste a { color: var(--dezent); padding: .5rem .7rem; border-radius: 8px; }
.seitenleiste a:hover { background: var(--flaeche); color: var(--text); text-decoration: none; }
.seitenleiste a.aktiv { background: var(--flaeche); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--primaer); }
.navi-trenner { height: 1px; background: var(--rand); margin: .5rem .3rem; }
main { flex: 1; padding: 1.2rem clamp(1rem, 3vw, 2rem); max-width: 1240px; min-width: 0; }

/* Elemente */
.knopf { display: inline-flex; align-items: center; gap: .3rem; background: var(--flaeche2);
    color: var(--text); border: 1px solid var(--rand); border-radius: var(--radius);
    padding: .5rem .9rem; cursor: pointer; font: inherit; transition: .12s; }
.knopf:hover { background: var(--rand); text-decoration: none; }
.knopf-primaer { background: var(--primaer); border-color: var(--primaer); color: #fff; }
.knopf-primaer:hover { background: var(--primaer-dunkel); }
.knopf-gefahr { background: transparent; border-color: var(--fehler); color: var(--fehler); }
.knopf-gefahr:hover { background: var(--fehler); color: #fff; }
.knopf-klein { padding: .25rem .6rem; font-size: .85rem; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--rand);
    border-radius: 8px; padding: .5rem .6rem; font: inherit; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaer); outline-offset: -1px; }
label.feld { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--dezent); }
label.feld input, label.feld select, label.feld textarea { color: var(--text); }
label.feld.vol, .feld.vol { grid-column: 1 / -1; }
.formular-spalten { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; align-items: end; }
.formular-spalten .knopf { justify-self: start; }
.zeile { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.zeile input[type=text], .zeile input:not([type]) , .zeile select { flex: 1; min-width: 140px; }
.inline { display: inline; }

.bereich { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
    padding: 1rem 1.1rem; margin: 0 0 1.2rem; box-shadow: var(--schatten); }
.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.zwei-spalten .bereich { margin: 0 0 1rem; }

/* Tabellen */
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th { text-align: left; color: var(--dezent); font-weight: 600; font-size: .82rem;
    text-transform: uppercase; letter-spacing: .03em; padding: .5rem; border-bottom: 2px solid var(--rand); }
.tabelle td { padding: .55rem .5rem; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle tr:last-child td { border-bottom: none; }
.aktionen { white-space: nowrap; text-align: right; }
.aktionen .inline + .inline { margin-left: .3rem; }
.zeile-gehemmt { opacity: .55; }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kachel { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
    padding: .9rem 1rem; display: flex; flex-direction: column; }
.kachel-zahl { font-size: 1.7rem; font-weight: 700; }
.kachel-text { color: var(--dezent); font-size: .82rem; }
a.kachel:hover { text-decoration: none; border-color: var(--primaer); }

/* Abzeichen */
.abzeichen { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: .78rem;
    background: var(--flaeche2); color: var(--dezent); border: 1px solid var(--rand); }
.ab-ok { color: var(--ok); border-color: var(--ok); }
.ab-laeuft { color: var(--primaer); border-color: var(--primaer); }
.ab-wartet { color: var(--warnt); border-color: var(--warnt); }
.ab-fehler { color: var(--fehler); border-color: var(--fehler); }
.st-aktiv { color: var(--ok); border-color: var(--ok); }
.st-wartend { color: var(--warnt); border-color: var(--warnt); }
.st-gesperrt { color: var(--dezent); }
.pr-ki { color: var(--primaer); border-color: var(--primaer); }
.pr-regel { color: var(--warnt); border-color: var(--warnt); }
.pr-mensch { color: var(--ok); border-color: var(--ok); }
.jahre-sprung { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kontrolle { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text); }
.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kacheln-dicht { gap: .6rem; }
.zweispaltig { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; align-items: start; }
@media (max-width: 860px) { .zweispaltig { grid-template-columns: 1fr; } }

/* Meldungen */
.meldung { padding: .6rem .9rem; border-radius: 8px; margin: 0 0 1rem; border: 1px solid; }
.meld-ok { background: color-mix(in srgb, var(--ok) 15%, transparent); border-color: var(--ok); }
.meld-fehler { background: color-mix(in srgb, var(--fehler) 15%, transparent); border-color: var(--fehler); }

/* Fortschritt */
.mini-fortschritt { display: inline-block; width: 90px; height: 7px; background: var(--flaeche2);
    border-radius: 5px; overflow: hidden; vertical-align: middle; }
.mini-fortschritt i { display: block; height: 100%; background: var(--primaer); transition: width .3s; }

/* Upload-Ablage */
.import-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ablage, .kamera { border: 2px dashed var(--rand); border-radius: var(--radius); padding: 1.2rem;
    text-align: center; transition: .15s; }
.ablage.DragOver, .ablage:hover { border-color: var(--primaer); background: color-mix(in srgb, var(--primaer) 6%, transparent); }
.ablage-ergebnis { list-style: none; padding: 0; margin: .6rem 0 0; text-align: left; font-size: .85rem; }
.ablage-ergebnis li.ok { color: var(--ok); } .ablage-ergebnis li.dup { color: var(--warnt); }
.ablage-ergebnis li.fehler { color: var(--fehler); }
.fortschrittsbalken { height: 8px; background: var(--flaeche2); border-radius: 5px; overflow: hidden; margin: .5rem 0 .2rem; }
.fortschrittsbalken i { display: block; height: 100%; width: 0; background: var(--primaer); transition: width .2s; }
.kamera video { width: 100%; max-width: 480px; border-radius: 8px; background: #000; }
.kamera-knopfe { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; margin: .6rem 0; }
.kamera-leiste { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.kamera-leiste img { width: 48px; height: 64px; object-fit: cover; border-radius: 5px; border: 1px solid var(--rand); }

/* Editor */
.editor-werkzeug { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.seitenraster { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1rem; margin-bottom: 3rem; }
.seitenkarte { background: var(--flaeche); border: 2px solid var(--rand); border-radius: 8px; padding: .5rem;
    text-align: center; cursor: grab; position: relative; }
.seitenkarte.aktiv { border-color: var(--primaer); }
.seitenkarte.zeht { opacity: .35; }
.seitenkarte drueber { border-color: var(--ok); }
.seitenkarte img { width: 100%; height: 150px; object-fit: contain; background: #fff; border-radius: 4px; }
.seitenkarte .nr { position: absolute; top: 4px; left: 6px; background: var(--primaer); color: #fff;
    width: 22px; height: 22px; border-radius: 50%; font-size: .78rem; line-height: 22px; font-weight: 700; }
.seitenkarte .srcnr { position: absolute; top: 6px; right: 8px; font-size: .7rem; color: var(--dezent); }
.seitenkarte .wz { display: flex; gap: 2px; justify-content: center; margin-top: .4rem; }
.seitenkarte .wz button { background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 5px;
    color: var(--text); cursor: pointer; width: 28px; height: 26px; font-size: .9rem; }
.seitenkarte .wz button:hover { background: var(--rand); }
.seitenkarte.geloescht img { opacity: .25; }
.editor-unten { position: fixed; bottom: 0; left: 0; right: 0; background: var(--flaeche);
    border-top: 1px solid var(--rand); padding: .7rem 1.2rem; display: flex; gap: .6rem; justify-content: flex-end; z-index: 15; }

/* Detail */
.detail-kopf { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.detail-aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.detail-vorschau { position: sticky; top: 70px; }
.pdf-preview { width: 100%; height: 80vh; border: 1px solid var(--rand); border-radius: var(--radius); background: #fff; }
.bild-preview { width: 100%; border: 1px solid var(--rand); border-radius: var(--radius); }
.seitenliste { max-height: 300px; overflow-y: auto; border: 1px solid var(--rand); border-radius: 8px; }
.seite { border-bottom: 1px solid var(--rand); }
.seite summary { padding: .4rem .6rem; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
.seitentext { white-space: pre-wrap; word-break: break-word; margin: 0; padding: .5rem .7rem;
    background: var(--bg); font-size: .85rem; max-height: 300px; overflow: auto; }
.ki-seite { margin-left: auto; }

/* Suche-Treffer */
.trefferliste { display: flex; flex-direction: column; gap: .8rem; }
.treffer { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: .8rem 1rem; }
.treffer h3 { margin: 0 0 .2rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.treffer-meta { margin: .1rem 0 .4rem; }
.treffer-auszug { margin: 0; }
mark { background: color-mix(in srgb, var(--warnt) 45%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; }

/* Diagramme */
.stapel-balken { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-bottom: .6rem; }
.stapel-balken .segment { min-width: 0; }
.ocrc-fertig { background: var(--ok); } .ocrc-wartend { background: var(--warnt); }
.ocrc-laufend { background: var(--primaer); } .ocrc-fehler { background: var(--fehler); }
.ocrc-uebersprungen { background: var(--dezent); }
.legende { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--dezent); }
.legende span { display: inline-flex; align-items: center; gap: .3rem; }
.kaestchen { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.balken-diagramm { display: flex; flex-direction: column; gap: .35rem; }
.balken-zeile { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: .5rem; font-size: .85rem; }
.balken-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balken-schiene { background: var(--flaeche2); border-radius: 4px; height: 16px; overflow: hidden; }
.balken-schiene i { display: block; height: 100%; background: var(--primaer); }
.balken-zahl { text-align: right; color: var(--dezent); }
.kurve { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 1rem; }
.kurve-saeule { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.kurve-saeule i { width: 100%; max-width: 34px; background: var(--primaer); border-radius: 4px 4px 0 0; min-height: 2px; }
.kurve-saeule span { font-size: .65rem; color: var(--dezent); }

/* Login/Einrichten */
.zentriert { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.anmeldekarte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 14px;
    padding: 2rem; width: 100%; max-width: 380px; box-shadow: var(--schatten); }
.anmeldekarte form { display: flex; flex-direction: column; gap: .8rem; margin-top: 1rem; }
.anmeldekarte label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--dezent); }
.zentriert-text { text-align: center; }
.karte-hinweis { border-color: var(--warnt); }
.systemliste { list-style: none; padding: 0; }

/* Steuer-Rubrik: Checkliste + Vor-Sortierung */
.checkliste td { vertical-align: top; }
.checkliste .check-symbol { width: 1.8rem; font-size: 1.05rem; }
.checkliste .check-fehlt { background: color-mix(in srgb, var(--warnt) 10%, transparent); }
.checkliste .check-ok td { opacity: .92; }
.rubrik-ueberschrift { margin: 1.1rem 0 .3rem; font-size: .98rem; color: var(--text); }
.rubrik-ueberschrift .abzeichen { margin-left: .35rem; }
.zahlen-rechts { text-align: right; white-space: nowrap; }
select.kat-select { max-width: 15rem; }

/* Responsive */
@media (max-width: 860px) {
    .navi-knopf { display: block; }
    .seitenleiste { position: fixed; left: 0; top: 58px; bottom: 0; background: var(--bg); z-index: 25;
        transform: translateX(-100%); transition: transform .2s; box-shadow: var(--schatten); }
    body.navi-offen .seitenleiste { transform: none; }
    .detail, .zwei-spalten, .import-spalten, .formular-spalten { grid-template-columns: 1fr; }
    .detail-vorschau { position: static; }
    .kopfsuche { order: 3; flex-basis: 100%; max-width: none; }
    .kopf { flex-wrap: wrap; }
}
