/* =====================================================================
   KI-Assistenz Jugendhilfe – Stylesheet nach DESIGN.md
   Aufbau: 1 Tokens · 2 Farbschemata · 3 Grundlagen · 4 App-Shell · 5 Bausteine
           6 Seitentypen · 7 Module · 8 Dialoge · 9 Responsiv · 10 Bewegung
   ===================================================================== */

/* ---------- 1. Tokens (unabhängig vom Farbschema) ---------- */
:root {
  --a1: 4px; --a2: 8px; --a3: 12px; --a4: 16px; --a5: 24px; --a6: 32px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --schrift-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gr-basis: 14px; --gr-klein: 12px; --gr-h1: 20px; --gr-h2: 16px; --gr-h3: 14px;
  --r-klein: 6px; --r-gross: 10px;
  --h-feld: 36px; --h-kopf: 52px;
  --seitenrand: 16px;
  --dauer: 200ms;
}

/* ---------- 2. Farbschemata: hell (Standard), dunkel, System ---------- */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --flaeche: #ffffff;
  --flaeche-2: #f7f8fa;
  --flaeche-erhoeht: #ffffff;
  --text: #17202b;
  --leise: #5b6676;
  --linie: #dfe3e9;
  --linie-stark: #c5ccd6;
  --akzent: var(--marke-hell, #1d5fa8);
  --akzent-text: var(--marke-hell-text, #ffffff);
  --ok: #157a3b;       --ok-bg: #e7f5ec;
  --warn: #8a5a00;     --warn-bg: #fff4d6;
  --krit: #b42318;     --krit-bg: #fdecea;
  --info: #1d5fa8;     --info-bg: #e8f0fb;
  --fokus: #1d5fa8;
  --schatten-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --schatten-2: 0 12px 32px rgb(16 24 40 / .18), 0 2px 6px rgb(16 24 40 / .08);
  --imp: #b45309;
}
:root[data-theme="dunkel"] {
  color-scheme: dark;
  --bg: #0e1218;
  --flaeche: #161c24;
  --flaeche-2: #1b222c;
  --flaeche-erhoeht: #1f2732;
  --text: #e7ebf0;
  --leise: #9aa6b5;
  --linie: #2a333f;
  --linie-stark: #3a4555;
  --akzent: var(--marke-dunkel, #6ea8ec);
  --akzent-text: var(--marke-dunkel-text, #0b1220);
  --ok: #6fd193;       --ok-bg: #133022;
  --warn: #f2c25b;     --warn-bg: #33270e;
  --krit: #ff8a7f;     --krit-bg: #3a1c1a;
  --info: #8ab8f0;     --info-bg: #17263a;
  --fokus: #8ab8f0;
  --schatten-1: 0 1px 2px rgb(0 0 0 / .4);
  --schatten-2: 0 16px 40px rgb(0 0 0 / .55);
  --imp: #c2620d;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #0e1218;
    --flaeche: #161c24;
    --flaeche-2: #1b222c;
    --flaeche-erhoeht: #1f2732;
    --text: #e7ebf0;
    --leise: #9aa6b5;
    --linie: #2a333f;
    --linie-stark: #3a4555;
    --akzent: var(--marke-dunkel, #6ea8ec);
    --akzent-text: var(--marke-dunkel-text, #0b1220);
    --ok: #6fd193;       --ok-bg: #133022;
    --warn: #f2c25b;     --warn-bg: #33270e;
    --krit: #ff8a7f;     --krit-bg: #3a1c1a;
    --info: #8ab8f0;     --info-bg: #17263a;
    --fokus: #8ab8f0;
    --schatten-1: 0 1px 2px rgb(0 0 0 / .4);
    --schatten-2: 0 16px 40px rgb(0 0 0 / .55);
    --imp: #c2620d;
  }
}
:root { --akzent-weich: color-mix(in srgb, var(--akzent) 14%, var(--flaeche)); }

/* ---------- 3. Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: var(--gr-basis)/1.45 var(--schrift); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: var(--gr-h1); font-weight: 650; }
h2 { font-size: var(--gr-h2); font-weight: 650; }
h3 { font-size: var(--gr-h3); font-weight: 650; display: flex; align-items: center; gap: var(--a2); }
p { margin: 0; }
a { color: var(--akzent); }
code { font-family: var(--schrift-mono); font-size: .92em; background: var(--flaeche-2); border: 1px solid var(--linie);
       padding: 0 4px; border-radius: 4px; }
[hidden] { display: none !important; }
.leise { color: var(--leise); }
.klein { font-size: var(--gr-klein); }
.hinweis { color: var(--leise); font-size: var(--gr-klein); }
:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }

/* Symbole (Lucide-Sprite) */
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; vertical-align: -3px; }
.ic-l { width: 20px; height: 20px; }

/* ---------- 4. App-Shell ---------- */
.app { height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
/* feste Zeilen: ausgeblendeter Banner darf den Inhalt nicht in die auto-Zeile verschieben */
.app > .imp-banner { grid-row: 1; } .app > .kopf { grid-row: 2; } .app > .inhalt { grid-row: 3; }
.inhalt { min-height: 0; overflow: hidden; }

.kopf {
  height: var(--h-kopf); display: flex; align-items: center; gap: var(--a4); padding: 0 var(--seitenrand);
  background: var(--flaeche); border-bottom: 1px solid var(--linie); position: relative; z-index: 10;
}
.marke { display: flex; align-items: center; gap: var(--a2); white-space: nowrap; }
.marke-zeichen { color: var(--akzent); font-size: 18px; }
.marke-logo { height: 28px; max-width: 120px; object-fit: contain; }
.marke-logo:not([hidden]) + .marke-zeichen { display: none; }
.marke-name { font-weight: 700; font-size: 15px; }
.marke-zusatz { font-weight: 500; color: var(--leise); }
.hauptnavi { display: flex; gap: 2px; height: 100%; }
.reiter-btn {
  display: flex; align-items: center; gap: var(--a2); padding: 0 var(--a3); height: 100%; border: 0; background: none;
  color: var(--leise); font: inherit; font-weight: 550; cursor: pointer; border-bottom: 2px solid transparent;
}
.reiter-btn:hover { color: var(--text); }
.reiter-btn.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); }
.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: var(--a3); }

.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--gr-klein); color: var(--leise);
  padding: 3px 10px; border-radius: 99px; background: var(--flaeche-2); border: 1px solid var(--linie); white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status.demo::before { background: var(--warn); }
