/* Infoauslage Klinik Amsee – mobile-first, barrierearm (WCAG 2.1 AA).
   Design-Tokens hell/dunkel; Bedienziele min. 48px; Fokus sichtbar;
   Ampel nie nur über Farbe (Symbole + Text stehen im Markup). */

:root {
  --primary: #0e6e85;        /* Amsee-Blaugrün, Kontrast zu Weiß 5.2:1 */
  --primary-dunkel: #0a5468;
  --akzent: #b45309;         /* Amber-Ton für "knapp"/gelb, 4.6:1 auf Weiß */
  --gefahr: #b91c1c;         /* Rot für "leer"/überfällig, 5.9:1 auf Weiß */
  --ok: #15803d;
  --grund: #f4f7f8;
  --karte: #ffffff;
  --text: #1b2430;
  --text-schwach: #49555e;
  --linie: #d5dde1;
  --fokus: #7c3aed;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #4fb3cc;
    --primary-dunkel: #7accdf;
    --akzent: #e8a13d;
    --gefahr: #f07575;
    --ok: #66bb84;
    --grund: #12181d;
    --karte: #1c242b;
    --text: #e8edf0;
    --text-schwach: #a3b0b8;
    --linie: #37424a;
    --fokus: #c4b5fd;
  }
}

* { box-sizing: border-box; }
html { font-size: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--grund);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: calc(4.2rem + env(safe-area-inset-bottom));
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--karte);
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

header.kopf {
  background: var(--primary); color: #fff;
  padding: .7rem 1rem calc(.7rem);
  display: flex; align-items: center; gap: .6rem;
}
@media (prefers-color-scheme: dark) {
  header.kopf { background: var(--karte); color: var(--text); border-bottom: 1px solid var(--linie); }
}
header.kopf h1 { font-size: 1.05rem; margin: 0; font-weight: 600; flex: 1; }
header.kopf .zurueck { color: inherit; text-decoration: none; font-size: 1.4rem; min-width: 2.5rem; min-height: 2.75rem; display: inline-flex; align-items: center; }

main { max-width: 44rem; margin: 0 auto; padding: 1rem; }

/* Karten */
.karte {
  background: var(--karte); border: 1px solid var(--linie);
  border-radius: 12px; padding: .9rem 1rem; margin-bottom: .8rem;
}
.karte h2 { font-size: 1rem; margin: 0 0 .5rem; }
.karte.warn-rot { border-left: 6px solid var(--gefahr); }
.karte.warn-gelb { border-left: 6px solid var(--akzent); }
.karte.warn-ok { border-left: 6px solid var(--ok); }

