/* Café-Inventur – mobil zuerst, ohne Framework.
   Zwei Regeln bestimmen das Layout:
   1. Alles Bedienbare ist mindestens 44 px hoch (Daumenbedienung).
   2. Kopf- und Aktionsleiste sind fixiert, nur die Liste scrollt. */

:root {
  color-scheme: light dark;

  --blau:        #1f3a5f;
  --blau-hell:   #2f5c94;
  --akzent:      #0a7c66;
  --rot:         #b3261e;
  --gelb:        #8a6d00;
  --gruen:       #1b5e20;

  --bg:          #f4f6f9;
  --bg-karte:    #ffffff;
  --bg-gedimmt:  #eaeef4;
  --text:        #16202b;
  --text-leise:  #5b6672;
  --linie:       #d8dfe8;
  --schatten:    0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);

  --sicher-oben:   env(safe-area-inset-top, 0px);
  --sicher-unten:  env(safe-area-inset-bottom, 0px);
  --kopf-hoehe:    calc(64px + var(--sicher-oben));
  --fuss-hoehe:    calc(68px + var(--sicher-unten));
}

@media (prefers-color-scheme: dark) {
  :root {
    --blau:       #4d8fd6;
    --blau-hell:  #6aa6e6;
    --akzent:     #35b79a;
    --rot:        #ff8a80;
    --gelb:       #e0bb45;
    --gruen:      #7cc47f;

    --bg:         #0f1720;
    --bg-karte:   #18222e;
    --bg-gedimmt: #1f2b39;
    --text:       #e6edf5;
    --text-leise: #97a4b3;
    --linie:      #2b3846;
    --schatten:   0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* Muss vor allen Layout-Regeln stehen: Klassen mit display:flex/grid würden
   sonst das eingebaute [hidden] aushebeln – die "versteckte" Einzelansicht
   läge dann unsichtbar über der Liste und würde jeden Klick abfangen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }

:focus-visible { outline: 3px solid var(--blau-hell); outline-offset: 2px; border-radius: 6px; }

.visuell-versteckt {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- Kopfzeile */

.kopf {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--kopf-hoehe);
  padding: var(--sicher-oben) 1rem 0;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  background: var(--blau);
  color: #fff;
  box-shadow: 0 1px 8px rgba(16, 24, 40, .18);
}
@media (prefers-color-scheme: dark) {
  .kopf { background: #16202b; border-bottom: 1px solid var(--linie); }
}

.kopf-titel { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.logo { font-size: 1.6rem; line-height: 1; }
.kopf h1 { font-size: 1.15rem; }
.kopf-meta {
  margin: 0; font-size: .76rem; opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw;
}

.pill {
  font-size: .72rem; font-weight: 600; padding: .25rem .55rem; border-radius: 999px;
  background: rgba(255, 255, 255, .16); white-space: nowrap;
}
.pill[data-zustand="offline"] { background: var(--gelb); color: #201a00; }
.pill[data-zustand="wartet"]  { background: #e8871a; color: #241100; }
.pill[data-zustand="online"]  { background: rgba(255, 255, 255, .16); }

.fortschritt {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(255, 255, 255, .2);
}
.fortschritt-fuellung {
  height: 100%; width: 0%;
  background: var(--akzent);
  transition: width .18s ease-out;
}

/* --------------------------------------------------------------- Hinweise */

.hinweise {
  position: fixed; z-index: 25;
  top: var(--kopf-hoehe); left: 0; right: 0;
}
.hinweis {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1rem;
  font-size: .85rem;
  border-bottom: 1px solid var(--linie);
}
.hinweis-warnung { background: #fff4d4; color: #4a3a00; }
.hinweis-info    { background: #dbeafe; color: #123a6b; }
.hinweis-fehler  { background: #fde4e2; color: #6d1410; }
@media (prefers-color-scheme: dark) {
  .hinweis-warnung { background: #3a2f07; color: #f4e3a8; }
  .hinweis-info    { background: #12283f; color: #bcd8f5; }
  .hinweis-fehler  { background: #401614; color: #ffcdc7; }
}
.hinweis p { margin: 0; flex: 1; }
.hinweis button {
  font-size: .8rem; font-weight: 650; text-decoration: underline;
  padding: .3rem .1rem; white-space: nowrap;
}

/* ------------------------------------------------------------------ Main */

main {
  padding-top: calc(var(--kopf-hoehe) + var(--hinweis-hoehe, 0px));
  padding-bottom: calc(var(--fuss-hoehe) + 1rem);
  min-height: 100%;
}

.karte {
  background: var(--bg-karte);
  border: 1px solid var(--linie);
  border-radius: 14px;
  box-shadow: var(--schatten);
}

/* ------------------------------------------------------------ Startseite */

.start { margin: 1.25rem 1rem; padding: 1.25rem; }
.start h2 { font-size: 1.2rem; }
.hilfetext { color: var(--text-leise); font-size: .88rem; margin: .35rem 0 1rem; }

.feld { display: block; margin-bottom: 1rem; }
.feld > span {
  display: block; font-size: .78rem; font-weight: 650;
  color: var(--text-leise); text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: .35rem;
}
.feld input {
  width: 100%; padding: .8rem .85rem;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 10px;
}
.feld input:focus { border-color: var(--blau-hell); outline: none; }

.fehlertext { color: var(--rot); font-size: .85rem; margin: .5rem 0 0; font-weight: 600; }

/* --------------------------------------------------------------- Knöpfe */

.knopf {
  min-height: 48px; padding: 0 1.1rem;
  border-radius: 12px; font-weight: 650; font-size: .95rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .06s ease, filter .12s ease;
}
.knopf:active { transform: scale(.98); }
.knopf-primaer { background: var(--blau); color: #fff; }
@media (prefers-color-scheme: dark) { .knopf-primaer { background: var(--blau); color: #06101b; } }
.knopf-neutral { background: var(--bg-gedimmt); color: var(--text); border: 1px solid var(--linie); }
.knopf-breit { width: 100%; }
.knopf[disabled] { opacity: .5; pointer-events: none; }

.ikon-knopf {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.15rem;
  background: var(--bg-gedimmt); color: var(--text);
}

/* --------------------------------------------------------- Werkzeugleiste */

.werkzeugleiste {
  position: sticky; top: calc(var(--kopf-hoehe) + var(--hinweis-hoehe, 0px)); z-index: 20;
  padding: .6rem 1rem .55rem;
  background: var(--bg);
  border-bottom: 1px solid var(--linie);
  display: grid; gap: .5rem;
}

.segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--bg-gedimmt); border-radius: 10px; padding: 3px;
  border: 1px solid var(--linie);
}
.segment-knopf {
  min-height: 38px; border-radius: 8px;
  font-size: .87rem; font-weight: 600; color: var(--text-leise);
}
.segment-knopf[aria-pressed="true"] {
  background: var(--bg-karte); color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .14);
}

.werkzeug-zeile { display: flex; gap: .5rem; }
.suche { flex: 1; display: block; }
.suche input {
  width: 100%; min-height: 40px; padding: 0 .8rem;
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.chip {
  min-height: 40px; padding: 0 .85rem; border-radius: 10px;
  font-size: .85rem; font-weight: 600;
  background: var(--bg-karte); border: 1px solid var(--linie); color: var(--text-leise);
  white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--blau); border-color: var(--blau); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { color: #06101b; } }

/* ----------------------------------------------------------------- Liste */

.liste { list-style: none; margin: 0; padding: 0 0 1rem; }

.gruppe-kopf {
  padding: 1rem 1rem .4rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-leise);
  display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
}
.gruppe-kopf .anzahl { font-weight: 600; letter-spacing: 0; text-transform: none; }

.zeile {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .25rem .75rem;
  padding: .65rem 1rem;
  background: var(--bg-karte);
  border-bottom: 1px solid var(--linie);
  content-visibility: auto;
  contain-intrinsic-size: auto 74px;
}
.zeile-info { min-width: 0; }
/* Produktnamen dürfen umbrechen statt abgeschnitten zu werden – wer zählt,
   muss den vollen Namen lesen können ("Espressobohnen Hausmischung"). */
.zeile-name { font-weight: 600; font-size: .97rem; overflow-wrap: anywhere; }
.zeile-unter { font-size: .78rem; color: var(--text-leise); display: flex; gap: .4rem; flex-wrap: wrap; }
.zeile-unter .notiz { font-style: italic; }

.aktionsleiste .knopf { padding: 0 .7rem; font-size: .9rem; }
.aktionsleiste #pausieren { padding: 0 .8rem; }

.zeile-eingabe { display: flex; align-items: center; gap: .4rem; }
.zeile-eingabe input {
  width: 4.6rem; min-height: 44px; padding: 0 .5rem;
  text-align: center; font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.zeile-eingabe input:focus { border-color: var(--blau-hell); background: var(--bg-karte); outline: none; }
.zeile-lupe { width: 38px; height: 44px; display: grid; place-items: center; color: var(--text-leise); font-size: 1.1rem; }

.zeile-status {
  grid-column: 1 / -1;
  font-size: .77rem; font-weight: 650; min-height: 1.1em;
}
.zeile[data-status="offen"]   { border-left: 3px solid transparent; }
.zeile[data-status="ok"]      { border-left: 3px solid var(--gruen); }
.zeile[data-status="fehlt"]   { border-left: 3px solid var(--rot); }
.zeile[data-status="ok"]    .zeile-status { color: var(--gruen); }
.zeile[data-status="fehlt"] .zeile-status { color: var(--rot); }
.zeile[data-status="offen"] .zeile-status { color: var(--text-leise); }

.leer-hinweis { text-align: center; color: var(--text-leise); padding: 2.5rem 1rem; font-style: italic; }

/* --------------------------------------------------------- Aktionsleiste */

.aktionsleiste {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  height: var(--fuss-hoehe);
  padding: .6rem 1rem calc(.6rem + var(--sicher-unten));
  display: grid; grid-template-columns: auto 1fr 1.15fr; gap: .5rem;
  background: var(--bg-karte);
  border-top: 1px solid var(--linie);
  box-shadow: 0 -2px 12px rgba(16, 24, 40, .07);
}

/* --------------------------------------------------------- Einzelansicht */

.einzel {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding-top: var(--sicher-oben);
  padding-bottom: var(--sicher-unten);
  animation: einblenden .16s ease-out;
}
@keyframes einblenden { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .einzel { animation: none; } .fortschritt-fuellung { transition: none; } }

.einzel-kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; border-bottom: 1px solid var(--linie);
}
.einzel-zaehler { font-size: .9rem; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text-leise); }

.einzel-inhalt {
  flex: 1; overflow-y: auto;
  padding: 1.5rem 1.25rem;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: .55rem;
}
.einzel-gruppe {
  margin: 0; font-size: .76rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-leise);
}
.einzel-name { font-size: 1.55rem; line-height: 1.2; margin: 0; }
.einzel-notiz {
  margin: 0; font-size: .87rem; font-style: italic; color: var(--text-leise);
  max-width: 32ch;
}
.einzel-soll {
  margin-top: .5rem; display: flex; align-items: baseline; gap: .4rem;
  background: var(--bg-gedimmt); border-radius: 999px; padding: .35rem 1rem;
  font-size: .9rem; color: var(--text-leise);
}
.einzel-soll strong { font-size: 1.25rem; color: var(--text); font-variant-numeric: tabular-nums; }

.zaehler {
  margin-top: .75rem;
  display: flex; align-items: center; gap: .8rem;
}
.zaehler-knopf {
  width: 64px; height: 64px; border-radius: 20px;
  font-size: 2rem; line-height: 1;
  background: var(--bg-karte); border: 1px solid var(--linie); box-shadow: var(--schatten);
}
.zaehler-knopf:active { background: var(--bg-gedimmt); }
.zaehler-eingabe {
  width: 8rem; height: 84px;
  text-align: center; font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--bg-karte); border: 2px solid var(--linie); border-radius: 18px;
  -webkit-appearance: none; appearance: none;
}
.zaehler-eingabe:focus { border-color: var(--blau-hell); outline: none; }

.schnellwahl { display: flex; gap: .5rem; margin-top: .35rem; flex-wrap: wrap; justify-content: center; }
.schnellwahl button {
  min-height: 40px; padding: 0 .95rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  background: var(--bg-gedimmt); border: 1px solid var(--linie); color: var(--text-leise);
}

.einzel-diff { margin: .35rem 0 0; font-size: .95rem; font-weight: 650; min-height: 1.4em; }
.einzel-diff[data-status="ok"]    { color: var(--gruen); }
.einzel-diff[data-status="fehlt"] { color: var(--rot); }
.einzel-diff[data-status="offen"] { color: var(--text-leise); font-weight: 500; }

.einzel-fuss {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: .6rem;
  padding: .7rem 1rem;
  border-top: 1px solid var(--linie); background: var(--bg-karte);
}
.einzel-fuss .knopf { min-height: 54px; font-size: 1rem; }

/* --------------------------------------------------------------- Dialoge */

.dialog {
  border: 0; border-radius: 16px; padding: 1.25rem;
  width: min(30rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  background: var(--bg-karte); color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(8, 14, 22, .55); }
.dialog h2 { font-size: 1.2rem; margin-bottom: .85rem; }

.zusammenfassung { display: grid; gap: .45rem; margin-bottom: 1rem; font-size: .92rem; }
.zusammenfassung .z-zeile { display: flex; justify-content: space-between; gap: 1rem; }
.zusammenfassung .z-zeile span:first-child { color: var(--text-leise); }
.zusammenfassung .z-zeile strong { font-variant-numeric: tabular-nums; text-align: right; }
.zusammenfassung .z-warnung {
  background: #fff4d4; color: #4a3a00; padding: .55rem .7rem; border-radius: 9px; font-size: .86rem;
}
@media (prefers-color-scheme: dark) { .zusammenfassung .z-warnung { background: #3a2f07; color: #f4e3a8; } }
.zusammenfassung ul { margin: .15rem 0 0; padding-left: 1.15rem; }

/* Bei langen Dialogen (Produkt anlegen) scrollt der Inhalt – die Knöpfe
   bleiben am unteren Rand stehen, sonst sucht man auf dem Handy das Speichern. */
.dialog-knoepfe {
  position: sticky; bottom: -1.25rem; z-index: 1;
  display: flex; gap: .6rem; justify-content: flex-end;
  margin: 0 -1.25rem -1.25rem; padding: .8rem 1.25rem 1.25rem;
  background: linear-gradient(to bottom, transparent, var(--bg-karte) 35%);
}
.dialog-knoepfe .knopf { flex: 1; }

/* ---------------------------------------------------------------- Archiv */

.kopf-status { display: flex; align-items: center; gap: .5rem; }
.kopf-ikon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem;
  background: rgba(255, 255, 255, .14); color: #fff;
}
.kopf-ikon:active { background: rgba(255, 255, 255, .26); }

.textlink {
  display: block; width: 100%; margin-top: 1rem; padding: .6rem 0;
  font-size: .9rem; font-weight: 600; color: var(--blau-hell); text-align: center;
}

.archiv {
  position: fixed; inset: 0; z-index: 45;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding-top: var(--sicher-oben); padding-bottom: var(--sicher-unten);
  animation: einblenden .16s ease-out;
}
@media (prefers-reduced-motion: reduce) { .archiv { animation: none; } }

.archiv-kopf {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; border-bottom: 1px solid var(--linie);
}
.archiv-titel { flex: 1; min-width: 0; }
.archiv-titel h2 { font-size: 1.1rem; }
.archiv-titel p { margin: 0; font-size: .76rem; color: var(--text-leise); }

.archiv-filter {
  display: flex; gap: .4rem; padding: .6rem 1rem;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--linie);
}
.archiv-filter::-webkit-scrollbar { display: none; }

.archiv-inhalt { flex: 1; overflow-y: auto; padding: .85rem 1rem 2rem; }

.dokument {
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 14px;
  box-shadow: var(--schatten); margin-bottom: .85rem; overflow: hidden;
}
.dokument-kopf { padding: .85rem .9rem .7rem; }
.dokument-art {
  display: inline-block; font-size: .68rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 6px; margin-bottom: .4rem;
  background: var(--bg-gedimmt); color: var(--text-leise);
}
.dokument-art[data-art="einkaufsliste"] { background: #dcefe9; color: #0a5b4a; }
.dokument-art[data-art="stammdaten"]    { background: #dde7f6; color: #1c4272; }
.dokument-art[data-art="historie"]      { background: #f3e6d0; color: #6b4d12; }
@media (prefers-color-scheme: dark) {
  .dokument-art[data-art="einkaufsliste"] { background: #12362e; color: #7fd8c2; }
  .dokument-art[data-art="stammdaten"]    { background: #16283f; color: #9dc4ef; }
  .dokument-art[data-art="historie"]      { background: #362a10; color: #e3c479; }
}
.dokument-titel { font-size: 1.02rem; font-weight: 650; margin: 0 0 .2rem; }
.dokument-unter { font-size: .78rem; color: var(--text-leise); }

.fassung {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: .3rem .7rem;
  padding: .6rem .9rem;
  border-top: 1px solid var(--linie);
}
.fassung-nr {
  font-size: .76rem; font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 2.4rem; text-align: center;
  padding: .25rem .35rem; border-radius: 7px;
  background: var(--bg-gedimmt); color: var(--text-leise);
}
.fassung[data-aktuell="ja"] .fassung-nr { background: var(--akzent); color: #fff; }
@media (prefers-color-scheme: dark) { .fassung[data-aktuell="ja"] .fassung-nr { color: #04211b; } }
.fassung-info { min-width: 0; font-size: .82rem; }
.fassung-info .zeit { font-weight: 600; }
.fassung-info .details { color: var(--text-leise); font-size: .76rem; overflow-wrap: anywhere; }
.fassung-laden {
  min-height: 44px; min-width: 44px; padding: 0 .75rem; border-radius: 11px;
  font-size: .85rem; font-weight: 650;
  background: var(--bg-gedimmt); border: 1px solid var(--linie); color: var(--text);
  display: inline-flex; align-items: center; gap: .35rem;
}
.fassung[data-aktuell="ja"] .fassung-laden { background: var(--blau); border-color: var(--blau); color: #fff; }
@media (prefers-color-scheme: dark) { .fassung[data-aktuell="ja"] .fassung-laden { color: #06101b; } }
.fassung-laden[disabled] { opacity: .55; }

.aeltere-schalter {
  width: 100%; padding: .6rem .9rem; border-top: 1px solid var(--linie);
  font-size: .8rem; font-weight: 650; color: var(--text-leise); text-align: left;
}
.aeltere-schalter::before { content: '▸ '; }
.aeltere-schalter[aria-expanded="true"]::before { content: '▾ '; }

.archiv-leer { text-align: center; color: var(--text-leise); padding: 3rem 1rem; font-style: italic; }
.archiv-fehler {
  background: #fde4e2; color: #6d1410; padding: .8rem .9rem; border-radius: 12px; font-size: .87rem;
}
@media (prefers-color-scheme: dark) { .archiv-fehler { background: #401614; color: #ffcdc7; } }

/* ------------------------------------------------------------- Anmeldung */

.anmelden {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  background: var(--bg);
  overflow-y: auto;
}
.anmelden-karte {
  width: min(24rem, 100%);
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 18px;
  box-shadow: var(--schatten);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
}
.anmelden-logo { font-size: 2.6rem; line-height: 1; display: block; }
.anmelden-karte h1 { font-size: 1.5rem; margin-top: .5rem; }
.anmelden-unter { margin: .1rem 0 1.5rem; color: var(--text-leise); font-size: .9rem; }
.anmelden-karte .feld { text-align: left; }
.anmelden-hinweis { margin: 1rem 0 0; font-size: .78rem; color: var(--text-leise); line-height: 1.4; }

/* ------------------------------------------------------------ Verwaltung */

.verwaltung-aktionen { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .85rem; }
.verwaltung-aktionen .knopf { flex: 1 1 10rem; min-height: 46px; }

.upload-status {
  margin: 0 0 .85rem; padding: .7rem .85rem; border-radius: 11px; font-size: .86rem;
  background: var(--bg-gedimmt); color: var(--text);
}
.upload-status[data-art="fehler"] { background: #fde4e2; color: #6d1410; }
.upload-status[data-art="erfolg"] { background: #dcefe9; color: #0a5b4a; }
@media (prefers-color-scheme: dark) {
  .upload-status[data-art="fehler"] { background: #401614; color: #ffcdc7; }
  .upload-status[data-art="erfolg"] { background: #12362e; color: #7fd8c2; }
}

.suche-block { display: block; margin-bottom: .75rem; }

.stamm-liste { display: grid; gap: .5rem; }

.stamm-zeile {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .2rem .7rem;
  width: 100%; text-align: left;
  padding: .7rem .85rem;
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 12px;
}
.stamm-zeile:active { background: var(--bg-gedimmt); }
.stamm-zeile[data-aktiv="nein"] { opacity: .58; }
.stamm-name { font-weight: 650; font-size: .95rem; overflow-wrap: anywhere; }
.stamm-detail { grid-column: 1; font-size: .77rem; color: var(--text-leise); overflow-wrap: anywhere; }
.stamm-marke {
  grid-row: 1 / span 2; font-size: .72rem; font-weight: 700;
  padding: .2rem .5rem; border-radius: 7px; white-space: nowrap;
  background: var(--bg-gedimmt); color: var(--text-leise);
}
.stamm-marke[data-rolle="admin"] { background: #dde7f6; color: #1c4272; }
.stamm-marke[data-rolle="bearbeiter"] { background: #dcefe9; color: #0a5b4a; }
.stamm-marke[data-zustand="inaktiv"] { background: #f3e0de; color: #6d1410; }
@media (prefers-color-scheme: dark) {
  .stamm-marke[data-rolle="admin"] { background: #16283f; color: #9dc4ef; }
  .stamm-marke[data-rolle="bearbeiter"] { background: #12362e; color: #7fd8c2; }
  .stamm-marke[data-zustand="inaktiv"] { background: #401614; color: #ffcdc7; }
}

.rechte-tabelle { margin-top: 1.75rem; }
.rechte-tabelle h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-leise); margin: 0 0 .5rem; }
.rechte-tabelle table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rechte-tabelle th, .rechte-tabelle td {
  text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--linie);
}
.rechte-tabelle th:not(:first-child), .rechte-tabelle td:not(:first-child) {
  text-align: center; width: 5.5rem;
}
.rechte-tabelle th { color: var(--text-leise); font-weight: 650; }

/* ------------------------------------------------------- Dialog-Bausteine */

.feld-gitter { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .7rem; }
@media (max-width: 24rem) { .feld-gitter { grid-template-columns: 1fr; } }

.feld select {
  width: 100%; padding: .8rem .85rem;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}

/* Die ganze Zeile ist der Tap-Bereich, nicht nur das 22-px-Kästchen –
   am Handy sonst kaum zu treffen. */
.schalter {
  display: flex; align-items: center; gap: .7rem;
  min-height: 48px; padding: 0 .8rem;
  margin-bottom: 1rem; font-size: .9rem; cursor: pointer;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 10px;
}
.schalter:active { background: var(--bg-gedimmt); }
.schalter input { width: 22px; height: 22px; accent-color: var(--blau); flex: none; }
.schalter span { flex: 1; }

.dialog-menue h2 { font-size: 1.15rem; margin-bottom: .1rem; }
.dialog-menue .hilfetext { margin-bottom: 1.1rem; }
.menue-knoepfe { display: grid; gap: .5rem; }
.menue-knoepfe .knopf { justify-content: flex-start; }

.gesperrt-hinweis {
  display: flex; align-items: center; gap: .4rem;
  font-size: .78rem; color: var(--text-leise); font-style: italic;
  padding: .2rem .1rem;
}

/* ------------------------------------------------------- Fällige Zählungen */

.start-bereich { padding-top: .5rem; }
.faellig-liste { display: grid; gap: .85rem; margin: 0 1rem .85rem; }

.faellig-karte {
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 14px;
  box-shadow: var(--schatten); padding: 1rem;
  border-left: 4px solid var(--akzent);
}
.faellig-karte[data-zustand="ueberfaellig"] { border-left-color: var(--rot); }
.faellig-karte[data-zustand="gesperrt"] { border-left-color: var(--gelb); }
.faellig-karte[data-zustand="ruhe"] { border-left-color: var(--linie); }

.faellig-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.faellig-titel { font-size: 1.08rem; font-weight: 650; }
.faellig-marke {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .2rem .5rem; border-radius: 6px; white-space: nowrap;
  background: var(--bg-gedimmt); color: var(--text-leise);
}
.faellig-karte[data-zustand="ueberfaellig"] .faellig-marke { background: #fde4e2; color: #6d1410; }
@media (prefers-color-scheme: dark) {
  .faellig-karte[data-zustand="ueberfaellig"] .faellig-marke { background: #401614; color: #ffcdc7; }
}
.faellig-info { margin: .35rem 0 .8rem; font-size: .85rem; color: var(--text-leise); }
.faellig-warnung {
  margin: 0 0 .8rem; padding: .6rem .7rem; border-radius: 10px; font-size: .84rem;
  background: #fff4d4; color: #4a3a00;
}
@media (prefers-color-scheme: dark) { .faellig-warnung { background: #3a2f07; color: #f4e3a8; } }

.bedarf-liste { display: grid; gap: .4rem; margin-bottom: .9rem; max-height: 15rem; overflow-y: auto; }
.bedarf-zeile {
  display: flex; align-items: center; gap: .6rem;
  min-height: 44px; padding: 0 .7rem;
  background: var(--bg); border: 1px solid var(--linie); border-radius: 10px;
  font-size: .88rem; cursor: pointer;
}
.bedarf-zeile input { width: 20px; height: 20px; accent-color: var(--blau); flex: none; }
.bedarf-zeile .anzahl { margin-left: auto; color: var(--text-leise); font-size: .8rem; }

/* -------------------------------------------------------------------- MHD */

.mhd-block {
  width: 100%; max-width: 22rem; margin-top: 1rem;
  padding: .9rem; border-radius: 14px; text-align: left;
  background: var(--bg-gedimmt); border: 1px solid var(--linie);
}
.mhd-block .feld { margin-bottom: .5rem; }
.mhd-block input[type="date"] {
  width: 100%; min-height: 48px; padding: .6rem .7rem; font-size: 1rem;
  background: var(--bg-karte); border: 1.5px solid var(--linie); border-radius: 10px;
}
.mhd-letztes { margin: 0; font-size: .78rem; color: var(--text-leise); }
.mhd-urteil { margin: .4rem 0 0; font-size: .88rem; font-weight: 650; min-height: 1.2em; }
.mhd-urteil[data-status="ok"] { color: var(--gruen); }
.mhd-urteil[data-status="warnung"] { color: var(--gelb); }
.mhd-urteil[data-status="kritisch"] { color: var(--rot); }
.mhd-urteil[data-status="fehlt"] { color: var(--text-leise); font-weight: 500; }

.zeile-mhd { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; margin-top: .3rem; }
.zeile-mhd input[type="date"] {
  min-height: 40px; padding: 0 .5rem; font-size: .85rem;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 9px;
}
.zeile-mhd .marke {
  font-size: .74rem; font-weight: 650; padding: .15rem .45rem; border-radius: 6px;
  background: var(--bg-gedimmt); color: var(--text-leise);
}
.zeile-mhd .marke[data-status="kritisch"] { background: #fde4e2; color: #6d1410; }
.zeile-mhd .marke[data-status="warnung"] { background: #fff4d4; color: #4a3a00; }
.zeile-mhd .marke[data-status="ok"] { background: #dcefe9; color: #0a5b4a; }
@media (prefers-color-scheme: dark) {
  .zeile-mhd .marke[data-status="kritisch"] { background: #401614; color: #ffcdc7; }
  .zeile-mhd .marke[data-status="warnung"] { background: #3a2f07; color: #f4e3a8; }
  .zeile-mhd .marke[data-status="ok"] { background: #12362e; color: #7fd8c2; }
}

.zeile[data-gesperrt="ja"] { opacity: .72; border-left: 3px solid var(--gelb); }
.zeile[data-gesperrt="ja"] .zeile-eingabe input { display: none; }
.gesperrt-box {
  margin: 0; padding: .6rem .7rem; border-radius: 10px; font-size: .85rem;
  background: #fff4d4; color: #4a3a00; max-width: 22rem;
}
@media (prefers-color-scheme: dark) { .gesperrt-box { background: #3a2f07; color: #f4e3a8; } }

.mhd-kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.mhd-kachel {
  padding: .7rem; border-radius: 12px; text-align: center;
  background: var(--bg-karte); border: 1px solid var(--linie);
}
.mhd-kachel strong { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.mhd-kachel span { font-size: .74rem; color: var(--text-leise); }
.mhd-kachel[data-status="kritisch"] strong { color: var(--rot); }
.mhd-kachel[data-status="warnung"] strong { color: var(--gelb); }
.mhd-kachel[data-status="ok"] strong { color: var(--gruen); }

.vorgabe-zeile {
  display: grid; grid-template-columns: 1fr 5.5rem; align-items: center; gap: .3rem .6rem;
  padding: .6rem .8rem;
  background: var(--bg-karte); border: 1px solid var(--linie); border-radius: 12px;
}
.vorgabe-zeile[data-offen="ja"] { border-left: 3px solid var(--gelb); }
.vorgabe-zeile input {
  width: 100%; min-height: 44px; padding: 0 .5rem; text-align: center;
  font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums;
  background: var(--bg); border: 1.5px solid var(--linie); border-radius: 9px;
}
.vorgabe-zeile .detail { grid-column: 1; font-size: .77rem; color: var(--text-leise); }

/* ---------------------------------------------------------- Dashboard */

.kopf-konto {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); color: #fff;
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
}

.start-bereich > .karte,
.start-bereich > .faellig-karte { margin: 0 1rem .85rem; }
.start-bereich > .karte { padding: 1rem; }

.karte-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-bottom: .5rem;
}
.karte-kopf h2 { font-size: 1.08rem; }
.ikon-knopf.klein { width: 40px; height: 40px; font-size: 1rem; }

.knopf-liste { display: grid; gap: .5rem; }
.knopf-liste .knopf { justify-content: flex-start; }
.knopf-paar { display: grid; grid-template-columns: 1fr 1.4fr; gap: .6rem; }

.faellig-karte[data-zustand="laufend"] { border-left-color: var(--blau); }

.vorgabe-status { display: grid; gap: .5rem; }
.vorgabe-status-zeile {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .3rem .7rem;
  padding: .7rem .8rem; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--linie);
}
.vorgabe-status-zeile[data-offen="ja"] { border-left: 3px solid var(--gelb); }
.vorgabe-status-zeile[data-offen="nein"] { border-left: 3px solid var(--gruen); }
.vorgabe-status-zeile .titel { font-weight: 650; font-size: .95rem; }
.vorgabe-status-zeile .detail { grid-column: 1; font-size: .78rem; color: var(--text-leise); }
.vorgabe-status-zeile .knopf { grid-row: 1 / span 2; min-height: 44px; padding: 0 .9rem; font-size: .85rem; }

/* Das Archiv liegt jetzt direkt auf der Hauptseite. */
#archivInhalt { margin-top: .3rem; }
#archivKarte .archiv-filter { padding: 0 0 .7rem; border-bottom: 0; margin: 0 -.2rem; }
#mhdKarte .stamm-liste { margin-bottom: .6rem; }

/* --------------------------------------------------- Einheit am Eingabefeld */

.zeile-einheit {
  font-size: .92rem; font-weight: 650; color: var(--text);
  min-width: 3.4rem; line-height: 1.15;
  overflow-wrap: anywhere;
}

.zaehler-feld { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.zaehler-einheit {
  font-size: 1.05rem; font-weight: 650; color: var(--text);
  text-align: center; max-width: 10rem; line-height: 1.2;
}

/* ------------------------------------------------------- Haltbarkeitswarnung */

.dialog-warnung {
  width: min(26rem, calc(100vw - 2rem));
  text-align: center;
  padding: 1.75rem 1.4rem 1.4rem;
  border-top: 8px solid var(--rot);
}
.dialog-warnung[data-status="warnung"] { border-top-color: var(--gelb); }
.warn-kopf { display: grid; gap: .4rem; justify-items: center; margin-bottom: .9rem; }
.warn-zeichen { font-size: 3.2rem; line-height: 1; }
.dialog-warnung h2 { font-size: 1.45rem; color: var(--rot); }
.dialog-warnung[data-status="warnung"] h2 { color: var(--gelb); }
.warn-artikel { margin: 0 0 .2rem; font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.warn-frist { margin: 0 0 .9rem; font-size: 1.1rem; font-weight: 650; color: var(--text-leise); }
.warn-text {
  margin: 0 0 1.3rem; font-size: 1rem; line-height: 1.45;
  padding: .8rem; border-radius: 12px; background: var(--bg-gedimmt);
}
.warn-knopf { min-height: 56px; font-size: 1.05rem; background: var(--rot); color: #fff; }
.dialog-warnung[data-status="warnung"] .warn-knopf { background: var(--gelb); color: #201a00; }

/* ----------------------------------------------------------------- Toast */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--fuss-hoehe) + .75rem); z-index: 60;
  max-width: calc(100vw - 2rem);
  padding: .7rem 1.1rem; border-radius: 12px;
  background: #16202b; color: #fff;
  font-size: .88rem; font-weight: 600; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) { .toast { background: #35424f; } }

/* ----------------------------------------------------- Größere Bildschirme */

@media (min-width: 640px) {
  main { max-width: 46rem; margin: 0 auto; }
  .werkzeugleiste { max-width: 46rem; margin: 0 auto; }
  .aktionsleiste { max-width: 46rem; margin: 0 auto; border-radius: 14px 14px 0 0; }
  .zeile { border-radius: 0; }
  .einzel-inhalt { justify-content: center; }
}