.status.fehler { color: var(--krit); }
.status.fehler::before { background: var(--krit); }

.nutzer-menue { position: relative; }
.nutzer-btn {
  display: flex; align-items: center; gap: var(--a2); border: 0; background: none; color: inherit; font: inherit;
  padding: 4px 6px; border-radius: var(--r-klein); cursor: pointer; text-align: right;
}
.nutzer-btn:hover { background: var(--flaeche-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--akzent-weich); color: var(--akzent);
}
.nutzer-text { display: grid; line-height: 1.2; }
.nutzer-text #nutzer-name { font-weight: 600; font-size: 13px; }
.nutzer-text .leise { font-size: 11px; }
.schwebend {
  background: var(--flaeche-erhoeht); border: 1px solid var(--linie); border-radius: var(--r-gross); box-shadow: var(--schatten-2);
}
.nutzer-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 280px; padding: var(--a2); display: grid; gap: 2px; z-index: 30; }
.panel-kopf { display: grid; padding: var(--a2); border-bottom: 1px solid var(--linie); margin-bottom: var(--a1); }
.panel-gruppe { display: grid; gap: 6px; padding: var(--a2); }
.panel-eintrag {
  display: flex; align-items: center; gap: var(--a2); padding: 8px; border-radius: var(--r-klein); border: 0; background: none;
  color: inherit; font: inherit; text-decoration: none; cursor: pointer; text-align: left;
}
.panel-eintrag:hover { background: var(--flaeche-2); }
.panel-fuss { padding: var(--a2); border-top: 1px solid var(--linie); margin-top: var(--a1); }

/* Seitenmenü (mobil) */
.seitenmenue { position: fixed; inset: 0; z-index: 40; }
.seitenmenue-flaeche { position: absolute; inset: 0; background: rgb(0 0 0 / .4); }
.seitenmenue-panel {
  position: absolute; inset: 0 auto 0 0; width: min(300px, 85vw); background: var(--flaeche); box-shadow: var(--schatten-2);
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.seitenmenue-kopf { height: var(--h-kopf); display: flex; align-items: center; justify-content: space-between;
                    padding: 0 var(--a2) 0 var(--a4); border-bottom: 1px solid var(--linie); }
.seitenmenue-navi { display: grid; gap: 2px; padding: var(--a2); overflow: auto; }
.seitenmenue-navi button {
  display: flex; align-items: center; gap: var(--a3); min-height: 44px; padding: 0 var(--a3); border: 0; border-radius: var(--r-klein);
  background: none; color: inherit; font: inherit; font-weight: 550; text-align: left; cursor: pointer;
}
.seitenmenue-navi button.aktiv { background: var(--akzent-weich); color: var(--akzent); }
.seitenmenue-navi .navi-titel { padding: var(--a3) var(--a3) var(--a1); font-size: var(--gr-klein); color: var(--leise); }

/* Impersonation */
.imp-banner {
  display: flex; align-items: center; gap: var(--a3); padding: 6px var(--seitenrand); background: var(--imp); color: #fff;
  font-size: 13px;
}
.imp-kurz { display: none; }
.imp-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; background: #fff;
  color: var(--imp); border: 0; border-radius: var(--r-klein); padding: 4px 12px; cursor: pointer; white-space: nowrap;
}

/* ---------- 5. Bausteine ---------- */
.ansicht { display: none; height: 100%; min-height: 0; padding: var(--a4) var(--seitenrand); gap: var(--a4);
           overflow: auto; max-width: 1600px; margin: 0 auto; }
.ansicht.aktiv { display: grid; }

.karte {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r-gross); box-shadow: var(--schatten-1);
  padding: var(--a4); min-width: 0; display: flex; flex-direction: column; gap: var(--a3);
}
.karte-scroll { min-height: 0; overflow: auto; }
.karte-kopf, .abschnitt-kopf, .spalte-kopf, .seiten-kopf {
  display: flex; align-items: center; justify-content: space-between; gap: var(--a3); flex-wrap: wrap;
}
.seiten-kopf { align-items: flex-end; }
.seiten-kopf h1 { display: flex; align-items: center; gap: var(--a2); }
.aktionen { display: flex; align-items: center; gap: var(--a2); flex-wrap: wrap; }

/* Raster */
.raster { display: grid; gap: var(--a3); }
.raster-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.raster-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.raster-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.raster-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.s1 { grid-column: span 1; } .s2 { grid-column: span 2; } .s3 { grid-column: span 3; }
.s4 { grid-column: span 4; } .s6 { grid-column: span 6; }
.spalte-alle { grid-column: 1 / -1; }

/* Schaltflächen */
.btn-haupt, .btn-zweit, .btn-gefahr, .btn-text {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--h-feld);
  padding: 0 14px; border-radius: var(--r-klein); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; text-decoration: none;
}
.btn-haupt { background: var(--akzent); color: var(--akzent-text); }
.btn-haupt:hover { filter: brightness(1.08); }
.btn-zweit { background: var(--flaeche); color: var(--text); border-color: var(--linie-stark); }
.btn-zweit:hover { background: var(--flaeche-2); }
.btn-gefahr { background: none; color: var(--krit); border-color: currentColor; }
.btn-text { background: none; color: var(--akzent); padding: 0 6px; min-height: 28px; }
.btn-text.gefahr { color: var(--krit); }
.klein.btn-haupt, .klein.btn-zweit, .klein.btn-gefahr { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-text.klein { font-size: 13px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.symbol-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--r-klein);
  background: none; color: var(--leise); cursor: pointer; flex: none;
}
.symbol-btn:hover { background: var(--flaeche-2); color: var(--text); }
.symbol-btn.gefahr:hover { color: var(--krit); }

