/* ============================================================
   BAT Reinigung — Design-Token-Layer (W4-1)
   ------------------------------------------------------------
   EIN zentrales Stylesheet, kein Framework, kein Build-Schritt.
   Alle Werte haengen an CSS-Variablen — Komponenten (W4-3) und
   Seiten (W4-4/5) verwenden AUSSCHLIESSLICH diese Tokens.

   FARBEN
     --c-primary        BAT-Dunkelblau (bestehende Markenfarbe)
     --c-primary-600    dunklere Stufe (Hover, Sidebar)
     --c-primary-050    sehr helle Stufe (aktive Flaechen, Chips)
     --c-accent         EIN Akzent (Links, aktive Zustaende)
     --c-ok / --c-warn / --c-danger   Ampelfarben fuer Status
     --c-*-bg           zugehoerige helle Hintergruende
     --c-text / --c-text-muted        Textfarben
     --c-bg / --c-surface / --c-line  Flaechen + Linien

   TYPOGRAFIE (system-ui/Inter-Stack, 3 Stufen)
     --fs-1  Ueberschrift (18px)   --fs-2  Standard (14px)
     --fs-3  Klein/Meta (12px)

   SPACING-SKALA  --sp-1..--sp-6 = 4/8/12/16/24/32
   RADIUS         --r-card 8px (Karten), --r-ctl 6px (Controls)
   SCHATTEN       --shadow (genau EINE weiche Stufe)
   ============================================================ */

:root {
  /* Farben */
  --c-primary: #1C3A5E;
  --c-primary-600: #16304e;
  --c-primary-050: #eef3f8;
  --c-accent: #2f6fb2;
  --c-ok: #1c7a37;
  --c-ok-bg: #e4f5e7;
  --c-warn: #a5610a;
  --c-warn-bg: #fdeede;
  --c-danger: #8a2a22;
  --c-danger-bg: #fdecea;
  --c-hint: #7a5b12;
  --c-hint-bg: #fff8e6;
  --c-hint-line: #f0dca0;
  --c-text: #1b2733;
  --c-text-muted: #6b7885;
  --c-bg: #f5f7f9;
  --c-surface: #ffffff;
  --c-line: #e2e6ea;

  /* Typografie */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-1: 18px;
  --fs-2: 14px;
  --fs-3: 12px;

  /* Spacing 4/8/12/16/24/32 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* Radius + Schatten */
  --r-card: 8px;
  --r-ctl: 6px;
  --shadow: 0 1px 3px rgba(27, 39, 51, 0.08);

  /* Alt-Aliase (Bestand aus base.html; fallen mit W4-3 weg) */
  --navy: var(--c-primary);
  --line: var(--c-line);
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }

body {
  font-family: var(--font);
  font-size: var(--fs-2);
  margin: 0;
  color: var(--c-text);
  background: var(--c-bg);
}

h1 { font-size: var(--fs-1); color: var(--c-primary); margin: 0 0 var(--sp-3); }
h2 { font-size: 15px; color: var(--c-primary); margin: var(--sp-2) 0 var(--sp-2); }

a { color: var(--c-accent); }

code {
  background: var(--c-primary-050);
  padding: 1px 5px;
  border-radius: var(--r-ctl);
  font-size: var(--fs-3);
  word-break: break-all;
}

/* ============================================================
   W4-2 — Layout: Topbar + linke Sidebar (Admin)
   CSS-only-Umschalter #nav-auf: Desktop = einklappen,
   <900px = Off-Canvas-Overlay mit Burger + Schleier.
   ============================================================ */

.nav-schalter { display: none; }

.topbar {
  background: var(--c-primary);
  color: #fff;
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow);
}
.topbar-links { display: flex; align-items: center; gap: var(--sp-3); }
.topbar .brand { font-weight: 600; }
.topbar a { color: #cfe0f5; text-decoration: none; font-size: var(--fs-2); }
.topbar .logout { margin-left: var(--sp-3); }
.burger {
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-ctl);
}
.burger:hover { background: var(--c-primary-600); }
.langs a { margin-left: var(--sp-2); opacity: .8; }
.langs a.active { text-decoration: underline; opacity: 1; }

