/* =========================================================================
   Reiber Intensivpflege – Bestands- und Bestellverwaltung
   Eigenes Stylesheet (ersetzt Bootstrap), inkl. Druckausgabe fuer Listen.
   ========================================================================= */

/* ---- 1. Design-Tokens --------------------------------------------------- */
/*
   Drei Zustände der Darstellung:
   - ohne data-theme  => die Einstellung des Betriebssystems entscheidet
   - data-theme="light" => immer hell
   - data-theme="dark"  => immer dunkel

   Das Attribut setzt templates/layout.php serverseitig aus der im Profil
   gespeicherten Wahl, damit beim Laden nichts kurz in der falschen Farbe
   aufblitzt. Der dunkle Satz steht deshalb zweimal: einmal für die
   Systemeinstellung, einmal für die ausdrückliche Wahl.
*/
:root {
  color-scheme: light;

  --brand:        #0195aa;
  --brand-strong: #017688;
  --brand-tint:   #e6f7fa;
  --brand-line:   #b6e4ec;
  --on-brand:     #ffffff;   /* Schrift auf gefüllten Brandflächen */

  --green:        #7d9418;
  --green-tint:   #f2f7e0;
  --green-line:   #cddb99;
  --green-ink:    #4e5e0d;

  --amber:            #a7750c;
  --amber-tint:       #fdf4e0;
  --amber-tint-hover: #fbeed0;

  --red:        #b3261e;
  --red-tint:   #fdeceb;
  --red-line:   #f0c4c1;
  --red-ink:    #8c1d17;

  --ink:         #17212b;
  --ink-soft:    #4a5764;
  --ink-muted:   #6c7a89;
  --ink-faint:   #9aa7b3;
  --line:        #dde4ea;
  --line-soft:   #eef2f5;
  --line-strong: #c6d1da;
  --bg:          #f2f5f7;
  --surface:     #ffffff;
  --surface-alt: #f8fafb;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(23, 33, 43, .06), 0 4px 16px rgba(23, 33, 43, .05);

  /* Das Logo ist mehrfarbig; im Dunkeln wird es rein weiß. */
  --logo-filter: none;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Systemeinstellung: dunkel, solange nicht ausdrücklich hell gewählt wurde. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --brand:        #2fc0d4;
    --brand-strong: #6bdbea;
    --brand-tint:   #0f3138;
    --brand-line:   #1d5c68;
    --on-brand:     #0b1116;

    --green:        #a9c63c;
    --green-tint:   #242e11;
    --green-line:   #4a5c18;
    --green-ink:    #c3dc62;

    --amber:            #e0a33c;
    --amber-tint:       #322710;
    --amber-tint-hover: #3d2f13;

    --red:        #f07a72;
    --red-tint:   #3a1c1a;
    --red-line:   #6d2f2b;
    --red-ink:    #f5a49e;

    --ink:         #e7edf3;
    --ink-soft:    #b2bfcb;
    --ink-muted:   #8b98a6;
    --ink-faint:   #6b7885;
    --line:        #2b3640;
    --line-soft:   #212a33;
    --line-strong: #3d4a56;
    --bg:          #0f151b;
    --surface:     #171f27;
    --surface-alt: #1d262f;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .35);

    --logo-filter: brightness(0) invert(1);
  }
}

/* Ausdrückliche Wahl im Profil – gilt unabhängig vom Betriebssystem. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --brand:        #2fc0d4;
  --brand-strong: #6bdbea;
  --brand-tint:   #0f3138;
  --brand-line:   #1d5c68;
  --on-brand:     #0b1116;

  --green:        #a9c63c;
  --green-tint:   #242e11;
  --green-line:   #4a5c18;
  --green-ink:    #c3dc62;

  --amber:            #e0a33c;
  --amber-tint:       #322710;
  --amber-tint-hover: #3d2f13;

  --red:        #f07a72;
  --red-tint:   #3a1c1a;
  --red-line:   #6d2f2b;
  --red-ink:    #f5a49e;

  --ink:         #e7edf3;
  --ink-soft:    #b2bfcb;
  --ink-muted:   #8b98a6;
  --ink-faint:   #6b7885;
  --line:        #2b3640;
  --line-soft:   #212a33;
  --line-strong: #3d4a56;
  --bg:          #0f151b;
  --surface:     #171f27;
  --surface-alt: #1d262f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .35);

  --logo-filter: brightness(0) invert(1);
}

/* ---- 2. Grundlagen ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-y: scroll;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

img, svg { max-width: 100%; }

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

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

.print-only { display: none; }

/* ---- 3. Seitengeruest --------------------------------------------------- */
.shell {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 16px;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding-block: 10px;
}

