/* ==========================================================================
   Laubenwerk – Design-System (M1)
   Eigenes CSS, kein Framework, kein Build-Schritt.
   Palette „Forest": Tiefgrün + warmes Bone, Bernstein nur für Warnungen.
   Radius-System: Karten 12px, Eingaben/Buttons 8px, Chips pill.
   ========================================================================== */

:root {
    /* Grün (Marke) */
    --gruen-950: #0e2018;
    --gruen-900: #143024;
    --gruen-800: #1a4230;
    --gruen-700: #1f5138;   /* Primärfarbe */
    --gruen-600: #2a6a49;
    --gruen-500: #3a8560;
    --gruen-100: #d9ecdf;
    --gruen-50:  #eef6f0;

    /* Neutrale (warmes Bone/Papier) */
    --papier:    #f7f6f2;   /* Seitenhintergrund */
    --flaeche:   #ffffff;   /* Karten/Flächen */
    --flaeche-2: #fbfaf7;   /* leicht abgesetzte Flächen */
    --linie:     #e4e1d8;   /* Rahmen/Trenner */
    --tinte:     #1d2621;   /* Text */
    --tinte-2:   #58655e;   /* Sekundärtext */
    --tinte-3:   #8b968f;   /* gedämpft (Meta, deaktiviert) */

    /* Semantik */
    --fehler:      #a13c2e;
    --fehler-bg:   #f9ece9;
    --bernstein:   #9a6a1f;
    --bernstein-bg:#f8f0e0;
    --erfolg:      #1f5138;
    --erfolg-bg:   #e7f2ea;

    /* Form */
    --radius:      12px;
    --radius-s:    8px;
    --radius-pill: 999px;

    /* Schatten – auf Hintergrundton abgestimmt, nie reines Schwarz */
    --schatten-s: 0 1px 2px rgba(20, 48, 36, 0.06);
    --schatten:   0 1px 2px rgba(20, 48, 36, 0.05), 0 8px 24px rgba(20, 48, 36, 0.07);

    /* Typografie */
    --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

    /* Layout */
    --seitenleiste-breite: 264px;
    --topbar-hoehe: 64px;
    --inhalt-max: 1200px;
}

/* --------------------------------------------------------------------------
   Basis
   -------------------------------------------------------------------------- */

*, *::before, *::after { 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(--tinte);
    background: var(--papier);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; letter-spacing: -0.015em; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1rem; }

a { color: var(--gruen-700); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--gruen-600); }

small, .meta { font-size: 0.875rem; color: var(--tinte-2); }

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

::selection { background: var(--gruen-100); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* --------------------------------------------------------------------------
   App-Shell: Seitenleiste + Topbar + Inhalt
   -------------------------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--seitenleiste-breite) 1fr;
    min-height: 100dvh;
}

/* Seitenleiste */
.seitenleiste {
    background: var(--gruen-950);
    color: #e8efe9;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    gap: 1.5rem;
}

.seitenleiste .wortmarke {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.125rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    padding: 0.25rem 0.5rem;
}

.wortmarke svg { flex: none; }

.nav-gruppe { display: flex; flex-direction: column; gap: 0.125rem; }

.nav-titel {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9db3a5;
    padding: 0 0.75rem;
    margin: 0 0 0.375rem;
}

.nav-link,
.nav-bald {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-s);
    font-size: 0.9375rem;
    text-decoration: none;
}

