/* SENTO Betrieb: Arbeitsoberfläche für das Team.
   Dieselbe Welt wie das Kundenportal (warmes Papier, dunkles Braun), aber dichter:
   Seitenleiste, Tabellen, Statusmarken. Farbe nur für Zustand und Handlung. */
:root {
  --grund: #fdfcfb; --flaeche: #ffffff; --leiste: #f6f1ed; --text: #1a1514;
  --akzent: #4d3533; --akzent-hover: #3b2826; --akzent-text: #fdfcfb;
  --leise: #6f5b58; --linie: rgba(77, 53, 51, 0.12); --linie-stark: rgba(77, 53, 51, 0.22); --zart: rgba(77, 53, 51, 0.05);
  --warn: #b3261e; --warn-grund: #fbeceb; --warn-linie: rgba(179, 38, 30, 0.28);
  --gelb: #8a5a00; --gelb-grund: #fbf1dc; --gruen: #2f6b3a; --gruen-grund: #e7f2e8; --blau: #2c5282; --blau-grund: #e8eef7;
  --fokus: #8c5a3c;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #16110f; --flaeche: #1d1715; --leiste: #120e0c; --text: #f2ebe7;
    --akzent: #e8d8d0; --akzent-hover: #f5ebe6; --akzent-text: #1d1715;
    --leise: #b4a29d; --linie: rgba(242, 235, 231, 0.1); --linie-stark: rgba(242, 235, 231, 0.2); --zart: rgba(242, 235, 231, 0.05);
    --warn: #ff9b94; --warn-grund: rgba(255, 99, 90, 0.12); --warn-linie: rgba(255, 155, 148, 0.3);
    --gelb: #f0c46a; --gelb-grund: rgba(240, 196, 106, 0.12); --gruen: #8fd19b; --gruen-grund: rgba(143, 209, 155, 0.12);
    --blau: #9cc0f0; --blau-grund: rgba(156, 192, 240, 0.12);
    --fokus: #e0b08f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--grund); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-feature-settings: "tnum" 0; }
::selection { background: rgba(140, 90, 60, 0.22); }
:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; caret-color: var(--akzent); }
a { color: var(--akzent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--akzent-hover); }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Gerüst ---------- */
body.mit-leiste { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.leiste { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 22px 14px 18px; background: var(--leiste); border-right: 1px solid var(--linie); }
.marke { display: flex; align-items: baseline; gap: 8px; padding: 0 10px; text-decoration: none; color: var(--akzent); }
.marke span { font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; letter-spacing: 0.03em; }
.marke small { font-size: 0.78rem; color: var(--leise); letter-spacing: 0.02em; }
.leiste nav { display: flex; flex-direction: column; gap: 2px; }
.leiste nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--leise); text-decoration: none; font-weight: 500; transition: background-color 150ms ease-out, color 150ms ease-out; }
.leiste nav a:hover { background: var(--zart); color: var(--text); }
.leiste nav a[aria-current="page"] { background: var(--flaeche); color: var(--akzent); box-shadow: 0 1px 2px rgba(77, 53, 51, 0.08), 0 0 0 1px var(--linie); }
.icon { width: 18px; height: 18px; flex: none; }
.ich { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding: 12px 10px 0; border-top: 1px solid var(--linie); }
.ich-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ich form { margin: 0; }
button.link { padding: 0; border: 0; background: none; color: var(--leise); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 0.86rem; min-height: 0; }
button.link:hover { color: var(--text); }

main { padding: 28px 40px 64px; max-width: 1240px; width: 100%; }
body.ohne-leiste main { max-width: 400px; margin: 12vh auto 0; padding: 24px 16px; }
.kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { margin: 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; color: var(--akzent); text-wrap: balance; }
h2 { margin: 0 0 8px; font-size: 1rem; font-weight: 600; color: var(--akzent); }
.untertitel { margin: 6px 0 0; color: var(--leise); max-width: 72ch; }
section { margin-top: 28px; }
.abschnitt-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.abschnitt-kopf h2 { margin: 0; }
.abschnitt-kopf a { font-size: 0.86rem; }
.spalten { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; align-items: start; }
.spalten.breit-schmal { grid-template-columns: minmax(0, 1fr) 280px; }
.spalten > section, .spalten > div > section:first-child { margin-top: 28px; }

