/* Store-Chat Verwaltung */
:root {
    --bg: #0a0a0a; --flaeche: #141414; --flaeche2: #1e1e1e; --linie: rgba(255, 255, 255, .12);
    --text: #f0f0f0; --grau: #9a9a9a; --gold: #c89b3c; --gold-hell: #e0b455;
    --gruen: #3fb950; --gelb: #d29922; --rot: #f85149; --blau: #58a6ff;
    --kopf-hoehe: 56px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--gold); }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.grau { color: var(--grau); font-size: 13px; }
.fehler { color: var(--rot); }
.leer { color: var(--grau); padding: 30px 20px; text-align: center; }
.unsichtbar { position: fixed; left: -9999px; }

/* ---------- Anmeldung ---------- */
body.anmeldung { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 16px; padding: 28px; text-align: center; }
.login-logo { border-radius: 16px; margin-bottom: 10px; }
.login-box h1 { color: var(--gold); font-size: 22px; margin-bottom: 14px; }
.login-box p { margin-bottom: 14px; font-size: 14px; color: #ccc; }
.login-box code { color: var(--gold); }
.login-box form, .formular { display: flex; flex-direction: column; gap: 12px; text-align: left; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #ccc; }
label.haken { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
    background: #0f0f0f; border: 1px solid rgba(255, 255, 255, .2); border-radius: 8px; padding: 10px 12px; font-size: 16px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.login-box button, .formular button, .antwort button[type=submit], .knopf, .aktionen button, .notiz-zeile button {
    background: linear-gradient(45deg, var(--gold), #9e7f45); color: #050505; border: none; border-radius: 8px;
    padding: 10px 16px; font-weight: 700; text-decoration: none; display: inline-block; white-space: nowrap;
}
button:disabled { opacity: .5; cursor: default; }

/* ---------- Kopfzeile ---------- */
.kopf {
    position: sticky; top: 0; z-index: 10; height: var(--kopf-hoehe); flex-shrink: 0;
    display: flex; align-items: center; gap: 16px; padding: 0 16px; padding-top: env(safe-area-inset-top);
    background: var(--flaeche); border-bottom: 1px solid var(--linie);
}
.titel { color: var(--gold); font-size: 18px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: none; color: #ccc; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.tabs button:hover { background: var(--flaeche2); }
.tabs button.aktiv { background: var(--flaeche2); color: var(--gold); font-weight: 700; }
.zahl { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--rot); color: #fff; font-size: 12px; font-weight: 700; text-align: center; margin-left: 4px; }
.kopf-rechts { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ich { color: var(--grau); font-size: 13px; }
button.klein { background: var(--flaeche2); border: 1px solid var(--linie); border-radius: 8px; padding: 6px 10px; font-size: 13px; color: var(--text); }

/* ---------- Zweiteilige Ansicht: Liste + Detail ---------- */
body.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
main#app { flex: 1; min-height: 0; }
.tab { height: 100%; min-height: 0; }
.zweiteilig { display: grid; grid-template-columns: 340px 1fr; }
.liste { border-right: 1px solid var(--linie); display: flex; flex-direction: column; min-height: 0; }
.liste-kopf { padding: 10px; border-bottom: 1px solid var(--linie); }
.liste-kopf select { width: 100%; padding: 8px 10px; font-size: 14px; }
.eintraege { overflow-y: auto; flex: 1; }
.eintrag {
    display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--linie);
    padding: 10px 14px; color: var(--text); border-left: 3px solid transparent;
}
.eintrag:hover { background: var(--flaeche); }
.eintrag.aktiv { background: var(--flaeche2); border-left-color: var(--gold); }
.eintrag.neu .zeile1 strong::after { content: ' ●'; color: var(--rot); }
.eintrag.wartet { background: rgba(248, 81, 73, .08); }
.zeile1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.zeile1 strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zeile2 { color: #bbb; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 2px 0; }
.zeile3 { display: flex; gap: 10px; color: var(--grau); font-size: 12px; }

.status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; background: var(--flaeche2); color: var(--grau); }
.s-bot { color: var(--blau); background: rgba(88, 166, 255, .12); }
.s-wartet { color: #fff; background: var(--rot); }
.s-mitarbeiter { color: var(--gruen); background: rgba(63, 185, 80, .12); }
.as-neu { color: #111; background: var(--gold); }
.as-angeboten { color: var(--gelb); background: rgba(210, 153, 34, .15); }
.as-bestaetigt { color: #fff; background: var(--gruen); }
.as-bestellt { color: var(--blau); background: rgba(88, 166, 255, .12); }
.as-erledigt { color: var(--gruen); background: rgba(63, 185, 80, .12); }
.as-abgelehnt { color: var(--grau); background: var(--flaeche2); }
.as-abholbereit { color: #111; background: var(--gruen); }
.bestellung .abholnummer { font-weight: 800; margin: 6px 0 2px; }
.bestellung .naechster { margin-top: 6px; color: var(--gold); font-weight: 600; }
.bestellung .drucken { margin-top: 8px; padding: 6px 12px; font-size: 13px; }

.detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.detail-kopf { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--linie); background: var(--flaeche); }
.detail-titel { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.detail-titel strong { font-size: 17px; }
.unterzeile { width: 100%; color: var(--grau); font-size: 13px; }
.kontakt a { margin-right: 6px; }
.aktionen { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.aktionen button { padding: 7px 12px; font-size: 13px; background: var(--flaeche2); color: var(--text); border: 1px solid var(--linie); }
.aktionen button.haupt { background: linear-gradient(45deg, var(--gold), #9e7f45); color: #050505; border: none; }
button.gefahr, .aktionen button.gefahr { background: none; color: var(--rot); border: 1px solid rgba(248, 81, 73, .5); }
.zurueck { display: none; background: none; border: none; font-size: 22px; color: var(--gold); padding: 0 6px; }
.detail-inhalt { overflow-y: auto; padding: 16px; }

/* ---------- Chatverlauf ---------- */
.verlauf { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.blase { max-width: 75%; padding: 8px 12px; border-radius: 12px; overflow-wrap: anywhere; }
.b-kunde { align-self: flex-start; background: var(--flaeche2); border-bottom-left-radius: 3px; }
.b-bot { align-self: flex-end; background: rgba(88, 166, 255, .12); border-bottom-right-radius: 3px; }
.b-mitarbeiter { align-self: flex-end; background: rgba(200, 155, 60, .2); border-bottom-right-radius: 3px; }
.wer { font-size: 11px; color: var(--grau); margin-bottom: 2px; }
.text { white-space: pre-wrap; }
.bild img { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; margin: 4px 0; }
.datei, .datei-weg { display: block; margin: 4px 0; }
.datei-weg { color: var(--grau); font-style: italic; }
.sys { align-self: center; font-size: 12px; color: var(--grau); background: var(--flaeche); padding: 4px 10px; border-radius: 10px; text-align: center; }
.tippt { padding: 0 16px 6px; color: var(--grau); font-style: italic; font-size: 13px; }
#chatAnfragen { max-height: 45%; overflow-y: auto; padding: 6px 16px; border-top: 1px solid var(--linie); }
#chatAnfragen:empty { display: none; }
.anfrage-klapp > summary {
    cursor: pointer; padding: 6px 0; color: var(--gold); font-weight: 700; font-size: 14px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.anfrage-klapp > .karte { margin-top: 4px; }

.antwort { border-top: 1px solid var(--linie); padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); background: var(--flaeche); display: flex; flex-direction: column; gap: 6px; }
.antwort-hinweis { font-size: 12px; color: var(--gelb); }
.antwort-hinweis:empty { display: none; }
.antwort-zeile { display: flex; gap: 8px; align-items: flex-end; }
.antwort-zeile textarea { flex: 1; resize: vertical; min-height: 44px; max-height: 200px; }
.bausteine { font-size: 13px; padding: 6px 8px; color: var(--grau); max-width: 260px; }
/* Oben im Antwortfeld: an den Assistenten (Standard) oder selbst schreiben */
.modus { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--linie); border-radius: 10px; padding: 3px; align-self: flex-start; }
.modus button { background: none; border: none; color: var(--grau); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.modus button.aktiv { background: var(--flaeche2); color: var(--gold); }
.antwort.selbst .modus button.aktiv { color: var(--gelb); }
.antwort.selbst textarea { border-color: rgba(210, 153, 34, .6); }
.antwort .antwort-hinweis { color: var(--grau); }
.antwort.selbst .antwort-hinweis { color: var(--gelb); }
.antwort .bausteine { align-self: flex-start; }

.b-anweisung { align-self: flex-end; background: transparent; border: 1px dashed var(--gold); border-bottom-right-radius: 3px; }
.b-anweisung .wer { color: var(--gold); }
.b-angebot { align-self: flex-end; background: rgba(200, 155, 60, .1); border: 1px solid rgba(200, 155, 60, .7); border-bottom-right-radius: 3px; }
.b-angebot .text { font-weight: 700; }
.angebot-status { font-size: 12px; margin-top: 4px; color: var(--grau); }
.angebot-status.a-bestellt { color: var(--gruen); font-weight: 700; }
.angebot-status.a-abgelehnt { color: var(--rot); }
.bestellung { margin-top: 6px; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.bestellung.ok { background: rgba(63, 185, 80, .12); border: 1px solid rgba(63, 185, 80, .5); }
.bestellung.nein { background: rgba(248, 81, 73, .08); border: 1px solid rgba(248, 81, 73, .4); }

/* ---------- Tab "Assistent" ---------- */
.assistent { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }

/* Chat auf der Webseite ein/aus (oben im Tab "Assistent") */
.webseite-schalter { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie); }
.webseite-schalter label.haken { font-size: 15px; color: var(--text); cursor: pointer; }
.webseite-schalter input[type=checkbox] { width: 20px; height: 20px; padding: 0; accent-color: var(--gold); }
.webseite-schalter .an { color: var(--gruen); font-size: 13px; }
.webseite-schalter .aus { color: var(--gelb); font-size: 13px; }
.webseite-schalter .test { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.webseite-schalter .grau { flex-basis: 100%; margin: 0; }
button.klein.warnhinweis { color: var(--gelb); border-color: rgba(210, 153, 34, .6); }
.trainer { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--linie); }
.trainer > .grau, .trainer .bereich-kopf { padding: 0 16px; }
.trainer .bereich-kopf { padding-top: 14px; }
.bereich-kopf { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.assistent h2 { color: var(--gold); font-size: 18px; }
.assistent h3 { font-size: 14px; margin: 16px 0 6px; color: var(--text); }
.b-ich { align-self: flex-end; background: rgba(200, 155, 60, .2); border-bottom-right-radius: 3px; }
.b-assistent { align-self: flex-start; background: rgba(88, 166, 255, .12); border-bottom-left-radius: 3px; }
.wissen { overflow-y: auto; padding: 14px 16px; }
.wissen > .grau { margin: 4px 0 10px; }
.wissen-neu { display: flex; gap: 8px; margin: 12px 0; }
.wissen-neu input { flex: 1; min-width: 0; }
.wissen-neu button { background: linear-gradient(45deg, var(--gold), #9e7f45); color: #050505; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 700; }
.wissen-eintrag { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.wissen-eintrag.vorschlag { border-color: var(--gold); background: rgba(200, 155, 60, .08); }
.wissen-text { white-space: pre-wrap; margin-bottom: 4px; }
.wissen-knoepfe { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
button.klein.haupt { background: linear-gradient(45deg, var(--gold), #9e7f45); color: #050505; border: none; font-weight: 700; }
button.klein.gefahr { background: none; color: var(--rot); border: 1px solid rgba(248, 81, 73, .5); }

/* ---------- Teileanfrage ---------- */
.karte { background: var(--flaeche); border: 1px solid rgba(200, 155, 60, .5); border-radius: 12px; padding: 14px; margin: 10px 0; }
.karte-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.karte-kopf strong { color: var(--gold); font-size: 16px; }
.karte-kopf .grau { flex: 1; }
.anfrage-status { padding: 5px 10px; font-size: 14px; font-weight: 700; }
.anfrage-status.s-neu { border-color: var(--gold); color: var(--gold); }
.anfrage-status.s-bestellt { border-color: var(--blau); color: var(--blau); }
.anfrage-status.s-erledigt { border-color: var(--gruen); color: var(--gruen); }
.anfrage-status.s-angeboten { border-color: var(--gelb); color: var(--gelb); }
.anfrage-status.s-bestaetigt { border-color: var(--gruen); color: #fff; background: rgba(63, 185, 80, .35); }
.anfrage-status.s-abgelehnt { color: var(--grau); }
.anfrage-status.s-abholbereit { border-color: var(--gruen); color: var(--gruen); font-weight: 800; }
.block { margin-top: 12px; }
.block h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--grau); margin-bottom: 4px; }
.werte { border-collapse: collapse; }
.werte th { text-align: left; font-weight: 400; color: var(--grau); padding: 3px 14px 3px 0; white-space: nowrap; vertical-align: middle; }
.werte td { padding: 3px 0; }
.wert { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .3px; }
.warnung { color: var(--gelb); font-size: 13px; padding-top: 6px; }
.kopieren { background: var(--flaeche2); border: 1px solid var(--linie); border-radius: 6px; padding: 1px 7px; margin-left: 8px; font-size: 13px; color: var(--grau); }
.kopieren:hover { color: var(--gold); border-color: var(--gold); }
.kopieren.ok { color: var(--gruen); border-color: var(--gruen); }
.teil { padding: 8px 0; border-bottom: 1px dashed var(--linie); }
.teil:last-child { border-bottom: none; }
.teil-name { font-weight: 700; }
.oe-titel { font-size: 12px; color: var(--grau); margin-top: 6px; }
.oe { list-style: none; margin-top: 4px; }
.oe li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 3px 0; }
.sicherheit { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; margin-left: 6px; }
.si-hoch { color: var(--gruen); background: rgba(63, 185, 80, .12); }
.si-mittel { color: var(--gelb); background: rgba(210, 153, 34, .15); }
.si-niedrig { color: var(--rot); background: rgba(248, 81, 73, .12); }
.quelle { font-size: 12px; }
.notiz-bot { margin-top: 8px; font-size: 14px; color: #ccc; }
.lieferanten { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.knopf { font-size: 14px; }
.knopf.hell { background: var(--flaeche2); color: var(--text); border: 1px solid var(--linie); }
.notiz textarea { width: 100%; resize: vertical; }
.notiz-zeile { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.notiz-zeile button { padding: 7px 14px; font-size: 13px; }
.gespeichert { color: var(--gruen); font-size: 13px; }

/* ---------- Zugänge, Nutzung ---------- */
.einzeln { overflow-y: auto; padding: 20px; max-width: 760px; }
.einzeln h2 { color: var(--gold); font-size: 20px; margin-bottom: 12px; }
.einzeln .formular { max-width: 420px; margin-top: 28px; }
.formular h3 { font-size: 16px; }
.tabelle { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tabelle th, .tabelle td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--linie); }
.tabelle th { color: var(--grau); font-weight: 600; font-size: 13px; }

/* ---------- Handy: Liste oder Detail ---------- */
@media (max-width: 800px) {
    .kopf { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px 10px; padding-top: calc(8px + env(safe-area-inset-top)); }
    .tabs { order: 3; flex-basis: 100%; }
    .kopf-rechts { margin-left: auto; }
    .ich { display: none; }
    .zweiteilig { grid-template-columns: 1fr; }
    .zweiteilig .detail { display: none; }
    .zweiteilig.detail-offen .liste { display: none; }
    .zweiteilig.detail-offen .detail { display: flex; }
    .zurueck { display: block; }
    .detail-kopf { flex-wrap: wrap; padding: 10px 12px; }
    .aktionen { width: 100%; justify-content: flex-start; }
    .blase { max-width: 88%; }
    .verlauf { padding: 12px; }
    #chatAnfragen { max-height: 50%; padding: 0 10px; }
    .karte { padding: 12px; }
    .einzeln { padding: 14px; }
    .modus { align-self: stretch; }
    .modus button { flex: 1; }
    .antwort .antwort-hinweis { display: none; } /* Platz für den Chat */
    .antwort.selbst .antwort-hinweis { display: block; }
    .bausteine { max-width: none; }
    .assistent { display: block; overflow-y: auto; }
    .trainer { border-right: none; border-bottom: 1px solid var(--linie); }
    .trainer .verlauf { min-height: 260px; max-height: 55vh; }
}