.nav-link { color: #dbe7de; transition: background-color 0.15s ease, color 0.15s ease; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.aktiv { background: var(--gruen-700); color: #fff; font-weight: 600; }

.nav-bald { color: #7e948a; cursor: default; }

.nav-bald .tag {
    margin-left: auto;
    font-size: 0.68rem;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.08);
    color: #9db3a5;
}

.seitenleiste .fuss {
    margin-top: auto;
    padding: 0.75rem 0.75rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    font-size: 0.8rem;
    color: #7e948a;
}

/* Topbar */
.hauptbereich { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-hoehe);
    background: var(--flaeche);
    border-bottom: 1px solid var(--linie);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar .burger {
    display: none;
    background: none;
    border: 1px solid var(--linie);
    border-radius: var(--radius-s);
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    cursor: pointer;
    color: var(--tinte);
}

/* Kontext-Chip („Du agierst als …") */
.kontext-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gruen-50);
    border: 1px solid var(--gruen-100);
    color: var(--gruen-800);
    border-radius: var(--radius-pill);
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
    max-width: 100%;
}

.kontext-chip .rolle { font-weight: 600; }
.kontext-chip .bereich { color: var(--gruen-700); }

/* Benutzermenü (ohne JS, über <details>) */
.benutzermenue { margin-left: auto; position: relative; }

.benutzermenue summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-s);
    transition: background-color 0.15s ease;
}
.benutzermenue summary::-webkit-details-marker { display: none; }
.benutzermenue summary:hover { background: var(--flaeche-2); }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-pill);
    background: var(--gruen-700);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
}

.benutzermenue .menue {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    box-shadow: var(--schatten);
    min-width: 220px;
    padding: 0.5rem;
    z-index: 30;
}

.menue .menue-kopf {
    padding: 0.5rem 0.75rem 0.625rem;
    border-bottom: 1px solid var(--linie);
    margin-bottom: 0.5rem;
}
.menue .menue-kopf strong { display: block; font-size: 0.9375rem; }
.menue .menue-kopf span { font-size: 0.8125rem; color: var(--tinte-2); }

.menue button,
.menue a {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--tinte);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-s);
    cursor: pointer;
    text-decoration: none;
}
.menue button:hover, .menue a:hover { background: var(--flaeche-2); }

/* Inhaltsbereich */
.inhalt {
    width: 100%;
    max-width: var(--inhalt-max);
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.seitenkopf { margin-bottom: 1.5rem; }
.seitenkopf p { color: var(--tinte-2); margin: 0; }

/* --------------------------------------------------------------------------
   Komponenten
   -------------------------------------------------------------------------- */

/* Karten */
.karte {
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--schatten-s);
}

.karten-raster {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--gruen-700);
    color: #fff;
    border: 1px solid var(--gruen-700);
    border-radius: var(--radius-s);
    padding: 0.625rem 1.125rem;
    font: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--gruen-600); border-color: var(--gruen-600); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--tinte-3); border-color: var(--tinte-3); cursor: not-allowed; }

.btn--sekundaer {
    background: var(--flaeche);
    color: var(--tinte);
    border-color: var(--linie);
}
.btn--sekundaer:hover { background: var(--flaeche-2); border-color: var(--tinte-3); color: var(--tinte); }

.btn--gefahr { background: var(--fehler); border-color: var(--fehler); }
.btn--gefahr:hover { background: #8d3427; border-color: #8d3427; }

.btn--leise {
    background: transparent;
    border-color: transparent;
    color: var(--gruen-700);
}
.btn--leise:hover { background: var(--gruen-50); color: var(--gruen-800); }

.btn--breit { width: 100%; }

/* Formulare: Label oben, Hilfe/Fehler unten */
.feld { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1.125rem; }

.feld label { font-size: 0.875rem; font-weight: 600; color: var(--tinte); }

.feld input[type="text"],
.feld input[type="email"],
.feld input[type="password"],
.feld input[type="number"],
.feld input[type="date"],
.feld select,
.feld textarea {
    font: inherit;
    font-size: 1rem;
    color: var(--tinte);
    background: var(--flaeche);
    border: 1px solid var(--linie);
    border-radius: var(--radius-s);
    padding: 0.625rem 0.75rem;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.feld input:focus,
.feld select:focus,
.feld textarea:focus {
    outline: none;
    border-color: var(--gruen-600);
    box-shadow: 0 0 0 3px var(--gruen-100);
}

.feld input[aria-invalid="true"] { border-color: var(--fehler); }

.feld-hilfe { font-size: 0.8125rem; color: var(--tinte-2); }
.feld-fehler { font-size: 0.8125rem; color: var(--fehler); font-weight: 500; }

.feld--zeile {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}
.feld--zeile label { font-weight: 500; }
.feld--zeile input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--gruen-700); }