/* ---------- Lage (Kennzahlen als Zeile, nicht als Kacheln) ---------- */
.lage { display: flex; flex-wrap: wrap; margin: 0; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
.lage > div { flex: 1 1 140px; padding: 14px 18px; border-right: 1px solid var(--linie); }
.lage > div:last-child { border-right: 0; }
.lage dt { font-size: 0.82rem; color: var(--leise); }
.lage dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.lage.klein dd { font-size: 1rem; font-weight: 500; }

/* ---------- Listen ---------- */
ul.zeilen { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--linie); }
ul.zeilen li { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--linie); min-height: 52px; }
ul.zeilen li > .zeile-text { padding: 9px 0; }
ul.zeilen form { margin: 0; flex: none; }
.zeile-link { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 9px 8px; margin: 0 -8px; border-radius: 6px; color: inherit; text-decoration: none; transition: background-color 150ms ease-out; }
.zeile-link:hover { background: var(--zart); color: inherit; }
.zeile-text { display: flex; flex-direction: column; min-width: 0; }
.zeile-haupt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zeile-neben { font-size: 0.84rem; color: var(--leise); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nr { color: var(--leise); font-variant-numeric: tabular-nums; margin-right: 2px; }
.gedimmt { color: var(--leise); }
.hilfe { margin: 10px 0 0; font-size: 0.84rem; color: var(--leise); max-width: 70ch; }

/* ---------- Tabellen ---------- */
.tabelle-rahmen { overflow-x: auto; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
table.tabelle { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabelle th { text-align: left; font-size: 0.8rem; font-weight: 500; color: var(--leise); padding: 9px 14px; border-bottom: 1px solid var(--linie-stark); white-space: nowrap; background: var(--zart); }
.tabelle td { padding: 10px 14px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
.tabelle tbody tr:last-child td { border-bottom: 0; }
.tabelle tbody tr { transition: background-color 120ms ease-out; }
.tabelle tbody tr:hover { background: var(--zart); }
.tabelle .zahl { text-align: right; }
.tabelle td.zeit { white-space: nowrap; color: var(--leise); }
.tabelle.kompakt { border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; background: var(--flaeche); margin-top: 8px; }
.tabelle.kompakt td, .tabelle.kompakt th { padding: 7px 12px; }
a.kunde { white-space: nowrap; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 0.86rem; letter-spacing: 0.01em; }
.hervor { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--gelb-grund); color: var(--gelb); font-weight: 600; text-align: center; }

/* ---------- Marken ---------- */
.status, .marke-kanal, .hinweis-marke { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.status-offen { background: var(--gelb-grund); color: var(--gelb); }
.status-in_bearbeitung { background: var(--blau-grund); color: var(--blau); }
.status-erledigt { background: var(--gruen-grund); color: var(--gruen); }
.status-aus { background: var(--zart); color: var(--leise); }
.marke-kanal { background: var(--zart); color: var(--leise); border: 1px solid var(--linie); }
.hinweis-marke { background: var(--gelb-grund); color: var(--gelb); height: 20px; font-size: 0.74rem; }

/* ---------- Reiter ---------- */
nav.reiter { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--linie); overflow-x: auto; }
nav.reiter a { padding: 8px 12px; color: var(--leise); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
nav.reiter a:hover { color: var(--text); }
nav.reiter a[aria-current="page"] { color: var(--akzent); border-bottom-color: var(--akzent); }

/* ---------- Formulare ---------- */
label { display: block; margin: 14px 0 5px; font-size: 0.86rem; font-weight: 500; color: var(--leise); }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 36px; padding: 7px 11px; border: 1px solid var(--linie-stark); border-radius: var(--radius); background: var(--flaeche);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
textarea { resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--leise); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--fokus); box-shadow: 0 0 0 3px rgba(140, 90, 60, 0.18); }
::placeholder { color: var(--leise); opacity: 0.75; }
button, a.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--akzent); color: var(--akzent-text);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, transform 100ms ease-out;
}
button:hover, a.knopf:hover { background: var(--akzent-hover); color: var(--akzent-text); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.hell, a.knopf.hell { background: var(--flaeche); color: var(--akzent); border-color: var(--linie-stark); }
button.hell:hover, a.knopf.hell:hover { background: var(--zart); border-color: var(--leise); color: var(--akzent); }
button.gefahr { background: var(--warn); color: #fff; }
button.gefahr:hover { background: #8f1e18; color: #fff; }
form > button { margin-top: 14px; }
.reihe { display: flex; gap: 8px; align-items: center; }
.reihe input, .reihe select { flex: 1; min-width: 0; }
.suche { display: flex; gap: 8px; width: min(420px, 100%); }
.suche input { flex: 1; min-width: 0; }
form.anmeldung { margin-top: 8px; }
form.anmeldung button { width: 100%; margin-top: 20px; }

/* ---------- Meldungen und Leere ---------- */
.meldung { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--gruen-grund); color: var(--gruen); border: 1px solid transparent; }
.meldung.fehler { background: var(--warn-grund); color: var(--warn); border-color: var(--warn-linie); }
.leer { padding: 18px 0 6px; color: var(--leise); }
.leer p { margin: 0; max-width: 60ch; }
.leer .leer-titel { color: var(--text); font-weight: 500; margin-bottom: 2px; }

/* ---------- Gefahrzone ---------- */
.gefahrzone { margin-top: 40px; padding: 18px 20px; border: 1px solid var(--warn-linie); border-radius: var(--radius); background: var(--warn-grund); }
.gefahrzone h2 { color: var(--warn); }
.gefahrzone p { margin: 0; max-width: 72ch; }
.gefahrzone label { color: var(--text); }
.gefahrzone .reihe { max-width: 460px; }

/* ---------- Ticket-Verlauf ---------- */
ol.verlauf { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.nachricht { max-width: 78%; padding: 10px 14px 12px; border-radius: 12px; border: 1px solid var(--linie); background: var(--flaeche); }
.nachricht.von-betreiber { align-self: flex-end; background: var(--leiste); border-color: var(--linie-stark); }
.nachricht-kopf { display: flex; justify-content: space-between; gap: 16px; font-size: 0.8rem; color: var(--leise); margin-bottom: 4px; }
.nachricht-kopf span { font-weight: 500; color: var(--text); }
.nachricht p { margin: 0; overflow-wrap: anywhere; }
form.antwort { margin-top: 24px; padding-top: 4px; border-top: 1px solid var(--linie); }
.seitenblock { position: sticky; top: 24px; margin-top: 0; padding: 16px; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
dl.eigenschaften { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 6px; }
dl.eigenschaften dt { color: var(--leise); font-size: 0.84rem; }
dl.eigenschaften dd { margin: 0; }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 900px) {
  body.mit-leiste { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .leiste { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--linie); }
  .leiste nav { flex-direction: row; overflow-x: auto; gap: 2px; order: 3; width: 100%; }
  .leiste nav a { padding: 7px 10px; }
  .ich { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 12px; }
  main { padding: 20px 16px 48px; }
  .spalten, .spalten.breit-schmal { grid-template-columns: 1fr; }
  .seitenblock { position: static; margin-top: 24px; }
  .nachricht { max-width: 92%; }
  .lage > div { border-right: 0; border-bottom: 1px solid var(--linie); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Agent: Versionen und Editor ---------- */
.status-version-entwurf { background: var(--gelb-grund); color: var(--gelb); }
.status-version-aktiv { background: var(--gruen-grund); color: var(--gruen); }
.status-version-archiviert { background: var(--zart); color: var(--leise); }
.tabelle .zeile-neben { display: block; }
.hilfe.ohne-abstand { margin-top: 0; margin-bottom: 14px; }
pre.prompt, pre.vergleich { margin: 8px 0 0; padding: 12px 14px; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); font: 0.86rem/1.55 ui-monospace, "SF Mono", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.vergleich span { display: block; padding: 0 4px; border-radius: 3px; }
pre.vergleich .z-neu { background: var(--gruen-grund); color: var(--gruen); }
pre.vergleich .z-weg { background: var(--warn-grund); color: var(--warn); text-decoration: line-through; text-decoration-color: currentColor; }
.baustein-ansicht { margin-top: 22px; }
.baustein-ansicht:first-of-type { margin-top: 0; }
form.editor .baustein { margin-bottom: 18px; }
form.editor .baustein label { margin-top: 0; color: var(--akzent); font-size: 0.95rem; font-weight: 600; }
form.editor .baustein .hilfe { margin: 0 0 6px; }
form.editor textarea { font: 0.88rem/1.55 ui-monospace, "SF Mono", Consolas, monospace; }
details.fest { margin-top: 18px; }
details.fest summary { cursor: pointer; color: var(--leise); font-weight: 500; }
details.fest summary:hover { color: var(--text); }
.seitenblock label:first-child { margin-top: 0; }
.notiz { margin: 12px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--zart); white-space: pre-wrap; }
.reihe.umbruch { flex-wrap: wrap; }
form.aktivieren { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--linie); }
form.aktivieren p { margin: 0 0 8px; font-size: 0.88rem; color: var(--leise); }
label.haken { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--text); font-weight: 400; }
label.haken input { margin-top: 3px; accent-color: var(--akzent); }
.umbruch-text { white-space: pre-wrap; overflow-wrap: anywhere; }
fieldset.werkzeuge { margin: 4px 0 18px; padding: 12px 14px 14px; border: 1px solid var(--linie); border-radius: var(--radius); background: var(--flaeche); }
fieldset.werkzeuge legend { padding: 0 4px; color: var(--akzent); font-weight: 600; font-size: 0.95rem; }
fieldset.werkzeuge .hilfe { margin: 0 0 8px; }
fieldset.werkzeuge label.haken { margin-top: 10px; }
fieldset.werkzeuge label.haken > span { display: flex; flex-direction: column; }
