/* ============================================================================
   app.css – kiobet
   Nüchternes, klares Verwaltungs-Design. Handgeschrieben, kein Build-Step.
   Design-Tokens in :root, dunkles Schema per prefers-color-scheme.
   ========================================================================== */

:root {
    /* Farben (hell) */
    --bg:        #eef1f4;   /* Seitenhintergrund */
    --flaeche:   #ffffff;   /* Karten/Tabellen */
    --flaeche-2: #f5f7f9;   /* zarte Abhebung */
    --text:      #1c2430;   /* Haupttext */
    --text-leise:#5c6775;   /* Sekundärtext */
    --rahmen:    #d4dbe2;   /* Linien/Rahmen */
    --akzent:    #0f6b6b;   /* Petrol – sachlicher Akzent */
    --akzent-tf: #0a4f4f;   /* dunkler bei Hover */
    --akzent-bg: #e3f0ef;   /* heller Akzenthintergrund */
    --ok:        #1e7a46;
    --ok-bg:     #e3f3ea;
    --warn:      #8a5a00;
    --warn-bg:   #f7eed8;
    --gefahr:    #b3261e;
    --gefahr-bg: #f7e3e1;
    --info-bg:   #e6eef6;
    --info-tf:   #234b73;

    /* Maße */
    --radius:    8px;
    --radius-s:  5px;
    --abstand:   16px;
    --max-breite:1080px;
    --schrift:   system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --schatten:  0 1px 2px rgba(20, 30, 45, .05), 0 1px 3px rgba(20, 30, 45, .05);
    --schatten-l:0 6px 20px rgba(20, 30, 45, .10), 0 2px 6px rgba(20, 30, 45, .06);

    /* Abgeleiteter Abstands-Rhythmus (skaliert mit --abstand) */
    --abstand-s: calc(var(--abstand) * .5);
    --abstand-l: calc(var(--abstand) * 1.5);
}

/* Dunkel: automatisch per Betriebssystem – ausser der Nutzer hat fest "Hell"
   gewählt – ODER fest auf "Dunkel" gestellt (data-theme am <html>). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="hell"]) {
        --bg:        #131820;
        --flaeche:   #1b232e;
        --flaeche-2: #222c39;
        --text:      #e7edf3;
        --text-leise:#9aa7b5;
        --rahmen:    #313d4c;
        --akzent:    #45c0bb;
        --akzent-tf: #6fd3cf;
        --akzent-bg: #173433;
        --ok:        #5cc98a;  --ok-bg:     #15301f;
        --warn:      #d8a13a;  --warn-bg:   #332912;
        --gefahr:    #ef6a62;  --gefahr-bg: #371a18;
        --info-bg:   #16273a;  --info-tf:   #9cc2e8;
        --schatten:  0 1px 2px rgba(0,0,0,.4);
        --schatten-l:0 8px 24px rgba(0,0,0,.5);
    }
}
:root[data-theme="dunkel"] {
    --bg:        #131820;
    --flaeche:   #1b232e;
    --flaeche-2: #222c39;
    --text:      #e7edf3;
    --text-leise:#9aa7b5;
    --rahmen:    #313d4c;
    --akzent:    #45c0bb;
    --akzent-tf: #6fd3cf;
    --akzent-bg: #173433;
    --ok:        #5cc98a;  --ok-bg:     #15301f;
    --warn:      #d8a13a;  --warn-bg:   #332912;
    --gefahr:    #ef6a62;  --gefahr-bg: #371a18;
    --info-bg:   #16273a;  --info-tf:   #9cc2e8;
    --schatten:  0 1px 2px rgba(0,0,0,.4);
    --schatten-l:0 8px 24px rgba(0,0,0,.5);
}

/* --- Grundlagen --------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--schrift);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;              /* kein horizontales Seiten-Scrollen */
    overflow-wrap: break-word;       /* lange Wörter/URLs brechen statt zu überlaufen */
}
/* Medien nie breiter als ihr Container */
img { max-width: 100%; height: auto; }
svg, canvas, video, iframe { max-width: 100%; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .3rem; }
h2 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -.005em; margin: 0 0 .5rem; }
a  { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    background: var(--flaeche-2);
    border: 1px solid var(--rahmen);
    border-radius: 4px;
    padding: .05em .35em;
    font-size: .9em;
}

/* Sichtbarer Tastatur-Fokus (Barrierearmut). */
:focus-visible {
    outline: 3px solid var(--akzent);
    outline-offset: 2px;
}

/* --- Kopfzeile / Navigation -------------------------------------------- */
.kopf {
    position: sticky; top: 0; z-index: 20;
    background: var(--flaeche);
    border-bottom: 1px solid var(--rahmen);
    box-shadow: var(--schatten);
}
/* Modern: leicht durchscheinender Kopf, wo unterstützt (Progressive Enhancement). */
@supports ((backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px))) {
    .kopf {
        background: color-mix(in srgb, var(--flaeche) 82%, transparent);
        -webkit-backdrop-filter: saturate(1.1) blur(10px);
        backdrop-filter: saturate(1.1) blur(10px);
    }
}
.kopf-inner {
    max-width: var(--max-breite);
    margin: 0 auto;
    padding: 0 var(--abstand);
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: var(--abstand);
    flex-wrap: wrap;
}
.marke {
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--text);
    font-size: 1.1rem;
}
.marke:hover { text-decoration: none; color: var(--akzent); }
.haupt-nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.haupt-nav a {
    color: var(--text-leise);
    padding: .45rem .7rem;
    border-radius: var(--radius-s);
    font-size: .95rem;
    transition: background .12s, color .12s;
}
.haupt-nav a:hover { background: var(--flaeche-2); color: var(--text); text-decoration: none; }
.haupt-nav a[aria-current] { color: var(--akzent); background: var(--akzent-bg); font-weight: 600; }
.kopf-rechts { display: flex; align-items: center; gap: .6rem; }

/* Hamburger-Schalter ist eine versteckte Checkbox (reiner CSS-Mechanismus). */
.nav-check { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nav-toggle { display: none; }   /* Label nur auf dem Handy sichtbar */

/* Desktop (≥769px): Navigation immer sichtbar, kein Hamburger. */
@media (min-width: 769px) {
    .kopf-panel { display: contents; }   /* nav + rechts werden direkte Flex-Kinder */
}
.benutzer-chip {
    display: flex; flex-direction: column; line-height: 1.15; text-align: right;
    font-size: .9rem;
}
.benutzer-chip small { color: var(--text-leise); font-size: .78rem; }

/* --- Inhalt ------------------------------------------------------------- */
.inhalt {
    flex: 1;
    width: 100%;
    max-width: var(--max-breite);
    margin: 0 auto;
    padding: calc(var(--abstand) * 1.5) var(--abstand);
}
.seiten-kopf { margin-bottom: var(--abstand); }
.seiten-kopf.mit-aktion {
    display: flex; align-items: center; justify-content: space-between; gap: var(--abstand);
    flex-wrap: wrap;
}
.lead { color: var(--text-leise); margin: 0; }
.zurueck { font-size: .9rem; color: var(--text-leise); }

/* --- Karten / Boxen ----------------------------------------------------- */
.karte, .info-box {
    background: var(--flaeche);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
}
.info-box { padding: var(--abstand); margin-top: var(--abstand); }
.info-box p { margin: .4rem 0; }
.notiz { color: var(--text-leise); font-size: .92rem; }

/* --- Kacheln ------------------------------------------------------------ */
.kachel-gitter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--abstand);
}
.kachel {
    background: var(--flaeche);
    border: 1px solid var(--rahmen);
    border-left: 4px solid var(--akzent);
    border-radius: var(--radius);
    padding: var(--abstand);
    box-shadow: var(--schatten);
    display: flex; flex-direction: column; gap: .2rem;
}
.kachel { transition: transform .12s, box-shadow .12s, border-color .12s; }
.kachel:hover { box-shadow: var(--schatten-l); transform: translateY(-2px); }
.kachel-zahl { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.kachel-label { color: var(--text-leise); font-size: .9rem; }
.dash-block { margin-top: var(--abstand); }
.dash-titel { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--text-leise); font-weight: 600; }
.kachel-link { text-decoration: none; color: var(--text); }
.kachel-link:hover { text-decoration: none; color: var(--text); border-left-color: var(--akzent-tf); }
.kachel-titel { font-weight: 600; font-size: 1.05rem; }
.kachel-text { color: var(--text-leise); font-size: .9rem; }
.kachel-aktion { border-left-color: var(--akzent); background: var(--akzent-bg); }
.kachel-aktion .kachel-titel::before { content: "+ "; color: var(--akzent); font-weight: 700; }