/* Buttons & Formulare */
button, .knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .6rem 1.1rem;
  border-radius: 10px; border: 1px solid var(--linie);
  background: var(--karte); color: var(--text);
  font-size: 1rem; font-family: inherit; cursor: pointer; text-decoration: none;
}
button.primaer, .knopf.primaer { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  button.primaer, .knopf.primaer { color: #10181d; }
}
button.gefahr { color: var(--gefahr); border-color: var(--gefahr); background: transparent; }
button.breit, .knopf.breit { width: 100%; }
button[disabled] { opacity: .55; cursor: not-allowed; }

label { display: block; font-weight: 600; margin: .8rem 0 .25rem; }
input, select, textarea {
  width: 100%; min-height: 48px; padding: .55rem .7rem;
  font-size: 1rem; /* >=16px: verhindert iOS-Autozoom */
  font-family: inherit;
  border: 1px solid var(--linie); border-radius: 10px;
  background: var(--karte); color: var(--text);
}
textarea { min-height: 6rem; }
.feld-hinweis { font-size: .85rem; color: var(--text-schwach); margin-top: .2rem; }
.fehler-text { color: var(--gefahr); font-weight: 600; }

/* Flash-Meldungen */
.flash { border-radius: 10px; padding: .7rem 1rem; margin-bottom: .8rem; font-weight: 500; }
.flash.ok { background: var(--ok); color: #fff; }
.flash.fehler { background: var(--gefahr); color: #fff; }
@media (prefers-color-scheme: dark) {
  .flash.ok { color: #0c1510; } .flash.fehler { color: #1a0d0d; }
}

/* Bottom-Navigation (Muster .mp-nav aus der Vereinsverwaltung) */
.mp-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: var(--karte); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.mp-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: .45rem .2rem .5rem; min-height: 52px;
  text-decoration: none; color: var(--text-schwach); font-size: .72rem;
  position: relative;
}
.mp-nav a .ic { font-size: 1.35rem; line-height: 1.2; }
.mp-nav a.aktiv { color: var(--primary); font-weight: 700; }
.mp-nav a.aktiv::after { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--primary); border-radius: 0 0 3px 3px; }
.nav-zahl {
  position: absolute; top: 2px; right: 18%;
  background: var(--gefahr); color: #fff; border-radius: 999px;
  font-size: .68rem; font-weight: 700; min-width: 1.15rem; height: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 .25rem;
}

/* Status-Ampel: immer Symbol + Text im Markup, Farbe nur zusätzlich */
.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; font-weight: 600; border: 1px solid var(--linie); }
.badge.rot { color: var(--gefahr); border-color: var(--gefahr); }
.badge.gelb { color: var(--akzent); border-color: var(--akzent); }
.badge.gruen { color: var(--ok); border-color: var(--ok); }

/* Kontrollgang-Karten */
.pub-karte { display: grid; grid-template-columns: 64px 1fr; gap: .7rem; align-items: start; }
.pub-karte img, .pub-platzhalter {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--linie);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; background: var(--grund);
}
.status-reihe { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .45rem; margin-top: .55rem; }
.status-reihe button { min-height: 52px; font-weight: 600; }
.status-reihe button.gewaehlt-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.status-reihe button.gewaehlt-knapp { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.status-reihe button.gewaehlt-leer { background: var(--gefahr); border-color: var(--gefahr); color: #fff; }
.mengen-reihe { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .55rem; }
.mengen-reihe[hidden] { display: none; }
.mengen-reihe button { flex: 1 1 5.5rem; }
.karte.erledigt { opacity: .72; }
.karte.erledigt .pub-name::after { content: " ✓"; color: var(--ok); font-weight: 700; }

.fuss-leiste {
  position: sticky; bottom: calc(4.2rem + env(safe-area-inset-bottom));
  padding: .5rem 0; background: linear-gradient(transparent, var(--grund) 40%);
}

/* Tabellen */
.tab-umbruch { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--linie); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-schwach); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

/* Statistik-Balken (Wert steht immer als Text daneben) */
.balken-zeile { display: grid; grid-template-columns: minmax(7rem, 1fr) 2fr auto; gap: .6rem; align-items: center; margin: .4rem 0; }
.balken { background: var(--linie); border-radius: 999px; height: .9rem; overflow: hidden; }
.balken .fuellung { display: block; background: var(--primary); height: 100%; border-radius: 999px; min-width: 2px; }
.balken .fuellung.rot { background: var(--gefahr); }

/* Kacheln (Standortliste) */
.kachel-liste { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.kachel {
  display: flex; align-items: center; gap: .8rem; text-decoration: none; color: inherit;
  background: var(--karte); border: 1px solid var(--linie); border-radius: 12px;
  padding: .9rem 1rem; min-height: 60px;
}
.kachel:active { background: var(--grund); }
.kachel .titel { font-weight: 600; flex: 1; }

.hinweis { color: var(--text-schwach); font-size: .9rem; }
.abstand-oben { margin-top: 1.2rem; }
.zeile { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.zeile > * { flex: 1; }

/* Toast (Service-Worker-Update) */
#swUpdate {
  display: none; position: fixed; left: 1rem; right: 1rem;
  bottom: calc(5rem + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--karte); border: 1px solid var(--linie); border-radius: 12px;
  padding: .7rem 1rem; align-items: center; gap: .7rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}

/* Chips (Zeitraum-Auswahl) */
.chips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.chips a {
  border: 1px solid var(--linie); border-radius: 999px; padding: .5rem .95rem;
  min-height: 44px; display: inline-flex; align-items: center;
  text-decoration: none; color: var(--text);
}
.chips a.aktiv { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .chips a.aktiv { color: #10181d; } }

@media (min-width: 700px) {
  .kachel-liste { grid-template-columns: 1fr 1fr; }
}