.brand { display: inline-flex; align-items: center; }
.brand img { height: 42px; width: auto; display: block; filter: var(--logo-filter); }

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .875rem;
  color: var(--ink-muted);
}
/* Der eigene Name führt ins Profil. */
.session__user {
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
}
.session__user:hover { color: var(--brand-strong); text-decoration: underline; text-underline-offset: 3px; }

.nav-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}

/* ---- 4. Navigation ------------------------------------------------------ */
.app-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* Die Navigation bleibt immer einzeilig. Passt sie nicht in die Breite,
   lässt sie sich seitlich schieben, statt in eine zweite Zeile zu rutschen. */
.app-nav__list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.app-nav__list > li { flex: none; }

.app-nav__list::-webkit-scrollbar { height: 5px; }
.app-nav__list::-webkit-scrollbar-track { background: transparent; }
.app-nav__list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.app-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: .9rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.app-nav__link:hover { background: var(--surface-alt); color: var(--ink); }
.app-nav__link[aria-current="page"] { background: var(--brand-tint); color: var(--brand-strong); }

.app-nav__group { display: flex; gap: 2px; margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); }

/* Konto und Abmelden: in der Kopfzeile, solange dort Platz ist. */
.app-nav__account { display: none; }

/* Schaltfläche, die wie ein Menüpunkt aussieht (Abmelden ist ein Formular). */
.app-nav__link--button {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  font-size: .9rem;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}

/* Punkt am Kategorienamen: Bestand wurde laenger nicht gezaehlt. */
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  flex: none;
}

/* ---- 5. Inhaltsbereich -------------------------------------------------- */
.main { padding: 26px 0 56px; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.page-head__meta { margin: 4px 0 0; color: var(--ink-muted); font-size: .9rem; }
.page-head__actions { display: flex; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card__body { padding: 18px; }
.card__foot {
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---- 6. Ablauf-Hinweise ------------------------------------------------- */
.steps {
  counter-reset: step;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
  color: var(--ink-soft);
  font-size: .945rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 1px;
  width: 23px; height: 23px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.steps li strong { color: var(--ink); font-weight: 650; }
.steps li em { font-style: normal; color: var(--amber); font-weight: 650; }

/* ---- 7. Tabellen -------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .945rem;
}
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line-soft);
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-alt); }

.table .num { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .name { font-weight: 550; }
.table .shrink { width: 1%; white-space: nowrap; }

/* Bestand unter Mindestmenge */
.table tbody tr.is-low { background: var(--amber-tint); }
.table tbody tr.is-low:hover { background: var(--amber-tint-hover); }
.table tbody tr.is-low .name::before {
  content: "";
  display: inline-block;
  width: 3px; height: 1em;
  margin-right: 9px;
  vertical-align: -.15em;
  background: var(--amber);
  border-radius: 2px;
}

.empty { padding: 34px 18px; text-align: center; color: var(--ink-muted); }

/* ---- 8. Formularelemente ------------------------------------------------ */
/* align-content: start ist wichtig, sobald Felder nebeneinander stehen:
   Ohne das verteilt der Raster die überschüssige Höhe eines Nachbarn mit
   Hinweistext auf die eigenen Zeilen – das Eingabefeld würde höher und
   säße tiefer als das daneben. */
.field { display: grid; gap: 6px; align-content: start; }

/* Mehrere Felder nebeneinander, die auf schmalen Bildschirmen umbrechen. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
/* Fuer Textfelder, die mehr Platz brauchen (Ablauf, E-Mail-Text). */
.form-grid--wide { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* Kaestchen mit Beschriftung daneben, ausserhalb einer Tabelle. */
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: .9rem;
  cursor: pointer;
}
.check-inline input { width: 20px; height: 20px; accent-color: var(--brand); cursor: pointer; }

/* Auswahl aus mehreren Moeglichkeiten, z. B. die Darstellung im Profil. */
.choices { display: grid; gap: 8px; }

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.choice:hover { border-color: var(--line-strong); background: var(--surface-alt); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.choice input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--brand); cursor: pointer; flex: none; }

.choice__text { display: grid; gap: 2px; }
.choice__label { font-weight: 600; color: var(--ink); }
.choice__hint { font-size: .85rem; color: var(--ink-muted); }

/* Zwei Spalten für Seiten mit mehreren unabhängigen Karten.
   Jede Spalte stapelt für sich – so bleibt unten kein Versatz, wenn die
   Karten unterschiedlich hoch sind. Der senkrechte Abstand kommt aus dem
   margin-bottom der Karten. */
.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
}

/* Zweispaltige Aufstellung aus Begriff und Wert. */
.facts {
  display: grid;
  grid-template-columns: minmax(0, 11rem) minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
  font-size: .945rem;
}
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; color: var(--ink); font-weight: 550; }

@media (max-width: 520px) {
  .facts { grid-template-columns: 1fr; gap: 2px 0; }
  .facts dd { margin-bottom: 10px; }
}

/* Platzhalternamen im Fliesstext. */
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: .88em;
}