/* Hinweise / Statusmeldungen */
.hinweis {
    border-radius: var(--radius-s);
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    margin-bottom: 1.125rem;
    border: 1px solid transparent;
}
.hinweis--erfolg { background: var(--erfolg-bg); color: var(--erfolg); border-color: #cfe4d5; }
.hinweis--fehler { background: var(--fehler-bg); color: var(--fehler); border-color: #eccfc9; }
.hinweis--warnung { background: var(--bernstein-bg); color: var(--bernstein); border-color: #ecd9b4; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-pill);
    padding: 0.15rem 0.625rem;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--gruen-50);
    color: var(--gruen-800);
    border: 1px solid var(--gruen-100);
}
.badge--neutral { background: var(--flaeche-2); color: var(--tinte-2); border-color: var(--linie); }
.badge--warnung { background: var(--bernstein-bg); color: var(--bernstein); border-color: #ecd9b4; }
.badge--fehler { background: var(--fehler-bg); color: var(--fehler); border-color: #eccfc9; }

/* Tabellen */
.tabelle { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.tabelle th {
    text-align: left;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--tinte-2);
    font-weight: 600;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--linie);
}
.tabelle td { padding: 0.75rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
.tabelle tbody tr:hover { background: var(--flaeche-2); }
.tabelle .zahl { font-variant-numeric: tabular-nums; text-align: right; }

/* Leerzustand */
.leer-zustand {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--tinte-2);
}
.leer-zustand h3 { color: var(--tinte); }

/* --------------------------------------------------------------------------
   Gast-Layout (Login, Passwort zurücksetzen)
   -------------------------------------------------------------------------- */

.gast-split {
    display: grid;
    grid-template-columns: minmax(360px, 5fr) 7fr;
    min-height: 100dvh;
}

.gast-marke {
    background:
        radial-gradient(120% 90% at 15% 0%, rgba(58, 133, 96, 0.35), transparent 55%),
        radial-gradient(110% 80% at 100% 100%, rgba(14, 32, 24, 0.9), transparent 60%),
        var(--gruen-900);
    color: #eaf2ec;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
}

.gast-marke .wortmarke {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-size: 1.375rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.gast-marke .claim { max-width: 26rem; }
.gast-marke .claim h2 {
    font-size: 1.75rem;
    line-height: 1.3;
    color: #fff;
    margin-bottom: 0.75rem;
}
.gast-marke .claim p { color: #b9ccbf; font-size: 1rem; margin: 0; }

.gast-marke .fuss { color: #7e948a; font-size: 0.8125rem; }

.gast-formseite {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.gast-karte { width: 100%; max-width: 420px; }
.gast-karte > h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.gast-karte > .unterzeile { color: var(--tinte-2); margin-bottom: 1.75rem; }

.gast-fusszeile {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--tinte-2);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Struktur-Browser & Auswahllisten
   -------------------------------------------------------------------------- */

.struktur-spalten {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: start;
}

.struktur-spalte h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }

.auswahl-liste {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 26rem;
    overflow-y: auto;
}

.auswahl-zeile {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.9375rem;
    color: var(--tinte);
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-s);
    cursor: pointer;
}
.auswahl-zeile:hover { background: var(--flaeche-2); }
.auswahl-zeile.gewaehlt { background: var(--gruen-50); color: var(--gruen-800); font-weight: 600; }
.auswahl-zeile.statisch { cursor: default; }
.auswahl-zeile.statisch:hover { background: none; }
.auswahl-zeile small { display: block; }

.zeile-mit-aktionen { display: flex; align-items: center; gap: 0.25rem; }
.zeile-mit-aktionen .auswahl-zeile { flex: 1; min-width: 0; }
.zeilen-aktionen { display: flex; gap: 0.125rem; flex: none; }
.zeilen-aktionen .btn { padding: 0.25rem 0.5rem; font-size: 0.8125rem; }

.leer-hinweis { color: var(--tinte-2); font-size: 0.875rem; padding: 0.5rem 0.25rem; list-style: none; }

.anlege-form { border-top: 1px solid var(--linie); padding-top: 1rem; margin-top: 0.5rem; }

.inline-edit {
    border: 1px solid var(--gruen-100);
    border-radius: var(--radius-s);
    padding: 0.75rem;
    background: var(--gruen-50);
}
.inline-edit .feld { margin-bottom: 0.625rem; }
.inline-aktionen { display: flex; gap: 0.5rem; }

/* Rechte-Matrix */
.rechte-matrix {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}
.rechte-gruppe {
    border: 1px solid var(--linie);
    border-radius: var(--radius-s);
    background: var(--flaeche);
    padding: 0.625rem 0.75rem;
    margin: 0;
}
.rechte-gruppe legend {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tinte-2);
    padding: 0 0.25rem;
}
.rechte-zeile {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
    cursor: pointer;
}
.rechte-zeile input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-top: 0.15rem;
    accent-color: var(--gruen-700);
    flex: none;
}

.blaettern {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.blaettern .btn { padding: 0.375rem 0.875rem; font-size: 0.875rem; }

/* Ablese-Runde / Portal-Meldung */
.ablese-zeile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    border-top: 1px solid var(--linie);
}
.ablese-zeile:first-of-type { border-top: none; }
.ablese-info { min-width: 180px; display: flex; flex-direction: column; }
.ablese-eingabe {
    font: inherit;
    font-size: 1rem;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--linie);
    border-radius: var(--radius-s);
    width: 140px;
}
.ablese-eingabe:focus {
    outline: none;
    border-color: var(--gruen-600);
    box-shadow: 0 0 0 3px var(--gruen-100);
}

/* Formular-Raster für CRUD-Karten */
.formular-raster {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 1rem;
}

/* Protokoll-Diffs */
.diff-liste { margin: 0.5rem 0 0; font-size: 0.8125rem; }
.diff-liste div { display: flex; gap: 0.5rem; padding: 0.125rem 0; flex-wrap: wrap; }
.diff-liste dt { font-weight: 600; color: var(--tinte-2); min-width: 120px; }
.diff-liste dd { margin: 0; word-break: break-word; }
.diff-alt { color: var(--fehler); text-decoration: line-through; }
.diff-neu { color: var(--erfolg); font-weight: 500; }

/* --------------------------------------------------------------------------
   Responsiv
   -------------------------------------------------------------------------- */

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

    .seitenleiste {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--seitenleiste-breite);
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--schatten);
    }
    .app-shell.nav-offen .seitenleiste { transform: translateX(0); }

    .nav-schleier {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(20, 38, 29, 0.4);
        z-index: 35;
        border: none;
        padding: 0;
    }
    .app-shell.nav-offen .nav-schleier { display: block; }

    .topbar { padding: 0 1rem; }
    .topbar .burger { display: inline-flex; }
    .kontext-chip .bereich { display: none; }

    .gast-split { grid-template-columns: 1fr; }
    .gast-marke { display: none; }
    .gast-mobilmarke { display: flex !important; }

    .struktur-spalten { grid-template-columns: 1fr; }
}

/* Mobile Markenkopf über dem Gast-Formular (Desktop versteckt) */
.gast-mobilmarke {
    display: none;
    align-items: center;
    gap: 0.625rem;
    color: var(--gruen-800);
    font-weight: 650;
    font-size: 1.25rem;
    margin-bottom: 2rem;
}
