:root {
    --bg: #f5f3ee;
    --karte: #ffffff;
    --text: #1f2a27;
    --leise: #5d6b66;
    --rand: #e2ded5;
    --primaer: #2f6f5e;
    --primaer-hover: #255a4c;
    --ok-bg: #e3f3ea;
    --ok-text: #1e6440;
    --warte-bg: #fdf1dc;
    --warte-text: #8a5a0b;
    --aus-bg: #eeecE7;
    --aus-text: #6b6a66;
    --fehler-bg: #fbe5e3;
    --fehler-text: #9b2c22;
    --radius: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151b19;
        --karte: #1f2724;
        --text: #e8ece9;
        --leise: #9fb0aa;
        --rand: #2f3a36;
        --primaer: #5fb39a;
        --primaer-hover: #74c4ab;
        --ok-bg: #1d3a2c;
        --ok-text: #9be0b8;
        --warte-bg: #3d3018;
        --warte-text: #f2c878;
        --aus-bg: #2a302e;
        --aus-text: #a8b0ad;
        --fehler-bg: #472420;
        --fehler-text: #f5aaa2;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
pre { white-space: pre-wrap; }

.kopf {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--karte);
    border-bottom: 1px solid var(--rand);
}
.marke { font-weight: 700; color: var(--text); text-decoration: none; }
.konto { display: flex; align-items: center; gap: .5rem; }
.konto form { margin: 0; }
.konto-name { color: var(--leise); font-size: .9rem; }

.inhalt { max-width: 640px; margin: 0 auto; padding: 1rem 1rem 3rem; display: flex; flex-direction: column; gap: 1rem; }

.karte {
    background: var(--karte);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
}

.klein { font-size: .85rem; color: var(--leise); }