.field__label { font-size: .875rem; font-weight: 600; color: var(--ink-soft); }
.field__hint { font-size: .82rem; color: var(--ink-muted); }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
}
textarea.input { min-height: 68px; resize: vertical; line-height: 1.45; }

/* Auswahlfelder berechnen ihre Höhe anders als Text- und Zahlenfelder.
   Ohne Angleich stehen sie 2 px niedriger daneben. */
select.input { height: calc(1.5em + 22px); cursor: pointer; }

.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--brand); outline: 2px solid var(--brand-tint); outline-offset: 0; }
.input::placeholder { color: var(--ink-faint); }

/* Zaehlfeld in der Bestandsliste */
.input--count {
  width: 92px;
  margin: 0 auto;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  -moz-appearance: textfield;
}
.input--count::-webkit-outer-spin-button,
.input--count::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Im Zaehlfeld traegt der Platzhalter den bisherigen Bestand – er darf
   deshalb nicht so blass sein wie ein blosser Hinweis. opacity, weil
   Firefox den Platzhalter von sich aus durchscheinend zeichnet. */
.input--count::placeholder { color: var(--ink-muted); opacity: 1; font-weight: 400; }

/* Bestellhaken */
.check { display: inline-grid; place-items: center; }
.check input {
  width: 24px; height: 24px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ---- 9. Schaltflaechen -------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: .945rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { color: var(--ink); }

.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }

.btn--ghost { border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-alt); border-color: var(--line-strong); }

.btn--lg { padding: 13px 22px; font-size: 1rem; }
.btn--sm { padding: 7px 12px; font-size: .875rem; }
.btn--block { width: 100%; }

.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn--primary[disabled]:hover { background: var(--brand); border-color: var(--brand); }

/* Knoepfe am rechten Rand einer Tabellenzelle. Nebeneinander, obwohl die
   Spalte schmal gehalten ist: untereinander waere jede Zeile der Historie
   26 px hoeher, breiter wird die Tabelle davon nicht. */
.cell-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
}

/* Statusschalter in der Bestellhistorie */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink-soft); }
.chip::before {
  content: "";
  display: inline-grid;
  place-items: center;
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  flex: none;
  color: var(--on-brand);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.chip.is-done { background: var(--green-tint); border-color: var(--green-line); color: var(--green-ink); }
.chip.is-done::before { content: "✓"; border-color: var(--green); background: var(--green); }

/* Blaetterleiste unter einer langen Liste. Sitzt im Fuss der Karte, wird
   also nicht mitgedruckt. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pager__pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.pager__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: .92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
a.pager__page:hover { border-color: var(--line); background: var(--surface); color: var(--ink); }
.pager__page[aria-current="page"] {
  border-color: var(--brand-line);
  background: var(--brand-tint);
  color: var(--brand-strong);
}
.pager__gap { padding: 0 2px; color: var(--ink-faint); }

/* Erste bzw. letzte Seite: der Knopf bleibt stehen, damit die Leiste nicht
   springt – anfassen laesst er sich nicht. */
.btn[aria-disabled="true"] { opacity: .4; cursor: default; pointer-events: none; }

/* ---- 10. Meldungen ------------------------------------------------------ */
.alert {
  display: flex;
  gap: 10px;
  padding: 13px 16px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: .945rem;
}
.alert--success { background: var(--green-tint); border-color: var(--green-line); color: var(--green-ink); }
.alert--error   { background: var(--red-tint);   border-color: var(--red-line);   color: var(--red-ink); }
.alert--info    { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-strong); }

/* ---- 11. Zaehlverlauf --------------------------------------------------- */
.history { margin: 0; padding: 0; list-style: none; font-size: .845rem; color: var(--ink-muted); }
.history li { white-space: nowrap; }
.history li + li { color: var(--ink-faint); }
.history__value { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink-soft); }
.history li + li .history__value { font-weight: 550; color: var(--ink-muted); }
.history .is-stale { color: var(--red); font-weight: 650; }

/* ---- 12. Anmeldung ------------------------------------------------------ */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login__card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.login__logo {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto 26px;
  filter: var(--logo-filter);
}
.login__fields { display: grid; gap: 12px; margin-bottom: 18px; }
.login__foot { margin: 20px 0 0; text-align: center; font-size: .8rem; color: var(--ink-muted); }