/* Felder */
.feld { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 550; color: var(--text); min-width: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--flaeche); border: 1px solid var(--linie-stark);
  border-radius: var(--r-klein); padding: 0 10px; min-height: var(--h-feld); width: 100%;
}
textarea { padding: 8px 10px; resize: vertical; line-height: 1.45; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fokus); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--akzent); margin: 0; flex: none; }
input[type=color] { padding: 2px; width: 40px; flex: none; cursor: pointer; }
select.klein { min-height: 30px; font-size: 13px; width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; cursor: pointer; }
.feld-check { align-self: end; min-height: var(--h-feld); }
.optionen { display: flex; flex-wrap: wrap; gap: var(--a2) var(--a4); }
.label-zeile { display: flex; align-items: center; gap: var(--a2); }
.suche { position: relative; display: block; }
.suche .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--leise); }
.suche input { padding-left: 32px; width: 220px; }

/* Segmentschalter */
.segment { display: inline-flex; background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: var(--r-klein); padding: 2px; gap: 2px; }
.segment button, .segment label {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; border: 0; border-radius: 4px;
  background: none; color: var(--leise); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
  position: relative;
}
.segment [aria-checked="true"], .segment [aria-selected="true"], .segment label:has(input:checked) {
  background: var(--flaeche); color: var(--text); box-shadow: var(--schatten-1);
}
.segment label input { position: absolute; opacity: 0; pointer-events: none; }

/* Schalter */
.schalter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.schalter input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--linie-stark); position: relative;
                  transition: background var(--dauer); }
.schalter input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
                         background: #fff; transition: transform var(--dauer); }
.schalter input:checked { background: var(--ok); }
.schalter input:checked::after { transform: translateX(14px); }

/* Pillen, Meldungen, Boxen */
.pille { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap;
         background: var(--flaeche-2); color: var(--leise); border: 1px solid var(--linie); vertical-align: middle; }
.pille.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pille.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pille.aus { background: var(--krit-bg); color: var(--krit); border-color: transparent; }
.meldung { color: var(--krit); font-size: 13px; }
.meldung:empty { display: none; }
.meldung.ok { color: var(--ok); }
.warnbox { display: flex; gap: 8px; align-items: flex-start; background: var(--warn-bg); color: var(--text); border-radius: var(--r-klein);
           padding: 8px 12px; font-size: 13px; }
.warnbox .ic { color: var(--warn); margin-top: 2px; }
.testbox { border-radius: var(--r-klein); padding: 8px 12px; background: var(--flaeche-2); font-size: 13px; white-space: pre-wrap; }
.testbox.ok { background: var(--ok-bg); color: var(--ok); }
.testbox.fehler { background: var(--krit-bg); color: var(--krit); }

/* Tabellen */
.tabelle-wrap { overflow: auto; min-height: 0; }
.liste { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.liste th, .liste td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
.liste th { position: sticky; top: 0; z-index: 1; background: var(--flaeche); color: var(--leise); font-weight: 600; font-size: 12px; white-space: nowrap; }
.liste tr:hover td { background: var(--flaeche-2); }
.liste td .leise, .liste td .hinweis { font-size: 12px; display: block; }
.aktionen-zelle { white-space: nowrap; text-align: right; width: 1%; }
.aktionen-zelle .symbol-btn { width: 30px; height: 30px; }
.warn-zeile td { background: var(--warn-bg); }
.matrix th:not(:first-child), .matrix td:not(:first-child) { text-align: center; }
/* Rechte-Matrix: gleich breite Rollenspalten, Rechte-Spalte bleibt beim Wischen stehen */
.matrix { table-layout: fixed; min-width: 640px; }
.matrix th:first-child { width: 27%; vertical-align: bottom; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; background: var(--flaeche); }
.matrix th:first-child { z-index: 2; }
.matrix tr:hover td:first-child { background: var(--flaeche-2); }
.matrix th:not(:first-child) { white-space: normal; vertical-align: bottom; padding: 6px 6px 8px; }
.matrix td { padding-top: 4px; padding-bottom: 4px; }
.matrix tr.gruppe td { background: var(--flaeche-2); font-weight: 650; font-size: 12px; color: var(--leise); text-align: left;
                       padding-top: 10px; text-transform: uppercase; letter-spacing: .04em; }
.haken { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
         background: var(--akzent-weich); color: var(--akzent); }
.haken .ic { width: 14px; height: 14px; stroke-width: 3; }
.kein { color: var(--linie-stark); }
.rollen-kopf { display: grid; justify-items: center; gap: 2px; }
.rollen-kopf b { color: var(--text); font-size: 13.5px; line-height: 1.25; text-align: center; }
.rollen-meta { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.rollen-meta .leise { display: inline-flex; align-items: center; gap: 3px; }
.rollen-meta .ic { width: 13px; height: 13px; }
.rollen-aktionen { display: inline-flex; gap: 2px; }
.rollen-aktionen .symbol-btn { width: 28px; height: 28px; }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--a3); }
.kpi { display: grid; gap: 2px; padding: 10px 14px; border-radius: var(--r-gross); background: var(--flaeche);
       border: 1px solid var(--linie); border-left: 4px solid var(--akzent); box-shadow: var(--schatten-1); }
.kpi.hoch { border-left-color: var(--krit); }
.kpi.mittel { border-left-color: var(--warn); }
.kpi-wert { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi-titel { font-size: 12px; color: var(--leise); }

/* Diagramme */
.diagramm { position: relative; flex: 1; min-height: 180px; }

/* Ausklappbares Panel */
.ausklapp { position: relative; }
.ausklapp summary { list-style: none; }
.ausklapp summary::-webkit-details-marker { display: none; }
.ausklapp-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; width: 380px; padding: var(--a4); display: grid; gap: var(--a4); }

/* Meldungen (Toasts) */
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--flaeche); padding: 10px 16px; border-radius: var(--r-gross); font-size: 13px;
         box-shadow: var(--schatten-2); border-left: 4px solid var(--ok); }
.toast.fehler { border-left-color: var(--krit); }