/* Tageskopf */
.tageskopf { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }
.datum { margin: .1rem 0 0; color: var(--leise); }
.kennzahlen { display: flex; gap: .5rem; }
.kennzahl {
    display: flex; flex-direction: column; align-items: center;
    min-width: 4.5rem; padding: .4rem .6rem;
    background: var(--karte); border: 1px solid var(--rand); border-radius: 10px;
    font-size: .75rem; color: var(--leise);
}
.kennzahl .zahl { font-size: 1.4rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.hinweis { font-size: .9rem; color: var(--leise); padding: .6rem .9rem; border-left: 3px solid var(--rand); }
.hinweis.final { border-left-color: var(--primaer); color: var(--text); font-weight: 600; }

.meldung { padding: .7rem .9rem; border-radius: 10px; font-size: .95rem; }
.meldung.ok { background: var(--ok-bg); color: var(--ok-text); }
.meldung.fehler { background: var(--fehler-bg); color: var(--fehler-text); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    min-height: 44px; padding: .55rem 1rem;
    border: 1px solid transparent; border-radius: 10px;
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primaer { background: var(--primaer); color: #fff; }
.btn-primaer:hover:not(:disabled) { background: var(--primaer-hover); }
.btn-sekundaer { background: transparent; color: var(--text); border-color: var(--rand); }
.btn-gefahr { background: var(--fehler-text); color: #fff; }
.btn-link { background: none; color: var(--primaer); padding-inline: .25rem; min-height: 0; }
.btn-whatsapp { background: #25d366; color: #0b3d1f; }
.btn-breit { width: 100%; }
.btn-rund { width: 44px; padding: 0; background: transparent; border-color: var(--rand); color: var(--text); font-size: 1.3rem; }

.zeile { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* Pills & Badges */
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.warte { background: var(--warte-bg); color: var(--warte-text); }
.pill.aus { background: var(--aus-bg); color: var(--aus-text); font-weight: 500; }
.kind-badge {
    display: inline-block; min-width: 2.6rem; padding: .1rem .45rem;
    border-radius: 8px; background: var(--aus-bg); color: var(--text);
    font-weight: 700; text-align: center; letter-spacing: .03em;
}
.kind-badge.gross { font-size: 1rem; vertical-align: middle; }
.status-zeile { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; }

/* Kinderliste */
.kinderliste { list-style: none; padding: 0; margin: 0; }
.kinderliste li {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
    padding: .55rem .25rem; border-top: 1px solid var(--rand);
}
.kinderliste li:first-child { border-top: none; }
.kinderliste li.eigenes { background: color-mix(in srgb, var(--primaer) 8%, transparent); border-radius: 8px; padding-inline: .5rem; }
.kind-status { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.fairness { font-size: .8rem; color: var(--leise); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Kapazität */
.kapazitaet input[type=number] {
    width: 5rem; min-height: 44px; text-align: center; font: inherit; font-size: 1.3rem; font-weight: 700;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--bg); color: var(--text);
}

/* Finalisierung */
.listentext {
    margin: 0 0 .75rem; padding: .8rem; border-radius: 10px;
    background: var(--bg); border: 1px solid var(--rand); font-family: inherit; font-size: .95rem;
}

/* Protokoll */
.protokoll summary { cursor: pointer; font-weight: 600; }
.protokoll ul { list-style: none; padding: 0; margin: .75rem 0 0; font-size: .9rem; }
.protokoll li { padding: .3rem 0; border-top: 1px solid var(--rand); }
.protokoll .zeit { font-variant-numeric: tabular-nums; color: var(--leise); margin-right: .4rem; }

/* Login */
.login { max-width: 380px; margin: 2rem auto 0; width: 100%; }
.login form { display: flex; flex-direction: column; gap: .35rem; margin-top: 1rem; }
.login label { font-weight: 600; font-size: .9rem; margin-top: .5rem; }
.login input {
    min-height: 44px; padding: .5rem .7rem; font: inherit;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--bg); color: var(--text);
}
.login button { margin-top: 1rem; }
.validation-message { color: var(--fehler-text); font-size: .85rem; }

#blazor-error-ui {
    background: var(--fehler-bg); color: var(--fehler-text);
    bottom: 0; left: 0; right: 0; display: none; position: fixed;
    padding: .75rem 1.25rem; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Liste bearbeiten (Admin) */
.bearbeiten summary { cursor: pointer; font-weight: 600; }
.bearbeiten[open] summary { margin-bottom: .5rem; }
.bearbeiten-liste { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.bearbeiten-liste li {
    display: grid; grid-template-columns: 1.6rem auto 1fr auto; align-items: center; gap: .5rem;
    padding: .35rem .25rem; border-top: 1px solid var(--rand);
}
.bearbeiten-liste li:first-child { border-top: none; }
.bearbeiten-liste .nr { color: var(--leise); font-variant-numeric: tabular-nums; text-align: right; }
.bearbeiten-liste li.warte .kind-badge { background: var(--warte-bg); color: var(--warte-text); }
.bearbeiten-liste li.ok .kind-badge { background: var(--ok-bg); color: var(--ok-text); }
.bearbeiten-liste li.grenze { display: block; border-top: 2px dashed var(--primaer); padding: 0; margin-top: .2rem; }
.bearbeiten-liste li.grenze span {
    display: inline-block; position: relative; top: -.7rem; left: 1rem; padding: 0 .4rem;
    background: var(--karte); color: var(--primaer); font-size: .75rem; font-weight: 600;
}
.bearbeiten-liste li.grenze + li { border-top: none; }
.aktionen { display: flex; gap: .25rem; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; background: transparent; border-color: var(--rand); color: var(--text); font-size: 1.05rem; }
.btn-klein { min-height: 36px; padding: .3rem .6rem; font-size: .85rem; }
.hinzufuegen select {
    min-height: 44px; padding: .4rem .6rem; font: inherit; flex: 1;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--bg); color: var(--text);
}
.fairness { display: flex; flex-direction: column; align-items: flex-end; }
.fairness .heute { color: var(--ok-text); font-weight: 600; }

/* Navigation */
.konto { flex-wrap: wrap; justify-content: flex-end; }
.konto-nav { display: flex; gap: .75rem; font-size: .9rem; }
.konto-nav a { color: var(--primaer); text-decoration: none; font-weight: 600; }

/* Benutzerverwaltung */
.benutzerliste { list-style: none; padding: 0; margin: 0 0 .5rem; }
.benutzerliste li {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .4rem .6rem;
    grid-template-areas: "badge name aktionen" "badge rolle aktionen";
    padding: .55rem .1rem; border-top: 1px solid var(--rand);
}
.benutzerliste .kind-badge { grid-area: badge; align-self: start; margin-top: .15rem; }
.benutzerliste .benutzer-name { grid-area: name; font-weight: 600; }
.benutzerliste .auswahl { grid-area: rolle; display: flex; flex-wrap: wrap; gap: .4rem; }
.benutzerliste .rolle-select { min-width: 9.5rem; }
.benutzerliste .gruppe-select { min-width: 8rem; }
.benutzerliste .aktionen { grid-area: aktionen; }
.benutzerliste li:first-child { border-top: none; }
.benutzer-name { overflow-wrap: anywhere; }
.benutzerliste select, .neuer-benutzer input, .neuer-benutzer select {
    min-height: 40px; padding: .35rem .5rem; font: inherit;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--bg); color: var(--text);
}
.formular-raster { display: grid; grid-template-columns: 1fr; gap: .3rem; margin-bottom: .5rem; }
.formular-raster label { font-weight: 600; font-size: .9rem; margin-top: .4rem; }
.passwort-feld { flex: 1; font-family: ui-monospace, monospace; }
.passwort-anzeige {
    font-size: 1.2rem; padding: .4rem .7rem; border-radius: 8px; background: var(--bg);
    border: 1px solid var(--rand); letter-spacing: .04em; user-select: all;
}

/* Gruppen & Kontingente */
.pill.normal { background: var(--ok-bg); color: var(--ok-text); font-weight: 500; }
.gruppe-badge {
    display: inline-block; padding: .05rem .45rem; border-radius: 6px; font-size: .75rem; font-weight: 600;
    border: 1px solid var(--rand); color: var(--leise); vertical-align: middle;
}
.anmeldung h2 .gruppe-badge { font-size: .8rem; margin-left: .3rem; }
.hinweis.einstellung { border-left-color: var(--primaer); color: var(--text); }
.abschnitt-titel {
    display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
    font-size: .95rem; margin: 1rem 0 .3rem; padding-bottom: .25rem; border-bottom: 2px solid var(--rand);
}
.abschnitt-titel:first-of-type { margin-top: .25rem; }
.abschnitt-titel.normal { color: var(--ok-text); }
.bearbeiten-liste li.normal .kind-badge { background: var(--ok-bg); color: var(--ok-text); }

.gruppenliste { list-style: none; padding: 0; margin: 0 0 .5rem; }
.gruppenliste li {
    display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .6rem;
    padding: .45rem .1rem; border-top: 1px solid var(--rand);
}
.gruppenliste li:first-child { border-top: none; }
.gruppenliste form { grid-column: 1 / -1; }
.gruppen-name { font-weight: 600; }
.gruppen input, .gruppe-eingabe {
    min-height: 40px; padding: .35rem .6rem; font: inherit; flex: 1;
    border: 1px solid var(--rand); border-radius: 10px; background: var(--bg); color: var(--text);
}

.vorlagen { margin-bottom: .5rem; }
.kontingent-editor {
    border: 1px solid var(--rand); border-radius: 12px; padding: .7rem .8rem; margin-bottom: .6rem; background: var(--bg);
}
.kontingent-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.gruppen-auswahl { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-bottom: .6rem; }
.gruppen-auswahl label { display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; font-weight: 600; }
.gruppen-auswahl label.belegt { color: var(--leise); font-weight: 400; text-decoration: line-through; }
.gruppen-auswahl input { width: 1.2rem; height: 1.2rem; accent-color: var(--primaer); }
.kontingent-editor input[type=number] { background: var(--karte); }
.normalbetrieb-hinweis { color: var(--ok-text); margin: .2rem 0 0; }
.speichern { margin-top: .6rem; }

/* Tier-Icons der Gruppen (Igel, Eule) */
.gruppen-icon { width: 1.35em; height: 1.35em; vertical-align: -0.3em; flex: none; }
.gruppen-icon.gross { width: 1.9em; height: 1.9em; vertical-align: -0.55em; margin-right: .35rem; }
.gruppe-badge .gruppen-icon { width: 1.25em; height: 1.25em; margin-right: .2rem; vertical-align: -0.35em; }
.titel-mit-icons { display: inline-flex; align-items: center; gap: .3rem; }
.gruppen-auswahl label .gruppen-icon { width: 1.5em; height: 1.5em; }

/* Icon-Auswahl beim Anlegen/Bearbeiten einer Gruppe */
.gruppe-formular { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; width: 100%; }
.gruppe-formular .gruppe-eingabe { width: 100%; }
.neue-gruppe { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--rand); }
.neue-gruppe h3 { margin: 0; font-size: .95rem; }
.tier-auswahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: .35rem; width: 100%; }
.tier-knopf {
    display: flex; align-items: center; justify-content: center; aspect-ratio: 1; min-height: 44px; padding: .25rem;
    border: 2px solid var(--rand); border-radius: 12px; background: var(--bg); cursor: pointer;
}
.tier-knopf .gruppen-icon { width: 30px; height: 30px; vertical-align: middle; }
.tier-knopf:hover:not(:disabled) { border-color: var(--primaer); }
.tier-knopf.gewaehlt { border-color: var(--primaer); background: color-mix(in srgb, var(--primaer) 16%, var(--karte)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primaer) 35%, transparent); }
.tier-knopf:disabled { opacity: .5; cursor: not-allowed; }
.tier-keins { font-size: 1.2rem; color: var(--leise); }
.neue-gruppe button[type=submit] .gruppen-icon { width: 1.3em; height: 1.3em; }

/* Icon-Auswahl mit Kategorien */
.icon-auswahl { display: flex; flex-direction: column; gap: .5rem; width: 100%; }
.icon-kategorien { display: flex; flex-wrap: wrap; gap: .35rem; }
.kategorie-knopf {
    display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; min-height: 36px; padding: .25rem .65rem;
    border: 1px solid var(--rand); border-radius: 999px; background: var(--karte); color: var(--text);
    font: inherit; font-size: .82rem; cursor: pointer;
}
.kategorie-knopf .gruppen-icon { width: 1.2em; height: 1.2em; vertical-align: middle; }
.kategorie-knopf.aktiv { border-color: var(--primaer); background: color-mix(in srgb, var(--primaer) 16%, var(--karte)); font-weight: 600; }
img.gruppen-icon { display: inline-block; object-fit: contain; }
.hinweis.vorlage-hinweis { border-left-color: var(--primaer); margin: .25rem 0 .75rem; }
.kind-badge.ohne-kind { background: transparent; color: var(--leise); }

/* Toast: Rückmeldungen unten am Bildschirm */
.toast-bereich {
    position: fixed; left: 0; right: 0; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 60;
    display: flex; justify-content: center; padding: 0 1rem; pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: .6rem; width: 100%; max-width: 440px;
    padding: .6rem .5rem .6rem .9rem; border-radius: 12px; font-size: .95rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18); animation: toast-rein .2s ease-out;
}
.toast.ok { background: var(--ok-bg); color: var(--ok-text); border: 1px solid color-mix(in srgb, var(--ok-text) 25%, transparent); }
.toast.fehler { background: var(--fehler-bg); color: var(--fehler-text); border: 1px solid color-mix(in srgb, var(--fehler-text) 30%, transparent); }
.toast-text { flex: 1; }
.toast-schliessen { flex: none; color: inherit; border-color: transparent; }
@keyframes toast-rein { from { opacity: 0; transform: translateY(.75rem); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Dialog (z. B. neues Passwort) */
.dialog-hintergrund {
    position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.dialog {
    width: 100%; max-width: 420px; background: var(--karte); color: var(--text);
    border: 1px solid var(--rand); border-radius: var(--radius); padding: 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.dialog h2 { margin-top: 0; }
.dialog .passwort-anzeige { display: block; text-align: center; margin: .5rem 0 .75rem; font-size: 1.35rem; }
.dialog-knoepfe { justify-content: flex-end; margin-top: 1rem; }
.fehler-text { color: var(--fehler-text); }