/* ---- 13. Modale Fenster ------------------------------------------------- */
/* <dialog> bringt Einblenden, Esc und die Abdunkelung selbst mit; hier kommt
   nur das Aussehen dazu. Geschlossen ist es von sich aus unsichtbar. */
.modal {
  --modal-max-height: calc(100dvh - 48px);

  width: min(660px, calc(100vw - 28px));
  max-width: none;
  max-height: var(--modal-max-height);
  padding: 0;
  overflow: hidden;            /* laufen soll nur der Inhalt, nicht der Rahmen */
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 44px rgba(0, 0, 0, .3);
}
.modal::backdrop { background: rgba(10, 16, 22, .55); }

/* Nur im geöffneten Zustand – sonst würde die Angabe das display: none
   überschreiben, mit dem sich <dialog> selbst verbirgt. Der Rahmen ist damit
   Flex-Behälter und gibt dem Inhalt genau seine eigene Höhe. */
.modal[open] { display: flex; }

/* Kopf und Fuss bleiben stehen, der Inhalt dazwischen laeuft. */
.modal__inner {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal__title { margin: 0; font-size: 1.05rem; }
.modal__close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.modal__close:hover { border-color: var(--line); background: var(--surface-alt); color: var(--ink); }

.modal__body { display: grid; gap: 14px; padding: 18px; overflow: auto; }
.modal__hint { margin: 0; color: var(--ink-muted); font-size: .88rem; }

.modal__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Feld mit Kopierknopf daneben. flex-start, damit der Knopf beim mehrzeiligen
   Textfeld oben bleibt statt mitzuwachsen. */
.copy { display: flex; align-items: flex-start; gap: 8px; }
.copy .input { flex: 1 1 10rem; min-width: 0; }
.copy .btn { flex: none; min-width: 7.5rem; }

/* Rueckmeldung am Kopierknopf, verschwindet nach kurzer Zeit wieder. */
.copy .btn.is-done {
  border-color: var(--green-line);
  background: var(--green-tint);
  color: var(--green-ink);
}
.copy .btn.is-warn {
  border-color: var(--amber);
  background: var(--amber-tint);
  color: var(--amber);
}

textarea.input--tall { min-height: 150px; }

@media (max-width: 520px) {
  /* Beschriftung bleibt lesbar: der Knopf rutscht unter das Feld. */
  .copy { flex-wrap: wrap; }
  .copy .btn { width: 100%; }
  .modal__foot .btn { flex: 1 1 auto; }
}

/* ---- 14. Schmale Bildschirme ------------------------------------------- */
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }

  /* Konto und Abmelden wandern aus der Kopfzeile ins Menü. */
  .session__only-wide { display: none; }
  .app-nav__account { display: flex; }

  .app-nav { display: none; }
  .app-nav.is-open { display: block; }
  .app-nav__list { flex-direction: column; align-items: stretch; padding: 10px 0; overflow: visible; }
  .app-nav__link { padding: 12px 14px; }
  .app-nav__group { flex-direction: column; margin: 0; padding: 10px 0 0; border-left: 0; border-top: 1px solid var(--line); }

  .table { font-size: .9rem; }
  .table th, .table td { padding: 10px; }
  .page-head { align-items: flex-start; }
}