/* Drag & Drop */
.zieh-geist { opacity: .35; outline: 2px dashed var(--akzent); outline-offset: -2px; }
.zieh-aktiv { box-shadow: var(--schatten-2); }
.ziehgriff { cursor: grab; color: var(--leise); display: grid; place-items: center; touch-action: none; }

/* ---------- 6. Seitentypen ---------- */
/* Arbeitsseite: 2 Spalten in voller Höhe, innen scrollend */
.arbeitsseite.aktiv { grid-template-columns: minmax(360px, 40%) minmax(0, 1fr); overflow: hidden; }
.spalte { padding: 0; gap: 0; overflow: hidden; min-height: 0; }
.spalte-inhalt { flex: 1; min-height: 0; overflow: auto; padding: var(--a4); display: flex; flex-direction: column; gap: var(--a3); }
.spalte-kopf { padding: var(--a3) var(--a4); border-bottom: 1px solid var(--linie); }
.spalte-fuss { display: flex; justify-content: flex-end; gap: var(--a2); padding: var(--a3) var(--a4); border-top: 1px solid var(--linie);
               background: var(--flaeche-2); border-radius: 0 0 var(--r-gross) var(--r-gross); }

/* Dashboard */
.dashboard.aktiv, .bereich.dashboard { align-content: start; grid-template-columns: minmax(0, 1fr); }
.raster-sr { grid-template-columns: minmax(240px, 1fr) minmax(0, 1.4fr) minmax(0, 1.2fr); }
/* Sozialraum füllt die Höhe: Kopf, Kennzahlen, Diagramme, Tabelle + Bericht */
#sozialraum.aktiv { grid-template-rows: auto auto minmax(220px, 1fr) minmax(220px, 1.15fr); }
.raster-sr > .karte, .raster-ue > .karte { min-height: 0; }
.raster-ue { grid-template-columns: 2fr 1fr 1fr; min-height: 250px; }
.raster-ue:has(> .karte[hidden]) { grid-template-columns: 2fr 1fr; }
/* Übersicht füllt die verfügbare Höhe: Kopf, Kennzahlen, Diagramme */
#v-uebersicht { height: 100%; grid-template-rows: auto auto minmax(250px, 1fr); }
@media (min-width: 1280px) { .dashboard .raster-2, .dashboard .raster-2 > .karte { min-height: 0; } }

