/* ============================================================================
   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, .06), 0 2px 8px rgba(20, 30, 45, .05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --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);
    }
}

/* --- Grundlagen --------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--schrift);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; 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 {
    background: var(--flaeche);
    border-bottom: 1px solid var(--rahmen);
}
.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: .4rem .6rem;
    border-radius: var(--radius-s);
    font-size: .95rem;
}
.haupt-nav a:hover { background: var(--flaeche-2); color: var(--text); text-decoration: none; }
.kopf-rechts { display: flex; align-items: center; gap: .6rem; }
.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-zahl { font-size: 2rem; font-weight: 700; line-height: 1; }
.kachel-label { color: var(--text-leise); font-size: .9rem; }

/* --- 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: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 ---------------------------------------------------------- */
.formular { display: flex; flex-direction: column; gap: var(--abstand); }
.formular.karte { padding: var(--abstand); max-width: 520px; }
.feld { display: flex; flex-direction: column; gap: .3rem; }
.feld-label { font-weight: 600; font-size: .92rem; }
.feld input, .feld select {
    font: inherit;
    color: var(--text);
    background: var(--flaeche);
    border: 1px solid var(--rahmen);
    border-radius: var(--radius-s);
    padding: .55rem .65rem;
    width: 100%;
}
.feld input:focus, .feld select:focus { border-color: var(--akzent); }
.feld input:disabled { background: var(--flaeche-2); color: var(--text-leise); }
.hilfe { color: var(--text-leise); font-size: .82rem; }
.feld-check { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }
.formular-aktion { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* --- 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 .9rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { background: var(--akzent-tf); border-color: var(--akzent-tf); text-decoration: none; }
.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; }

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

/* --- Kleine Bildschirme ------------------------------------------------- */
@media (max-width: 640px) {
    .kopf-inner { min-height: 0; padding: .6rem var(--abstand); }
    .benutzer-chip { text-align: left; }
    .inhalt { padding: var(--abstand); }
}

/* --- Daten-Engine: Suche, Blättern, Feldfehler ------------------------- */
.suchleiste { display: flex; gap: .5rem; margin-bottom: var(--abstand); max-width: 520px; }
.suchleiste input { flex: 1; }
.feld textarea {
    font: inherit; color: var(--text); background: var(--flaeche);
    border: 1px solid var(--rahmen); border-radius: var(--radius-s);
    padding: .55rem .65rem; width: 100%; resize: vertical;
}
.feld textarea:focus { border-color: var(--akzent); }
.feld-fehler { color: var(--gefahr); font-size: .82rem; font-weight: 600; }
.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); }

/* --- 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;
}

/* =========================================================================
   Modul-Editor (Etappe 3)
   ========================================================================= */
.badge-info { background: #e7f0ff; color: #1d4ed8; }

.btn-mini {
    padding: .1rem .35rem; font-size: .8rem; line-height: 1;
    min-width: 1.6rem;
}

.feld-hilfe { display: block; margin-top: .25rem; color: var(--farbe-text-schwach, #666); font-size: .85rem; }

.feld-check-zeile { flex-direction: row; align-items: center; gap: .5rem; }
.feld-check-zeile input { width: auto; }

.kopf-aktionen { display: inline-flex; gap: .5rem; flex-wrap: wrap; }

.formular-gefahr {
    margin-top: 1.5rem; padding: 1rem; border: 1px solid var(--farbe-gefahr, #c0392b);
    border-radius: var(--radius, 8px); background: #fff6f5;
}
.formular-gefahr small { display: block; margin-top: .5rem; color: var(--farbe-text-schwach, #666); }

.editor-modul { margin-bottom: 1.25rem; }
.editor-modul-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.editor-modul-kopf h2 { margin: 0; font-size: 1.15rem; }
.editor-modul-aktion { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.editor-beschr { color: var(--farbe-text-schwach, #666); margin: .35rem 0 .75rem; }

.editor-code {
    font-family: var(--font-mono, monospace); font-size: .82rem;
    background: var(--farbe-flaeche-2, #f1f1f4); padding: .05rem .35rem;
    border-radius: 4px; color: var(--farbe-text-schwach, #555);
}

.editor-entity-liste { list-style: none; margin: 0; padding: 0; }
.editor-entity {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .5rem 0; border-top: 1px solid var(--farbe-rand, #e6e6ea);
}
.editor-entity-name { font-weight: 600; text-decoration: none; }
.editor-entity-aktion { margin-left: auto; }

.editor-sort { white-space: nowrap; }