/* --- Tabellen ----------------------------------------------------------- */
.tabelle-huelle {
    background: var(--flaeche);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    overflow-x: auto;
}
.tabelle { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabelle th, .tabelle td {
    padding: .65rem .8rem;
    text-align: left;
    border-bottom: 1px solid var(--rahmen);
    white-space: nowrap;
}
.tabelle thead th {
    background: var(--flaeche-2);
    color: var(--text-leise);
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.tabelle tbody tr { transition: background .1s; }
.tabelle tbody tr:hover td { background: var(--flaeche-2); }
.tabelle tbody tr:last-child td { border-bottom: 0; }
.tabelle .rechts { text-align: right; }
.aktionen { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }

/* --- Abzeichen ---------------------------------------------------------- */
.badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 999px;
    font-size: .8rem; font-weight: 600;
}
.badge-ok  { background: var(--ok-bg);     color: var(--ok); }
.badge-aus { background: var(--gefahr-bg); color: var(--gefahr); }

/* --- Formulare & Eingaben (app-weit, EINZIGE Quelle) ------------------- */
.formular { display: flex; flex-direction: column; gap: var(--abstand); }
.formular.karte { padding: var(--abstand); max-width: 560px; }

/* Karten-Innenabstand & Abstand zwischen Karten einheitlich */
.karte:not(.tabelle-huelle) { padding: var(--abstand); }
.karte + .karte { margin-top: var(--abstand); }
.karte > h2:first-child, .karte > h3:first-child { margin-top: 0; }

/* Ein Feld = Label + Eingabe + optionaler Hinweis/Fehler */
.feld { display: flex; flex-direction: column; gap: .35rem; }
.feld-label { font-weight: 600; font-size: .9rem; }
.feld-label .req, .req { color: var(--gefahr); margin-left: .15rem; font-weight: 700; }

/* Gleichmässiger Abstand zwischen Feldern innerhalb eines Formulars/einer Karte */
form.karte > .feld, form.karte > .feld-check, form.karte > .feld-row,
form.karte > .feld-grid, form.karte > fieldset,
.formular > .feld, .formular > .feld-check, .formular > .feld-row,
.formular > .feld-grid { margin-bottom: 1rem; }
form.karte > .feld:last-of-type, form.karte > .feld-check:last-of-type { margin-bottom: .25rem; }

/* ----------------------------------------------------------------------- *
 *  EINHEITLICHE EINGABE-BOX – EINE zentrale Stelle für ALLE Eingaben.
 *  Global per Element-Selektor: jedes Text-/Zahl-/Datum-/Zeit-/Auswahl-/
 *  Textfeld bekommt app-weit dieselbe Höhe, dasselbe Padding, denselben
 *  Rahmen, Fokus, Pfeil und Disabled/Readonly – OHNE dass neue Modulklassen
 *  je nachgetragen werden müssen. Checkboxen/Radios separat (siehe unten).
 *  Breite/Spalten regeln nur noch die Layout-Klassen (.feld, .feld-row …).
 * ----------------------------------------------------------------------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="image"]),
select, textarea {
    font: inherit; color: var(--text); background: var(--flaeche);
    border: 1px solid var(--rahmen); border-radius: var(--radius-s);
    padding: .5rem .65rem; min-height: 2.5rem; line-height: 1.3;
    max-width: 100%;
    transition: border-color .12s, box-shadow .12s;
}
.feld input, .feld select, .feld textarea { width: 100%; }
textarea { min-height: 5rem; resize: vertical; }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="image"]):hover,
select:hover, textarea:hover {
    border-color: var(--text-leise);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="hidden"]):not([type="image"]):focus,
select:focus, textarea:focus {
    outline: none; border-color: var(--akzent); box-shadow: 0 0 0 3px var(--akzent-bg);
}

/* read-only / disabled app-weit gleich erkennbar */
input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly], .kfg-locked {
    background: var(--flaeche-2); color: var(--text-leise); cursor: not-allowed;
}
input[readonly]:focus, textarea[readonly]:focus {
    box-shadow: none; border-color: var(--rahmen);
}

/* Eigener Select-Pfeil – für ALLE Selects identisch */
select {
    -webkit-appearance: none; appearance: none; padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23808a96' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center;
}

/* Checkboxen / Radios: saubere, ausgerichtete Zeile statt inline */
.feld-check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; cursor: pointer; }
.feld-check input[type=checkbox], .feld-check input[type=radio],
.feld > input[type=checkbox], .feld > input[type=radio] {
    width: 1.05rem; height: 1.05rem; min-height: 0; flex: 0 0 auto;
    accent-color: var(--akzent); margin: 0;
}
.feld.feld-check-zeile { flex-direction: row; align-items: center; gap: .5rem; }

/* Hinweise & Fehler */
.hilfe, .feld-hint { color: var(--text-leise); font-size: .82rem; }
.feld-fehler { color: var(--gefahr); font-size: .82rem; font-weight: 600; }

/* Mehrspaltige Feld-Layouts */
.feld-row { display: flex; flex-wrap: wrap; gap: .9rem; }
.feld-row > .feld { flex: 1 1 12rem; margin-bottom: 0; }
.feld-row > .feld.eng { flex: 0 0 auto; }
.feld-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .9rem; }
.feld-grid > .feld { margin-bottom: 0; }

/* Abschnitt im Formular (Fieldset oder Trenner) */
fieldset.feld-fieldset {
    border: 1px solid var(--rahmen); border-radius: var(--radius);
    padding: .8rem 1rem; margin: 0;
}
fieldset.feld-fieldset legend { padding: 0 .4rem; font-weight: 600; font-size: .92rem; }
.feld-abschnitt {
    margin: 1.2rem 0 .4rem; padding-top: .9rem; border-top: 1px solid var(--rahmen);
    font-weight: 600; font-size: .95rem;
}
.feld-abschnitt:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* Schmale Eingaben (statt Inline-Breiten) */
.feld input.w6,  .w6  { max-width: 6rem; }
.feld input.w7,  .w7  { max-width: 7rem; }
.feld input.w8,  .w8  { max-width: 8rem; }
.feld input.w12, .w12 { max-width: 12rem; }