/* Verwaltung: Seitennavigation + Inhalt */
.verwaltung.aktiv { grid-template-columns: 196px minmax(0, 1fr); overflow: hidden; }
.unter-reiter { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.mandant-wahl { display: grid; gap: 4px; margin-bottom: var(--a2); }
.mandant-wahl select { min-height: 32px; font-size: 13px; }
.unter-btn {
  display: flex; align-items: center; gap: var(--a2); padding: 7px 10px; border: 0; border-radius: var(--r-klein); background: none;
  color: var(--text); font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.unter-btn:hover { background: var(--flaeche); }
.unter-btn.aktiv { background: var(--akzent-weich); color: var(--akzent); font-weight: 650; }
.verwaltung-inhalt { min-height: 0; overflow: auto; }
.bereich { display: grid; gap: var(--a4); align-content: start; }
.listenseite { grid-template-rows: auto minmax(0, 1fr); height: 100%; min-height: 0; }
.leer-hinweis { max-width: 560px; margin: var(--a6) auto; }

/* Editor: Liste links, Formular rechts */
.editorseite { grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; min-height: 0; }
.editor-form { min-height: 0; overflow: auto; }
.form-voll { display: flex; flex-direction: column; gap: var(--a3); height: 100%; min-height: 0; }
.feld-wachsend { flex: 1; min-height: 140px; }
.feld-wachsend textarea { flex: 1; min-height: 110px; resize: none; }
.form-fuss { display: flex; align-items: center; gap: var(--a3); }
.form-fuss > :last-child { margin-left: auto; }
.form-fuss .meldung { margin-left: auto; }
.form-fuss .meldung:not(:empty) + .btn-haupt { margin-left: 0; }
.raster-vorlage { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 100px auto; }
/* Anweisung und Beispielnotizen teilen sich die Resthöhe nebeneinander */
.vorlage-texte { min-height: 0; grid-template-rows: minmax(0, 1fr); }
.vorlage-texte .feld { min-height: 0; }
.label-zeile .leise { font-weight: 400; font-size: 12px; }

/* ---------- 7. Module ---------- */
/* Doku-Assistent */
.vorlagen { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
#doku .spalte-inhalt { gap: 10px; }
#notizen { flex: 1 1 auto; min-height: 88px; }
#namen { min-height: 0; }
.vorlage {
  text-align: left; border: 1px solid var(--linie); background: var(--flaeche); color: var(--text); border-radius: var(--r-klein);
  padding: 5px 8px; cursor: pointer; font: inherit; min-height: 40px; min-width: 0; display: grid; align-content: center;
}
.vorlage strong { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; hyphens: auto; }
.vorlage span { display: none; }
.vorlage:hover { border-color: var(--linie-stark); }
.vorlage.aktiv { border-color: var(--akzent); background: var(--akzent-weich); box-shadow: inset 0 0 0 1px var(--akzent); }
textarea.wachsend { flex: 1; min-height: 130px; resize: none; }
.pseudo { border: 1px dashed var(--linie-stark); border-radius: var(--r-klein); padding: 6px 10px; display: grid; gap: 6px; }
.pseudo summary { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; cursor: pointer; }
.pseudo summary .pille { margin-left: auto; }
.vorschau-box { white-space: pre-wrap; font: 12px/1.45 var(--schrift-mono); background: var(--flaeche-2); border: 1px solid var(--linie);
                border-radius: var(--r-klein); padding: 10px; max-height: 200px; overflow: auto; margin: 0; }
.dokument { padding: var(--a4) var(--a5); line-height: 1.55; }
.dokument.leer { color: var(--leise); }
.dokument h1 { font-size: 18px; margin: .4em 0; }
.dokument h2 { font-size: 15px; margin: 1em 0 .4em; }
.dokument h3 { font-size: 14px; margin: .8em 0 .3em; }
.dokument p, .dokument ul, .dokument ol { margin: .4em 0; }
.dokument table { border-collapse: collapse; }
.dokument td, .dokument th { border: 1px solid var(--linie); padding: 4px 8px; }
.karte .dokument { padding: var(--a4) var(--a5); overflow: auto; flex: 1; min-height: 0; display: block; }
.raster .karte .dokument { padding: 0; }
.ausgabe-spinner::after { content: " ▍"; animation: blinken 1s steps(2) infinite; color: var(--akzent); }
@keyframes blinken { 50% { opacity: 0; } }
.doku-umschalter { display: none; }

/* Sozialraum */
.hinweise { display: grid; gap: 6px; }
.hinweis-karte { border-radius: var(--r-klein); padding: 8px 10px; border-left: 4px solid; font-size: 13px; }
.hinweis-karte.hoch { background: var(--krit-bg); border-color: var(--krit); }
.hinweis-karte.mittel { background: var(--warn-bg); border-color: var(--warn); }
.hinweis-karte b { display: block; }
#tabelle td, #tabelle th { text-align: right; font-variant-numeric: tabular-nums; }
#tabelle td:first-child, #tabelle th:first-child { text-align: left; }
#tabelle tr.kreis td { font-weight: 700; border-top: 2px solid var(--linie-stark); }
#tabelle td.hoch { background: var(--krit-bg); color: var(--krit); font-weight: 650; }
#tabelle td.mittel { background: var(--warn-bg); }

/* Vorlagen-Verwaltung */
.vl-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.vl-liste li.fest { border-bottom: 1px solid var(--linie); padding-bottom: 4px; margin-bottom: 4px; }
.vl-liste li:not(.fest) { cursor: grab; }
.vl-eintrag { width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 1px solid transparent;
              border-radius: var(--r-klein); padding: 6px 8px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.vl-eintrag b { flex: 1 1 100%; font-weight: 550; font-size: 13px; }
.vl-eintrag:hover { background: var(--flaeche-2); }
.vl-eintrag.aktiv { border-color: var(--akzent); background: var(--akzent-weich); }
.vl-eintrag.inaktiv b { color: var(--leise); text-decoration: line-through; }
#f-vorlage textarea, #f-prompts textarea { font: 12.5px/1.5 var(--schrift-mono); }

/* Benutzer- und Rollendialog */
.rollen-wahl { border: 1px solid var(--linie); border-radius: var(--r-klein); padding: 6px 12px 10px; margin: 0; }
.rollen-wahl legend { padding: 0 4px; font-size: 13px; font-weight: 600; }
.check-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
.check-raster label { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; cursor: pointer; }
.check-raster > p { grid-column: 1 / -1; }
.rechte-auswahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 16px; margin-top: var(--a2); }
.rechte-auswahl h3 { grid-column: 1 / -1; margin-top: var(--a2); font-size: 12px; color: var(--leise); }
.rechte-auswahl label { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; cursor: pointer; }
.rechte-auswahl p { grid-column: 1 / -1; }

/* KI-Modell */
.ki-erben { margin-bottom: var(--a1); }
.ki-felder { border: 0; padding: 0; margin: 0; min-width: 0; }
.raster-ki { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
.ki-felder.geerbt { opacity: .55; }
.modellbox { max-height: calc(100dvh - 260px); }
.om-laden { display: flex; gap: var(--a2); }
.om-fortschritt { background: var(--flaeche-2); border-radius: var(--r-klein); padding: 8px 12px; font-size: 13px; }
.om-fortschritt.fehler { background: var(--krit-bg); color: var(--krit); }
.om-fortschritt progress { width: 100%; height: 8px; accent-color: var(--akzent); }
.zeile { display: flex; justify-content: space-between; align-items: center; gap: var(--a2); }
#v-ki form, #v-sicherheit form { display: grid; gap: var(--a3); }

/* Mandant-Dialog */
.mandant-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--a5); }
.mandant-daten { display: grid; gap: var(--a3); align-content: start; }
.abschnitt-titel { display: flex; align-items: center; justify-content: space-between; gap: var(--a2); font-size: 13px; color: var(--leise); }
.abschnitt-titel h3 { font-size: 13px; color: var(--leise); }
h3.abschnitt-titel { justify-content: flex-start; }
.kontakte { flex: 1; }
.notizen-feld { margin-top: auto; padding-top: var(--a2); }
.mandant-unten { padding-top: var(--a3); border-top: 1px solid var(--linie); }
.farbwahl, .logowahl { display: flex; align-items: center; gap: var(--a2); }
.farbwahl input[name=akzentfarbe] { width: 96px; font-family: var(--schrift-mono); }
.logo-vorschau { width: 72px; height: var(--h-feld); border: 1px dashed var(--linie-stark); border-radius: var(--r-klein);
                 display: grid; place-items: center; color: var(--leise); background: var(--flaeche-2); flex: none; }
.logo-vorschau img { max-width: 64px; max-height: 30px; object-fit: contain; }
.mandant-kontakte { display: flex; flex-direction: column; gap: var(--a2); min-height: 0; border-left: 1px solid var(--linie);
                    padding-left: var(--a5); }
.kontakte { display: grid; gap: var(--a2); overflow: auto; min-height: 0; align-content: start; }
.kontakt-zeile {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) minmax(0, 1fr) 30px; gap: 6px; padding: 8px; align-items: center;
  border: 1px solid var(--linie); border-radius: var(--r-klein); background: var(--flaeche-2);
}
.kontakt-zeile .ziehgriff { grid-row: span 2; }
.kontakt-zeile input, .kontakt-zeile select { min-height: 30px; font-size: 13px; padding: 0 8px; }
.kontakt-zeile [data-k=funktion] { grid-column: 2; }
.kontakt-zeile [data-k=name] { grid-column: 3; }
.kontakt-zeile .symbol-btn { grid-column: 4; grid-row: 1 / span 2; }
.kontakt-zeile [data-k=telefon] { grid-column: 2; }
.kontakt-zeile [data-k=email] { grid-column: 3; }

/* ---------- 8. Dialoge ---------- */
.dlg {
  padding: 0; border: 1px solid var(--linie); border-radius: var(--r-gross); background: var(--flaeche); color: var(--text);
  box-shadow: var(--schatten-2); max-height: calc(100dvh - 32px); width: min(720px, calc(100vw - 32px)); overflow: hidden;
}
.dlg-s { width: min(440px, calc(100vw - 32px)); }
.dlg-m { width: min(720px, calc(100vw - 32px)); }
.dlg-l { width: min(1080px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgb(10 15 25 / .45); }
.dlg-form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.dlg-kopf { display: flex; align-items: center; gap: var(--a3); padding: var(--a2) var(--a2) var(--a2) var(--a5);
            border-bottom: 1px solid var(--linie); min-height: 52px; }
.dlg-kopf h2 { margin-right: auto; }
.dlg-inhalt { padding: var(--a4) var(--a5); overflow: auto; min-height: 0; flex: 1; }
.dlg-inhalt.raster { align-content: start; }
.dlg-fuss { display: flex; align-items: center; gap: var(--a2); padding: var(--a3) var(--a5); border-top: 1px solid var(--linie);
            background: var(--flaeche-2); }
.dlg-fuss .meldung { margin-left: auto; text-align: right; }
.dlg-fuss > .btn-zweit { margin-left: auto; }
.dlg-fuss .meldung:not(:empty) ~ .btn-zweit { margin-left: 0; }

/* ---------- Hilfe ---------- */
/* Kontext-Knopf „?“ neben Überschriften */
.hilfe-knopf { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
               background: none; color: var(--leise); cursor: pointer; vertical-align: middle; flex: none; }
.hilfe-knopf .ic { width: 17px; height: 17px; }
.hilfe-knopf:hover, .hilfe-knopf:focus-visible { color: var(--akzent); background: var(--akzent-weich); }
.hilfe-knopf[hidden] { display: none; }
.panel-hilfe { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--a2); }
.kopf-hilfe.aktiv { color: var(--akzent); background: var(--akzent-weich); }

/* Seitenpanel rechts (dialog: nicht modal, über Dialogen modal) */
.hilfe-panel { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(460px, 100vw); height: 100dvh; max-height: 100dvh;
               padding: 0; border: 0; border-left: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
               box-shadow: var(--schatten-2); z-index: 50; }
.hilfe-panel[open] { display: flex; flex-direction: column; }
.hilfe-panel::backdrop { background: rgb(10 15 25 / .25); }
.hilfe-panel-kopf { display: flex; align-items: center; gap: var(--a2); padding: var(--a2) var(--a2) var(--a2) var(--a4);
                    border-bottom: 1px solid var(--linie); background: var(--flaeche-2); }
.hilfe-panel-kopf b { margin-right: auto; }
.hilfe-panel .hilfe-text { flex: 1; overflow: auto; min-height: 0; }
.hilfe-frage { display: flex; gap: var(--a2); padding: var(--a3); border-top: 1px solid var(--linie); background: var(--flaeche-2); }
.hilfe-frage input { flex: 1; min-width: 0; }
.hilfe-ki-knopf { justify-content: center; }
.hilfe-text h1 .ic { color: var(--akzent); vertical-align: -2px; }
.ki-hinweis { margin-top: 1em; padding-top: .6em; border-top: 1px solid var(--linie); }
.hilfe-zurueck-link { display: inline-flex; margin-top: .8em; }

/* Hilfeseite: Themen links, Artikel rechts */
.hilfeseite.aktiv { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.hilfe-navi { min-height: 0; overflow: hidden; }
.hilfe-navi h1 { display: flex; align-items: center; gap: var(--a2); }
.hilfe-navi .suche, .hilfe-navi .suche input { width: 100%; }
.hilfe-liste { overflow: auto; min-height: 0; flex: 1; margin: 0 calc(-1 * var(--a2)); padding: 0 var(--a2); }
.hilfe-kapitel { font-size: 12px; font-weight: 650; color: var(--leise); text-transform: uppercase; letter-spacing: .04em;
                 margin: var(--a3) 0 4px; padding: 0 8px; }
.hilfe-eintrag { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); font: inherit;
                 padding: 6px 8px; border-radius: var(--r-klein); cursor: pointer; }
.hilfe-eintrag:hover { background: var(--flaeche-2); }
.hilfe-eintrag.aktiv { background: var(--akzent-weich); color: var(--akzent); font-weight: 600; }
.hilfe-eintrag small { display: block; color: var(--leise); font-size: 12px; font-weight: 400; line-height: 1.35; margin-top: 1px; }
.hilfe-treffer mark { background: var(--warn-bg); color: inherit; border-radius: 2px; }
.hilfe-inhalt { padding: 0; overflow: hidden; min-height: 0; }
/* Artikel mit lesbarer Zeilenlänge, daneben die Seitenleiste – gescrollt wird gemeinsam, Balken am Kartenrand */
.hilfe-scroll { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 860px) minmax(220px, 300px);
                justify-content: space-between; gap: var(--a5); align-items: start; padding-right: var(--a5); }
