/* Zeiterfassung — Gestaltung (Master-Spezifikation Abschnitt 2).
   Ein :root-Block mit allen Werten; hell und dunkel; volle Breite 1600 px (B9);
   Handy zuerst mit unterer Leiste (D39); keine Inline-Stile (CSP). */

:root {
  --inhalt: 1600px;
  --rand: clamp(12px, 3vw, 32px);
  --bg: #faf8f5;
  --flaeche: #ffffff;
  --flaeche-2: #f2efea;
  --linie: #e2ddd5;
  --text: #1c1b19;
  --text-2: #5d5a55;
  --akzent: #0e6e78;
  --akzent-dunkel: #0a535a;
  --akzent-hell: #e3f1f2;
  --auf-akzent: #ffffff;
  --gut: #2e7d4f;
  --gut-hell: #e6f4ec;
  --hinweis: #8a5a00;
  --hinweis-hell: #fff4db;
  --warnung: #b42318;
  --warnung-hell: #fdecea;
  --fokus: #1a73e8;
  --r: 10px;
  --r-klein: 6px;
  --schatten: 0 1px 2px rgba(28, 27, 25, .06), 0 2px 8px rgba(28, 27, 25, .05);
  --zeile: 44px;
  --leiste: 64px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --dauer: 140ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --flaeche: #1e1d1b;
    --flaeche-2: #26251f;
    --linie: #3a3833;
    --text: #f1efea;
    --text-2: #b7b2a9;
    --akzent: #4fb3bd;
    --akzent-dunkel: #7cc9d1;
    --akzent-hell: #16363a;
    --auf-akzent: #0b1c1e;
    --gut: #6cc28f;
    --gut-hell: #173325;
    --hinweis: #f0b94a;
    --hinweis-hell: #3a2c0c;
    --warnung: #ff8a80;
    --warnung-hell: #3d1a17;
    --fokus: #8ab4f8;
    --schatten: none;
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) { :root { --dauer: 0ms; } }

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--schrift); font-variant-numeric: tabular-nums;
}
img, svg, video { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--akzent); }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.nur-vorleser { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Rahmen: Kopf, Inhalt, untere Leiste (alle auf --inhalt) ---------- */
.rahmen { width: 100%; max-width: var(--inhalt); margin: 0 auto; padding: 0 var(--rand); }
.topbar { background: var(--flaeche); border-bottom: 1px solid var(--linie); position: sticky; top: 0; z-index: 20; }
.topbar .rahmen { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.marke { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.marke svg { width: 26px; height: 26px; color: var(--akzent); }
.marke small { font-weight: 400; color: var(--text-2); }
.nav-oben { display: none; margin-left: auto; gap: 4px; flex-wrap: wrap; }
.nav-oben a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r-klein);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav-oben a:hover { background: var(--flaeche-2); }
.nav-oben a[aria-current="page"] { background: var(--akzent-hell); color: var(--akzent-dunkel); }
.netz { margin-left: auto; font-size: .85rem; color: var(--hinweis); background: var(--hinweis-hell); padding: 2px 10px; border-radius: 99px; }

main { padding-block: 20px calc(var(--leiste) + 28px + env(safe-area-inset-bottom)); min-height: 60vh; }

.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--flaeche);
  border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom);
}
.leiste { display: grid; grid-template-columns: repeat(5, 1fr); padding-inline: max(0px, calc((100vw - var(--inhalt)) / 2)); }
.leiste a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--leiste); color: var(--text-2); text-decoration: none; font-size: .75rem; font-weight: 500;
}
.leiste a svg { width: 24px; height: 24px; }
.leiste a[aria-current="page"] { color: var(--akzent); }
.leiste a.mitte svg { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--akzent); color: var(--auf-akzent); }

@media (min-width: 900px) {
  .nav-oben { display: flex; }
  .netz { margin-left: 0; }
  .leiste { display: none; }
  main { padding-block: 28px 48px; }
}

