:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --line: #e3e2de;
  --text: #17171a;
  --text-2: #52514e;
  --text-3: #7a7974;
  --accent: #2a78d6;
  --accent-text: #ffffff;
  --accent-soft: #e8f1fc;
  --bar: #2a78d6;
  --good: #1f7a3d;
  --good-soft: #e6f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8e8d86;
    --accent: #3987e5;
    --accent-soft: #1b2a3d;
    --bar: #3987e5;
    --good: #6fcf8f;
    --good-soft: #17301f;
    --warn: #f0c060;
    --warn-soft: #352a12;
    --bad: #f28b82;
    --bad-soft: #3a1b19;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8e8d86;
  --accent: #3987e5; --accent-soft: #1b2a3d; --bar: #3987e5;
  --good: #6fcf8f; --good-soft: #17301f; --warn: #f0c060; --warn-soft: #352a12;
  --bad: #f28b82; --bad-soft: #3a1b19; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; }
p { margin: 0 0 12px; }
.leise { color: var(--text-2); }
.klein { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }

/* Layout */
.rahmen { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.seitenleiste {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.marke { font-weight: 700; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
.marke span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-size: 14px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500;
}
.kontoanzeige { margin: 0 4px 12px; padding: 10px; border-radius: 8px; background: var(--surface-2); line-height: 1.35; }
.kontoanzeige form { margin-top: 2px; }
.nav a.nav-betreiber { margin-top: 10px; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; padding-top: 12px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.aktiv { background: var(--accent-soft); color: var(--accent); }
.zaehler { background: var(--accent); color: var(--accent-text); border-radius: 999px;
  font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
.nav-fuss { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.nav-fuss form { display: inline; }
.inhalt { padding: 28px 32px 48px; max-width: 1200px; width: 100%; }
.kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap; }

@media (max-width: 800px) {
  .rahmen { grid-template-columns: 1fr; }
  .seitenleiste { position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .marke { padding: 4px 8px 4px 0; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-fuss { margin: 0; border: 0; padding: 8px 0 0; width: 100%; }
  .inhalt { padding: 20px 16px 40px; }
}

/* Bausteine */
.karte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); }
.raster { display: grid; gap: 16px; }
.raster-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kachel .label { color: var(--text-2); font-size: 13px; }
.kachel .wert { font-size: 2rem; font-weight: 650; line-height: 1.2; margin-top: 4px; }
.kachel .zusatz { color: var(--text-3); font-size: 13px; }
.abstand { margin-bottom: 16px; }

.meldung { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.meldung.ok { background: var(--good-soft); color: var(--good); }
.meldung.fehler { background: var(--bad-soft); color: var(--bad); }

.marke-status { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.marke-status.weitergeleitet, .marke-status.beantwortet { background: var(--good-soft); color: var(--good); }
.marke-status.rueckruf, .marke-status.nicht_erreicht { background: var(--warn-soft); color: var(--warn); }
.marke-status.fehler { background: var(--bad-soft); color: var(--bad); }

/* Tabellen */
.tabelle-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

/* Formulare */
label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.hilfe { color: var(--text-3); font-size: 13px; margin: 2px 0 0; font-weight: 400; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input[type=text], input[type=password], input[type=search], select { height: 40px; }
td.nowrap { white-space: nowrap; }
textarea { min-height: 90px; resize: vertical; }
textarea.gross { min-height: 420px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.feld { margin-bottom: 14px; }
.zeile { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.zeile.oben { align-items: flex-start; }
.zeile > * { flex: 1 1 160px; }
.zeile > .knopf, .zeile > button { flex: 0 0 auto; }

button, .knopf {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: inline-block;
}
button:hover, .knopf:hover { background: var(--surface-2); text-decoration: none; }
button.haupt, .knopf.haupt { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.haupt:hover { filter: brightness(1.08); }
button.gefahr { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; background: none; }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; }

.reiter { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.reiter a { padding: 8px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.reiter a.aktiv { color: var(--accent); border-color: var(--accent); }
.reiter a:hover { text-decoration: none; color: var(--text); }

/* Diagramme */
.saeulen { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding-top: 8px;
  border-bottom: 1px solid var(--line); }
.saeule { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; }
.saeule .fuell { width: 100%; background: var(--bar); border-radius: 4px 4px 0 0; min-height: 0; }
.saeule:hover .fuell { filter: brightness(1.12); }
.saeule .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px;
  white-space: nowrap; z-index: 2; pointer-events: none; }
.saeule:hover .tip, .saeule:focus .tip { display: block; }
.saeulen-achse { display: flex; gap: 2px; font-size: 11px; color: var(--text-3); margin-top: 6px; }
.saeulen-achse span { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; }
.balken { display: grid; gap: 10px; }
.balken-zeile { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.balken-spur { height: 10px; }
.balken-fuell { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
details.tabellenansicht { margin-top: 12px; font-size: 13px; }
details.tabellenansicht summary { cursor: pointer; color: var(--text-2); }

/* Gesprächsverlauf */
.verlauf { display: flex; flex-direction: column; gap: 10px; }
.blase { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); }
.blase.agent { align-self: flex-start; border-bottom-left-radius: 4px; }
.blase.anrufer { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.blase .wer { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.werkzeug { font-size: 13px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 4px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; font-size: 12px; color: var(--text-2); }

.liste { display: grid; gap: 12px; }
.leer { color: var(--text-3); padding: 24px 0; text-align: center; }

.anmelden { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.anmelden .karte { width: 100%; max-width: 380px; }

/* QR-Code für die Authenticator-App: immer schwarz auf weiß, auch im dunklen Modus */
.qr { display: inline-block; background: #fff; border-radius: 8px; margin: 8px 0; }
.qr svg { display: block; width: 240px; height: 240px; max-width: 100%; }