.hilfe-scroll .hilfe-text { max-width: none; }
.hilfe-scroll .hilfe-weiter { display: none; }   /* steht in der Seitenleiste */
.hilfe-seitenleiste { position: sticky; top: 0; display: grid; gap: var(--a4); padding: var(--a4) 0; font-size: 13px; }
.hilfe-seitenleiste h4 { margin: 0 0 6px; font-size: 12px; font-weight: 650; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; }
.hilfe-seitenleiste nav { display: grid; gap: 1px; border-left: 2px solid var(--linie); }
.hilfe-seitenleiste nav a { display: block; padding: 4px 10px; margin-left: -2px; border-left: 2px solid transparent; color: var(--text);
                            text-decoration: none; line-height: 1.35; }
.hilfe-seitenleiste nav a:hover { color: var(--akzent); }
.hilfe-seitenleiste nav a.aktiv { border-left-color: var(--akzent); color: var(--akzent); font-weight: 600; }
.hilfe-seitenleiste .verwandt a { display: block; padding: 4px 0; color: var(--akzent); text-decoration: none; line-height: 1.35; }
.hilfe-seitenleiste .verwandt a:hover { text-decoration: underline; }
.hilfe-frage-seite { display: grid; gap: 6px; padding: var(--a3); border-radius: var(--r-gross); background: var(--akzent-weich);
                     border: 1px solid color-mix(in srgb, var(--akzent) 25%, transparent); }