.fuss { color: var(--text-2); font-size: .85rem; padding-block: 24px calc(var(--leiste) + 24px); border-top: 1px solid var(--linie); }
.fuss .rahmen { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
@media (min-width: 900px) { .fuss { padding-bottom: 24px; } }

/* ---------- Bausteine ---------- */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); padding: 20px; box-shadow: var(--schatten); }
.karte + .karte, .abschnitt + .abschnitt { margin-top: 16px; }
.kopfzeile { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.kopfzeile h1, .kopfzeile h2 { margin: 0; }
.kopfzeile .aktionen { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.raster { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.stapel > * + * { margin-top: 12px; }
.zeile-flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.leise { color: var(--text-2); }
.klein { font-size: .875rem; }
.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }
.gross { font-size: 2rem; font-weight: 700; line-height: 1.1; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r-klein); border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background var(--dauer), border-color var(--dauer);
}
.knopf:hover { background: var(--flaeche-2); }
.knopf:disabled { opacity: .55; cursor: not-allowed; }
.knopf svg { width: 20px; height: 20px; }
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--auf-akzent); }
.knopf.primaer:hover { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); }
.knopf.gefahr { color: var(--warnung); border-color: currentColor; }
.knopf.gefahr:hover { background: var(--warnung-hell); }
.knopf.leise-knopf { border-color: transparent; background: transparent; }
.knopf.breit { width: 100%; }
.knopf.riesig { min-height: 72px; font-size: 1.25rem; border-radius: var(--r); width: 100%; }
.knopf.riesig svg { width: 28px; height: 28px; }
.knopf.laeuft { background: var(--warnung); border-color: var(--warnung); color: #fff; }

.feld { display: flex; flex-direction: column; gap: 6px; }
.feld > label, .feld > .label { font-weight: 600; }
.feld .hilfe { color: var(--text-2); font-size: .875rem; }
.feld .fehlertext { color: var(--warnung); font-size: .875rem; font-weight: 600; }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--r-klein); border: 1px solid var(--linie);
  background: var(--flaeche); color: var(--text); font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--fokus); outline-offset: 0; border-color: var(--fokus); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--warnung); }
textarea { min-height: 88px; resize: vertical; }
.kontrolle { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding-top: 10px; cursor: pointer; }
.kontrolle input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--akzent); flex: none; }
.formular { display: grid; gap: 16px; }
.formular .zwei { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
fieldset { border: 1px solid var(--linie); border-radius: var(--r); padding: 12px 16px 16px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }

.pw-zeile { display: flex; gap: 8px; }
.pw-zeile input { flex: 1; }
.pw-stufe { display: flex; gap: 8px; align-items: center; font-size: .9rem; font-weight: 600; min-height: 24px; }
.pw-balken { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 120px; }
.pw-balken span { height: 6px; border-radius: 3px; background: var(--linie); }
.pw-stufe[data-stufe="zu_kurz"] .pw-balken span:nth-child(1) { background: var(--warnung); }
.pw-stufe[data-stufe="erfuellt"] .pw-balken span:nth-child(-n+2) { background: var(--hinweis); }
.pw-stufe[data-stufe="stark"] .pw-balken span { background: var(--gut); }

/* Hinweisboxen: Text und Zeichen, nie nur Farbe */
.meldung { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-klein); border: 1px solid; }
.meldung svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.meldung p { margin: 0; }
.meldung.info { background: var(--akzent-hell); border-color: var(--akzent); color: var(--text); }
.meldung.gut { background: var(--gut-hell); border-color: var(--gut); }
.meldung.hinweis { background: var(--hinweis-hell); border-color: var(--hinweis); }
.meldung.warnung { background: var(--warnung-hell); border-color: var(--warnung); }
.meldung.warnung strong, .meldung.warnung svg { color: var(--warnung); }
.meldung.hinweis strong, .meldung.hinweis svg { color: var(--hinweis); }

.marke-klein {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600;
  background: var(--flaeche-2); color: var(--text-2); white-space: nowrap;
}
.marke-klein.gut { background: var(--gut-hell); color: var(--gut); }
.marke-klein.hinweis { background: var(--hinweis-hell); color: var(--hinweis); }
.marke-klein.warnung { background: var(--warnung-hell); color: var(--warnung); }
.marke-klein.akzent { background: var(--akzent-hell); color: var(--akzent-dunkel); }