/* Aktionsreihe */
.formular-aktion { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.formular-aktion .btn-voll { width: auto; min-width: 9rem; }

/* Allgemeine Button-Reihe */
.btn-reihe { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.karte > .btn-reihe { margin-top: .8rem; }
.seiten-kopf.mit-aktion > span { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Per JS umgeschaltete Bereiche */
.versteckt { display: none !important; }

/* Kleine generische Helfer */
.unter { font-weight: 400; color: var(--text-leise); font-size: .9rem; }
.spacer { flex: 1 1 auto; }
.titel-sek { font-size: 1.1rem; margin: .2rem 0 .6rem; }
.titel-sek.abstand { margin-top: 1.6rem; }

/* Abstands-Utilities (ersetzen Inline-Styles in den Views) */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 1rem; }
.mt-s { margin-top: .8rem; }
.my-1 { margin: 1rem 0; }
.pt-0 { padding-top: 0 !important; }
.eingerueckt { padding: 0 1rem 1rem; }
.hinweis { color: var(--text-leise); font-size: .92rem; }

/* --- Schaltflächen ------------------------------------------------------ */
.btn {
    display: inline-block;
    font: inherit; font-weight: 600;
    color: #fff; background: var(--akzent);
    border: 1px solid var(--akzent);
    border-radius: var(--radius-s);
    padding: .55rem 1rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    box-shadow: var(--schatten);
    transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
.btn:hover { background: var(--akzent-tf); border-color: var(--akzent-tf); text-decoration: none; box-shadow: var(--schatten-l); }
.btn:active { transform: translateY(1px); box-shadow: var(--schatten); }
.btn-still, .btn-gefahr { box-shadow: none; }
.btn-still:hover, .btn-gefahr:hover { box-shadow: var(--schatten); }
.btn-voll { width: 100%; text-align: center; }
.btn-klein { padding: .35rem .6rem; font-size: .85rem; }
.btn-still {
    background: var(--flaeche); color: var(--text); border-color: var(--rahmen);
}
.btn-still:hover { background: var(--flaeche-2); }
.btn-gefahr {
    background: var(--flaeche); color: var(--gefahr); border-color: var(--rahmen);
}
.btn-gefahr:hover { background: var(--gefahr-bg); border-color: var(--gefahr); }
form.inline { display: inline; margin: 0; }

/* --- Flash-Meldungen ---------------------------------------------------- */
.flash-bereich { display: flex; flex-direction: column; gap: .5rem; margin-bottom: var(--abstand); }
.flash {
    padding: .7rem .9rem; border-radius: var(--radius-s);
    border: 1px solid transparent; font-size: .95rem;
}
.flash-erfolg { background: var(--ok-bg);     color: var(--ok);     border-color: var(--ok); }
.flash-fehler { background: var(--gefahr-bg); color: var(--gefahr); border-color: var(--gefahr); }
.flash-info   { background: var(--info-bg);   color: var(--info-tf);border-color: var(--info-tf); }

/* --- Anmeldeseite ------------------------------------------------------- */
.auth-huelle { display: flex; justify-content: center; padding-top: 4vh; }
.auth-karte {
    background: var(--flaeche);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    padding: calc(var(--abstand) * 1.5);
    width: 100%; max-width: 380px;
}
.auth-titel { text-align: center; margin-bottom: .1rem; }
.auth-unter { text-align: center; color: var(--text-leise); margin: 0 0 var(--abstand); }
.auth-karte .formular { margin-top: var(--abstand); }

/* --- Leerzustand / Fehlerseite ----------------------------------------- */
.leer {
    background: var(--flaeche); border: 1px dashed var(--rahmen);
    border-radius: var(--radius); padding: calc(var(--abstand) * 2);
    text-align: center; color: var(--text-leise);
    display: flex; flex-direction: column; gap: var(--abstand); align-items: center;
}
.fehler-seite { text-align: center; padding: calc(var(--abstand) * 2) 0; }
.fehler-code { font-size: 3rem; font-weight: 800; color: var(--text-leise); margin: 0; }

/* --- Fusszeile ---------------------------------------------------------- */
.fuss {
    border-top: 1px solid var(--rahmen);
    background: var(--flaeche);
    color: var(--text-leise);
    font-size: .85rem;
}
.fuss-inner {
    display: flex; justify-content: space-between; align-items: center;
    max-width: var(--max-breite); margin: 0 auto; padding: .8rem var(--abstand);
}
.sprachwahl a { color: var(--text-leise); padding: 0 .35rem; }
.sprachwahl a[aria-current="true"] { color: var(--akzent); font-weight: 700; }
.theme-wahl { display: inline-flex; gap: .15rem; align-items: center; }
.theme-wahl a { color: var(--text-leise); padding: .1rem .4rem; border-radius: var(--radius-s); line-height: 1.4; }
.theme-wahl a:hover { background: var(--flaeche-2); text-decoration: none; }
.theme-wahl a[aria-current="true"] { color: var(--akzent); font-weight: 700; background: var(--akzent-bg); }
.fuss-inner .theme-wahl { margin-left: auto; }

/* --- Bewegung reduzieren ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* --- Handy / Tablet: eigene Darstellung -------------------------------- */
@media (max-width: 768px) {
    .kopf-inner { min-height: 0; padding: .55rem var(--abstand); gap: .5rem; flex-wrap: wrap; }
    .marke { flex: 1; }

    /* Hamburger (Label) sichtbar; schaltet die versteckte Checkbox. */
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        order: 2; flex: none;
        width: 2.6rem; height: 2.6rem;
        background: var(--flaeche); color: var(--text);
        border: 1px solid var(--rahmen); border-radius: var(--radius-s);
        font-size: 1.2rem; line-height: 1; cursor: pointer;
        transition: background .12s, border-color .12s;
    }
    .nav-toggle::before { content: "\2630"; }                        /* ☰ */
    .nav-check:checked ~ .nav-toggle::before { content: "\2715"; }   /* ✕ */
    .nav-toggle:hover { background: var(--flaeche-2); }
    .nav-check:focus-visible ~ .nav-toggle { outline: 3px solid var(--akzent); outline-offset: 2px; }

    /* Panel: eigene Zeile unter dem Kopf, standardmässig zu; Checkbox klappt auf. */
    .kopf-panel { order: 5; flex-basis: 100%; display: none; flex-direction: column; gap: .5rem; }
    .nav-check:checked ~ .kopf-panel { display: flex; }

    .haupt-nav {
        flex-direction: column; gap: .1rem; flex: none;
        padding-top: .4rem; border-top: 1px solid var(--rahmen);
    }
    .haupt-nav a { padding: .7rem .55rem; font-size: 1rem; }

    .kopf-rechts {
        flex-wrap: wrap; gap: .6rem;
        padding-top: .6rem; border-top: 1px solid var(--rahmen);
    }
    .benutzer-chip { text-align: left; }

    .inhalt { padding: var(--abstand); }
    h1 { font-size: 1.4rem; }
    .fuss-inner { flex-wrap: wrap; gap: .5rem; }

    /* Aktionen/Buttons greifen auf schmalen Schirmen die volle Breite */
    .formular-aktion .btn, .btn-reihe > .btn { flex: 1 1 auto; text-align: center; }
}

@media (max-width: 480px) {
    .kachel-gitter { grid-template-columns: 1fr 1fr; }
    .kachel-zahl { font-size: 1.7rem; }
    .seiten-kopf.mit-aktion { align-items: stretch; }
}

/* --- Daten-Engine: Suche, Blättern ------------------------------------- */
.suchleiste { display: flex; gap: .5rem; margin-bottom: var(--abstand); max-width: 520px; }
.suchleiste input { flex: 1; }
.leer-zelle { color: var(--text-leise); }
.blaettern {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: var(--abstand); flex-wrap: wrap; gap: .5rem;
    color: var(--text-leise); font-size: .9rem;
}
.blaettern-seiten { display: flex; gap: .3rem; }
.blaettern-seiten a, .blaettern-seiten .seite-akt {
    padding: .25rem .55rem; border-radius: var(--radius-s);
    border: 1px solid var(--rahmen);
}
.blaettern-seiten a { color: var(--akzent); }
.blaettern-seiten .seite-akt { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.blaettern-seiten .auslassung { padding: .25rem .2rem; color: var(--text-leise); }

/* --- Testleiste (Impersonation, nur Entwicklungsphase) ----------------- */
.testleiste {
    background: #2d2a26; color: #f3efe8;
    border-bottom: 2px solid #c9a227;
    font-size: .86rem;
}
.testleiste-aktiv { background: #7a3b12; border-bottom-color: #f0a04b; }
.testleiste-inner {
    max-width: var(--breite-max, 1100px); margin: 0 auto;
    padding: .4rem var(--abstand, 1rem);
    display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.testleiste-status { opacity: .92; white-space: nowrap; }
.testleiste-status strong { color: #f0c14b; }
.testleiste-aktiv .testleiste-status strong { color: #ffd9a8; }
.testleiste-wechsel { display: flex; gap: .35rem; flex-wrap: wrap; flex: 1; }
.testleiste .btn-klein {
    background: rgba(255,255,255,.10); color: #f3efe8;
    border: 1px solid rgba(255,255,255,.22); padding: .15rem .5rem;
}
.testleiste .btn-klein:hover { background: rgba(255,255,255,.20); }
.testleiste .testleiste-btn.ist-aktiv {
    background: #f0c14b; color: #2d2a26; border-color: #f0c14b; font-weight: 700;
}
.testleiste-zurueck .btn-klein {
    background: #f0a04b; color: #2d2a26; border-color: #f0a04b; font-weight: 700;
}

/* ======================================================================= *
 *  ZENTRALISIERTE MODUL-KOMPONENTEN
 *  Diese Bausteine waren früher wortgleich in mehreren _*_ui.php-Partials.
 *  Jetzt EINMAL hier – die Partials enthalten nur noch Modul-Spezifisches.
 * ======================================================================= */

/* --- Sekundärer Abschnittskopf ---------------------------------------- */
.abschnitt-kopf { margin-top: calc(var(--abstand) * 1.4); }
.abschnitt-kopf h2 { margin: 0; font-size: 1.1rem; }
.kat-titel { font-size: 1rem; margin: 1.3rem 0 .5rem; color: var(--text-leise); }
.kat-titel:first-of-type { margin-top: .4rem; }

/* --- Inline-Anlegen (neuer Typ / Kategorie / Eintrag) ----------------- */
.neu-form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.neu-form label { display: flex; flex-direction: column; font-size: .82rem; gap: .25rem; color: var(--text-leise); }
.neu-form input, .neu-form select { width: auto; min-width: 12rem; }

/* --- Reiter / Filter (Pillen) ----------------------------------------- */
.lab-tabs, .typ-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.lab-tab {
    display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem;
    border: 1px solid var(--rahmen); border-radius: 999px; background: var(--flaeche);
    color: var(--text); text-decoration: none; font-size: .9rem; line-height: 1;
}
.lab-tab:hover { background: var(--flaeche-2); text-decoration: none; }
.lab-tab.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.lab-tab .cnt {
    font-variant-numeric: tabular-nums; font-size: .8rem; padding: .05rem .4rem;
    border-radius: 999px; background: var(--flaeche-2); color: var(--text-leise);
}
.lab-tab.aktiv .cnt { background: rgba(255,255,255,.22); color: #fff; }

/* --- Metazeile (Detail-Kopf) ------------------------------------------ */
.lab-meta { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-bottom: 1rem; }
.lab-meta.lab-meta--trenner { border-top: 1px solid var(--rahmen); padding-top: .8rem; }
.lab-meta div span { display: block; font-size: .8rem; color: var(--text-leise); }

/* --- Listen-Karten (Becken / Grössen / Massnahmen / Kopffelder / Kat.) - */
.stamm-bad {
    border: 1px solid var(--rahmen); border-radius: var(--radius);
    padding: .7rem 1rem; margin-bottom: 1rem; background: var(--flaeche);
}
.stamm-bad-kopf { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.stamm-bad-kopf h3 { margin: 0; font-size: 1.05rem; display: inline-flex; align-items: center; gap: .45rem; }
.stamm-bad-kopf .bez { color: var(--text-leise); font-size: .9rem; }
.stamm-g {
    display: flex; justify-content: space-between; align-items: center; gap: .6rem;
    padding: .55rem 0; border-top: 1px solid var(--rahmen);
}
.stamm-g:first-child { border-top: 0; }
.stamm-g .gname { font-weight: 600; }
.stamm-g .gmeta, .stamm-g .gsoll { font-size: .85rem; color: var(--text-leise); }
.stamm-akt { display: flex; gap: .4rem; flex-wrap: wrap; }
.stamm-leer { color: var(--text-leise); font-size: .9rem; padding: .4rem 0; }
.badge.aus { background: var(--flaeche-2); color: var(--text-leise); }

/* --- Ampel-Badges (Kalibrierung / Bestand / Verfall) ------------------ */
.kal-status { display: inline-block; padding: .12rem .55rem; border-radius: 999px;
    font-size: .82rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.kal-ok    { background: var(--ok-bg);     color: var(--ok); }
.kal-bald  { background: var(--warn-bg);   color: var(--warn); }
.kal-ueber { background: var(--gefahr-bg); color: var(--gefahr); }
.kal-keine { background: var(--flaeche);   color: var(--text-leise); border-color: var(--rahmen); }

/* --- GHS-Chips --------------------------------------------------------- */
.chem-ghs { display: flex; flex-wrap: wrap; gap: .15rem .5rem; margin: .25rem 0; }
.ghs-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--text-leise); }
.ghs-raute { width: 1.45rem; height: 1.45rem; flex: none; }

/* --- Icons ------------------------------------------------------------- */
.ico { width: 1.05em; height: 1.05em; vertical-align: -.15em; flex: none; }
.btn .ico { margin-right: .35em; }
.dok-typ-ico { width: 1.35rem; height: 1.35rem; color: var(--text-leise); flex: none; }
.dok-zeile-haupt { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; min-width: 0; }

/* --- Datei-Vorschau (Dateimanager + Labor) ---------------------------- */
.dok-vorschau { margin: 0 0 1rem; }
.dok-bild { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--rahmen); }
.dok-pdf { width: 100%; height: 78vh; border: 1px solid var(--rahmen); border-radius: 6px; background: var(--flaeche); }
.dok-text { max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem;
    background: var(--flaeche); border: 1px solid var(--rahmen); border-radius: 6px; padding: .8rem; margin: 0; }
.dok-meta { color: var(--text-leise); font-size: .9rem; margin: 0 0 1rem; }
.dok-import { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.dok-import .feld { margin: 0; }
.dok-import-pfad { font-family: ui-monospace, Menlo, Consolas, monospace;
    background: var(--flaeche); border: 1px solid var(--rahmen); border-radius: var(--radius-s); padding: .1rem .4rem; }

/* --- Modul-Übersichtskacheln (Labor / Typen / Lager / Tool) ----------- */
.tool-grid, .labor-grid, .lager-grid, .typ-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--abstand); margin-top: 1rem;
}
.typ-grid { margin-bottom: .6rem; }
.tool-kachel, .labor-kachel, .lager-kachel, .typ-kachel {
    display: block; border: 1px solid var(--rahmen); border-radius: var(--radius);
    padding: 1rem 1.1rem; background: var(--flaeche); text-decoration: none; color: inherit;
    transition: box-shadow .15s, border-color .15s;
}
.tool-kachel:hover, .labor-kachel.aktiv:hover, .lager-kachel.aktiv:hover, .typ-kachel:hover {
    box-shadow: var(--schatten); border-color: var(--akzent); text-decoration: none;
}
.labor-kachel.inaktiv, .lager-kachel.inaktiv { opacity: .6; cursor: default; }
.tool-kachel h2, .labor-kachel h2, .lager-kachel h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.tool-kachel h2 { color: var(--akzent); }
.typ-kachel h3 { margin: 0; font-size: 1.05rem; }
.tool-kachel p, .labor-kachel p, .lager-kachel p { margin: 0; font-size: .88rem; color: var(--text-leise); }
.labor-kachel .bald, .lager-kachel .bald {
    display: inline-block; margin-top: .5rem; font-size: .75rem; padding: .1rem .5rem;
    border-radius: 999px; background: var(--flaeche-2); color: var(--text-leise);
}

/* --- Mobil (zentralisierte Komponenten) ------------------------------- */
@media (max-width: 640px) {
    .tool-grid, .labor-grid, .lager-grid, .typ-grid { grid-template-columns: 1fr; }
    .stamm-g { flex-wrap: wrap; }
    .dok-pdf { height: 60vh; }
}

/* ============================================================ KI-Assistent === */
#ki-assistent { position: fixed; right: 18px; bottom: 18px; z-index: 900; }
.ki-fab {
    display: inline-flex; align-items: center; gap: .5em;
    background: var(--akzent); color: #fff; border: 0; cursor: pointer;
    padding: .7em 1.05em; border-radius: 999px; font: inherit; font-weight: 600;
    box-shadow: var(--schatten-l);
}
.ki-fab:hover { background: var(--akzent-tf); }
.ki-fab span[aria-hidden] {
    display: inline-grid; place-items: center; width: 1.4em; height: 1.4em;
    border-radius: 50%; background: rgba(255,255,255,.22); font-weight: 700;
}
.ki-panel {
    position: absolute; right: 0; bottom: calc(100% + 12px);
    width: min(360px, calc(100vw - 36px)); height: min(520px, calc(100vh - 120px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--flaeche); color: var(--text);
    border: 1px solid var(--rahmen); border-radius: var(--radius);
    box-shadow: var(--schatten-l);
}
.ki-panel[hidden] { display: none; }
.ki-kopf {
    display: flex; align-items: center; justify-content: space-between;
    padding: .6em .8em; border-bottom: 1px solid var(--rahmen); background: var(--akzent-bg);
}
.ki-zu { border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text-leise); }
.ki-zu:hover { color: var(--text); }
.ki-verlauf { flex: 1 1 auto; overflow-y: auto; padding: .8em; display: flex; flex-direction: column; gap: .55em; }
.ki-msg {
    max-width: 85%; padding: .55em .75em; border-radius: var(--radius-s);
    white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; font-size: .94rem;
}
.ki-bot  { align-self: flex-start; background: var(--bg); border: 1px solid var(--rahmen); }
.ki-user { align-self: flex-end; background: var(--akzent); color: #fff; }
.ki-warte { opacity: .65; font-style: italic; }
.ki-fehler { background: var(--gefahr-bg); border-color: transparent; }
.ki-datenschutz { font-size: .76rem; color: var(--text-leise); margin: .2em 0 0; }
.ki-eingabe { display: flex; gap: .5em; padding: .6em; border-top: 1px solid var(--rahmen); }
.ki-eingabe textarea {
    flex: 1 1 auto; resize: none; font: inherit; padding: .5em .6em;
    border: 1px solid var(--rahmen); border-radius: var(--radius-s);
    background: var(--bg); color: var(--text);
}
.ki-eingabe .btn { align-self: stretch; }
@media (max-width: 480px) { .ki-fab-text { display: none; } }
.ki-tools-leiste { padding: .4em .8em; border-bottom: 1px solid var(--rahmen); background: var(--bg); }
.ki-tools { display: inline-flex; align-items: center; gap: .45em; font-size: .82rem; color: var(--text-leise); cursor: pointer; }
.ki-tools input { accent-color: var(--akzent); }

/* ============================================================ Mobile: breite Tabellen
 * Tabellen mit eigenen Klassen (Statistik, Verbrauch, Sprach-Editor, Tool-
 * Ergebnisse, Begleitschein) haben keine eigene Scroll-Hülle. Auf schmalen
 * Schirmen werden sie horizontal scrollbar, statt abgeschnitten zu werden.
 * Bereits umhüllte Tabellen (.tabelle in .tabelle-huelle, .rechte-tab in
 * .rechte-tab-wrap) sind ausgenommen. */
@media (max-width: 768px) {
    table { max-width: 100%; }
    table:not(.tabelle):not(.rechte-tab) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Druck-Etikett bleibt unverändert kompakt */
    .etikett-tab { display: table; overflow: visible; }
}

/* Fußzeile: Kontakt + Links */
.fuss-kontakt { color: var(--text-leise); }
.fuss-links { display: inline-flex; gap: .8rem; }
.fuss-links a { color: var(--akzent); }
.impressum-text { white-space: pre-wrap; }

/* Menü-Editor */
.me-list { list-style: none; margin: 0; padding: 0; }
.me-list .me-list { margin: .3rem 0 .3rem 1.4rem; padding-left: .6rem; border-left: 2px solid var(--rahmen, #ccd6dc); }
.me-row { margin: .3rem 0; }
.me-row.dragging { opacity: .45; }
.me-head { display: flex; align-items: center; gap: .5rem; padding: .4rem .55rem; border: 1px solid var(--rahmen, #ccd6dc); border-radius: .4rem; background: var(--flaeche, #fff); }
.me-grip::before { content: "\2630"; color: var(--text-leise, #888); cursor: grab; }
.me-label { flex: 0 1 auto; }
.me-row.me-hidden > .me-head .me-label { opacity: .5; text-decoration: line-through; }
.me-badge { font-size: .72rem; padding: .05rem .4rem; border-radius: .4rem; background: var(--akzent-bg, #e3f0ef); color: var(--akzent, #0f6b6b); }
.me-spacer { flex: 1; }
.me-ib { background: none; border: none; cursor: pointer; padding: .2rem .35rem; color: var(--text-leise, #666); font-size: .9rem; line-height: 1; }
.me-ib:hover { color: var(--text, #111); }
.me-eye::before { content: "\25CF"; }
.me-row.me-hidden > .me-head .me-eye::before { content: "\25CB"; }
.me-h2 { font-size: 1rem; margin: 0 0 .6rem; }

/* ===== Seitenleisten-Layout (Topbar + Sidebar + Inhalt) ===== */
.topbar { display: flex; align-items: center; gap: .6rem; padding: .5rem var(--abstand); background: var(--flaeche); border-bottom: 1px solid var(--rahmen); position: sticky; top: 0; z-index: 30; }
.topbar .marke { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.topbar .marke:hover { color: var(--akzent); }
.topbar-spacer { flex: 1; }
.menu-pos-btn { background: none; border: 1px solid var(--rahmen); border-radius: var(--radius-s); cursor: pointer; padding: .3rem .55rem; color: var(--text-leise); font-size: 1rem; line-height: 1; }
.menu-pos-btn:hover { color: var(--text); background: var(--flaeche-2); }
.shell { display: flex; align-items: stretch; }
.seitenleiste { flex: 0 0 232px; width: 232px; background: var(--flaeche-2); border-right: 1px solid var(--rahmen); padding: .6rem; overflow: auto; }
.shell-main { flex: 1; min-width: 0; }
[data-menu="rechts"] .shell { flex-direction: row-reverse; }
[data-menu="rechts"] .seitenleiste { border-right: none; border-left: 1px solid var(--rahmen); }
.sb-nav { display: flex; flex-direction: column; gap: .12rem; }
.sb-link { display: block; padding: .45rem .6rem; border-radius: var(--radius-s); color: var(--text-leise); text-decoration: none; border-left: 3px solid transparent; }
.sb-link:hover { background: var(--flaeche); color: var(--text); text-decoration: none; }
.sb-link[aria-current] { color: var(--akzent); background: var(--akzent-bg); border-left-color: var(--akzent); font-weight: 600; }
.sb-grp { margin: .04rem 0; }
.sb-sum { list-style: none; cursor: pointer; padding: .45rem .6rem; border-radius: var(--radius-s); font-weight: 600; color: var(--text); display: flex; align-items: center; }
.sb-sum::-webkit-details-marker { display: none; }
.sb-sum::before { content: "\25B8"; margin-right: .45rem; color: var(--text-leise); font-size: .8em; transition: transform .12s; }
.sb-grp[open] > .sb-sum::before { transform: rotate(90deg); }
.sb-sum:hover { background: var(--flaeche); }
.sb-sub { margin: .1rem 0 .3rem .55rem; padding-left: .5rem; border-left: 1px solid var(--rahmen); display: flex; flex-direction: column; gap: .12rem; }
.inhalt-zentriert { max-width: var(--max-breite); margin: 0 auto; }
@media (max-width: 768px) {
    .shell, [data-menu="rechts"] .shell { flex-direction: column; }
    .seitenleiste { display: none; flex-basis: auto; width: auto; border-right: none; border-left: none; border-bottom: 1px solid var(--rahmen); }
    .nav-check:checked ~ .shell .seitenleiste { display: block; }
}

/* ===== Dashboard ===== */
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: var(--abstand); }
.dash-kpi { background: var(--flaeche-2); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.dash-kpi-label { font-size: .82rem; color: var(--text-leise); }
.dash-kpi-wert { font-size: 1.7rem; font-weight: 700; color: var(--text); }
.dash-h2 { font-size: 1.05rem; margin: 1.2rem 0 .6rem; }

/* Schnellzugriff: gleichmässige Kacheln, kein versetzter Abstand im Gitter,
   lange Titel brechen um statt aus der Box zu laufen. */
.kachel-gitter > .karte { margin-top: 0; height: 100%; }
.kachel-gitter > .karte + .karte { margin-top: 0; }
.dash-modul { justify-content: center; min-height: 3.1rem; }
.dash-lager-kopf { flex-wrap: wrap; }
.dash-lager-kopf strong { min-width: 0; overflow-wrap: anywhere; }
.dash-boxen { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.dash-box { display: flex; flex-direction: column; gap: .2rem; padding: .85rem 1rem; border-radius: var(--radius); text-decoration: none; border: 1px solid transparent; }
.dash-box:hover { text-decoration: none; filter: brightness(.985); }
.dash-box-label { font-size: .85rem; }
.dash-box-wert { font-size: 1.5rem; font-weight: 700; }
.dash-box-wert small { font-size: .8rem; font-weight: 400; }
.dash-box.dash-gefahr { background: var(--gefahr-bg); color: var(--gefahr); border-color: var(--gefahr); }
.dash-box.dash-warn   { background: var(--warn-bg);   color: var(--warn);   border-color: var(--warn); }
.dash-box.dash-info   { background: var(--info-bg);   color: var(--info-tf); border-color: var(--info-tf); }
.dash-lager { display: flex; flex-direction: column; gap: .5rem; }
.dash-lager-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.dash-lager-n { font-size: .8rem; color: var(--text-leise); white-space: nowrap; }
.dash-lager-akt { display: flex; gap: .4rem; flex-wrap: wrap; }
.dash-modul { display: flex; align-items: center; text-decoration: none; color: var(--text); }
.dash-modul:hover { text-decoration: none; border-color: var(--akzent); }

/* Menü-Badge (z. B. offene Meldungen) */
.sb-link { display: flex; align-items: center; gap: .4rem; }
.sb-badge { margin-left: auto; background: var(--gefahr); color: #fff; border-radius: 999px; font-size: .72rem; line-height: 1; padding: .14rem .44rem; font-weight: 700; }

/* ===== App-Rahmen (Desktop): Bildschirm-Fenster, Inhalt scrollt INNEN =====
   Der Trick: body.app wird exakt bildschirmhoch gesperrt (100vh, kein
   Fenster-Scroll). Topbar oben + Fusszeile unten bleiben fix; der Bereich
   dazwischen (.shell) füllt den Rest. Seitenleiste und Inhalt bekommen je
   einen EIGENEN Scrollbalken – die Leiste bewegt sich dadurch NIE mit dem
   Inhalt, sie scrollt höchstens für sich selbst, wenn das Menü zu lang ist.
   100vh ist überall unterstützt; 100dvh nur als Zusatz (Handy-Adressleiste). */
@media (min-width: 769px) {
    body.app {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;          /* kein Scrollen auf Fenster-/Body-Ebene */
    }
    body.app > .topbar,
    body.app > .testleiste { flex: none; }   /* feste Höhe, wird nicht gestaucht */
    body.app > .shell {
        flex: 1 1 auto;            /* füllt den Platz zwischen Topbar und Fuss */
        min-height: 0;             /* erlaubt Schrumpfen -> innere Scroller wirken */
        align-items: stretch;      /* Leiste + Inhalt gleich hoch wie .shell */
    }
    body.app .seitenleiste { overflow-y: auto; }     /* scrollt nur bei Bedarf, bleibt sonst stehen */
    body.app .shell-main    { overflow-y: auto; min-height: 0; }   /* hier scrollt der Inhalt */
    body.app > .fuss { flex: none; border-top: 1px solid var(--rahmen); background: var(--flaeche); }
}

/* Gruppen-Kopf als Navigationslink (klick = Übersicht der Gruppe) */
.sb-sum-link { flex: 1; color: inherit; text-decoration: none; }
.sb-sum-link:hover { color: var(--akzent); text-decoration: none; }
.sb-sum-link[aria-current] { color: var(--akzent); }

/* ===== Menü-Editor + Rechte-Liste ===== */
.menue-add { margin-bottom: var(--abstand); }
.menue-h2 { font-size: 1rem; margin: 0 0 .6rem; }
.menue-add-grid { display: grid; grid-template-columns: 1.3fr 1.6fr 1.2fr auto; gap: .8rem; align-items: end; }
.menue-add-btn { display: flex; align-items: flex-end; }
@media (max-width: 760px) { .menue-add-grid { grid-template-columns: 1fr; } }

.menue-tabelle-wrap { overflow-x: auto; }
.menue-tabelle { width: 100%; border-collapse: collapse; font-size: .92rem; }
.menue-tabelle th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise); padding: .4rem .5rem; border-bottom: 2px solid var(--rahmen); }
.menue-tabelle th.num, .menue-tabelle th.mit { text-align: center; }
.menue-tabelle td { padding: .35rem .5rem; border-bottom: 1px solid var(--rahmen); vertical-align: middle; }
.menue-tabelle td.num, .menue-tabelle td.mit { text-align: center; }
/* Editor-Tabellen (Menü-/Seiten-Editor): kompakte, einheitliche Eingaben */
.menue-tabelle input[type="text"], .menue-tabelle input[type="number"],
.menue-tabelle select, .menue-tabelle textarea {
    width: 100%; min-height: 2.2rem; padding: .4rem .55rem;
}
.menue-tabelle select { padding-right: 1.8rem; background-position: right .55rem center; }
.menue-tabelle .w-num { width: 5rem; min-width: 4rem; }
.menue-tabelle textarea { min-height: 2.6rem; resize: vertical; }
.menue-tabelle tr.ist-system { background: var(--flaeche-2); }
.menue-tag { display: inline-block; margin-left: .4rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise); border: 1px solid var(--rahmen); border-radius: 999px; padding: .05rem .4rem; }

.feld-recht .feld-label { display: flex; flex-direction: column; }
.recht-pfad { color: var(--text-leise); font-size: .76rem; font-weight: 400; }

/* ===== Inhalts-Seiten (Boxen) ===== */
.inhalt-boxen { margin-top: var(--abstand); }
.inhalt-box { display: flex; flex-direction: column; gap: .35rem; text-align: left; }
.inhalt-box .kachel-titel { font-weight: 600; }
.inhalt-box .kachel-text { color: var(--text-leise); font-size: .92rem; line-height: 1.5; }
a.inhalt-box.ist-link { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.inhalt-box.ist-link:hover { border-color: var(--akzent); transform: translateY(-2px); }
.feld-mit-check { align-self: end; }
.zeile-rechts { display: flex; align-items: center; gap: .6rem; margin: 0 0 var(--abstand); flex-wrap: wrap; }
.menue-zeile-akt { display: flex; gap: .35rem; justify-content: flex-end; }

/* ===== Freitext-Block (Box ohne Link) ===== */
.inhalt-text { margin: var(--abstand) 0; }
.inhalt-text-titel { font-size: 1.15rem; margin: 0 0 .4rem; }
.inhalt-text-body { color: var(--text); line-height: 1.65; max-width: 70ch; }


/* =======================================================================
 *  MODUL: Labor  (zentralisiert aus modules/labor/views/_labor_ui.php)
 * ===================================================================== */
genau einmal pro
 * Seitenaufruf aus.
 */
if (!defined('APP')) { http_response_code(403); exit('Direktaufruf nicht erlaubt.'); }
if (!empty($GLOBALS['__lab_ui_css'])) { return; }
$GLOBALS['__lab_ui_css'] = true;
?>
<style>
/* ===================================================================== *
 *  Labor – NUR modulspezifische Layouts.
 *  Eingabe-Box, Reiter, Listen-Karten, Meta, Badges, GHS, Icons, Kacheln,
 *  Datei-Vorschau, Inline-Anlegen liegen jetzt zentral in app.css.
 * ===================================================================== */

/* --- Fremdanalyse: Positionen als ausgerichtete Spalten --------------- */
.fa-pos { display: grid; gap: .15rem; }
.fa-pos-zeile {
    display: grid;
    grid-template-columns: minmax(7rem, 1.5fr) minmax(7rem, 1fr) 5rem 5rem minmax(8rem, 2fr);
    gap: .55rem .8rem; align-items: end;
    padding: .6rem 0; border-top: 1px solid var(--rahmen);
}
.fa-pos-zeile:first-child { border-top: 0; padding-top: .2rem; }
.fa-pos .feld { margin-bottom: 0; }
.fa-pos .feld input, .fa-pos .feld select { width: 100%; }
.fa-pos-name { padding-bottom: .4rem; }
@media (max-width: 680px) {
    .fa-pos-zeile { grid-template-columns: 1fr; gap: .55rem; padding: .8rem 0; }
    .fa-pos-name { padding-bottom: 0; }
    .fa-pos-leer { display: none; }
}

/* --- Status-Ampel für Messwerte --------------------------------------- */
.g-ok    { background: var(--ok-bg);     border-color: var(--ok); }
.g-unter, .g-ueber, .g-bad {
    background: var(--gefahr-bg); border-color: var(--gefahr); color: var(--gefahr);
}

/* --- Toolbar ----------------------------------------------------------- */
.lab-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.lab-toolbar .lab-tb-label { font-size: .8rem; color: var(--text-leise); margin-right: .1rem; }

/* --- Protokoll-Liste (nach Tag gruppiert) ----------------------------- */
.prot-tag-kopf {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise);
    margin: 1rem 0 .2rem; padding-top: .6rem; border-top: 1px solid var(--rahmen);
}
.prot-liste > .prot-tag-kopf:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prot-zeile {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem .9rem;
    flex-wrap: wrap; padding: .55rem 0; border-top: 1px solid var(--rahmen);
}
.prot-tag-kopf + .prot-zeile { border-top: 0; }
.prot-haupt { display: flex; align-items: center; gap: .55rem; flex: 1 1 16rem; min-width: 0; flex-wrap: wrap; }
.prot-typ { font-weight: 600; }
.prot-zeit { color: var(--text-leise); font-variant-numeric: tabular-nums; }
.prot-ma { color: var(--text-leise); font-size: .9rem; }
.prot-akt { display: flex; gap: .4rem; flex-wrap: wrap; }
.prot-filter { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.prot-filter .feld { margin-bottom: 0; }
.prot-tagnav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .2rem 0 1rem; }
.prot-tagnav-d { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 6.5rem; text-align: center; }

/* --- Protokoll-Formular: Vorbehandlung (Becken-Karten) ---------------- */
.lab-kopf { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.lab-kopf label { display: flex; flex-direction: column; font-size: .9rem; gap: .25rem; }
.lab-karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: var(--abstand); }
.lab-karte { border: 1px solid var(--rahmen); border-radius: var(--radius); padding: .8rem 1rem; background: var(--flaeche); }
.lab-karte h3 { margin: 0; font-size: 1.02rem; }
.lab-karte .bez { display: block; font-size: .85rem; color: var(--text-leise); margin-bottom: .3rem; }
.lab-item { padding: .5rem 0; border-top: 1px solid var(--rahmen); }
.lab-item:first-of-type { border-top: 0; }
.lab-item-kopf { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.lab-mname { font-weight: 600; }
.lab-einheit { color: var(--text-leise); font-weight: 400; }
.lab-msoll { font-size: .8rem; color: var(--text-leise); }
.lab-ist { width: 6rem; text-align: right; }
.lab-zusatz { display: flex; gap: .4rem; margin-top: .35rem; flex-wrap: wrap; }
.lab-mass, .lab-bem { flex: 1 1 12rem; }
.lab-fx { display: inline-block; margin-left: .25rem; font-style: italic; font-weight: 700; color: var(--akzent); cursor: help; }
.lab-berechnet { background: var(--flaeche-2); }

/* --- Protokoll-Formular: generische Typen ----------------------------- */
.lab-titems { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: .7rem; }
.lab-titem { border: 1px solid var(--rahmen); border-radius: var(--radius); padding: .7rem .9rem; background: var(--flaeche); }
.lab-titem-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; flex-wrap: wrap; }
.lab-fototag { font-size: .72rem; padding: .05rem .4rem; border-radius: var(--radius-s); background: var(--info-bg); color: var(--info-tf); }
.lab-eingabe { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.t-ist, .t-avg { width: 6.5rem; text-align: right; }
.t-mw { width: 4.5rem; text-align: right; }
.t-mwwrap { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.lab-beleg-hint { font-size: .85rem; color: var(--text-leise); }

/* --- Protokoll-Anzeige ------------------------------------------------- */
.lab-zk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: .7rem; }
.lab-z { display: grid; grid-template-columns: 1fr auto; gap: .3rem .6rem; padding: .45rem 0; border-top: 1px solid var(--rahmen); }
.lab-zk-grid .lab-z { padding: .7rem .9rem; border: 1px solid var(--rahmen); border-radius: var(--radius); align-content: start; }
.lab-z .mname { font-weight: 600; }
.lab-z .einheit { color: var(--text-leise); font-weight: 400; }
.lab-z .msoll { font-size: .8rem; color: var(--text-leise); }
.lab-z .mist { text-align: right; font-variant-numeric: tabular-nums; padding: .1rem .45rem; border-radius: var(--radius-s); align-self: center; font-weight: 600; }
.lab-z .mist.g-ok  { background: var(--ok-bg); color: var(--ok); }
.lab-z .mist.g-bad, .lab-z .mist.g-unter, .lab-z .mist.g-ueber { background: var(--gefahr-bg); color: var(--gefahr); }
.lab-z .mwerte { grid-column: 1 / -1; font-size: .8rem; color: var(--text-leise); }
.lab-z .mbem  { grid-column: 1 / -1; font-size: .85rem; color: var(--text-leise); }
.lab-z .mmass { grid-column: 1 / -1; font-size: .85rem; color: var(--warn); }
.lab-z .mfoto { grid-column: 1 / -1; }
.lab-z .mfx { display: inline-block; margin-left: .25rem; font-style: italic; font-weight: 700; color: var(--akzent); cursor: help; }

/* --- Foto-Galerien ----------------------------------------------------- */
.lab-fotos { margin-top: 1.6rem; }
.lab-foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .8rem; }
.lab-foto { border: 1px solid var(--rahmen); border-radius: var(--radius); overflow: hidden; background: var(--flaeche); }
.lab-foto a.bild { display: block; background: var(--flaeche-2); line-height: 0; }
.lab-foto a.bild img { display: block; width: 100%; height: 9rem; object-fit: cover; }
.lab-foto .akt { display: flex; flex-wrap: wrap; gap: .25rem; padding: .4rem; align-items: center; }
.lab-foto .akt form { display: inline; }
.lab-foto .akt .btn-klein { padding: .2rem .45rem; font-size: .8rem; }
.lab-foto .masse { width: 100%; font-size: .72rem; color: var(--text-leise); padding: 0 .4rem .4rem; }
.lab-foto select { font-size: .8rem; padding: .15rem .3rem; min-height: 0; }
.lab-foto-pdf a.datei { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; height: 9rem; background: var(--flaeche-2); text-decoration: none; padding: .6rem; text-align: center; }
.lab-foto-pdf .pdf-icon { font-weight: 800; font-size: .8rem; letter-spacing: .05em; color: #fff; background: var(--gefahr, #b3261e); border-radius: var(--radius-s); padding: .35rem .55rem; }
.lab-foto-pdf .pdf-name { font-size: .78rem; color: var(--text); word-break: break-word; line-height: 1.25; max-height: 3.2em; overflow: hidden; }
.lab-upload { border: 1px dashed var(--rahmen); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1rem; }
.lab-upload input[type=file] { display: block; margin: .4rem 0 .6rem; }
.lab-zfoto { margin-top: .5rem; }
.lab-zfoto .titel { font-size: .8rem; color: var(--text-leise); margin-bottom: .3rem; }
.lab-zfoto-grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.lab-zfoto-grid .ff { border: 1px solid var(--rahmen); border-radius: var(--radius-s); overflow: hidden; width: 7rem; background: var(--flaeche); }
.lab-zfoto-grid .ff a.bild { display: block; background: var(--flaeche-2); line-height: 0; }
.lab-zfoto-grid .ff img { display: block; width: 100%; height: 5rem; object-fit: cover; }
.lab-zfoto-grid .ff .akt { display: flex; gap: .2rem; padding: .25rem; }
.lab-zfoto-grid .ff .akt form { display: inline; }
.lab-zfoto-grid .ff .akt .btn-klein { padding: .1rem .35rem; font-size: .75rem; }
.lab-zfoto-up { display: flex; gap: .4rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }
.lab-zfoto-up input[type=file] { font-size: .8rem; max-width: 14rem; }

/* --- Statistik --------------------------------------------------------- */
.stat-filter { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1.2rem; }
.stat-filter .feld { gap: .2rem; margin-bottom: 0; }
.stat-filter .feld-label { font-size: .8rem; color: var(--text-leise); }
.stat-karten { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1rem 0; }
.stat-kpi { border: 1px solid var(--rahmen); border-radius: var(--radius); padding: .6rem .9rem; min-width: 7rem; background: var(--flaeche); }
.stat-kpi .wert { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-kpi .lab { font-size: .75rem; color: var(--text-leise); }
.stat-kpi.warn .wert { color: var(--gefahr); }
.lab-chart { width: 100%; height: auto; border: 1px solid var(--rahmen); border-radius: var(--radius); background: var(--flaeche); }
.stat-tab { width: 100%; border-collapse: collapse; margin-top: .6rem; }
.stat-tab th, .stat-tab td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--rahmen); font-size: .9rem; }
.stat-tab td.num, .stat-tab th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-tab tr.warn td { background: var(--gefahr-bg); }

/* --- QR-Verwaltung ----------------------------------------------------- */
.qr-flex { display: flex; flex-wrap: wrap; gap: var(--abstand); align-items: flex-start; }
.qr-box { flex: 0 0 auto; text-align: center; }
.qr-box svg { width: 220px; height: 220px; background: #fff; border: 1px solid var(--rahmen); border-radius: var(--radius); padding: 8px; }
.qr-box .qr-datum { font-size: .8rem; color: var(--text-leise); margin-top: 6px; }
.qr-info { flex: 1 1 320px; min-width: 0; }
.qr-link { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; background: var(--flaeche-2); }
.qr-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.qr-row.ende { align-items: flex-end; }
.qr-toggles label { display: flex; gap: 8px; align-items: center; padding: 5px 0; }
@media print {
    body * { visibility: hidden; }
    .qr-print, .qr-print * { visibility: visible; }
    .qr-print { position: absolute; left: 0; top: 0; width: 100%; text-align: center; }
    .qr-print svg { width: 320px; height: 320px; border: none; }
}

/* --- Mobil ------------------------------------------------------------- */
@media (max-width: 768px) {
    .lab-aktion {
        position: sticky; bottom: 0; z-index: 10;
        margin: .6rem calc(var(--abstand) * -1) calc(var(--abstand) * -1);
        padding: .7rem var(--abstand);
        border-top: 1px solid var(--rahmen);
        background: var(--flaeche);
        box-shadow: 0 -2px 10px rgba(20, 30, 45, .08);
    }
    .lab-kopf input, .lab-kopf select,
    .lab-ist, .lab-mass, .lab-bem { min-height: 2.75rem; }
    .lab-item { padding: .65rem 0; }
    .prot-akt .btn-klein { padding: .5rem .75rem; font-size: .9rem; }
    .prot-zeile { padding: .7rem 0; }
    .prot-tagnav-d { flex: 1; }
}
@media (max-width: 640px) {
    .lab-karten, .lab-titems, .lab-zk-grid { grid-template-columns: 1fr; }
    .lab-ist, .t-ist, .t-avg { width: 5.5rem; }
}


/* =======================================================================
 *  MODUL: Lagerverwaltung  (zentralisiert aus modules/lagerverwaltung/views/_lager_ui.php)
 * ===================================================================== */
* genau einmal pro Seitenaufruf aus.
 */
if (!defined('APP')) { http_response_code(403); exit('Direktaufruf nicht erlaubt.'); }
if (!empty($GLOBALS['__lager_ui_css'])) { return; }
$GLOBALS['__lager_ui_css'] = true;
?>
<style>
.etikett { display: flex; gap: 1.2rem; align-items: flex-start; border: 2px solid var(--rahmen); border-radius: var(--radius); padding: 1rem 1.2rem; max-width: 520px; background: #fff; }
.etikett-qr { flex: none; width: 150px; }
.etikett-qr svg { width: 150px; height: 150px; display: block; }
.etikett-text { min-width: 0; }
.etikett-name { font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.etikett-lief { color: var(--text-leise); margin-bottom: .4rem; }
.etikett-tab { border-collapse: collapse; margin: .2rem 0; }
.etikett-tab td { padding: .15rem .5rem .15rem 0; vertical-align: top; }
.etikett-tab td:first-child { color: var(--text-leise); }
.etikett-ghs { margin: .4rem 0; }
.etikett-code { margin-top: .4rem; font-size: .9rem; }
.etikett-code span { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.etikett-url { font-size: .72rem; color: var(--text-leise); word-break: break-all; margin-top: .15rem; }
.etikett-hinweis { max-width: 520px; }

/* --- Scan-Entnahme (mobil) -------------------------------------------- */
.scan-karte { max-width: 480px; }
.scan-chem { font-size: 1.3rem; font-weight: 800; }
.scan-meta { color: var(--text-leise); margin: .2rem 0 .5rem; }
.scan-bestand { display: flex; align-items: baseline; justify-content: space-between; margin: .8rem 0; padding: .6rem .8rem; background: var(--flaeche-2); border-radius: var(--radius-s); }
.scan-bestand-label { color: var(--text-leise); }
.scan-bestand-wert { font-size: 1.4rem; font-weight: 800; }
.scan-leer { color: var(--gefahr); }
.scan-form { display: flex; flex-direction: column; gap: .8rem; }
.scan-form input[type="text"] { font-size: 1.05rem; }
.scan-voll { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.btn-gross { font-size: 1.1rem; padding: .8rem 1rem; width: 100%; }

/* --- Verbraucher / Verbrauch ------------------------------------------ */
.vb-textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; }
.vb-filter { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.vb-filter .feld { flex: 1 1 12rem; }
.vb-filter .formular-aktion { flex: 0 0 auto; margin: 0; }
.vb-gruppe h3 { margin: 0 0 .5rem; }
.vb-ohne { color: var(--text-leise); font-style: italic; font-weight: 600; }
.vb-tabelle { width: 100%; border-collapse: collapse; }
.vb-tabelle td { padding: .35rem 0; border-top: 1px solid var(--rahmen); }
.vb-tabelle tr:first-child td { border-top: 0; }
.vb-menge { text-align: right; font-weight: 700; white-space: nowrap; }

/* --- Wareneingang: Aufteilung ----------------------------------------- */
.we-pool { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; cursor: pointer; }
.we-summe { margin: .2rem 0 0; min-height: 1.1em; }
.feld.eng { flex: 0 0 8rem; }

/* --- Druck (Etikett) --------------------------------------------------- */
@media print {
    .no-print { display: none !important; }
    body * { visibility: hidden; }
    .etikett-print, .etikett-print * { visibility: visible; }
    .etikett-print { position: absolute; left: 0; top: 0; }
    .etikett { border-color: #000; }
}


/* =======================================================================
 *  MODUL: Tool / Rechner / Konfigurator  (zentralisiert aus modules/tool/views/_tool_ui.php)
 * ===================================================================== */
genau einmal pro Seite aus.
 */
if (!defined('APP')) { http_response_code(403); exit('Direktaufruf nicht erlaubt.'); }
if (!empty($GLOBALS['__tool_ui_css'])) { return; }
$GLOBALS['__tool_ui_css'] = true;
?>
<style>
/* --- Rechner-Layout (Eingabe links, Ergebnisse rechts) ----------------- */
.tool-rechner { margin-top: 1rem; }
.tr-spalten { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .tr-spalten { grid-template-columns: 3fr 2fr; align-items: start; } }

.tr-block { border: 1px solid var(--rahmen); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; background: var(--flaeche); }
.tr-block-kopf { background: var(--flaeche-2); padding: .65rem 1rem; font-weight: 700; color: var(--akzent);
    border-bottom: 1px solid var(--rahmen); font-size: .95rem; }

/* Eingabe-Zeile */
.tr-zeile { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; border-bottom: 1px solid var(--rahmen); }
.tr-zeile:last-child { border-bottom: none; }
.tr-label { flex: 1; font-size: .95rem; }
.tr-einheit { width: 90px; text-align: right; color: var(--text-leise); font-size: .85rem; }
.tr-input { width: 150px; }
.tr-input input, .tr-input select { width: 100%; }

/* Ergebnis-Zeile */
.tr-erg { display: flex; align-items: center; gap: .75rem; padding: .55rem 1rem; border-bottom: 1px solid var(--rahmen); }
.tr-erg:last-child { border-bottom: none; }
.tr-erg.highlight { background: var(--akzent-bg); border-left: 4px solid var(--akzent); padding-left: calc(1rem - 4px); }
.tr-erg-label { flex: 1; font-size: .95rem; font-weight: 600; }
.tr-erg-einheit { width: 90px; text-align: right; color: var(--text-leise); font-size: .85rem; }
.tr-erg-wert { width: 130px; text-align: right; font-size: 1.25rem; font-weight: 800; color: var(--akzent); white-space: nowrap; }

/* Charge-Energie-Balken */
.tr-bars { padding: .75rem 1rem; }
.tr-bar { display: flex; height: 26px; border-radius: var(--radius-s); overflow: hidden; border: 1px solid var(--rahmen); }
.tr-bar-seg { width: var(--bar, 0); display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem; font-weight: 700;
    transition: width .2s ease; min-width: 0; overflow: hidden; }
.tr-bar-seg.ofen { background: var(--akzent); }
.tr-bar-seg.charge { background: #2e9e5b; }
.tr-bar-legende { display: flex; gap: 1.2rem; margin-top: .5rem; font-size: .82rem; color: var(--text-leise); }
.tr-bar-legende span::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: .35rem; vertical-align: baseline; }
.tr-bar-legende .lg-ofen::before { background: var(--akzent); }
.tr-bar-legende .lg-charge::before { background: #2e9e5b; }

/* Belegungs-Canvas */
.tr-canvas-wrap { padding: 1rem; }
.tr-canvas-wrap canvas { width: 100%; height: auto; border: 1px solid var(--rahmen); border-radius: var(--radius-s); background: var(--bg); }

/* Speichern-Leiste + gespeicherte Liste */
.tr-save { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding: 1rem; }
.tr-save .feld { margin: 0; }
.tr-save .feld.titel { flex: 1; min-width: 180px; }
.tr-save .feld.notiz { flex: 2; min-width: 200px; }
.tool-liste-leer { color: var(--text-leise); font-style: italic; padding: .5rem 0; }
.tr-aktiv-zeile { background: var(--akzent-bg); }
.tabelle .num, .tabelle th.num { text-align: right; }

/* --- Vorbehandlung: Einsparungsbanner + Vergleich ---------------------- */
.vb-banner { display: grid; grid-template-columns: 1fr; gap: 1rem; margin: 1rem 0; }
@media (min-width: 760px) { .vb-banner { grid-template-columns: 220px 1fr; align-items: stretch; } }
.vb-banner-haupt { border: 1px solid var(--akzent); border-radius: var(--radius); background: var(--akzent-bg);
    padding: 1rem 1.2rem; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.vb-banner-lbl { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise); }
.vb-banner-val { font-size: 1.9rem; font-weight: 800; color: var(--akzent); line-height: 1.15; margin-top: .2rem; }
.vb-banner-pct { font-size: 1.1rem; font-weight: 700; color: var(--text-leise); }
.vb-banner-tab { margin: 0; }
.vb-vg-einheit { color: var(--text-leise); font-size: .82rem; }
.vb-vg-gesamt td { font-weight: 800; border-top: 2px solid var(--rahmen); }

/* --- Vorbehandlung: Szenario-Umschalter + Becken-Tabs ------------------ */
.vb-scen-bar { display: flex; gap: .5rem; margin: 1rem 0 .75rem; }
.vb-scen-btn { flex: 1; padding: .7rem; border: 1px solid var(--rahmen); border-radius: var(--radius-s);
    background: var(--flaeche); color: var(--text-leise); font: inherit; font-weight: 700; cursor: pointer; }
.vb-scen-btn.active { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.vb-tabbar { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .75rem; }
.vb-tab { padding: .5rem .9rem; border: 1px solid var(--rahmen); border-radius: var(--radius-s);
    background: var(--flaeche-2); color: var(--text-leise); font: inherit; font-size: .9rem; cursor: pointer; }
.vb-tab.active { background: var(--flaeche); color: var(--akzent); border-color: var(--akzent); font-weight: 700; }

/* --- Konfigurator (Baukasten) ----------------------------------------- */
.kfg-viewtabs { display: flex; flex-wrap: wrap; gap: .3rem; margin: 1rem 0; border-bottom: 2px solid var(--rahmen); }
.kfg-vtab { background: var(--flaeche-2); border: 1px solid var(--rahmen); border-bottom: none; color: var(--text-leise);
    font: inherit; font-weight: 600; padding: .6rem 1.1rem; border-radius: var(--radius-s) var(--radius-s) 0 0; cursor: pointer; margin-bottom: -2px; }
.kfg-vtab.active { background: var(--flaeche); color: var(--akzent); border-bottom: 2px solid var(--flaeche); }
.kfg-kammer { border: 1px solid var(--rahmen); border-radius: var(--radius); margin: 0 1rem 1rem; background: var(--flaeche-2); overflow: hidden; }
.kfg-kammer-head { display: flex; align-items: center; justify-content: space-between; background: var(--akzent-bg); padding: .5rem .9rem; }
.kfg-kammer-titel { font-weight: 700; color: var(--akzent); }
.kfg-schritt { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem .9rem; border-top: 1px solid var(--rahmen); background: var(--flaeche); }
.kfg-nr { width: 22px; height: 22px; border-radius: 50%; background: var(--akzent); color: #fff; font-size: .8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.kfg-badge { font-size: .8rem; font-weight: 700; padding: .15rem .5rem; border-radius: 4px; }
.kfg-badge.akt { background: var(--akzent); color: #fff; }
.kfg-badge.spu { background: var(--flaeche-2); color: var(--akzent); border: 1px solid var(--akzent); }
.kfg-badge.spk { background: #e3f0d6; color: #3d6b1f; }
.kfg-opt { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-size: .85rem; color: var(--text-leise); }
.kfg-temp, .kfg-stufen { width: 64px; text-align: right; }
.kfg-chk { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; }
.kfg-schritt-btns { margin-left: auto; display: flex; gap: .25rem; }
.kfg-mv, .kfg-x { border: 1px solid var(--rahmen); background: var(--flaeche); cursor: pointer; border-radius: var(--radius-s); color: var(--text-leise); width: 28px; height: 28px; line-height: 1; }
.kfg-mv:hover, .kfg-x:hover { border-color: var(--akzent); color: var(--akzent); }
.kfg-add-row { display: flex; gap: .5rem; flex-wrap: wrap; padding: .7rem .9rem; border-top: 1px solid var(--rahmen); background: var(--flaeche); }
.kfg-add-row button { border: 1px dashed var(--akzent); background: var(--flaeche); color: var(--akzent); font: inherit; font-weight: 600; padding: .4rem .8rem; border-radius: var(--radius-s); cursor: pointer; }
.kfg-add-kammer { width: 100%; justify-content: center; }
.kfg-leer { padding: .9rem; text-align: center; color: var(--text-leise); font-style: italic; }
.kfg-ein-becken { border: 1px solid var(--rahmen); border-radius: var(--radius); margin: .5rem 1rem; overflow: hidden; }
.kfg-ein-bhead { display: flex; align-items: center; gap: .4rem; background: var(--flaeche-2); padding: .5rem .9rem; border-bottom: 1px solid var(--rahmen); font-weight: 600; }
.kfg-ein-sub { font-size: .8rem; font-weight: 700; color: var(--akzent); text-transform: uppercase; letter-spacing: .04em; padding: .5rem .9rem .2rem; border-top: 1px solid var(--rahmen); }
.kfg-tag-nr { font-size: .75rem; font-weight: 700; background: #e8a317; color: #fff; padding: .1rem .4rem; border-radius: 3px; }
.kfg-locked { background: var(--flaeche-2) !important; color: var(--text-leise) !important; cursor: not-allowed; }
.kfg-din { width: 100%; }
.kfg-erg-block { border: 1px solid var(--rahmen); border-radius: var(--radius); margin: 0 1rem 1rem; overflow: hidden; }
.kfg-erg-head { background: var(--akzent-bg); color: var(--akzent); font-weight: 700; padding: .5rem .9rem; }
.kfg-erg-tab { width: 100%; border-collapse: collapse; }
.kfg-erg-tab td { padding: .4rem .9rem; border-bottom: 1px solid var(--rahmen); }
.kfg-erg-tab tr:last-child td { border-bottom: none; }
.kfg-erg-wert { text-align: right; font-weight: 700; white-space: nowrap; }
.kfg-erg-einheit { color: var(--text-leise); width: 60px; font-size: .85rem; }
.kfg-erg-trenn td { background: var(--flaeche-2); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise); font-size: .8rem; }
.kfg-erg-summe td { background: var(--akzent-bg); font-weight: 800; color: var(--akzent); }
.kfg-erg-gesamt { border-color: var(--akzent); border-width: 2px; }
.kfg-erg-gesamt .kfg-erg-head { background: var(--akzent); color: #fff; }
.kfg-massn-body { padding: .3rem .9rem .9rem; }
.kfg-massn { padding: .6rem 0; border-bottom: 1px dashed var(--rahmen); }
.kfg-massn:last-child { border-bottom: none; }
.kfg-massn-off { opacity: .6; }
.kfg-massn-det { margin: .35rem 0 0 1.6rem; font-size: .9rem; color: var(--text-leise); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.kfg-massn-det .kfg-temp { width: 70px; }
.kfg-erg-kopf td { background: var(--flaeche-2); font-weight: 700; font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-leise); text-align: right; }
.kfg-erg-kopf td:first-child { text-align: left; }
.kfg-erg-ersp { color: var(--ok); font-weight: 800; }
.kfg-hinweis { margin: 0 1rem 1rem; padding: .6rem .9rem; background: var(--akzent-bg); color: var(--akzent); border-radius: var(--radius-s); font-size: .9rem; }


/* =======================================================================
 *  MODUL: Dateimanager  (zentralisiert aus modules/dateimanager/views/_dm_ui.php)
 * ===================================================================== */
genau einmal pro Seitenaufruf aus.
 */
if (!defined('APP')) { http_response_code(403); exit('Direktaufruf nicht erlaubt.'); }
if (!empty($GLOBALS['__dm_ui_css'])) { return; }
$GLOBALS['__dm_ui_css'] = true;
?>
<style>
/* Alle früheren Regeln (Abschnittskopf, neu-form, Listen-Karten, Icons,
   Datei-Vorschau/Import, Kategorie-Titel) sind jetzt zentral in app.css.
   Der Dateimanager hat aktuell kein eigenes, nur hier benötigtes Styling. */


/* =======================================================================
 *  Utilities, die frühere Inline-Styles in den Views ersetzen
 * ===================================================================== */
/* Einzug nach Baumtiefe (Menü-/Rechte-/Seiten-Editor) – statt Inline-Padding */
.tief-1 { padding-left: 16px; } .tief-2 { padding-left: 32px; }
.tief-3 { padding-left: 48px; } .tief-4 { padding-left: 64px; }
.tief-5 { padding-left: 80px; } .tief-6 { padding-left: 96px; }
.tief-7 { padding-left: 112px; } .tief-8 { padding-left: 128px; }
/* schmale Zahl-Eingabe (z. B. Sortier-Spalte in Editor-Tabellen) */
.w-num { width: 5rem; min-width: 4rem; }
/* datengetriebene Werte: View liefert nur die Zahl/Farbe per CSS-Variable */
.bar-fuell { width: var(--bar, 0); }
.farbe-bg  { background: var(--c); }
.farbe-fg  { color: var(--c); }

/* ------------------------------------------------------------------ *
 *  Modul-Unternavigation (Reiter je Modul, lib/unternav.php)
 * ------------------------------------------------------------------ */
.modul-unternav {
    display: flex; flex-wrap: wrap; gap: .35rem;
    margin: 0 0 1.1rem; padding: 0 0 .6rem;
    border-bottom: 1px solid var(--rahmen);
}
.modul-unternav .un-tab {
    display: inline-flex; align-items: center; padding: .38rem .85rem;
    border: 1px solid transparent; border-radius: 999px;
    background: transparent; color: var(--text-leise);
    text-decoration: none; font-size: .9rem; line-height: 1; white-space: nowrap;
    transition: background .12s, color .12s;
}
.modul-unternav .un-tab:hover {
    background: var(--flaeche-2); color: var(--text); text-decoration: none;
}
.modul-unternav .un-tab.un-aktiv {
    background: var(--akzent); border-color: var(--akzent); color: #fff; font-weight: 600;
}
/* Mobile: horizontal scrollbar statt Umbruch, damit die Leiste kompakt bleibt. */
@media (max-width: 640px) {
    .modul-unternav {
        flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
        gap: .3rem; scrollbar-width: thin;
    }
    .modul-unternav .un-tab { flex: 0 0 auto; }
}

/* ------------------------------------------------------------------ *
 *  Brotkrumen (Breadcrumbs, lib/unternav.php)
 * ------------------------------------------------------------------ */
.brotkrumen {
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem;
    margin: 0 0 .7rem; font-size: .82rem; color: var(--text-leise);
}
.brotkrumen .bk-glied { color: var(--text-leise); text-decoration: none; }
.brotkrumen .bk-glied:hover { color: var(--akzent); text-decoration: underline; }
.brotkrumen .bk-sep { color: var(--text-leise); opacity: .6; }
.brotkrumen .bk-akt { color: var(--text); font-weight: 600; }

/* ================================================================== *
 *  Fokus-Modus – nacktes, touch-freundliches Layout für mobile
 *  Arbeitstätigkeiten (Scannen, Buchen/Abbuchen, QR).  lib/fokus.php
 * ================================================================== */
body.fokus {
    background: var(--bg);
    /* Kein Chrome: keine Sidebar/Topbar/Footer/Tabbar im Fokus-Modus. */
}
.fokus-inhalt {
    max-width: 34rem;
    margin: 0 auto;
    padding: 1.1rem 1rem 3rem;
    min-height: 100vh;
    box-sizing: border-box;
}
/* Grosse, gut lesbare Überschrift der Aufgabe. */
.fokus-inhalt h1,
.fokus-inhalt .seiten-kopf h1 { font-size: 1.4rem; margin: .2rem 0 1rem; }

/* Touch-Ziele grosszügig: Knöpfe und Eingaben mindestens ~3.2rem hoch. */
.fokus-inhalt .btn {
    min-height: 3.2rem; padding: .9rem 1.2rem; font-size: 1.05rem; border-radius: var(--radius);
}
.fokus-inhalt .btn-voll { width: 100%; }
.fokus-inhalt input[type="text"],
.fokus-inhalt input[type="number"],
.fokus-inhalt input[type="search"],
.fokus-inhalt input[type="date"],
.fokus-inhalt select,
.fokus-inhalt textarea {
    min-height: 3.2rem; font-size: 1.05rem; padding: .7rem .85rem;
}
/* Etwas mehr Luft zwischen Formularfeldern für dicke Finger. */
.fokus-inhalt .feld { margin-bottom: 1rem; }
.fokus-inhalt .karte { padding: 1.1rem; }

/* Schliessen-Knopf oben rechts – zurück in den normalen Bereich. */
.fokus-exit {
    position: fixed; top: .6rem; right: .6rem; z-index: 50;
    width: 2.6rem; height: 2.6rem; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; line-height: 1; text-decoration: none;
    background: var(--flaeche); color: var(--text-leise);
    border: 1px solid var(--rahmen); box-shadow: var(--schatten);
}
.fokus-exit:hover { background: var(--flaeche-2); color: var(--text); text-decoration: none; }

/* Auf sehr kleinen Geräten randlos und noch grösser. */
@media (max-width: 480px) {
    .fokus-inhalt { padding: .9rem .8rem 3rem; }
    .fokus-inhalt .karte { padding: .9rem; border-radius: var(--radius); }
}

/* ------------------------------------------------------------------ *
 *  Firmenlogo (Branding, lib/branding.php)
 * ------------------------------------------------------------------ */
/* Login-Seite: Logo statt Titel */
.auth-logo { text-align: center; margin: 0 0 1rem; }
.auth-logo img { max-width: 100%; max-height: 96px; height: auto; object-fit: contain; }
/* Menü-Topbar: Logo in der Marke */
.marke-logo { max-height: 34px; width: auto; display: block; object-fit: contain; }
/* Einstellungen: Vorschau des aktuellen Logos */
.branding-vorschau {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .7rem 1rem; margin: .3rem 0 .8rem;
    background: var(--flaeche-2); border: 1px solid var(--rahmen); border-radius: var(--radius);
}
.branding-vorschau img { max-height: 72px; max-width: 260px; width: auto; object-fit: contain; }