.hilfe-frage-seite textarea { min-height: 64px; resize: vertical; font-size: 13px; }
.hilfe-frage-seite p { margin: 0; color: var(--leise); font-size: 12px; }

/* Artikel-Typografie */
.hilfe-text { max-width: 820px; font-size: 14.5px; }
.hilfe-text h1 { font-size: 21px; margin: 0 0 .2em; }
.hilfe-text .hilfe-kurz { color: var(--leise); margin: 0 0 1em; font-size: 14px; }
.hilfe-text h2 { font-size: 16px; margin: 1.4em 0 .4em; }
.hilfe-text h3 { font-size: 14.5px; margin: 1.2em 0 .3em; }
.hilfe-text table { width: 100%; margin: .6em 0 1em; font-size: 13.5px; }
.hilfe-text th { background: var(--flaeche-2); text-align: left; }
.hilfe-text code { background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: 4px; padding: 0 4px; font-size: 13px; }
.hilfe-text pre { background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: var(--r-klein); padding: 8px 12px; overflow: auto; }
.hilfe-text pre code { border: 0; padding: 0; background: none; }
.hilfe-text a { color: var(--akzent); }
.hilfe-text .tot-link { border-bottom: 1px dotted var(--leise); }
/* Kästen aus Zitatblöcken: Fallbeispiel, Tipp, Wichtig, Schritt für Schritt */
.hilfe-text blockquote { margin: 1em 0; padding: 10px 14px 10px 44px; border-radius: var(--r-gross); position: relative;
                         background: var(--flaeche-2); border: 1px solid var(--linie); }