@media (max-width: 640px) {
  /* Reine Informationsspalten weichen, damit die Eingabefelder Platz haben. */
  .hide-narrow { display: none; }

  /* Die Zählspalte muss ohne seitliches Scrollen erreichbar bleiben. */
  .table th, .table td { padding: 9px 8px; }
  .table thead th { white-space: normal; letter-spacing: .02em; font-size: .7rem; }
  .table .shrink { white-space: normal; }
  .input--count { width: 74px; padding: 9px 6px; }
  .check input { width: 22px; height: 22px; }

  /* Hier ist die Breite knapper als die Hoehe. */
  .cell-actions { flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .card__body { padding: 14px; }
  .login__card { padding: 24px 20px; }
  .page-head h1 { font-size: 1.3rem; }
}

/* =========================================================================
   15. Druckausgabe
   Ziel: Listen lassen sich sauber auf A4 ausdrucken – ohne Navigation,
   mit wiederholter Tabellenkopfzeile und Feldern zum handschriftlichen
   Eintragen.
   ========================================================================= */
@page {
  size: A4 portrait;
  margin: 12mm 10mm 14mm;
}

@media print {
  /* Der Ausdruck ist immer hell – unabhängig von der gewählten Darstellung.
     Die Regel steht am Ende der Datei und überschreibt deshalb beide
     dunklen Token-Sätze. */
  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="dark"] {
    color-scheme: light;

    --brand:        #000000;
    --brand-strong: #000000;
    --brand-tint:   #eeeeee;
    --brand-line:   #999999;
    --on-brand:     #ffffff;

    --green:      #000000;
    --green-tint: #f0f0f0;
    --green-line: #999999;
    --green-ink:  #000000;

    --amber:            #000000;
    --amber-tint:       #f0f0f0;
    --amber-tint-hover: #f0f0f0;

    --red:      #000000;
    --red-tint: #f0f0f0;
    --red-line: #999999;
    --red-ink:  #000000;

    --ink:         #000000;
    --ink-soft:    #222222;
    --ink-muted:   #444444;
    --ink-faint:   #555555;
    --line:        #999999;
    --line-soft:   #bbbbbb;
    --line-strong: #777777;
    --bg:          #ffffff;
    --surface:     #ffffff;
    --surface-alt: #eeeeee;

    --shadow: none;
    --logo-filter: none;
  }

  html, body {
    background: #fff !important;
    color: #000;
    font-size: 10.5pt;
    overflow: visible;
  }

  /* Bildschirm-Bedienelemente ausblenden */
  .app-header,
  .app-nav,
  .nav-toggle,
  .page-head__actions,
  .btn,
  .chips,
  .alert,
  .card__foot,
  .steps,
  .modal,
  .no-print { display: none !important; }

  .print-only { display: block; }
  .print-only--text { white-space: pre-line; }
  tr.print-only { display: table-row; }
  td.print-only, th.print-only { display: table-cell; }
  .print-only.is-inline { display: inline; }

  .shell { max-width: none; padding: 0; }
  .main { padding: 0; }

  /* Druckkopf: Titel links, Art der Liste und Datum rechts */
  .print-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 12mm;
    padding-bottom: 3mm;
    margin-bottom: 5mm;
    border-bottom: 1.5pt solid #000;
  }
  .print-head__title { font-size: 16pt; margin: 0; }
  .print-head__meta { font-size: 9pt; text-align: right; line-height: 1.8; }

  .page-head { display: none; }

  .card {
    border: 0;
    box-shadow: none;
    margin: 0 0 6mm;
    break-inside: auto;
  }
  .card__head { padding: 0 0 2mm; border: 0; }
  .card__head h2, .card__head h3 { font-size: 12pt; }
  .card__body { padding: 0; }

  .table-wrap { overflow: visible !important; }

  .table { font-size: 9.5pt; width: 100%; }
  .table thead { display: table-header-group; }
  .table tfoot { display: table-footer-group; }
  .table tr { break-inside: avoid; page-break-inside: avoid; }
  .table th, .table td {
    padding: 1.8mm 2mm;
    border: .4pt solid #999;
    color: #000;
  }
  .table thead th {
    position: static;
    background: #e8e8e8 !important;
    border: .4pt solid #555;
    color: #000;
    font-size: 8.5pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .table tbody tr:hover { background: transparent; }
  /* Am Bildschirm hat die letzte Zeile keinen Abschluss – im Raster des
     Ausdrucks muss sie einen haben. */
  .table tbody tr:last-child td { border-bottom: .4pt solid #999; }

  /* Im Ausdruck wird nicht verraten, welche Menge unter dem Mindestbestand
     liegt – gezählt wird ohne Vorgabe. */
  .table tbody tr.is-low { background: transparent !important; }
  .table tbody tr.is-low .name::before { display: none; }

  /* Eingabefelder werden zu Kaestchen zum handschriftlichen Eintragen */
  .input, .check { display: none !important; }

  /* Feste Breiten: in einer Tabellenzelle traegt min-width sonst nicht zur
     Spaltenbreite bei und das Kaestchen faellt zusammen. */
  .write-box {
    display: block;
    width: 22mm;
    height: 8mm;
    margin: 0 auto;
    border: .5pt solid #555;
    border-radius: 1mm;
    background: #fff;
  }
  .write-box--check { width: 7mm; height: 7mm; border-color: #000; }

  .history { color: #000; font-size: 8pt; }
  .history li + li { color: #333; }
  .history .is-stale { color: #000; text-decoration: underline; }

  a { color: #000; text-decoration: none; }

  /* Unterschriftenfelder: je Feld eine eigene Spalte, mit deutlichem
     Abstand zur Liste darüber. */
  .print-sign {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 14mm;
    margin-top: 22mm;
    font-size: 9pt;
    break-inside: avoid;
  }
  .print-sign div { border-top: .5pt solid #000; padding-top: 1.5mm; }
}