.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 50px); }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--c-primary-600);
  color: #dce8f7;
  min-height: calc(100vh - 50px);
  position: sticky;
  top: 50px;
  transition: width .15s ease;
  overflow: hidden;
}
nav.haupt {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4) 0 var(--sp-5);
  min-height: calc(100vh - 50px - var(--sp-6));
}
nav.haupt .gruppe { display: flex; flex-direction: column; }
nav.haupt .gruppe b {
  color: #8fa9c9;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  padding: 0 var(--sp-4) var(--sp-1);
}
nav.haupt a {
  color: #dce8f7;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-4);
  font-size: 13px;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
nav.haupt a:hover { background: rgba(255, 255, 255, .07); }
nav.haupt a.active {
  background: rgba(255, 255, 255, .12);
  border-left-color: var(--c-accent);
  font-weight: 600;
}
nav.haupt .icon { width: 20px; text-align: center; }
nav.haupt .gruppe-unten { margin-top: auto; }
.nav-schleier { display: none; }

main {
  flex: 1;
  /* W5-7: Bildschirmbreite nutzen (Beleg 26.07.) — vorher 980px */
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-4);
  min-width: 0;
}

/* Desktop: Haken = Sidebar eingeklappt */
@media (min-width: 900px) {
  .nav-schalter:checked ~ .layout .sidebar { width: 0; }
}

/* Schmale Viewports: Off-Canvas + Schleier */
@media (max-width: 899.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 50px;
    bottom: 0;
    z-index: 50;
    width: 232px;
    transform: translateX(-100%);
    transition: transform .15s ease;
    min-height: 0;
    overflow-y: auto;
  }
  .nav-schalter:checked ~ .layout .sidebar { transform: translateX(0); }
  .nav-schalter:checked ~ .layout .nav-schleier {
    display: block;
    position: fixed;
    inset: 50px 0 0 0;
    background: rgba(27, 39, 51, .45);
    z-index: 45;
  }
}

/* ============================================================
   Komponenten-Basis (aus base.html uebernommen; W4-3 verfeinert)
   ============================================================ */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-card);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: var(--fs-2); }
th, td { text-align: left; padding: 9px var(--sp-2); border-bottom: 1px solid var(--c-line); }
.badge { font-size: var(--fs-3); padding: 2px var(--sp-2); border-radius: 10px; }
.ok { background: var(--c-ok-bg); color: var(--c-ok); }
.open { background: var(--c-warn-bg); color: var(--c-warn); }
.btn {
  background: var(--c-primary);
  color: #fff;
  border: 0;
  border-radius: var(--r-ctl);
  padding: 7px var(--sp-3);
  font-size: var(--fs-2);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--c-primary-600); }