.hilfe-text blockquote > p:first-of-type > strong:first-child { display: block; margin-bottom: 2px; }
.hilfe-text blockquote > :first-child { margin-top: 0; } .hilfe-text blockquote > :last-child { margin-bottom: 0; }
.hilfe-text blockquote .kasten-ic { position: absolute; left: 14px; top: 12px; width: 18px; height: 18px; }
.hilfe-text blockquote.kasten-fallbeispiel { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.hilfe-text blockquote.kasten-fallbeispiel .kasten-ic { color: var(--info); }
.hilfe-text blockquote.kasten-tipp { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.hilfe-text blockquote.kasten-tipp .kasten-ic { color: var(--ok); }
.hilfe-text blockquote.kasten-wichtig { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.hilfe-text blockquote.kasten-wichtig .kasten-ic { color: var(--warn); }
.hilfe-text blockquote.kasten-schritte { background: var(--akzent-weich); border-color: color-mix(in srgb, var(--akzent) 30%, transparent); }
.hilfe-text blockquote.kasten-schritte .kasten-ic { color: var(--akzent); }
.hilfe-text blockquote ol { padding-left: 1.3em; }
.hilfe-weiter { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 1.5em; padding-top: 1em; border-top: 1px solid var(--linie); }
.hilfe-weiter .leise { width: 100%; font-size: 12px; }

/* Hilfsklassen für Geräteklassen */
.nur-mobil { display: none !important; }

/* ---------- 9. Responsiv ---------- */
/* Tablet */
@media (max-width: 1279px) {
  /* Hilfe: ohne Seitenleiste, verwandte Themen wieder unter dem Artikel */
  .hilfe-scroll { display: block; padding-right: 0; }
  .hilfe-seitenleiste { display: none; }
  .hilfe-scroll .hilfe-weiter { display: flex; }
  /* Verwaltung: Bereiche als waagerechte, wischbare Leiste mit Mandantenauswahl vorne */
  .verwaltung.aktiv { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .unter-reiter { flex-direction: row; align-items: center; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: thin; }
  .mandant-wahl { display: flex; margin: 0 var(--a2) 0 0; flex: none; }
  .mandant-wahl > span { display: none; }
  .mandant-wahl select { width: 210px; }
  .unter-btn { flex: none; padding: 6px 10px; background: var(--flaeche); border: 1px solid var(--linie); }
  .unter-btn.aktiv { border-color: var(--akzent); }
  #sozialraum.aktiv { grid-template-rows: none; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
  .raster-sr { grid-template-columns: 1fr 1fr; height: auto; }
  .dashboard .raster-2 { height: clamp(280px, 42vh, 520px); }
  .raster-sr > .karte { min-height: 260px; }
  .raster-sr > .karte:first-child { grid-column: 1 / -1; max-height: 220px; min-height: 0; }
  .raster-ue { grid-template-columns: 1fr 1fr; height: auto; }
  .raster-ue .ue-verlauf { grid-column: 1 / -1; }
  .raster-ue > .karte { min-height: 260px; }
  .raster-ue:has(> .karte[hidden]) { grid-template-columns: 1fr 1fr; }
  #v-uebersicht { height: auto; grid-template-rows: none; }
  .marke-zusatz { display: none; }
  .raster-ki { grid-template-columns: 1fr; }
  .mandant-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); }
}
@media (max-width: 1023px) {
  .reiter-btn span { display: none; }
  .vorlage-texte { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(160px, 1fr)); }
  .spalte-kopf .aktionen span { display: none; }
  .arbeitsseite.aktiv { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  .mandant-layout { grid-template-columns: minmax(0, 1fr); }
  .mandant-kontakte { border-left: 0; padding-left: 0; border-top: 1px solid var(--linie); padding-top: var(--a3); }
}

/* Mobil */
@media (max-width: 767px) {
  .matrix { min-width: 520px; }
  .matrix th:first-child { width: 150px; }
  :root { --seitenrand: 12px; --h-feld: 44px; }
  input, select, textarea { font-size: 16px; }
  .nur-mobil { display: inherit !important; }
  .hauptnavi, .nutzer-text, .status, .marke-zusatz { display: none !important; }
  .kopf { gap: var(--a2); padding-left: 4px; }
  /* Touch-Ziele mindestens 44 px (WCAG 2.5.5) */
  .symbol-btn, .liste .symbol-btn, .aktionen-zelle .symbol-btn { width: 44px; height: 44px; }
  #nutzer-btn { min-height: 44px; }
  .mandant-wahl select { min-height: 44px; }
  .unter-btn { min-height: 44px; }
  .ansicht { padding: var(--a3) var(--seitenrand); }
  .raster-2, .raster-3, .raster-4, .raster-6, .raster-sr, .raster-ue, .raster-vorlage, .raster-ki { grid-template-columns: minmax(0, 1fr); }
  .s1, .s2, .s3, .s4, .s6 { grid-column: 1 / -1; }
  .raster-sr > .karte:first-child { grid-column: auto; }
  .dashboard .raster-2 { height: auto; }
  .dashboard .raster-2 > .karte { max-height: 70vh; }
  .seiten-kopf { align-items: stretch; }
  .seiten-kopf .aktionen { flex: 1; }
  .suche { flex: 1; }
  .suche input { width: 100%; }
  .ausklapp-panel { position: fixed; left: 12px; right: 12px; width: auto; top: 120px; }

  /* Doku: Eingabe und Entwurf als Reiter */
  .arbeitsseite.aktiv { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .doku-umschalter { display: flex !important; }
  .arbeitsseite [data-doku-teil] { display: none; }
  .arbeitsseite[data-doku-zeige="eingabe"] [data-doku-teil="eingabe"],
  .arbeitsseite[data-doku-zeige="entwurf"] [data-doku-teil="entwurf"] { display: flex; }
  .spalte-kopf .aktionen span { display: none; }

  /* Verwaltung */
  .unter-reiter { scrollbar-width: none; }
  .unter-btn { padding: 10px 12px; }
  .mandant-wahl select { width: 170px; }
  .editorseite { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .editor-liste { max-height: 30vh; }
  .vorlage-texte { grid-template-rows: repeat(2, 240px); }
  .seiten-kopf .btn-haupt span, .seiten-kopf .btn-zweit span { display: none; }

  /* Tabellen als Karten */
  .liste:not(.matrix) tr:has(th) { display: none; }
  .liste:not(.matrix) tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 10px 4px;
                            border-bottom: 1px solid var(--linie); }
  .liste:not(.matrix) td { border: 0; padding: 0; }
  .liste:not(.matrix) td[data-label]:not(:first-child)::before {
    content: attr(data-label) ": "; color: var(--leise); font-size: 12px;
  }
  .liste:not(.matrix) td:first-child { grid-column: 1; font-weight: 600; }
  .liste:not(.matrix) td.aktionen-zelle { grid-column: 2; grid-row: 1 / span 4; align-self: start; }
  .liste:not(.matrix) td:not(:first-child):not(.aktionen-zelle) { grid-column: 1; font-size: 13px; }
  .liste:not(.matrix) td .leise { display: inline; }
  #tabelle td { text-align: left !important; }

  /* Dialoge im Vollbild */
  .dlg, .dlg-s, .dlg-m, .dlg-l { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; margin: 0; }
  .dlg-form { max-height: 100dvh; height: 100%; }
  .dlg-inhalt { padding: var(--a3); }
  .dlg-kopf { padding-left: var(--a3); }
  .dlg-fuss { padding: var(--a3); padding-bottom: calc(var(--a3) + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .dlg-fuss .meldung { flex-basis: 100%; order: -1; text-align: left; }
  .dlg-fuss .btn-haupt, .dlg-fuss .btn-zweit { flex: 1; }
  .dlg-fuss .btn-gefahr span { display: none; }

  /* Hilfe: erst Themenliste, nach Auswahl der Artikel */
  .hilfeseite.aktiv { grid-template-columns: minmax(0, 1fr); }
  .hilfeseite[data-hilfe-zeige="liste"] .hilfe-inhalt, .hilfeseite[data-hilfe-zeige="artikel"] .hilfe-navi { display: none; }
  #hilfe-zurueck { margin: var(--a2) var(--a3) 0; align-self: flex-start; }
  .hilfe-text { font-size: 15px; }
  .hilfe-text blockquote { padding-left: 38px; }
  .hilfe-text blockquote .kasten-ic { left: 11px; }
  .hilfe-knopf { width: 44px; height: 44px; margin: -10px -8px; }
  .kontakt-zeile { grid-template-columns: 18px minmax(0, 1fr) 44px; }
  .kontakt-zeile [data-k] { grid-column: 2 !important; }
  .kontakt-zeile .symbol-btn { grid-column: 3 !important; grid-row: 1 / span 4; }
  .kontakt-zeile .ziehgriff { grid-row: 1 / span 4; }

  .imp-banner { font-size: 12px; gap: var(--a2); }
  .imp-banner .imp-lang { display: none; }
  .imp-banner .imp-kurz { display: inline; }
  #imp-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .imp-btn { padding: 6px 10px; }

  /* Doku: Dokumentarten als wischbare Leiste in zwei Reihen – mehr Platz für die Notizen */
  .vorlagen { grid-template-columns: none; grid-auto-flow: column; grid-template-rows: repeat(2, auto);
              grid-auto-columns: minmax(170px, 58%); overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px;
              scrollbar-width: thin; }
  .vorlage { scroll-snap-align: start; }
  .imp-btn { margin-left: 0; }
  #toasts { left: 12px; right: 12px; }
}

/* ---------- 10. Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Anmeldeseite */
.anmelde-seite { min-height: 100dvh; display: grid; place-items: center; padding: 16px; overflow: auto; }
.anmelde-box { width: 100%; max-width: 400px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r-gross);
               padding: 28px; box-shadow: var(--schatten-1); display: grid; gap: var(--a3); }
.anmelde-box h1 { font-size: 17px; }
.anmelde-box h2 { margin-top: var(--a2); }
.anmelde-box form { display: grid; gap: var(--a3); }
.breit-btn { width: 100%; margin-top: var(--a2); }
