:root {
  --bg: #f4f2ee;
  --karte: #ffffff;
  --text: #1d2430;
  --leise: #5f6877;
  --linie: #e2ded6;
  --marke: #086825;
  --marke-hell: #e6f1e3;
  --akzent: #6d9d22;
  --logo-grau: #867f72;
  --gut: #2e7d4f;
  --gut-hell: #e3f2e8;
  --warn: #b26a00;
  --warn-hell: #fdf1dc;
  --schlecht: #b3261e;
  --schlecht-hell: #fbe4e2;
  --radius: 12px;
  --schatten: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --karte: #1d232c;
    --text: #e8eaee;
    --leise: #9aa3b2;
    --linie: #2e3642;
    --marke: #a6be0e;
    --marke-hell: #253320;
    --akzent: #a6be0e;
    --gut: #6cc58f;
    --gut-hell: #1d3326;
    --warn: #e7b04f;
    --warn-hell: #3a2f1a;
    --schlecht: #f08a82;
    --schlecht-hell: #3d2220;
    --schatten: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--marke); }
.leise { color: var(--leise); font-size: .9rem; }
.klein { font-size: .85rem; }
.fett { font-weight: 600; }
.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }
.schicht .zeit { white-space: nowrap; }

/* Kopf und Navigation */
header.kopf {
  position: sticky; top: 0; z-index: 20;
  background: var(--karte); color: var(--text); border-bottom: 3px solid var(--marke);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
header.kopf .kopf-logo { height: 42px; width: auto; display: block; }
header.kopf h1 { color: var(--logo-grau); }
header.kopf h1 { font-size: 1.05rem; font-weight: 500; flex: 1; letter-spacing: .04em; padding-left: 10px; border-left: 1px solid var(--linie); }
header.kopf .wer { font-size: .85rem; color: var(--leise); }
@media (max-width: 420px) { header.kopf .wer { display: none; } }
nav.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  background: var(--karte); border-bottom: 1px solid var(--linie);
  padding: 6px 12px; position: sticky; top: 65px; z-index: 19;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap;
  color: var(--leise); font-weight: 550; cursor: pointer; position: relative;
}
nav.tabs button.aktiv { background: var(--marke-hell); color: var(--marke); }
nav.unten {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--karte); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.unten button {
  flex: 1; border: 0; background: none; padding: 8px 2px 7px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--leise); position: relative;
}
nav.unten button svg { width: 22px; height: 22px; }
nav.unten button.aktiv { color: var(--marke); font-weight: 600; }
.zaehler {
  background: var(--akzent); color: #fff; border-radius: 9px; font-size: .7rem; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center;
  margin-left: 4px;
}
nav.unten .zaehler { position: absolute; top: 3px; left: 50%; margin-left: 6px; }

main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
main.schmal { max-width: 640px; }