input, select, textarea {
  padding: 6px var(--sp-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-ctl);
  font-size: var(--fs-2);
  font-family: var(--font);
  background: var(--c-surface);
}
.counter { font-size: 30px; font-weight: 700; color: var(--c-primary); }
.hint {
  background: var(--c-hint-bg);
  border: 1px solid var(--c-hint-line);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-card);
  font-size: 13px;
  color: var(--c-hint);
  margin-bottom: var(--sp-3);
}
.login-wrap { max-width: 340px; margin: 60px auto; }
.form-group { margin-bottom: var(--sp-3); }
label { display: block; font-size: 13px; margin-bottom: var(--sp-1); color: #41505f; }
.error { color: #b3261e; font-size: var(--fs-2); }

/* ============================================================
   W4-3 — Komponenten + Utilities
   Buttons: .btn (primaer) / .btn-sekundaer / .btn-gefahr, eine Hoehe (32px)
   Badges:  .badge + badge-ok / badge-offen / badge-fehler / badge-neutral
            (.ok/.open bleiben als Aliase der alten Klassen)
   Tabellen: Zebra + klebriger Kopf; Formulare: Label ueber Feld,
   .formzeile / .stapel; Utilities ersetzen die alten Inline-Styles.
   ============================================================ */

/* Buttons — einheitliche Hoehe */
.btn, .btn-sekundaer, .btn-gefahr {
  height: 32px;
  line-height: 18px;
  padding: 6px var(--sp-3);
  border-radius: var(--r-ctl);
  font-size: var(--fs-2);
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  border: 1px solid transparent;
}
.btn-sekundaer {
  background: var(--c-surface);
  color: var(--c-primary);
  border-color: var(--c-line);
}
.btn-sekundaer:hover { background: var(--c-primary-050); }
.btn-gefahr { background: var(--c-danger); color: #fff; }
.btn-gefahr:hover { filter: brightness(.92); }
.btn-klein, .btn.btn-klein { height: 26px; padding: 3px var(--sp-2); font-size: var(--fs-3); }

/* Status-Badges — EINE Farblogik ueberall */
.badge { display: inline-block; white-space: nowrap; line-height: 18px; }
.badge-ok { background: var(--c-ok-bg); color: var(--c-ok); }
.badge-offen { background: var(--c-warn-bg); color: var(--c-warn); }
.badge-fehler { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-neutral { background: var(--c-primary-050); color: var(--c-text-muted); }
.chip { background: var(--c-primary-050); border: 1px solid var(--c-line); }

/* Tabellen: luftig, Zebra, Kopf bleibt beim Scrollen sichtbar */
tbody tr:nth-child(even) { background: #fafbfc; }
thead th {
  position: sticky;
  top: 50px;
  background: var(--c-surface);
  z-index: 5;
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: var(--fs-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Formulare: Label ueber Feld, einheitliche Feldhoehen */
input, select { height: 32px; }
input[type="checkbox"], input[type="radio"], input[type="file"] { height: auto; }
label { margin: 0 0 var(--sp-1); }
.formzeile { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; margin: 0; }
.formzeile label, .zeile label { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-3); }
.formzeile label.zeile, label.zeile { flex-direction: row; align-items: center; gap: var(--sp-1); }
.stapel { display: grid; gap: var(--sp-2); max-width: 520px; margin: 0; }
.feld-s { width: 80px; }
.feld-m { width: 130px; }
.feld-l { width: 220px; }
.fehltext { color: #b3261e; font-size: var(--fs-3); }

/* Utilities (ersetzen die haeufigen Inline-Styles) */
.muted { color: var(--c-text-muted); }
.klein { font-size: var(--fs-3); }
.mini { font-size: 11px; }
.titel-s { font-size: 15px; }
.m0 { margin: 0; }
.mb0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.umbruch { word-break: break-all; }  /* W8-5: lange Reset-Links (Debug-Block) */
.voll { width: 100%; }
.start { justify-self: start; }
.zeile { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin: 0; }
.zeile-gross { display: flex; gap: var(--sp-5); flex-wrap: wrap; }
.spalte { display: flex; flex-direction: column; gap: var(--sp-1); }
.versteckt { display: none; }

/* Karten-Raster (W4-4: Heute-Seite) */
.karten-raster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  align-items: start;
}

/* Kalender-Baender (Dashboard) — Zustandsklassen statt Inline-Farben */
.kalender-raster { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.kalender-tag {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--c-line);
  border-radius: var(--r-card);
  padding: 6px;
  background: var(--c-surface);
  font-size: var(--fs-3);
}
.kalender-tag.heute { border-color: var(--c-primary); }
.kalender-tag.heute .tag-datum { font-weight: 700; }
.band { margin-top: 3px; padding: 2px 5px; border-radius: 5px; background: #f1f3f5; }
.band-gruen { background: var(--c-ok-bg); }
.band-rot { background: var(--c-danger-bg); }

/* Balken (Eigenleistung) */
.balken { flex: 1; background: #f1f3f5; border-radius: 5px; overflow: hidden; }
.balken > span {
  display: block;
  min-width: 2px;
  background: var(--c-primary);
  color: #fff;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 5px;
}

/* Notfall-Zeile (W4-4) + Hinweis-Varianten */
.hint-gefahr { background: var(--c-danger-bg); border-color: #e5b6b0; color: var(--c-danger); }
.hint-warn { background: #fdf6e3; border-color: #e0c98f; color: #7a5c12; }

/* Feinklassen fuer die letzten Inline-Reste (W4-3) */
.code-anzeige { font-size: 28px; letter-spacing: 4px; }
.zentriert { text-align: center; }
.fehler-wrap { max-width: 480px; margin: 40px auto; text-align: center; }
.fehler-wrap h1 { font-size: 22px; }
.zeile-hell { background: #f8fafc; }
.zeile-warnung { background: var(--c-danger-bg); }
.gedimmt { opacity: .45; }
.hint-ok { background: var(--c-ok-bg); border-color: #9fd3ab; color: var(--c-ok); }
.zaehler-warn { color: #b3261e; }
.inline { display: inline; }
.kursiv { font-style: italic; }
.vorformatiert { white-space: pre-wrap; }
.text-block {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--c-line);
  border-radius: var(--r-card);
  padding: var(--sp-2);
}
.max-s { max-width: 420px; }
.max-m { max-width: 560px; }
.max-l { max-width: 640px; }
.eintrag-block {
  display: block;
  padding: var(--sp-2);
  margin-bottom: var(--sp-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-ctl);
}

/* Telegram-Vorschau (bewusst eigener Look) */
.tg-rahmen { background: #8db3d6; border-radius: 12px; padding: 18px; max-width: 520px; margin: 0 auto; }
.tg-datum { font-size: var(--fs-3); color: #22415e; margin: 14px 0 4px 4px; font-weight: 600; }
.tg-bild { width: 100%; border-radius: var(--r-card); margin-bottom: var(--sp-2); }
.tg-meta { text-align: right; font-size: 11px; color: #9ab; }
.tg-buttons { display: flex; gap: var(--sp-1); margin-top: 3px; max-width: 100%; }
.tg-button {
  flex: 1;
  background: rgba(255, 255, 255, .85);
  border-radius: var(--r-card);
  text-align: center;
  padding: 7px 4px;
  font-size: 13.5px;
  color: #2a6da3;
}
.tg-blase {
  background: #fff;
  border-radius: 12px 12px 12px 3px;
  padding: 10px 14px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15);
  font-size: 15px;
  line-height: 1.45;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #111;
}

/* W4-4: EINE prominente Notfall-Zeile (statt Banner-Stapel) */
.notfall {
  background: var(--c-danger-bg);
  border: 1px solid #e5b6b0;
  border-left: 4px solid var(--c-danger);
  border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  color: var(--c-danger);
  box-shadow: var(--shadow);
}
.notfall-titel { font-weight: 700; display: block; margin-bottom: var(--sp-1); }
.notfall-eintrag { padding: var(--sp-1) 0; }
.notfall-eintrag + .notfall-eintrag { border-top: 1px dashed #e5b6b0; }
.karten-raster > .card { margin-bottom: 0; }
.karten-raster { margin-bottom: var(--sp-4); }

/* ============================================================
   W4-5 — Kraft-Seite: Handy-first
   Eine Spalte, grosse Tap-Flaechen (min. 44px), lesbar ohne Zoom,
   Tabellen stapeln sich zeilenweise — kein horizontales Scrollen
   auch bei 380px Viewport.
   ============================================================ */
img { max-width: 100%; }

.kraft-mobil { max-width: 520px; margin: 0 auto; font-size: 16px; }
.kraft-mobil * { max-width: 100%; }
.kraft-mobil .card { padding: var(--sp-4); }
.kraft-mobil .btn {
  min-height: 44px;
  width: 100%;
  justify-content: center;
  font-size: 16px;
  height: auto;
}
.kraft-mobil input, .kraft-mobil select {
  height: 44px;
  font-size: 16px;
  width: 100%;
}
.kraft-mobil input[type="checkbox"], .kraft-mobil input[type="file"] {
  height: auto;
  width: auto;
}
.kraft-mobil table, .kraft-mobil tbody,
.kraft-mobil tr, .kraft-mobil td { display: block; width: 100%; }
.kraft-mobil thead { display: none; }
.kraft-mobil td { border: 0; padding: 2px 0; }
.kraft-mobil tr { border-bottom: 1px solid var(--c-line); padding: var(--sp-2) 0; }
.kraft-mobil tbody tr:nth-child(even) { background: transparent; }

/* ============================================================
   W5-6 — Kachel-Tabellen responsive
   Tabellen scrollen INNERHALB ihrer Karte (kein Seiten-Overflow
   bei 380px) — der Scrollbalken gehoert zur Karte, nicht zur Seite.
   ============================================================ */
.tabelle-scroll { overflow-x: auto; max-width: 100%; }
.tabelle-scroll table { width: max-content; min-width: 100%; }

/* ============================================================
   W5-7 — Bildschirmbreite nutzen
   Kalender-Karte laeuft ohnehin volle Breite (ausserhalb des
   Rasters); das untere Kachel-Raster wird ab 1200px 3-spaltig.
   ============================================================ */
@media (min-width: 1200px) {
  .karten-raster-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   W5-10 — Nutzerkarten am Waesche-UI-Muster
   Tabellenartige Kopfzeile (Name links, Rollen-Zaehler rechts),
   zweispaltiger Detail-Bereich; inaktive Karten sichtbar gedimmt.
   ============================================================ */
.karten-kopf { justify-content: space-between; }
.detail-zwei {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  align-items: start;
  padding-top: var(--sp-3);
}
@media (max-width: 700px) { .detail-zwei { grid-template-columns: 1fr; } }
.karte-inaktiv { opacity: 0.65; background: var(--c-bg, #f6f7f9); }