/* Tabellen: Zeile 44 px, scrollen im eigenen Kasten */
.tabelle-kasten { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--linie); vertical-align: middle; height: var(--zeile); }
th { font-size: .82rem; text-transform: none; color: var(--text-2); font-weight: 600; background: var(--flaeche-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.zahl, th.zahl { text-align: right; }
tr.heute td { background: var(--akzent-hell); }
tr.frei td { color: var(--text-2); }
tfoot td { font-weight: 700; background: var(--flaeche-2); }
.aktionen-zelle { white-space: nowrap; text-align: right; }

/* Leere, Lade- und Fehlerzustände */
.zustand { text-align: center; padding: 40px 16px; color: var(--text-2); }
.zustand svg { width: 40px; height: 40px; color: var(--akzent); }
.zustand.fehler svg { color: var(--warnung); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--linie); border-top-color: var(--akzent); margin: 0 auto 12px; animation: drehen .8s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Dialog */
dialog { border: 1px solid var(--linie); border-radius: var(--r); padding: 0; background: var(--flaeche); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-kopf { display: flex; align-items: center; gap: 8px; padding: 12px 12px 0 20px; }
.dialog-kopf h2 { margin: 0; flex: 1; }
.dialog-inhalt { padding: 12px 20px 20px; overflow: auto; }
.dialog-fuss { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 0 20px 20px; }

/* Kurzmeldung unten */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--leiste) + 16px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--r-klein); z-index: 50;
  display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 24px); box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast button { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; min-height: 44px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.qr { width: 220px; max-width: 100%; background: #fff; padding: 8px; border-radius: var(--r-klein); border: 1px solid var(--linie); }
.code-text { font-family: var(--mono); word-break: break-all; background: var(--flaeche-2); padding: 8px 10px; border-radius: var(--r-klein); }
.codes-liste { columns: 2; font-family: var(--mono); font-size: 1.05rem; padding-left: 20px; }

.anmelde-seite { display: grid; place-items: start center; padding-top: clamp(8px, 6vh, 64px); }
.anmelde-seite .karte { width: 100%; }
@media (min-width: 700px) { .anmelde-seite .karte { width: min(100%, 520px); } }

.ziffern { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 12px; }
.ziffer { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); padding: 14px 16px; }
.ziffer .wert { font-size: 1.6rem; font-weight: 700; }
.ziffer .was { color: var(--text-2); font-size: .85rem; }
.ziffer.gut .wert { color: var(--gut); }
.ziffer.warnung .wert { color: var(--warnung); }

.farbmuster { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.farbmuster div { border-radius: var(--r-klein); padding: 28px 8px 8px; font-size: .8rem; border: 1px solid var(--linie); }
.fm-akzent { background: var(--akzent); color: var(--auf-akzent); }
.fm-gut { background: var(--gut-hell); }
.fm-hinweis { background: var(--hinweis-hell); }
.fm-warnung { background: var(--warnung-hell); }
.fm-flaeche { background: var(--flaeche-2); }

/* ---------- Druck: A4 hoch, nur der Zettel ---------- */
.nur-druck { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar, .leiste, .fuss, .kein-druck, .toast, dialog { display: none !important; }
  .nur-druck { display: block; }
  main { padding: 0; }
  .rahmen { max-width: none; padding: 0; }
  .karte { border: 0; box-shadow: none; padding: 0; }
  .tabelle-kasten { border: 0; overflow: visible; }
  th, td { padding: 3px 5px; height: auto; border-bottom: .5pt solid #999; }
  th { background: #eee !important; color: #000; }
  tr { break-inside: avoid; }
  .zettel { break-after: page; }
  .zettel:last-child { break-after: auto; }
  .marke-klein { border: .5pt solid #999; background: none !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
}

/* ---------- Ergänzungen ---------- */
.knopf-karte { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); min-height: 120px; transition: border-color var(--dauer); }
.knopf-karte:hover { border-color: var(--akzent); }
.knopf-karte svg { width: 28px; height: 28px; color: var(--akzent); }
.knopf[aria-current="page"] { background: var(--akzent-hell); border-color: var(--akzent); color: var(--akzent-dunkel); }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
details[open] > summary { margin-bottom: 12px; }
.druck-logo { max-height: 56px; width: auto; }
.unterschrift-linie { border-bottom: 1px solid var(--text); height: 40px; margin: 0; }
dl { margin: 0; } dd { margin: 0; }
@media print { .druck-logo { max-height: 40px; } .zettel h2 { font-size: 13pt; } }

/* Handy: Tabellen schlank, Blättern in einer Zeile */
.blaettern { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; }
.blaettern h1 { flex: 1 1 auto; min-width: 0; text-align: center; font-size: clamp(1.1rem, .9rem + 1.2vw, 2rem); }
@media (min-width: 700px) { .blaettern { flex: 0 1 auto; } .blaettern h1 { text-align: left; } }
td .knopf.leise-knopf { white-space: nowrap; padding: 0 6px; }
@media (max-width: 600px) { .neben { display: none; } th, td { padding: 8px 8px; } }
@media print { .neben { display: table-cell !important; } }
