:root {
    --akzent: #2b5d8a;
    --bg: #f5f6f7;
    --karte: #ffffff;
    --rand: #d9dde2;
    --text: #2b2b2b;
    --fehler: #b3261e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    background: var(--karte);
    border-bottom: 1px solid var(--rand);
    /* Kopfzeile bleibt beim Scrollen oben sichtbar (Navigation immer erreichbar). */
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .logo { font-weight: 600; }
.topbar .user { font-size: 0.9rem; color: #666; }
.topbar a { color: var(--akzent); }

main { max-width: 760px; margin: 1.5rem auto; padding: 0 1rem; }

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

h1 { margin-top: 0; font-size: 1.4rem; }

form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
input:not([type="checkbox"]):not([type="radio"]), select {
    padding: 0.6rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    font-size: 1rem;
}

button {
    padding: 0.6rem 1.1rem;
    border: 0;
    border-radius: 6px;
    background: var(--akzent);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.fehler { color: var(--fehler); font-weight: 500; }
.leer { color: #777; }

.liste { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.liste th, .liste td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--rand); }
.liste th { font-size: 0.85rem; color: #666; }

/* breiter Inhalt für die Datentabellen: auf breitem Bildschirm bis 1600px bzw.
   95 % der Fensterbreite nutzen, damit alle Spalten in die Kachel passen. */
main.weit { max-width: min(1600px, 95vw); }

/* Kontext-Umschalter (Getränke / Lebensmittel) */
.kontext-schalter { display: flex; gap: 0.3rem; margin-left: 1.2rem; }
.kontext-schalter a {
    text-decoration: none; font-size: 0.9rem; color: #666;
    padding: 0.25rem 0.7rem; border: 1px solid var(--rand); border-radius: 999px;
    background: var(--bg);
}
.kontext-schalter a.ist-aktiv { background: var(--akzent); color: #fff; border-color: var(--akzent); font-weight: 600; }

/* Navigation */
.hauptnav { display: flex; gap: 1.2rem; flex: 1; margin-left: 1.5rem; }
.hauptnav a { color: var(--text); text-decoration: none; font-size: 0.95rem; padding-bottom: 2px; }
.hauptnav a:hover { color: var(--akzent); }
.hauptnav a.ist-aktiv { color: var(--akzent); font-weight: 600; border-bottom: 2px solid var(--akzent); }

/* Hinweisboxen */
.hinweis { padding: 0.8rem 1rem; border-radius: 8px; margin: 0 0 1rem; font-size: 0.95rem; }
.hinweis.erfolg   { background: #e7f4ea; border: 1px solid #b6dcc0; color: #1f6b34; }
.hinweis.warnung  { background: #fff6e5; border: 1px solid #f0d9a8; color: #8a5a00; }
.hinweis.fehlerbox{ background: #fdeceb; border: 1px solid #f1bdb9; color: var(--fehler); }
.hinweis.vorschau { background: #e9f1f9; border: 1px solid #b9d0e6; color: #234b6e; }
.hinweis ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

/* Nav-Badge: Anzahl offener Zweifelsfälle (nur aus dem Cache) */
.nav-badge { display: inline-block; min-width: 1.2rem; text-align: center;
             background: var(--fehler); color: #fff; border-radius: 9px;
             padding: 0.05rem 0.4rem; font-size: 0.75rem; font-weight: 700;
             vertical-align: 1px; }
.nav-badge.leer0 { background: #cfd6dc; color: #555; font-weight: 600; }

/* Δ-Ampel */
.d-gruen { color: #1f6b34; font-weight: 600; }
.d-gelb  { color: #9a6a00; font-weight: 600; }
.d-rot   { color: var(--fehler); font-weight: 700; }
/* Prozentwert nicht umbrechen ("0,0 %" bleibt einzeilig) */
.d-gruen, .d-gelb, .d-rot { white-space: nowrap; }

/* neutraler Status-Marker (kein Fehler) */
.badge { display: inline-block; background: #eef0f2; color: #666; border-radius: 5px;
         padding: 0.1rem 0.45rem; font-size: 0.8rem; }

/* Datentabelle */
.liste.daten td, .liste.daten th { padding: 0.4rem 0.55rem; font-size: 0.92rem; }

/* Werkzeugleiste (Filter/Sortierung) */
.werkzeugleiste { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; align-items: baseline;
                  margin-top: 1rem; font-size: 0.9rem; }
.werkzeugleiste a { color: var(--akzent); text-decoration: none; margin-left: 0.4rem; }
.werkzeugleiste a.ist-aktiv { font-weight: 700; text-decoration: underline; }

.blaettern { display: flex; gap: 1.5rem; align-items: center; margin-top: 1rem; }
.blaettern a { color: var(--akzent); text-decoration: none; }

/* Regel-Editor */
.eingabe-zeile { display: inline-flex; align-items: center; gap: 0.4rem; }
.eingabe-zeile input { width: 7rem; }
.liste td input[type="number"] { width: 6.5rem; }
.schalter { flex-direction: row; align-items: center; gap: 0.4rem; }
.aktionsleiste { margin: 1.2rem 0; }
.aktionsleiste button { font-size: 1.05rem; padding: 0.7rem 1.6rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; margin-top: 1.2rem;
               border-top: 1px solid var(--rand); padding-top: 1.2rem; }
.inline-form label { font-size: 0.85rem; }
.inline-form input, .inline-form select { width: auto; }

/* Knöpfe in zwei Tonlagen */
.knopf-leise { background: none; color: #888; padding: 0.2rem 0.4rem; font-size: 0.85rem; }
.knopf-leise:hover { color: var(--fehler); }
.knopf-neutral { background: #eef0f2; color: var(--text); }
form { margin: 0; }

/* kleiner grauer Kasten: Live-Beispielrechnung auf den Regel-Seiten */
.beispielkasten { background: #f0f2f4; border: 1px solid var(--rand); border-radius: 8px;
                  padding: 0.7rem 1rem; font-size: 0.9rem; color: #555; }

/* Legende unter den Artikel-Tabellen */
.legende { font-size: 0.82rem; color: #777; margin: 0.6rem 0 0; line-height: 1.6; }

/* Suchfeld in der Werkzeugleiste */
.suchform { flex-direction: row; align-items: center; gap: 0.4rem; }
.suchform input[type="search"] { padding: 0.35rem 0.6rem; font-size: 0.9rem; width: 14rem; }
.suchform button { padding: 0.35rem 0.8rem; font-size: 0.9rem; }
.suchform a { color: var(--akzent); text-decoration: none; font-size: 0.85rem; }

/* Hinweis direkt am Speichern-Knopf */
.knopf-hinweis { font-size: 0.85rem; margin: 0.5rem 0 0; max-width: 46rem; }

/* zugeklappter Technik-Kasten (Startseite) */
details.tech-details { margin-top: 1rem; font-size: 0.9rem; }
details.tech-details summary { cursor: pointer; color: #777; }
details.tech-details p { color: #777; margin: 0.5rem 0 0; }

/* Zweifelsfall-Karten */
.fall-kopf { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.fall-titel { font-size: 1.1rem; }
.fall-delta { font-size: 1.05rem; }
.fall-aktionen { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-top: 1rem; }
.aktion-block { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

/* Zielpreis-Modus (LM): AUSNAHME — bewusst an der Marge vorbei. Amber, damit klar
   erkennbar ist, dass hier NICHT einfach ein Wunsch-VK steht. */
.badge-zielpreis { background: #fdecc8; color: #8a5a00; font-weight: 700; }
.zp-ausnahme { font-size: 0.78rem; font-weight: 400; color: #8a5a00; }
.th-zielpreis { color: #8a5a00; }
.zp-erklaerung { line-height: 1.55; }
.zp-warnung { margin: 0 0 0.5rem; font-size: 0.85rem; color: #8a5a00;
              background: #fff6e5; border: 1px solid #f0d9a8; border-radius: 6px; padding: 0.4rem 0.6rem; }
.zp-zelle { min-width: 9rem; }
details.zp summary { cursor: pointer; color: var(--akzent); font-size: 0.85rem; white-space: nowrap; }
.zp-innen { margin-top: 0.4rem; padding: 0.5rem 0.6rem; background: #f0f2f4;
            border: 1px solid var(--rand); border-radius: 8px; }
.zp-form { display: flex; flex-direction: row; gap: 0.4rem; align-items: center; flex-wrap: wrap;
           margin: 0 0 0.4rem; font-size: 0.85rem; }
.zp-form input[type="text"] { padding: 0.3rem 0.5rem; font-size: 0.85rem; width: 7rem; }
.zp-form button { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.zp-innen .leer { font-size: 0.78rem; margin: 0; }
.zp-eingabe { width: 8rem; }
/* kleine Zusatzzeile in der Zielpreis-Spalte (Warenanteil netto) */
.zp-klein { display: block; font-size: 0.75rem; white-space: nowrap; }
/* zusammengelegte Faktor-Spalte ("heute → Vorschlag") und Euro-Spalten: kein Umbruch */
.faktorpaar { white-space: nowrap; }

/* Spaltenkopf-Tooltips: gepunktete Unterstreichung deutet den title-Text an */
.th-hilfe { cursor: help; text-decoration: underline dotted #a8adb3; text-underline-offset: 3px; }

/* Regel-Historie: zugeklappter Block unten auf den Regel-Seiten */
details.historie { margin-top: 1.5rem; font-size: 0.9rem; }
details.historie summary { cursor: pointer; color: #777; }
details.historie .liste td, details.historie .liste th { font-size: 0.88rem; }
details.historie .knopf-leise { white-space: nowrap; }
details.historie .knopf-leise:hover { color: var(--akzent); }

/* Bestätigungsseite bei grosser Regel-Änderung (K3) */
.bestaetigung-aktionen { display: flex; align-items: center; gap: 1.2rem; margin-top: 1.2rem; }
.bestaetigung-aktionen button { font-size: 1.05rem; padding: 0.7rem 1.6rem; }
.knopf-abbrechen { color: #666; }

/* Anklickbare Sortier-Kopfzellen */
.th-sort a { color: inherit; text-decoration: none; white-space: nowrap; display: block; }
.th-sort:hover a { text-decoration: underline; }
.th-sort.ist-sortiert { color: var(--akzent); }

/* Cloud-Session (Claude-Chat) */
.chat-verlauf { margin-top: 1rem; max-height: 55vh; overflow-y: auto; display: flex;
                flex-direction: column; gap: 0.8rem; padding-right: 0.3rem; }
.chat-leer { text-align: center; padding: 1.5rem 0; }
.chat-nachricht { max-width: 85%; padding: 0.6rem 0.9rem; border-radius: 12px; }
.chat-du     { align-self: flex-end;  background: var(--akzent); color: #fff; }
.chat-claude { align-self: flex-start; background: #f0f2f4; color: var(--text); }
.chat-fehler { background: #fdeceb; color: var(--fehler); }
.chat-wer  { display: block; font-size: 0.72rem; opacity: 0.7; margin-bottom: 0.15rem; }
.chat-text { font-size: 0.95rem; line-height: 1.5; white-space: normal; }
.chat-warte .chat-text { opacity: 0.6; font-style: italic; }
/* flex-direction:row explizit — die globale form-Regel setzt sonst column */
.chat-form { display: flex; flex-direction: row; gap: 0.5rem; margin-top: 1rem; align-items: flex-end; width: 100%; }
.chat-form textarea { flex: 1; padding: 0.6rem; border: 1px solid var(--rand); border-radius: 8px;
                      font-size: 1rem; font-family: inherit; resize: vertical; }
.chat-neu { margin: 0.6rem 0 0; }

/* Breite Datentabellen: horizontal scrollbar innerhalb der Kachel halten
   (statt rechts aus der Kachel herauszulaufen). */
.tabelle-umschlag { overflow-x: auto; max-width: 100%; }

/* Lade-Ball in der Kopfzeile (nur während des Ladens sichtbar, per JS eingeblendet).
   Bunter, rotierender Ring — signalisiert: Tool holt gerade die Google-Tabelle. */
.lade-anzeige { display: none; align-items: center; gap: 0.4rem; margin-left: 0.8rem;
                margin-right: 1.6rem; font-size: 0.8rem; color: #666; white-space: nowrap; }
.lade-ball { width: 16px; height: 16px; border-radius: 50%;
             background: conic-gradient(from 0deg, #e0245e, #f5a623, #2ecc71, #2b8fd6, #9b59b6, #e0245e);
             -webkit-mask: radial-gradient(circle 5px at center, transparent 97%, #000 100%);
                     mask: radial-gradient(circle 5px at center, transparent 97%, #000 100%);
             animation: lade-dreh 0.8s linear infinite; }
@keyframes lade-dreh { to { transform: rotate(360deg); } }