/* Karten und Listen */
.karte {
  background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius);
  box-shadow: var(--schatten); padding: 14px 16px; margin-bottom: 12px;
}
.karte.knapp { padding: 10px 14px; }
.zeile { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.zeile.zwischen { justify-content: space-between; }
.stapel > * + * { margin-top: 10px; }
.leiste { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.woche { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.leiste .titel { flex: 1; min-width: 140px; }
.raster { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.kennzahl { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.kennzahl .wert { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kennzahl .name { font-size: .8rem; color: var(--leise); }
.kennzahl.gut .wert { color: var(--gut); }
.kennzahl.schlecht .wert { color: var(--schlecht); }
.leer { text-align: center; color: var(--leise); padding: 28px 10px; }

/* Knöpfe und Felder */
.knopf {
  border: 1px solid var(--linie); background: var(--karte); border-radius: 9px;
  padding: 8px 14px; cursor: pointer; font-weight: 550; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.knopf:hover { border-color: var(--leise); }
a.knopf { text-decoration: none; color: inherit; }
a.knopf.haupt { color: #fff; }
.knopf.haupt { background: var(--marke); border-color: var(--marke); color: #fff; }
@media (prefers-color-scheme: dark) { .knopf.haupt { color: #10161f; } }
.knopf.gut { background: var(--gut); border-color: var(--gut); color: #fff; }
.knopf.schlecht { color: var(--schlecht); }
.knopf.klein { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
.knopf.rund { width: 40px; padding: 0; justify-content: center; }
.knopf:disabled { opacity: .5; cursor: default; }
label.feld { display: block; }
label.feld > span { display: block; font-size: .82rem; color: var(--leise); margin-bottom: 4px; font-weight: 550; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=time], input[type=month], select, textarea {
  width: 100%; border: 1px solid var(--linie); background: var(--karte); border-radius: 9px;
  padding: 9px 11px; min-height: 42px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--marke); outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
.felder { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 4px 0; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--marke); }
.umschalter { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; border: 1px solid var(--linie); }
.umschalter button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; color: var(--leise); }
.umschalter button.aktiv { background: var(--karte); color: var(--text); box-shadow: var(--schatten); }

/* Kennzeichen */
.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px;
  font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--leise); white-space: nowrap;
}
.chip.offen, .chip.angefragt, .chip.angenommen { background: var(--warn-hell); color: var(--warn); }
.chip.genehmigt { background: var(--gut-hell); color: var(--gut); }
.chip.abgelehnt, .chip.abgelehnt_kollege, .chip.ungueltig { background: var(--schlecht-hell); color: var(--schlecht); }
.hinweis { border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.hinweis.warn { background: var(--warn-hell); color: var(--warn); }
.hinweis.schlecht { background: var(--schlecht-hell); color: var(--schlecht); }
.hinweis.gut { background: var(--gut-hell); color: var(--gut); }
.hinweis.info { background: var(--marke-hell); color: var(--marke); }

/* Schichten */
.schicht {
  display: flex; align-items: center; gap: 8px; border-radius: 9px; padding: 6px 10px;
  background: color-mix(in srgb, var(--f, #2f6fde) 14%, var(--karte));
  border-left: 4px solid var(--f, #2f6fde); font-size: .9rem;
}
.schicht .zeit { font-variant-numeric: tabular-nums; font-weight: 600; }
.abw {
  display: flex; align-items: center; gap: 6px; border-radius: 9px; padding: 6px 10px; font-size: .88rem;
  background: repeating-linear-gradient(135deg, var(--bg) 0 6px, var(--karte) 6px 12px); border: 1px dashed var(--linie);
  color: var(--leise); font-weight: 550;
}
.abw.genehmigt { background: var(--gut-hell); border: 0; color: var(--gut); }
.abw.krank { background: var(--schlecht-hell); color: var(--schlecht); }

/* Wochenliste (Mitarbeiter) */
.tag { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--linie); }
.tag:first-child { border-top: 0; }
.tag .datum { text-align: center; }
.tag .datum .wt { font-size: .75rem; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; }
.tag .datum .nr { font-size: 1.35rem; font-weight: 650; line-height: 1.1; }
.tag.heute .datum .nr { color: #fff; background: var(--marke); border-radius: 10px; display: inline-block; min-width: 38px; padding: 2px 4px; }
@media (prefers-color-scheme: dark) { .tag.heute .datum .nr { color: #10161f; } }
.tag .inhalt { display: flex; flex-direction: column; gap: 6px; justify-content: center; min-height: 40px; }
.tag .name { font-size: .82rem; color: var(--leise); }

/* Wochenraster (Admin) */
.raster-huelle { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--karte); box-shadow: var(--schatten); }
table.plan { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 860px; }
table.plan th, table.plan td { border-bottom: 1px solid var(--linie); border-left: 1px solid var(--linie); padding: 6px; vertical-align: top; }
table.plan th { background: var(--karte); font-size: .82rem; font-weight: 600; text-align: left; position: sticky; top: 0; }
table.plan th.heute { color: var(--marke); box-shadow: inset 0 -3px 0 var(--marke); }
table.plan td:first-child, table.plan th:first-child {
  border-left: 0; position: sticky; left: 0; background: var(--karte); z-index: 2; width: 130px; min-width: 130px; font-weight: 600; font-size: .9rem;
}
table.plan td.zelle { cursor: pointer; min-width: 105px; height: 54px; }
table.plan td.zelle:hover { background: var(--bg); }
table.plan td.zelle .schicht, table.plan td.zelle .abw { padding: 4px 7px; font-size: .78rem; margin-bottom: 3px; gap: 0; }
table.plan td.zelle .schicht { flex-direction: column; align-items: flex-start; }
table.plan td.zelle .schicht span:last-child:not(.zeit) { font-size: .72rem; color: var(--leise); }
table.plan tfoot td { font-size: .82rem; background: var(--bg); position: static; }
table.plan tfoot td:first-child { background: var(--bg); }
.besetzung { font-weight: 700; font-variant-numeric: tabular-nums; }
.besetzung.ok { color: var(--gut); }
.besetzung.zuwenig { color: var(--schlecht); }
.feiertag-mark { color: var(--akzent); font-size: .74rem; display: block; font-weight: 550; }

/* Tabellen */
table.liste { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.liste th { text-align: left; font-size: .78rem; color: var(--leise); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--linie); }
table.liste td { padding: 8px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
table.liste tr.klickbar { cursor: pointer; }
table.liste tr.klickbar:hover td { background: var(--bg); }
table.liste .r { text-align: right; font-variant-numeric: tabular-nums; }
.tabelle-huelle { overflow-x: auto; }
.pos { color: var(--gut); } .neg { color: var(--schlecht); }

/* Dialog */
.schleier {
  position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .schleier { align-items: center; } }
.dialog {
  background: var(--karte); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .dialog { border-radius: 16px; } }
.dialog .kopfzeile { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.dialog .fuss { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* Meldung */
#meldung {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60;
  background: #222b38; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .92rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: calc(100% - 32px); display: none;
}
#meldung.fehler { background: var(--schlecht); }

/* Anmeldung */
.anmeldung { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.anmeldung .karte { width: 100%; max-width: 380px; padding: 24px; }
.anmeldung .logo { width: 220px; max-width: 80%; height: auto; display: block; margin: 0 auto 18px; }

@media (max-width: 640px) {
  main { padding: 12px 12px 96px; }
  table.liste th, table.liste td { padding: 7px 5px; }
  table.liste td:first-child { white-space: nowrap; }
  .karte { padding: 12px 14px; }
}
@media print {
  header.kopf, nav, .leiste .knopf, #meldung { display: none !important; }
  body { background: #fff; }
}

/* Unterschrift */
.unterschrift-feld {
  display: block; width: 100%; height: 170px; touch-action: none; cursor: crosshair;
  background: #fff; border: 2px dashed var(--linie); border-radius: 10px;
}

/* Belegung im Wochenplan */
tbody.belegung-block tr td { background: var(--marke-hell); padding: 3px 6px; font-size: .82rem; }
tbody.belegung-block tr td:first-child { background: var(--marke-hell); font-weight: 600; }
tbody.belegung-block tr.berechnet td { border-bottom: 2px solid var(--marke); }
input.bel-feld { width: 100%; min-height: 30px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; border-radius: 6px; background: var(--karte); }
input.bel-feld.gespeichert { border-color: var(--gut); }
input.bel-feld.fehlerhaft { border-color: var(--schlecht); }
tbody.belegung-block td.r { text-align: right; }

/* Version 1.7: Freigabe, offene Schichten, Verfügbarkeit */
.freigabe { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px;
  border: 1px dashed var(--warn); border-radius: var(--radius); background: var(--warn-hell); }
.freigabe.ist { border: 1px solid var(--linie); background: var(--karte); }
.offen-chip { display: block; padding: 4px 7px; margin-bottom: 3px; border-radius: 8px; font-size: .78rem; cursor: pointer;
  border: 1.5px dashed var(--warn); color: var(--warn); background: var(--warn-hell); font-weight: 600; }
tr.offene-zeile td { background: var(--warn-hell); vertical-align: top; }
.verf-mark { font-size: .7rem; color: var(--leise); margin-top: 2px; }
table.plan td.zelle.unverfuegbar { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--bg) 6px 12px); }
.nachricht-karte { border-left: 4px solid var(--warn); }
ul.aenderungen { margin: 6px 0 0; padding-left: 18px; }
ul.aenderungen li { margin: 2px 0; }
.verf { display: grid; gap: 8px; }
.verf-zeile { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; align-items: center;
  padding-bottom: 8px; border-bottom: 1px solid var(--linie); }
.verf-zeile > :nth-child(n+3) { grid-column: 2; }
.verf-zeile .zeile input[type=time] { flex: 1 1 0; min-width: 0; max-width: 130px; padding-left: 6px; padding-right: 4px; font-size: .95rem; }
@media (min-width: 640px) {
  .verf-zeile { grid-template-columns: 110px 190px auto minmax(0, 1fr); }
  .verf-zeile > :nth-child(n+3) { grid-column: auto; }
}

/* Version 2.0: Kennzahlen */
table.kennzahlen td, table.kennzahlen th { white-space: nowrap; }
table.kennzahlen td.r { min-width: 74px; }
.kz-balken { height: 4px; margin-top: 3px; margin-left: auto; border-radius: 2px; background: var(--gruen-hell, #a6be0e); }
.kz-balken.neg { background: var(--schlecht, #c0392b); }

/* Version 2.1: Zwei-Faktor */
.mfa-qr { width: 200px; max-width: 100%; margin: 8px 0; }
.mfa-qr svg { width: 100%; height: auto; display: block; }
.stempel-karte { border-left: 4px solid var(--gruen, #086825); }
.knopf.gross { padding: 12px 18px; font-size: 1.05rem; }
.beleh-text { white-space: pre-wrap; max-height: 40vh; overflow: auto; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 8px; background: var(--bg); font-size: .95rem; }
.dialog textarea { width: 100%; font: inherit; padding: 8px; border: 1px solid var(--linie); border-radius: 8px; }
