/* thiesen HUB – Stylesheet. Bausteine: src/hub/web/ui.js, lebende Vorlage: Einstellungen → Template.
   Gestaltung: Farben von thiesen-bremser.de (Blau primär, Weinrot für Seitenleiste und Akzente), eckig, flach.
   Skalen: Abstände 4-px-Raster (--s1 … --s8), Schriftgrößen --fs-*, Kontrollhöhe --control-h. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8f9;
  --surface-3: #eef0f2;
  --text: #2b2b2b;
  --text-strong: #1a1a1a;
  --muted: #6b7076;
  --muted-2: #9aa0a6;
  --border: #e3e5e8;
  --border-strong: #cfd3d8;
  --primary: #0055a4;
  --primary-hover: #00447f;
  --primary-soft: #e8eff8;
  --primary-text: #ffffff;
  --accent: #7e4455;
  --accent-hover: #653646;
  --accent-soft: #f3e9ec;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --success-strong: #0d5227;
  --warning: #b45309;
  --warning-soft: #fdf1d6;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info: #0055a4;
  --info-soft: #e8eff8;
  --sidebar: #7e4455;
  --sidebar-2: #6f3a4a;
  --sidebar-text: #f1e4e8;
  --sidebar-muted: #d3b4bd;
  --sidebar-active: #5e3242;
  --sidebar-border: rgba(255,255,255,.14);
  --sidebar-strong: #ffffff;
  --radius: 0;
  --radius-sm: 0;
  --shadow: none;
  --shadow-pop: 0 10px 30px rgba(20, 20, 20, .16);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .3);
  --focus: 0 0 0 3px rgba(0, 85, 164, .28);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  /* Abstandssystem (siehe Block „Abstände“ unten): vier Stufen, überall dieselben */
  --gap-inline: var(--s2);   /* nebeneinander: Buttons, Tags, Badges, Chips */
  --gap-text: var(--s3);     /* Textfluss: Absätze, Listenpunkte, Beschriftung → Feld */
  --gap-block: var(--s4);    /* untereinander: Feld, Karte, Tabelle, Hinweis, Codeblock, Button-Zeile */
  --gap-section: var(--s6);  /* Abschnitte: Seitenkopf, Reiter, Kachelreihe, h2 */
  --pad-box: var(--s5);      /* Innenabstand von Containern: Karte, Dialog, leerer Zustand */
  --fs-xs: 0.75rem; --fs-sm: 0.85rem; --fs-md: 0.95rem; --fs-lg: 1.1rem; --fs-xl: 1.35rem; --fs-2xl: 1.7rem;
  --control-h: 38px;
  --topbar-h: 60px;    /* mobile Kopfzeile (Burger); klebende Elemente darunter nutzen denselben Wert */
  --sidebar-w: 240px;
  --subnav-w: 220px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
/* hidden-Attribut gewinnt immer, auch gegen display-Regeln für Buttons (Zurück im Assistenten, Standard-Submit im Dialog) */
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
a { color: var(--primary); }
img, svg { vertical-align: middle; }

/* ---------- Typografie ---------- */
h1 { margin: 0 0 var(--s4); font-size: var(--fs-2xl); line-height: 1.2; font-weight: 700; color: var(--text-strong); letter-spacing: -0.01em; }
h2 { margin: var(--gap-section) 0 var(--gap-text); font-size: var(--fs-xl); line-height: 1.3; font-weight: 700; color: var(--text-strong); }
h3 { margin: var(--s4) 0 var(--s2); font-size: var(--fs-lg); font-weight: 600; color: var(--text-strong); }
h4 { margin: var(--s3) 0 var(--s1); font-size: var(--fs-md); font-weight: 600; }
p { margin: 0 0 var(--gap-text); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.05rem; color: var(--muted); }
.inactive { color: var(--muted); text-decoration: line-through; }
.eyebrow { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.mono, code, kbd, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.88em; }
code { background: var(--surface-3); border: 1px solid var(--border); padding: 0.05em 0.35em; }
pre { background: #22262b; color: #e6edf7; padding: var(--s3) var(--s4); overflow-x: auto; margin: var(--s2) 0 0; line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
kbd { background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; padding: 0.05em 0.4em; }
hr, .divider { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }
.text-right, .align-right { text-align: right; }

/* ---------- Abstände ----------
   Vier Stufen (Variablen in :root): --gap-inline nebeneinander, --gap-text im Textfluss, --gap-block untereinander,
   --gap-section zwischen Abschnitten; --pad-box ist der Innenabstand von Containern.
   Regeln: Geschwister in einer Zeile stehen in einem Flex-Container mit gap (.btn-row, .row, .card-actions …), nie lose
   nebeneinander. Gestapelte Bausteine tragen margin-bottom: var(--gap-block); das letzte Kind eines Containers verliert
   ihn. Innenabstände liegen auf dem Container, nie als Rand auf den Kindern. Keine festen Pixelwerte in Seiten. */
.row { display: flex; flex-wrap: wrap; gap: var(--gap-inline); align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.card-body > :last-child, .dialog-body > :last-child, .frame > :last-child, .empty-state > :last-child, .alert > div > :last-child,
.tab-panel > :last-child, .wizard-pane > :last-child, .tpl-demo > :last-child, .cell > :last-child { margin-bottom: 0; }
.card-body > :first-child, .dialog-body > :first-child, .tab-panel > :first-child, .alert > div > :first-child, .tpl-demo > :first-child { margin-top: 0; }
/* Listen im Inhalt: Textabstand zwischen Punkten, Blockabstand danach */
/* nur direkte Inhaltslisten, nicht die ul innerhalb von Bausteinen (Combobox-Liste, Reiter) */
.card-body > ul, .card-body > ol, .dialog-body > ul, .dialog-body > ol, .alert > div > ul, .alert > div > ol, ul.list, ol.list { margin: 0 0 var(--gap-block); padding-left: 1.4em; }
.card-body > ul > li, .card-body > ol > li, .dialog-body > ul > li, .dialog-body > ol > li, .alert > div > ul > li, .alert > div > ol > li, .list > li { margin-bottom: var(--s1); }
ul.plain { list-style: none; margin: 0 0 var(--gap-block); padding: 0; }
/* Sicherheitsnetz: Buttons, die ohne Zeilen-Container direkt nebeneinander stehen */
.card-body > button + button, .dialog-body > button + button, .empty-state > button + button, p > button + button, .alert button + button { margin-left: var(--gap-inline); }
/* Ausnahmen, sparsam: kleine Rand-Helfer auf der Skala, Breite, Innenabstand, begrenzte Höhe */
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.pad { padding: var(--s7); }
.scroll-box { max-height: 220px; overflow: auto; }
/* Längerer Rohtext (ausgelesene Unterlagen, Bemerkungen): Zeilenumbrüche bleiben, scrollt ab einer gewissen Höhe */
.text-box { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: 1.5; max-height: 320px; overflow: auto; padding: var(--s3); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: var(--gap-block); }
.text-box:last-child, details > .text-box { margin-bottom: 0; }

.app { min-height: 100vh; }
.loading { padding: var(--s7) 0; color: var(--muted); display: flex; align-items: center; gap: var(--s2); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); background: linear-gradient(180deg, var(--sidebar) 0, var(--sidebar) 42%, var(--bg) 42%); }
.login form:not(.consent-form) { background: var(--surface); padding: var(--s7); width: 100%; max-width: 380px; border: 1px solid var(--border); box-shadow: var(--shadow-pop); }
.login h1 { margin: 0 0 var(--s5); font-size: var(--fs-xl); display: flex; align-items: center; gap: var(--s3); }
/* Erlaubnis-Seite (OAuth): Karte statt Login-Formular */
.consent { width: 100%; max-width: 560px; }
.consent .card { box-shadow: var(--shadow-pop); }
.consent .card-title { display: flex; align-items: center; gap: var(--s3); }
.consent .card-title .brand-mark { width: 32px; height: 32px; background: var(--sidebar); color: var(--sidebar-strong); }
.consent .perms { max-height: 220px; overflow: auto; }
.login h1 .brand-mark { width: 40px; height: 40px; background: var(--sidebar); color: var(--sidebar-strong); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) auto 1fr; min-height: 100vh; align-items: start; }
.topbar { display: none; }
.drawer { display: contents; }
.backdrop { position: fixed; inset: 0; background: rgba(20, 10, 14, .5); z-index: 20; }
.backdrop[hidden] { display: none; }

/* Seitenleiste */
.sidebar { grid-column: 1; position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--sidebar); color: var(--sidebar-text); padding: var(--s5) var(--s3) var(--s3); display: flex; flex-direction: column; gap: var(--s4); }
.sidebar .brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s4); border-bottom: 1px solid var(--sidebar-border); flex: none; color: var(--sidebar-strong); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; background: var(--sidebar-strong); color: var(--sidebar); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.02em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 1.02rem; font-weight: 700; white-space: nowrap; }
.brand-text small { font-size: var(--fs-xs); color: var(--sidebar-muted); font-weight: 400; }
.icon-btn.drawer-close { display: none; }
.sidebar nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent; display: flex; flex-direction: column; gap: var(--s1); padding-right: 2px; }
.nav-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sidebar-muted); padding: var(--s2) var(--s3) var(--s1); }
.sidebar nav a { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); color: var(--sidebar-text); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; transition: background 0.12s, color 0.12s; }
.sidebar nav a svg { flex: none; opacity: 0.85; }
.sidebar nav a:hover { background: var(--sidebar-2); color: var(--sidebar-strong); }
.sidebar nav a.active { background: var(--sidebar-active); color: var(--sidebar-strong); border-left-color: var(--sidebar-strong); font-weight: 600; }
.sidebar nav a.active svg { opacity: 1; }

.me-bar { position: relative; flex: none; padding-top: var(--s3); border-top: 1px solid var(--sidebar-border); display: flex; justify-content: flex-start; gap: var(--s1); }
.me-bar #logout { margin-left: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--sidebar-text); cursor: pointer; transition: background 0.12s, color 0.12s; }
.icon-btn:hover, .icon-btn.active, .icon-btn[aria-expanded="true"] { background: var(--sidebar-active); color: var(--sidebar-strong); }
.dropup { position: absolute; bottom: calc(100% + var(--s1)); left: 0; right: 0; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-pop); padding: var(--s3); font-size: var(--fs-sm); z-index: 10; }
.dropup .name { font-weight: 600; color: var(--text-strong); }
.dropup .roles { color: var(--muted); font-size: var(--fs-xs); margin-bottom: var(--s2); }
.dropup a { display: block; padding: var(--s2) var(--s2); margin: 0 calc(-1 * var(--s1)); color: var(--primary); text-decoration: none; font-weight: 500; }
.dropup a:hover, .dropup a.active { background: var(--primary-soft); }

/* Untermenü */
.subnav { grid-column: 2; position: sticky; top: 0; height: 100vh; height: 100dvh; width: var(--subnav-w); background: var(--surface); border-right: 1px solid var(--border); padding: var(--s5) var(--s3); overflow-y: auto; scrollbar-width: thin; }
.subnav[hidden] { display: none; }
.subnav h2 { margin: 0 0 var(--s3); padding: 0 var(--s3); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
/* Gruppenüberschrift im Untermenü (Einträge mit `group`), ersetzt den Bereichstitel über der Liste */
.subnav h3 { margin: var(--s4) 0 var(--s3); padding: 0 var(--s3); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.subnav h3:first-child { margin-top: 0; }
.subnav nav { display: flex; flex-direction: column; gap: 2px; }
.subnav a { display: block; padding: var(--s2) var(--s3); color: var(--text); text-decoration: none; border-left: 3px solid transparent; transition: background 0.12s; }
.subnav a:hover { background: var(--surface-2); }
.subnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-left-color: var(--accent); }

.content { grid-column: 3; padding: var(--s6) var(--s7) var(--s8); min-width: 0; overflow-x: clip; } /* clip statt auto: sonst wird .content zum Scroll-Container und position: sticky (Dokumentvorschau) greift nicht */

/* Seitenkopf: links Titel + Breadcrumbs (Rückweg), rechts Status + Aktionen, Trennlinie zum Inhalt */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); margin: 0 0 var(--gap-section); padding-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.page-title { flex: 1 1 auto; min-width: 0; }
.page-header h1 { margin: 0; }
.page-header .subtitle { margin: var(--s2) 0 0; color: var(--muted); }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-top: var(--s1); font-size: var(--fs-sm); color: var(--muted); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumb-sep { display: inline-flex; color: var(--muted-2); }
.page-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); flex: none; }
.page-status { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: flex-end; color: var(--muted); font-size: var(--fs-sm); }
.page-actions { display: flex; gap: var(--gap-inline); flex-wrap: wrap; justify-content: flex-end; }
.page-actions[hidden] { display: none; }
.page-menu { position: relative; }
.page-menu-toggle { width: var(--control-h); height: var(--control-h); padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.page-menu-list { position: absolute; right: 0; top: calc(100% + var(--s1)); z-index: 40; min-width: 240px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-pop); padding: var(--s1) 0; display: flex; flex-direction: column; }
.page-menu-list[hidden] { display: none; }
.page-menu-list button { width: 100%; justify-content: flex-start; border: 0; background: transparent; color: var(--text); padding: var(--s3) var(--s4); white-space: nowrap; height: auto; }
/* Im Menü verlieren Buttons ihre Flächenfarbe (höhere Spezifität als button.primary / .btn-danger) */
.page-menu-list > button, .page-menu-list > button.primary, .page-menu-list > button.btn-danger, .page-menu-list > button.danger { background: transparent; border: 0; }
.page-menu-list > button:hover { background: var(--primary-soft); border: 0; }
.page-menu-list > button.primary { color: var(--primary); font-weight: 600; }
.page-menu-list > button.danger, .page-menu-list > button.btn-danger { color: var(--danger); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); margin-bottom: var(--gap-block); flex-wrap: wrap; }
.list-footer { display: flex; justify-content: flex-end; align-items: center; gap: var(--s3); margin: calc(-1 * var(--s2)) 0 var(--s4); color: var(--muted); font-size: var(--fs-sm); }

/* ---------- Karten, Rahmen, Kacheln, Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--border); margin-bottom: var(--gap-block); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.card-title { margin: 0; font-size: var(--fs-md); font-weight: 700; color: var(--text-strong); }
.card-actions { display: flex; gap: var(--gap-inline); align-items: center; }
.card-body { padding: var(--pad-box); }
.card-body > :last-child { margin-bottom: 0; }
.card-footer { padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: var(--gap-inline); justify-content: flex-end; }
/* Formulare füllen ihre Karte; Aufteilung über .form-row / .grid-2 statt über Maximalbreiten */
.frame { border: 1px solid var(--border); padding: var(--s3) var(--s4) var(--s2); margin: 0 0 var(--gap-block); min-width: 0; }
.frame legend { padding: 0 var(--s2); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-block); margin-bottom: var(--gap-block); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap-block); margin-bottom: var(--gap-block); }
.stack { display: flex; flex-direction: column; gap: var(--gap-block); margin-bottom: var(--gap-block); }
/* in Rastern und Stapeln regelt der gap den Abstand, nicht der Rand der Kinder */
.grid-2 > *, .grid-3 > *, .stack > * { margin-bottom: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap-block); margin-bottom: var(--gap-section); }
.tile { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); padding: var(--s4) var(--s5); }
.tile .label { color: var(--muted); font-size: var(--fs-sm); }
.tile .value { font-size: 1.9rem; font-weight: 700; margin-top: var(--s1); line-height: 1.15; color: var(--text-strong); letter-spacing: -0.01em; }
.tile-foot { margin-top: var(--s2); font-size: var(--fs-sm); display: flex; gap: var(--s2); align-items: center; }
.trend.up { color: var(--success); font-weight: 600; }
.trend.down { color: var(--danger); font-weight: 600; }
/* Kachel als Link zu ihren Werten (UI.kpi mit href oder scrollTo): Pfeil am Label, beim Überfahren hinterlegt */
a.tile.tile-link { display: block; color: inherit; text-decoration: none; transition: background 0.12s; }
a.tile.tile-link:hover { background: var(--surface-2); }
.tile-link .label { display: flex; justify-content: space-between; gap: var(--s2); }
.tile-link .label::after { content: "›"; font-weight: 700; color: var(--primary); }
/* Sprungziel (UI.scrollToTarget): Abstand zum oberen Rand und kurzer Rahmen, damit man sieht, wo man gelandet ist */
.jump-flash { scroll-margin-top: var(--s5); animation: jump-flash 1.8s ease-out; }
@keyframes jump-flash { 0%, 35% { outline: 3px solid var(--primary); outline-offset: 3px; } 100% { outline: 3px solid transparent; outline-offset: 3px; } }
@media (prefers-reduced-motion: reduce) { .jump-flash { animation-duration: 0.01s; } }
@media (max-width: 1079px) { .jump-flash { scroll-margin-top: calc(56px + var(--s4)); } } /* mobil unter der festen Kopfzeile */
/* Kachel mit Zustand: nur die Oberkante trägt die Farbe, Zahl und Text bleiben in Textfarbe */
.tile-success { border-top-color: var(--success); }
.tile-warning { border-top-color: var(--warning); }
.tile-danger { border-top-color: var(--danger); }
.tile-neutral { border-top-color: var(--border-strong); }

/* Anteilsbalken (UI.shareBar): Segmente mit 2 px Abstand, Legende mit Wert und Anteil darunter */
.share { margin-bottom: var(--gap-block); }
.share-bar { display: flex; gap: 2px; height: 14px; }
.share-seg { flex: 1 1 0; min-width: 4px; }
.share-success { background: var(--success); }
.share-warning { background: var(--warning); }
.share-danger { background: var(--danger); }
.share-info { background: var(--primary); }
.share-neutral { background: var(--border-strong); }
.share-empty { background: var(--surface-2); border: 1px solid var(--border); }
.share-legend { list-style: none; margin: var(--s3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s6); font-size: var(--fs-sm); }
.share-legend li { display: flex; align-items: center; gap: var(--s2); }
.share-dot { width: 10px; height: 10px; flex: none; }

/* Dashboard: zwei Spalten, sobald beide mindestens 560 px bekommen (breites Fenster), sonst untereinander. Eine Spalte ohne
   Inhalt verschwindet und die andere füllt die Breite; .keep hält eine Spalte offen, deren Inhalt noch lädt. */
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: 0 var(--gap-section); align-items: start; }
.dash-cols > div { min-width: 0; }
.dash-cols > div:not(.keep):not(:has(> div:not(:empty))) { display: none; }

/* Zielbalken (UI.goalBar): grüne Füllung bis zum Ziel; darüber voll, mit Marke am Ziel und dunklerem Teil dahinter */
.goal { margin-bottom: var(--gap-block); }
.goal-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s2) var(--s3); margin-bottom: var(--s2); }
.goal-label { color: var(--muted); font-size: var(--fs-sm); }
.goal-value { font-size: var(--fs-xl); color: var(--text-strong); line-height: 1.15; }
.goal-bar { position: relative; height: 18px; background: var(--surface-3); overflow: hidden; }
.goal-fill { position: absolute; inset: 0 auto 0 0; background: var(--success); }
.goal-over { position: absolute; top: 0; bottom: 0; right: 0; background: var(--success-strong); border-left: 2px solid var(--surface); }
.goal-hint { margin: var(--s2) 0 0; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); background: var(--surface); margin-bottom: var(--gap-block); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
/* Zellen immer oben links; Zahlen ausnahmsweise rechts (head: { align: "right" }), damit hohe Zellen lesbar bleiben */
th, td { text-align: left; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
tbody tr:hover td { background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: var(--gap-inline); }
.table-empty { text-align: center; padding: var(--s6); }
/* Gestapelt (wenn die Tabelle nicht in die Breite passt, auf jeder Bildschirmgröße; ui.js setzt .stacked): jede Zeile eine Karte,
   jede Zelle mit ihrem Spaltenkopf (data-label) als Beschriftung links, Inhalt rechts daneben */
.table-wrap.stacked { overflow: visible; border: 1px solid var(--border); background: var(--surface-3); padding: var(--s3); }
.table-wrap.stacked table, .table-wrap.stacked tbody, .table-wrap.stacked tr, .table-wrap.stacked td { display: block; }
.table-wrap.stacked thead { display: none; }
.table-wrap.stacked tr { border: 1px solid var(--border-strong); background: var(--surface); margin-bottom: var(--s3); }
.table-wrap.stacked tr:last-child { margin-bottom: 0; }
.table-wrap.stacked td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); white-space: normal; text-align: left; }
.table-wrap.stacked td:last-child { border-bottom: 0; }
.table-wrap.stacked tbody tr:hover td { background: var(--surface); }
/* erste Spalte als Kopfzeile der Karte: grauer Streifen, fetter Wert – so ist der Zeilenanfang sofort erkennbar */
.table-wrap.stacked td:first-child, .table-wrap.stacked tbody tr:hover td:first-child { background: var(--surface-2); }
.table-wrap.stacked td:first-child .cell { font-weight: 600; color: var(--text-strong); }
.table-wrap.stacked td.table-empty { background: var(--surface); font-weight: 400; }
.table-wrap.stacked td[data-label] { display: grid; grid-template-columns: minmax(0, min(12em, 35%)) minmax(0, 1fr); column-gap: var(--s3); align-items: start; }
.table-wrap.stacked td[data-label]::before { content: attr(data-label); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding-top: 0.2em; overflow-wrap: anywhere; }
.table-wrap.stacked td.align-right .cell { text-align: right; }
.table-wrap.stacked td.actions .cell { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--gap-inline); }
.table-wrap.stacked td.actions button + button { margin-left: 0; }
.table-wrap.stacked td.table-empty { text-align: center; }

/* ---------- Tags, Badges ---------- */
.tag { display: inline-block; background: var(--primary-soft); color: #23487a; padding: 0.1rem 0.5rem; font-size: var(--fs-xs); font-weight: 500; margin: 0 var(--s1) var(--s1) 0; line-height: 1.5; }
.tag.system { background: var(--accent-soft); color: var(--accent); }
.tag.success { background: var(--success-soft); color: var(--success); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.neutral { background: var(--surface-3); color: #4b5563; }
.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.55rem; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.01em; line-height: 1.6; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; background: currentColor; flex: none; }
.badge-busy::before { display: none; }
.badge .spinner { width: 10px; height: 10px; border-width: 2px; border-color: currentColor; border-top-color: transparent; opacity: 0.8; }
.badge-neutral { background: var(--surface-3); color: #4b5563; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

/* ---------- Hinweise (Alerts) ---------- */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid transparent; border-left-width: 4px; margin-bottom: var(--gap-block); }
.alert-icon { flex: none; display: inline-flex; margin-top: 0.15rem; }
.alert-title { font-weight: 700; margin-bottom: 0.15rem; }
.alert-info { background: var(--info-soft); border-color: #cfdcf0; border-left-color: var(--info); color: #1e3a66; }
.alert-success { background: var(--success-soft); border-color: #bfe5cb; border-left-color: var(--success); color: #14532d; }
.alert-warning { background: var(--warning-soft); border-color: #f1dca8; border-left-color: var(--warning); color: #713f12; }
.alert-danger { background: var(--danger-soft); border-color: #f3c3bd; border-left-color: var(--danger); color: #7f1d1d; }

/* ---------- Formulare ---------- */
.field { display: block; margin-bottom: var(--gap-block); min-width: 0; }
.field > span { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--s1); }
.field .req { color: var(--danger); font-style: normal; }
.field input:not([type=checkbox]):not([type=radio]), .field textarea, .field select {
  width: 100%; min-height: var(--control-h); padding: 0 var(--s3); border: 1px solid var(--border-strong); background: #fff; color: var(--text); transition: border-color 0.12s, box-shadow 0.12s;
}
.field textarea { padding: var(--s2) var(--s3); resize: vertical; min-height: calc(var(--control-h) * 2); line-height: 1.5; }
.field select { appearance: auto; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.field input[readonly], .field input:disabled, .field textarea:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.field .help { display: block; color: var(--muted); font-size: var(--fs-xs); margin-top: var(--s1); }
.field .field-error { display: none; color: var(--danger); font-size: var(--fs-xs); margin-top: var(--s1); }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--danger); }
.field.invalid .field-error { display: block; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap-block); }
.form-row.align-end { align-items: end; }   /* Button neben einem Feld auf dessen Unterkante */
.check { display: flex; gap: var(--s2); align-items: flex-start; margin: var(--s2) 0; cursor: pointer; }
.check input { margin: 0.3rem 0 0; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
.check .hint, .switch .hint { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.switch { display: flex; align-items: flex-start; gap: var(--s3); margin: var(--s2) 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { flex: none; width: 36px; height: 20px; background: var(--border-strong); position: relative; transition: background 0.15s; margin-top: 0.15rem; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.perm-group { margin-bottom: var(--s3); break-inside: avoid; }
.perm-group h4 { margin: 0 0 var(--s1); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.perm-groups { columns: 2; column-gap: var(--s7); }
.error { color: var(--danger); font-size: var(--fs-sm); margin: var(--s2) 0; }
.error:empty { display: none; }

/* ---------- Buttons ---------- */
button { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--control-h); padding: 0 var(--s4); border: 1px solid var(--border-strong); background: #fff; color: var(--text); cursor: pointer; line-height: 1.2; white-space: nowrap; font-weight: 500; transition: background 0.12s, border-color 0.12s, color 0.12s; }
button:hover { background: var(--surface-2); border-color: #b9bfc6; }
button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: #e7a9a2; }
button.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.btn-danger:hover { background: #961c13; border-color: #961c13; }
button.btn-ghost { background: transparent; border-color: transparent; }
button.btn-ghost:hover { background: var(--surface-3); }
button.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--primary); text-decoration: underline; }
button.small { height: 30px; padding: 0 var(--s3); font-size: var(--fs-sm); }
button.icon-only { width: var(--control-h); padding: 0; }
button.icon-only.small { width: 30px; }
button:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: var(--gap-inline); justify-content: flex-end; align-items: center; margin-top: var(--gap-block); flex-wrap: wrap; }
.btn-row.start { justify-content: flex-start; }
.btn-row.center { justify-content: center; }
/* Knopf rechtsbündig mit Hinweis darunter (z. B. Sammelaktion in einem Hinweis) */
.btn-stack { display: flex; flex-direction: column; align-items: flex-end; gap: var(--gap-inline); margin-top: var(--gap-block); }
.btn-stack:first-child { margin-top: 0; }
/* Massenaktionen über einer Tabelle (Excel-Abgleich): Abstand zur Tabelle darunter */
.sync-bulk { margin-bottom: var(--s4); }
.btn-row:first-child { margin-top: 0; }
.btn-group { display: inline-flex; }
.btn-group button { margin-left: -1px; }
.btn-group button:first-child { margin-left: 0; }

/* ---------- Reiter ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--gap-section); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: var(--s2) var(--s4); height: auto; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: none; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }
.tab-badge { display: inline-block; min-width: 1.4em; padding: 0 0.4em; margin-left: 0.3em; font-size: var(--fs-xs); font-weight: 700; background: var(--primary-soft); color: var(--primary); line-height: 1.5; }
.tab-panel[hidden] { display: none; }
.tab-panel > :last-child { margin-bottom: 0; }

/* ---------- Akkordeon ---------- */
.accordion { border: 1px solid var(--border); background: var(--surface); margin-bottom: var(--gap-block); }
.accordion-item + .accordion-item { border-top: 1px solid var(--border); }
.accordion-head { display: flex; width: 100%; align-items: center; gap: var(--gap-inline); height: auto; min-height: var(--control-h); padding: var(--s3) var(--s4); border: 0; background: var(--surface-2); color: var(--text-strong); font-weight: 600; text-align: left; cursor: pointer; }
.accordion-head:hover { background: var(--surface-3); border-color: transparent; }
.accordion-title { flex: 1 1 auto; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.accordion-head .tab-badge { flex: none; white-space: nowrap; }
.accordion-chev { flex: none; display: inline-flex; color: var(--muted); transition: transform 0.15s; }
.accordion-item.open > .accordion-head { border-bottom: 1px solid var(--border); }
.accordion-item.open > .accordion-head .accordion-chev { transform: rotate(180deg); }
.accordion-body { padding: var(--pad-box) var(--s4); }
.accordion-body[hidden] { display: none; }
.accordion-body > :first-child { margin-top: 0; }
.accordion-body > :last-child { margin-bottom: 0; }
/* Horizontal: Spalten nebeneinander, zugeklappte als schmale Leiste mit gedrehtem Titel, die offene füllt den Rest */
.accordion.horizontal { display: flex; align-items: stretch; min-height: 240px; }
.accordion.horizontal > .accordion-item { display: flex; flex: 0 0 auto; min-width: 0; }
.accordion.horizontal > .accordion-item + .accordion-item { border-top: 0; border-left: 1px solid var(--border); }
.accordion.horizontal > .accordion-item.open { flex: 1 1 auto; }
.accordion.horizontal > .accordion-item > .accordion-head { writing-mode: vertical-rl; width: auto; height: auto; min-height: 0; align-self: stretch; padding: var(--s4) var(--s3); border-bottom: 0; }
.accordion.horizontal > .accordion-item.open > .accordion-head { border-right: 1px solid var(--border); }
.accordion.horizontal > .accordion-item > .accordion-head .accordion-chev { transform: rotate(-90deg); }
.accordion.horizontal > .accordion-item.open > .accordion-head .accordion-chev { transform: rotate(90deg); }
.accordion.horizontal > .accordion-item > .accordion-body { flex: 1 1 auto; min-width: 0; overflow: auto; }
/* Mobil verhält sich das horizontale Akkordeon wie das vertikale */
@media (max-width: 1079px) {
  .accordion.horizontal { display: block; min-height: 0; }
  .accordion.horizontal > .accordion-item { display: block; }
  .accordion.horizontal > .accordion-item + .accordion-item { border-left: 0; border-top: 1px solid var(--border); }
  .accordion.horizontal > .accordion-item > .accordion-head { writing-mode: horizontal-tb; width: 100%; height: auto; min-height: 44px; padding: var(--s3) var(--s4); border-right: 0; }
  .accordion.horizontal > .accordion-item.open > .accordion-head { border-bottom: 1px solid var(--border); }
  .accordion.horizontal > .accordion-item > .accordion-head .accordion-chev { transform: none; }
  .accordion.horizontal > .accordion-item.open > .accordion-head .accordion-chev { transform: rotate(180deg); }
}

/* ---------- Leere Zustände, Laden ---------- */
.empty-state { text-align: center; padding: var(--s8) var(--s4); color: var(--text); }
.empty-state .btn-row { margin-top: var(--gap-block); }
.empty-icon { color: var(--muted-2); margin-bottom: var(--s2); }
.empty-title { font-weight: 700; margin-bottom: var(--s1); color: var(--text-strong); }
.empty-state .muted { margin: 0 auto; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-line { height: 0.9rem; background: linear-gradient(90deg, #e9ecf1 25%, #f4f5f7 50%, #e9ecf1 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin: var(--s2) 0; }
.skeleton-line:nth-child(2) { width: 85%; }
.skeleton-line:nth-child(3) { width: 60%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Dialoge ---------- */
dialog { border: 0; padding: 0; width: min(640px, 92vw); box-shadow: var(--shadow-lg); color: var(--text); max-height: 90vh; }
dialog.dialog-sm { width: min(440px, 92vw); }
dialog.dialog-lg { width: min(900px, 94vw); }
dialog::backdrop { background: rgba(20, 10, 14, .45); }
dialog form { display: flex; flex-direction: column; max-height: 90vh; }
dialog h2 { margin: 0; padding: var(--s4) calc(var(--s6) + 40px) var(--s4) var(--s6); font-size: var(--fs-lg); border-bottom: 1px solid var(--border); background: var(--surface-2); flex: none; position: relative; }
/* Schließen-Kreuz rechts im Dialogkopf (openDialog legt es an) */
dialog .dialog-close { position: absolute; top: 50%; right: var(--s3); transform: translateY(-50%); width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
dialog .dialog-close:hover { background: var(--surface); color: var(--text-strong); }
.wizard-steps.jump li { cursor: pointer; }
.wizard-steps.jump li:hover .wizard-label { text-decoration: underline; }
/* Inhalt in eigenem Container mit Innenabstand (kein Rand pro Kind → nichts kann ausscheren); scrollt bei Bedarf */
.dialog-body { padding: var(--pad-box) var(--s6); overflow-y: auto; min-height: 0; }
.dialog-body > :last-child { margin-bottom: 0; }
dialog .btn-row { margin: 0; padding: var(--s3) var(--s6); border-top: 1px solid var(--border); background: var(--surface-2); flex: none; }
/* Dialog mit Markdown-Editor: feste Höhe, der Editor füllt den Rest und ist der einzige Scrollbereich (kein doppelter Scrollbalken) */
dialog.dialog-fill { height: 90vh; }
dialog.dialog-fill form { height: 100%; }
dialog.dialog-fill .dialog-body { display: flex; flex-direction: column; flex: 1 1 auto; overflow: auto; }
dialog.dialog-fill .dialog-body > * { flex: none; }
dialog.dialog-fill .md-editor { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
dialog.dialog-fill .md-editor .md-editor-host { flex: 1 1 auto; min-height: 240px; } /* auf sehr niedrigen Fenstern scrollt dann der Dialog, statt den Editor zu quetschen */
dialog.dialog-fill .md-editor textarea { flex: 1 1 auto; min-height: 0; resize: none; }

/* ---------- Seitliches Overlay (UI.sidePanel) ---------- */
body.panel-open { overflow: hidden; }
.side-panel-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(20, 10, 14, .35); display: flex; justify-content: flex-end; opacity: 0; transition: opacity 0.15s; }
.side-panel-overlay.open { opacity: 1; }
.side-panel { width: min(440px, 100vw); height: 100%; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.18s ease; }
.side-panel-overlay.open .side-panel { transform: none; }
.side-panel.sm { width: min(340px, 100vw); }
.side-panel.lg { width: min(680px, 100vw); }
.side-panel-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--gap-inline); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.side-panel-head h2 { margin: 0; font-size: var(--fs-lg); }
.side-panel-close { width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--muted); }
.side-panel-close:hover { background: var(--surface); color: var(--text-strong); border-color: transparent; }
.side-panel-body { flex: 1 1 auto; overflow-y: auto; padding: var(--pad-box) var(--s5); }
.side-panel-body > :last-child { margin-bottom: 0; }
/* Liste im Overlay: Zeilen mit Haupt-Knopf (Titel + Hinweis) und kleinen Aktionen rechts */
ul.panel-list { list-style: none; margin: 0 0 var(--gap-block); padding: 0; border: 1px solid var(--border); }
.panel-list li { display: flex; align-items: center; gap: var(--gap-inline); padding: var(--s2) var(--s2) var(--s2) var(--s3); border-bottom: 1px solid var(--border); border-left: 3px solid transparent; }
.panel-list li:last-child { border-bottom: 0; }
.panel-list li.active { background: var(--accent-soft); border-left-color: var(--accent); }
.panel-list .item-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: auto; padding: var(--s1) 0; border: 0; background: none; text-align: left; white-space: normal; color: var(--text); font-weight: 500; }
.panel-list .item-main:hover { background: none; color: var(--primary); border-color: transparent; }
.panel-list .item-main .hint { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
@media (max-width: 1079px) {
  .side-panel, .side-panel.sm, .side-panel.lg { width: 100vw; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: var(--s6); right: var(--s6); display: flex; flex-direction: column; gap: var(--s2); z-index: 100; max-width: min(400px, calc(100vw - 2rem)); }
.toast { display: flex; gap: var(--s3); align-items: flex-start; background: #22262b; color: #fff; padding: var(--s3) var(--s3) var(--s3) var(--s4); border-left: 4px solid #fff; box-shadow: var(--shadow-pop); animation: toast-in 0.18s ease-out; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.18s, transform 0.18s; }
.toast-icon { flex: none; display: inline-flex; margin-top: 0.05rem; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; }
.toast-close { flex: none; background: none; border: 0; color: inherit; opacity: 0.7; padding: 0; height: auto; width: 24px; }
.toast-close:hover { opacity: 1; background: none; }
.toast-success { border-left-color: #4ade80; }
.toast-error { border-left-color: #f87171; }
.toast-warning { border-left-color: #fbbf24; }
.toast-info { border-left-color: #60a5fa; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Combobox mit Suche ---------- */
.combobox { position: relative; }
.combobox .combobox-input { padding-right: 2.2rem; }
.combobox-caret { position: absolute; right: var(--s3); top: 50%; transform: translateY(-50%); color: var(--muted); display: inline-flex; cursor: pointer; }
/* Die Liste liegt fest im Viewport (position: fixed, Koordinaten setzt ui.js beim Öffnen), damit kein scrollender
   Container (Dialoginhalt, Tabelle, Rahmen, Seiteninhalt) sie abschneidet; bei wenig Platz unten öffnet sie nach oben. */
ul.combobox-list { position: fixed; z-index: 60; margin: 0; padding: var(--s1) 0; list-style: none; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); max-height: 260px; overflow-y: auto; }
.combobox-list[hidden] { display: none; }
.combobox-option { margin: 0; padding: var(--s2) var(--s3); cursor: pointer; display: flex; justify-content: space-between; gap: var(--s3); }
.combobox-option small { font-size: var(--fs-xs); }
.combobox-option.active { background: var(--primary-soft); }
.combobox-option.selected { font-weight: 600; color: var(--primary); }
.combobox-empty { padding: var(--s2) var(--s3); }

/* Assistent: Schrittanzeige im Dialog */
.wizard-steps { list-style: none; margin: 0 0 var(--s5); padding: 0 0 var(--s4); display: flex; gap: var(--s2) var(--s4); flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.wizard-steps li { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--fs-sm); }
.wizard-num { width: 26px; height: 26px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 700; font-size: var(--fs-xs); }
.wizard-steps li.active { color: var(--text-strong); font-weight: 600; }
.wizard-steps li.active .wizard-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wizard-steps li.done .wizard-num { background: var(--success); border-color: var(--success); color: #fff; }
.wizard-pane > :last-child { margin-bottom: 0; }
.wizard-pane h3 { margin: 0 0 var(--s3); font-size: var(--fs-md); }
.wizard-pane > ol, .wizard-pane > ul { margin: 0 0 var(--gap-block); padding-left: 1.4em; }
.wizard-pane > ol > li, .wizard-pane > ul > li { margin-bottom: var(--s2); }
.wizard-wait { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: var(--s4); }

/* Claude im HUB: Chat */
/* Gesprächsfläche: die Nachrichten stehen direkt auf der Seite (nur der Seiten-Scrollbalken), die Eingabe klebt unten
   am Fenster (position: sticky) und spannt über die volle Inhaltsbreite; .chat füllt mindestens die Fensterhöhe */
/* Die Chat-Seite hat keinen Seitenkopf (Ausnahme): .chat füllt die Inhaltshöhe, die Eingabe klebt unten über die volle Breite */
.chat { display: flex; flex-direction: column; min-height: calc(100vh - var(--s6) - var(--s8)); }
.chat-log { flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--s5); padding-bottom: var(--s5); }
.chat-log .empty-state { margin: auto 0; }
/* Untere Leiste: Eingabe links, rechts ein Block aus den Icon-Knöpfen „Neues Gespräch“ und „Verlauf“ über dem Senden-Knopf (gleiche Breite) */
.chat-composer-tools { display: flex; gap: var(--gap-inline); }
.chat-composer-tools button { flex: 1 1 0; }
.chat-msg { display: flex; gap: var(--s3); align-items: flex-start; max-width: 85%; }
.chat-user { align-self: flex-end; flex-direction: row-reverse; }
.chat-assistant { align-self: flex-start; }
.chat-avatar { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.02em; }
.chat-user .chat-avatar { background: var(--primary); }
.chat-body { min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.chat-user .chat-body { align-items: flex-end; }
.chat-who { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.chat-bubble { padding: var(--s3) var(--s4); border: 1px solid var(--border); background: var(--surface); }
.chat-user .chat-bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.chat-bubble > :first-child { margin-top: 0; }
.chat-bubble > :last-child { margin-bottom: 0; }
.chat-bubble pre { white-space: pre-wrap; word-break: break-word; }
.chat-thinking { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--fs-sm); }
.chat-tools { display: flex; flex-wrap: wrap; gap: var(--gap-inline); }
.chat-msg .alert { margin: 0; }
/* Rückfrage von Claude: Karte mit Antwortmöglichkeiten; nach der Antwort bleibt die gewählte markiert */
.chat-question { border: 1px solid var(--accent); border-left-width: 4px; background: var(--surface); padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.chat-question-title { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.chat-question p { margin: 0; font-weight: 600; color: var(--text-strong); }
.chat-options { display: flex; flex-direction: column; gap: var(--gap-inline); }
.chat-option { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; height: auto; min-height: var(--control-h); padding: var(--s2) var(--s3); text-align: left; white-space: normal; }
.chat-option .hint { font-weight: 400; font-size: var(--fs-xs); color: var(--muted); }
.chat-option:hover, .chat-option.chosen { border-color: var(--primary); background: var(--primary-soft); }
.chat-option:disabled { opacity: 1; cursor: default; }
.chat-option:disabled:not(.chosen) { opacity: 0.55; }
.chat-question .check { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s2); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text); }
.chip .spinner { width: 12px; height: 12px; border-width: 2px; }
.chip-success { border-color: var(--success); }
.chip-danger { border-color: var(--danger); color: var(--danger); }
.chat-composer { position: sticky; bottom: 0; z-index: 20; flex: none; margin: 0 calc(-1 * var(--s7)) calc(-1 * var(--s8)); padding: var(--s3) var(--s7); border-top: 1px solid var(--border); background: var(--surface-2); }
.chat-composer-box { display: flex; gap: var(--gap-inline); align-items: flex-end; }
.chat-composer textarea { flex: 1 1 auto; resize: none; min-height: calc(var(--control-h) * 1.6); max-height: 200px; padding: var(--s2) var(--s3); border: 1px solid var(--border-strong); background: #fff; line-height: 1.5; }
.chat-composer textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.chat-composer-actions { display: flex; flex-direction: column; gap: var(--gap-inline); align-items: stretch; flex: none; }
.chat-composer-open, .chat-composer-hide { display: none; }
.chat-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap-inline); margin-top: var(--gap-block); }
.chat-suggest button { height: auto; min-height: var(--control-h); white-space: normal; text-align: left; }
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }

/* Codeblock mit Kopieren */
.code-block { position: relative; margin: 0 0 var(--gap-block); }
.code-block-label { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s1); }
.code-block pre { margin: 0; padding-right: 120px; white-space: pre-wrap; word-break: break-all; }
.code-block .code-copy { position: absolute; right: var(--s2); bottom: var(--s2); }

/* ---------- Checkliste (Verbindungstest) ---------- */
.check-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.check-steps li { display: flex; gap: var(--s3); align-items: flex-start; }
.check-steps .step-icon { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--muted-2); margin-top: 0.05rem; }
.check-steps li.ok .step-icon { background: var(--success); }
.check-steps li.fail .step-icon { background: var(--danger); }
.check-steps li.fail { color: var(--danger); }
.check-steps li.skipped { color: var(--muted); }

/* ---------- News / Schwarzes Brett ---------- */
/* Schwarzes Brett: eine Karte mit Titelleiste, die Beiträge darin als Einträge mit Trennlinie (keine Karte in der Karte) */
.news-item + .news-item { margin-top: var(--gap-block); padding-top: var(--gap-block); border-top: 1px solid var(--border); }
.news-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--gap-inline); margin-bottom: var(--gap-text); }
.news-item-title { min-width: 0; }
.news-item-title h4 { margin: 0; font-size: var(--fs-lg); color: var(--text-strong); overflow-wrap: anywhere; }
.news-item .card-actions { flex: none; align-items: center; }
.news-item.pinned { border-left: 4px solid var(--accent); padding-left: var(--s3); }
.news-body { overflow-wrap: anywhere; line-height: 1.6; }

/* ---------- Template-Seite ---------- */
.tpl-section { margin-bottom: var(--s8); scroll-margin-top: var(--s4); }
.tpl-section > h2 { padding-bottom: var(--s2); border-bottom: 1px solid var(--border); }
.tpl-demo { background: var(--surface); border: 1px dashed var(--border-strong); padding: var(--s5); }
.tpl-demo > :last-child { margin-bottom: 0; }
.tpl-row { display: flex; flex-wrap: wrap; gap: var(--gap-inline); align-items: center; }
.tpl-row + .tpl-row { margin-top: var(--gap-text); }
.tpl-toc { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s6); }
.tpl-toc a { font-size: var(--fs-sm); text-decoration: none; background: var(--surface); border: 1px solid var(--border); padding: 0.25rem 0.75rem; color: var(--text); }
.tpl-toc a:hover { border-color: var(--primary); color: var(--primary); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.swatch { border: 1px solid var(--border); overflow: hidden; background: var(--surface); }
.swatch-color { height: 48px; }
.swatch-name { padding: var(--s2) var(--s3); font-size: var(--fs-xs); }
.swatch-name code { display: block; margin-top: 0.1rem; color: var(--muted); border: 0; background: none; padding: 0; }
details.tpl-code { margin-top: var(--s3); }
details.tpl-code summary { cursor: pointer; font-size: var(--fs-sm); color: var(--muted); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s2); }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--s3) var(--s2); border: 1px solid var(--border); font-size: var(--fs-xs); color: var(--muted); background: var(--surface); }
.icon-cell svg { color: var(--text); }
.spacing-scale { margin-bottom: var(--gap-block); }
.spacing-row { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); font-size: var(--fs-sm); }
.spacing-bar { height: 14px; background: var(--primary); }

/* ---------- Mobil (eine Stufe: unter 1080 px) ---------- */
@media (max-width: 1079px) {
  .shell { grid-template-columns: 1fr; align-content: start; }
  .sidebar, .subnav, .content { grid-column: auto; }
  .topbar { display: flex; align-items: center; gap: var(--s2); position: sticky; top: 0; z-index: 15; background: var(--sidebar); color: var(--sidebar-strong); padding: 0 var(--s3); height: var(--topbar-h); }
  .topbar .brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: 1.05rem; }
  .topbar #menu-toggle { margin-left: auto; }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: 0.7rem; }
  /* Haupt- und Untermenü fahren gemeinsam als Schublade über dem Inhalt ein, nebeneinander wie auf dem Desktop */
  .drawer { display: flex; position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh; max-width: 100vw; z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; }
  .drawer.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar { position: static; flex: none; width: min(250px, 58vw); padding-top: var(--s2); }
  .sidebar .brand { padding: 0 0 var(--s3); }
  .icon-btn.drawer-close { display: inline-flex; margin-left: auto; }
  .subnav { position: static; flex: none; width: min(210px, 42vw); height: 100vh; height: 100dvh; padding-left: var(--s2); padding-right: var(--s2); }
  .subnav h2, .subnav h3, .subnav a { padding-left: var(--s2); padding-right: var(--s2); }
  .subnav a { overflow-wrap: anywhere; }
  .subnav[hidden] { display: none; }
  body.drawer-open { overflow: hidden; }
  .dropup { left: auto; right: 0; min-width: 220px; }
  .content { padding: var(--s4) var(--s4) var(--s7); }
  /* Seitenkopf: Status und Aktionen bleiben rechts neben dem Titel; passen die Buttons nicht, werden sie per Script zum Aufklappmenü */
  .page-header { gap: var(--s3); margin-bottom: var(--s5); }
  .page-side { max-width: 60%; }
  .page-header h1 { font-size: var(--fs-xl); }
  .perm-groups { columns: 1; }
  .form-row, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } /* minmax(0, …): sonst hält eine Tabelle die Spalte auf Mindestbreite und das Stapeln greift nicht */
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .tile { padding: var(--s3) var(--s4); }
  .tile .value { font-size: 1.5rem; }
  .card-header, .card-body, .card-footer { padding-left: var(--s4); padding-right: var(--s4); }
  th, td { padding: var(--s2) var(--s3); }
  button, .field input:not([type=checkbox]):not([type=radio]), .field select { min-height: 44px; }
  button.small { height: 36px; }
  button.icon-only.small { width: 36px; }
  dialog, dialog.dialog-sm, dialog.dialog-lg { width: calc(100vw - 2 * var(--s3)); max-height: 92vh; }
  dialog.dialog-fill { height: 92vh; }
  dialog h2 { padding: var(--s3) var(--s4); }
  .dialog-body { padding: var(--s4); }
  .wizard-steps li:not(.active) .wizard-label { display: none; }
  .chat { min-height: calc(100vh - var(--topbar-h) - var(--s4) - var(--s7)); }
  .chat-composer-actions { flex-direction: row; align-items: center; }
  .chat-composer-tools { flex: none; }
  .chat-log { gap: var(--s4); }
  .chat-msg { max-width: 100%; }
  .chat-avatar { display: none; }
  /* Eingabe mobil eingeklappt: nur ein Knopf am unteren Rand, der die Textbox einblendet */
  .chat-composer { margin: 0 calc(-1 * var(--s4)) calc(-1 * var(--s7)); padding: var(--s2) var(--s4); }
  .chat-composer-box { flex-direction: column; align-items: stretch; }
  .chat-composer-actions button { flex: 1 1 auto; }
  .chat-composer-hide { display: inline-flex; flex: none; }
  .chat-composer.collapsed .chat-composer-box { display: none; }
  .chat-composer.collapsed .chat-composer-open { display: flex; width: 100%; justify-content: center; gap: var(--gap-inline); }
  .code-block pre { padding-right: var(--s4); padding-bottom: calc(var(--control-h) + var(--s3)); }
  dialog .btn-row { padding: var(--s3) var(--s4); }
  dialog .btn-row button { flex: 1 1 auto; }
  .toasts { left: var(--s3); right: var(--s3); bottom: var(--s3); max-width: none; }
  .tpl-demo { padding: var(--s3); }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .toast, .switch-track, .switch-track::after, button, .sidebar nav a { transition: none; animation: none; }
}

/* Markdown-Editor (UI.markdownEditor): eckig wie der Rest, volle Breite; die Textarea ist nur der Fallback bis der Editor steht */
.md-editor .md-editor-host { width: 100%; }
.md-editor .toastui-editor-defaultUI { border-radius: 0; border-color: var(--border); font-family: inherit; }
.md-editor .toastui-editor-defaultUI .toastui-editor-md-tab-container, .md-editor .toastui-editor-defaultUI-toolbar { border-radius: 0; }
.md-editor .toastui-editor-contents { font-family: inherit; font-size: var(--fs-md); }
.md-editor .toastui-editor-contents table { width: auto; }
/* Die globalen Button-Regeln (Höhe, Innenabstand, Rahmen) würden die Symbolleiste des Editors verzerren */
.md-editor .toastui-editor-defaultUI-toolbar button, .md-editor .toastui-editor-mode-switch button { height: auto; min-height: 0; padding: 0 var(--s2); border: 0; background-color: transparent; white-space: normal; font-weight: 400; line-height: normal; }
.md-editor .toastui-editor-defaultUI-toolbar button.toastui-editor-toolbar-icons { width: 32px; height: 32px; min-height: 0; padding: 0; }

/* Berechnungsplan: Gruppenüberschriften zwischen Steckbrief und Positions-Akkordeons */
.plan-group { font-size: var(--fs-md); margin: var(--gap-section) 0 var(--gap-text); }
.plan-group:first-child { margin-top: 0; }

/* ---------- Zeitstrahl (Ereignisse eines Vorgangs) ---------- */
.timeline { list-style: none; margin: 0 0 var(--gap-block); padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.tl-entry { position: relative; padding-left: 44px; margin-bottom: var(--gap-block); }
.tl-entry:last-child { margin-bottom: 0; }
.tl-dot { position: absolute; left: 0; top: 2px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted); }
.tl-info .tl-dot { border-color: var(--primary); color: var(--primary); }
.tl-dot .spinner { border-color: currentColor; border-top-color: transparent; }
/* Laufender Eintrag: Fortschritt als Hauptzeile, Erklärung klein darunter */
.tl-progress { margin: 0 0 var(--s1); font-weight: 600; color: var(--text-strong); }
.tl-progress:empty { display: none; }
.tl-success .tl-dot { border-color: var(--success); color: var(--success); }
.tl-warning .tl-dot { border-color: var(--warning); color: var(--warning); }
.tl-danger .tl-dot { border-color: var(--danger); color: var(--danger); }
.tl-card { border: 1px solid var(--border); background: var(--surface); min-width: 0; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s2) var(--s3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tl-title { flex: 1 1 auto; min-width: 0; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-inline); overflow-wrap: anywhere; }
.tl-time { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; white-space: nowrap; }
.tl-actions { display: flex; flex-wrap: wrap; gap: var(--gap-inline); }
@media (max-width: 1079px) {
  .tl-actions { width: 100%; }
}
.tl-body { padding: var(--s3); }
.tl-body > :last-child { margin-bottom: 0; }
.tl-sub { margin: var(--s2) 0 0; padding: 0 0 0 var(--s4); list-style: none; border-left: 2px solid var(--border); }
.tl-sub li { padding: var(--s2) 0; }
.tl-sub li + li { border-top: 1px solid var(--border); }
.timeline:last-child { margin-bottom: 0; }

/* ---------- Ablaufanzeige (Schritte eines festen Ablaufs) ---------- */
.steps { list-style: none; margin: 0 0 var(--gap-block); padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.steps li { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--fs-sm); }
.steps-label { display: flex; flex-direction: column; line-height: 1.25; }
/* Schritt mit laufender Hintergrundarbeit: drehender Kreis im Nummernfeld (gleiche Höhe wie die anderen Schritte) */
.steps li .wizard-num .spinner { border-color: currentColor; border-top-color: transparent; opacity: 0.85; }
.steps-label small { font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.steps li.active { color: var(--text-strong); font-weight: 600; }
.steps li.active .wizard-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.steps li.done .wizard-num { background: var(--success); border-color: var(--success); color: #fff; }
.steps li.done { color: var(--text); }
.steps li.open .wizard-num { border-color: var(--primary); color: var(--primary); }
.steps li.open { color: var(--text); }
.steps.jump li.released { cursor: pointer; }
.steps.jump li.released:hover .steps-label, .steps.jump li.released:focus-visible .steps-label { text-decoration: underline; }
.steps.jump li.released:focus-visible { outline: none; box-shadow: var(--focus); }
.steps li.skipped { opacity: .55; }
.steps li.skipped .wizard-num { border-style: dashed; }
.steps:last-child { margin-bottom: 0; }

/* ---------- Ablagefläche (Dropzone) ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: var(--s1); padding: var(--pad-box); border: 2px dashed var(--border-strong); background: var(--surface-2); color: var(--muted); text-align: center; cursor: pointer; margin-bottom: var(--gap-block); outline: none; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); color: var(--text); }
.dropzone:focus-visible { box-shadow: var(--focus); }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone-input { display: none; }
.dropzone-title { font-weight: 600; color: var(--text); }
.dropzone-hint { font-size: var(--fs-sm); }
.dropzone-status { font-size: var(--fs-sm); color: var(--primary); }
.dropzone-status.error { color: var(--danger); }
.dropzone .help { color: var(--muted); font-size: var(--fs-xs); }
.dropzone.busy { pointer-events: none; opacity: .7; }

/* ---------- Rich-Text-Editor ---------- */
.rte { border: 1px solid var(--border-strong); background: #fff; }
.rte:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: var(--s1); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rte-btn { height: 30px; min-width: 30px; padding: 0 var(--s2); border: 1px solid transparent; background: transparent; color: var(--text); }
.rte-btn:hover { background: #fff; border-color: var(--border-strong); }
.rte-txt { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.02em; }
.rte-sep { width: 1px; height: 20px; background: var(--border-strong); margin: 0 var(--s1); }
.rte-content { padding: var(--s3) var(--s4); outline: none; line-height: 1.6; overflow-wrap: anywhere; max-height: 60vh; overflow-y: auto; }
.rte-content.is-empty::before { content: attr(data-placeholder); color: var(--muted-2); pointer-events: none; display: block; }
.rte-content > :first-child { margin-top: 0; }
.rte-content > :last-child { margin-bottom: 0; }
.rte-content img, .rich-text img { max-width: 100%; height: auto; display: block; margin: var(--s3) 0; border: 1px solid var(--border); }
.rte-content h2, .rich-text h2 { font-size: var(--fs-lg); margin: var(--s4) 0 var(--s2); }
.rte-content h3, .rich-text h3 { font-size: var(--fs-md); margin: var(--s3) 0 var(--s1); }
.rte-content blockquote, .rich-text blockquote { margin: var(--s3) 0; padding: var(--s2) var(--s4); border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text); }
.rte-content ul, .rte-content ol, .rich-text ul, .rich-text ol { margin: var(--s2) 0; padding-left: 1.4rem; }
.rte-content a, .rich-text a { color: var(--primary); }
.rte-content pre, .rich-text pre { margin: var(--s2) 0; }
.rte-status { padding: var(--s1) var(--s3); font-size: var(--fs-xs); color: var(--muted); border-top: 1px solid var(--border); background: var(--surface-2); }
.rte-status.error { color: var(--danger); }
.rich-text { line-height: 1.6; overflow-wrap: anywhere; }
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text p { margin: 0 0 var(--s2); }

/* ---------- Bereich Projekte ---------- */
/* Schlüssel-Wert-Zeilen auf der Projekt-Detailseite */
.kv { margin-bottom: var(--s3); }
.kv > span { display: block; }
/* Tabellenzeilen, die eine Detailseite öffnen */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
/* Aufklappbare Feldvergleiche im Excel-Abgleich */
details.small summary { cursor: pointer; color: var(--muted); margin-top: var(--s1); }
details.small .table-wrap { margin-top: var(--s2); }

/* ---------- Dokumentvorschau (Projekte → Dokumentseiten) ---------- */
.doc-preview { background: var(--surface); border: 1px solid var(--border); padding: var(--s7) var(--s7); font-size: var(--fs-sm); line-height: 1.5; color: var(--text-strong); }
.doc-preview .doc-head { display: flex; justify-content: space-between; gap: var(--s6); margin-bottom: var(--s6); }
.doc-preview .doc-address { flex: 1 1 55%; padding-top: var(--s7); }
.doc-preview .doc-return { font-size: var(--fs-xs); color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 2px; margin-bottom: var(--s2); }
.doc-preview .doc-letterhead { flex: 0 0 38%; font-size: var(--fs-xs); color: var(--muted); }
.doc-preview .doc-letterhead strong { font-size: var(--fs-md); color: var(--primary); }
.doc-preview .doc-meta { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); justify-content: flex-end; margin-bottom: var(--s4); }
.doc-preview .doc-meta em, .doc-preview .doc-reference em { font-style: normal; color: var(--muted); font-size: var(--fs-xs); margin-right: var(--s1); }
.doc-preview .doc-reference { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s3); margin-bottom: var(--s4); }
.doc-preview .doc-reference div { display: contents; }
.doc-preview .doc-title { font-weight: 700; margin: var(--s4) 0; }
.doc-preview h3 { font-size: var(--fs-md); margin: var(--s5) 0 var(--s2); }
.doc-preview h4 { font-size: var(--fs-sm); margin: var(--s3) 0 var(--s2); padding-left: var(--s5); }
.doc-preview p { margin: 0 0 var(--s3); }
.doc-preview p.bold { font-weight: 700; }
.doc-preview p.small { font-size: var(--fs-xs); }
.doc-preview .indent-1, .doc-preview ul.indent-1 { padding-left: var(--s5); }
.doc-preview .indent-2, .doc-preview ul.indent-2 { padding-left: var(--s8); }
.doc-preview p.align-justify { text-align: justify; }
.doc-preview ul { margin: 0 0 var(--s3); list-style: "– "; }
.doc-preview ul.indent-0 { padding-left: var(--s4); }
.doc-preview table.kv { border-collapse: collapse; margin: 0 0 var(--s3); }
.doc-preview table.kv th { text-align: left; font-weight: 400; color: var(--muted); padding: 1px var(--s4) 1px 0; vertical-align: top; }
.doc-preview table.kv td { padding: 1px 0; vertical-align: top; }
.doc-preview table.grid { border-collapse: collapse; width: 100%; margin: 0 0 var(--s3); }
.doc-preview table.grid th, .doc-preview table.grid td { border: 1px solid var(--border-strong); padding: var(--s1) var(--s2); text-align: left; vertical-align: top; }
.doc-preview .signature { margin-top: var(--s6); white-space: pre-line; }
/* Dokumentseiten: Formular links, Vorschau rechts (unter 1080 px untereinander) */
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
/* Rechte Spalte: bleibt beim Scrollen stehen und füllt die Fensterhöhe; die Vorschau ist ein A4-Blatt (210:297), das
   so hoch wie der verbleibende Platz ist. Längere Dokumente scrollen innerhalb des Blatts. */
.doc-layout .doc-sticky { position: sticky; top: var(--s4); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.doc-sticky > #doc-result { flex: none; }
.doc-sticky > #doc-result:empty { display: none; } /* sonst erzeugt der leere Container einen Flex-Abstand und das Blatt rutscht unter die Kartenkante */
.doc-sticky > #doc-result .alert { margin-bottom: 0; }
/* Breite = Spaltenbreite, höchstens so breit, dass das Blatt in die Fensterhöhe passt; Höhe folgt aus 210:297.
   Linksbündig, damit die Blattkante mit der Kartenkante der linken Spalte fluchtet. */
.doc-sheet { flex: none; width: min(100%, calc((100vh - 2 * var(--s4)) * 210 / 297)); aspect-ratio: 210 / 297; align-self: flex-start; box-sizing: border-box; background: var(--surface); border: 1px solid var(--border-strong); overflow: auto; }
.doc-sheet .doc-preview { border: 0; min-height: 100%; box-sizing: border-box; padding: 8% 9% 10%; }
.doc-sheet .empty-state { height: 100%; display: flex; flex-direction: column; justify-content: center; }

/* ---------- Dateisymbole (UI.fileIcon): Farbe je Dateiart ---------- */
.file-icon { display: inline-flex; flex: none; vertical-align: middle; color: var(--muted); }
.fi-folder { color: #d9a400; }
.fi-pdf { color: #c0392b; }
.fi-word { color: #2b5797; }
.fi-excel { color: #1f7244; }
.fi-ppt { color: #c55a11; }
.fi-image { color: #7e4455; }
.fi-text { color: #5f6b7a; }
.fi-mail { color: #0f766e; }
.fi-cad { color: #0055a4; }
.fi-archive { color: #8a6d3b; }
.fi-other { color: #6b7280; }
/* Zeile mit Symbol links und Text rechts (Listen von Dateien und Ordnern) */
.file-row { display: flex; align-items: flex-start; gap: var(--gap-inline); min-width: 0; }
.file-row > .file-icon { margin-top: 1px; }
.file-row > div { min-width: 0; flex: 1 1 auto; }
/* Pfadleiste wie im Explorer: Stationen anklickbar, die aktuelle fett */
.path-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); margin-bottom: var(--gap-block); padding: var(--s2) var(--s3); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-sm); }
.path-bar a { display: inline-flex; align-items: center; gap: var(--s1); text-decoration: none; color: var(--primary); }
.path-bar a:hover { text-decoration: underline; }
.path-bar .current { font-weight: 700; color: var(--text-strong); display: inline-flex; align-items: center; gap: var(--s1); }
.path-bar .crumb-sep { color: var(--muted-2); display: inline-flex; }

/* ---------- Büro: Vorschau eines Dokuments (PDF im Rahmen, Bild in voller Breite) ---------- */
.office-preview { display: block; width: 100%; height: 70vh; border: 1px solid var(--border); background: var(--surface-2); }
.office-preview-image { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s1) var(--s4); }
@media (max-width: 1079px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-layout .doc-sticky { position: static; height: auto; display: block; }
  .doc-sheet { aspect-ratio: auto; width: 100%; overflow: visible; }
  .doc-sheet .doc-preview { padding: var(--s5) var(--s4); }
}
/* Anlagenzeilen im Anschreiben: Unterlage breit, n-fach/von/bis schmal; Beschriftung nur in der ersten Zeile */
.anlage-row { display: grid; grid-template-columns: minmax(0, 3fr) repeat(3, minmax(0, 1fr)); gap: 0 var(--s3); }
.anlage-row .field { margin-bottom: var(--s2); }
.anlage-row + .anlage-row .field > span { display: none; }
@media (max-width: 1079px) { .anlage-row { grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--border); padding-top: var(--s2); } .anlage-row + .anlage-row .field > span { display: inline; } }
/* Links, die wie Schaltflächen aussehen (Downloads erzeugter Dokumente); gleiche Maße wie button */
a.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); height: var(--control-h); padding: 0 var(--s4); border: 1px solid var(--border-strong); background: #fff; color: var(--text); text-decoration: none; line-height: 1.2; white-space: nowrap; font-weight: 500; }
a.btn:hover { background: var(--surface-2); border-color: #b9bfc6; text-decoration: none; }
a.btn.small { height: 30px; padding: 0 var(--s3); font-size: var(--fs-sm); }

/* ---------- Wochenkalender (UI.weekCalendar) ---------- */
:root {
  --cal-1: #0055a4; --cal-2: #7e4455; --cal-3: #15803d; --cal-4: #b45309; --cal-5: #6d28d9; --cal-6: #0e7490; --cal-7: #9d174d; --cal-8: #4d7c0f;
}
.week-cal { --cal-time-w: 56px; border: 1px solid var(--border); background: var(--surface); overflow-x: auto; margin-bottom: var(--gap-block); }
.week-cal .cal-body { padding-top: 0.7em; } /* Platz für die erste Uhrzeit, die halb über der Linie steht */
.week-cal .cal-head, .week-cal .cal-allday, .week-cal .cal-body { display: grid; grid-template-columns: var(--cal-time-w) repeat(7, minmax(110px, 1fr)); }
.week-cal .cal-head { border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.week-cal .cal-day-head { padding: var(--s2) var(--s2); border-left: 1px solid var(--border); text-align: center; }
.week-cal .cal-day-head.today { background: var(--primary-soft); }
.week-cal .cal-day-label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.week-cal .cal-day-sub { font-size: var(--fs-lg); font-weight: 700; color: var(--text-strong); }
.week-cal .cal-day-total { font-size: var(--fs-xs); color: var(--muted); }
.week-cal .cal-allday { border-bottom: 1px solid var(--border); min-height: 28px; }
.week-cal .cal-allday-cell { border-left: 1px solid var(--border); padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.week-cal .cal-corner { padding: var(--s2); font-size: var(--fs-xs); color: var(--muted); }
.week-cal .cal-times { font-size: var(--fs-xs); color: var(--muted); text-align: right; padding-right: var(--s2); }
.week-cal .cal-hour { box-sizing: border-box; transform: translateY(-0.6em); }
.week-cal .cal-day { position: relative; border-left: 1px solid var(--border); }
.week-cal .cal-day.today { background: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
.week-cal .cal-line { box-sizing: border-box; border-top: 1px solid var(--border); }
.week-cal .cal-block { position: absolute; left: 2px; right: 2px; box-sizing: border-box; overflow: hidden; padding: 2px 4px; font-size: var(--fs-xs); line-height: 1.25; color: var(--text-strong); border: 1px solid; border-left-width: 3px; }
.week-cal .cal-block-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-cal .cal-block-hint { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-cal .cal-chip { font-size: var(--fs-xs); padding: 1px 4px; border: 1px solid; border-left-width: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-cal .cal-c1, .week-cal .cal-c2, .week-cal .cal-c3, .week-cal .cal-c4, .week-cal .cal-c5, .week-cal .cal-c6, .week-cal .cal-c7, .week-cal .cal-c8 { background: color-mix(in srgb, var(--cal-color) 14%, var(--surface)); border-color: color-mix(in srgb, var(--cal-color) 45%, var(--surface)); border-left-color: var(--cal-color); }
.week-cal .cal-c1 { --cal-color: var(--cal-1); } .week-cal .cal-c2 { --cal-color: var(--cal-2); } .week-cal .cal-c3 { --cal-color: var(--cal-3); } .week-cal .cal-c4 { --cal-color: var(--cal-4); }
.week-cal .cal-c5 { --cal-color: var(--cal-5); } .week-cal .cal-c6 { --cal-color: var(--cal-6); } .week-cal .cal-c7 { --cal-color: var(--cal-7); } .week-cal .cal-c8 { --cal-color: var(--cal-8); }
.week-cal .cal-muted { background: var(--surface-3); border-color: var(--border-strong); border-left-color: var(--muted); color: var(--muted); }
.week-nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.week-nav .week-title { font-weight: 700; font-size: var(--fs-md); margin: 0 var(--s2); }

/* ---------- Zähler im Hauptmenü (offene Anfragen, ungelesene Nachrichten) ---------- */
.nav-badge { margin-left: auto; min-width: 1.5em; padding: 0 0.4em; font-size: var(--fs-xs); font-weight: 700; line-height: 1.6; text-align: center; background: var(--sidebar-strong); color: var(--sidebar); }
.nav-badge[hidden] { display: none; }

/* ---------- Chat (pages/messenger.js): links die Unterhaltungen, rechts der Verlauf; mobil eine Spalte ---------- */
.msg-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: var(--gap-block); align-items: start; }
.msg-chats { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); }
.msg-chats li + li { border-top: 1px solid var(--border); }
.msg-chats a { display: flex; gap: var(--gap-inline); align-items: flex-start; padding: var(--s3); color: var(--text); text-decoration: none; border-left: 3px solid transparent; }
.msg-chats a:hover { background: var(--surface-2); }
.msg-chats a.active { background: var(--accent-soft); border-left-color: var(--accent); }
.msg-chats .msg-chat-main { flex: 1 1 auto; min-width: 0; }
.msg-chats .msg-chat-title { font-weight: 600; }
.msg-chats .msg-chat-last { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-thread { background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 360px; }
.msg-head { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface-2); font-weight: 600; display: flex; align-items: center; gap: var(--gap-inline); }
.msg-scroll { flex: 1 1 auto; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.msg-day { align-self: center; font-size: var(--fs-xs); color: var(--muted); padding: var(--s1) var(--s3); background: var(--surface-2); }
.msg { max-width: min(78%, 560px); padding: var(--s2) var(--s3); background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--primary-soft); border-color: transparent; }
.msg.deleted { color: var(--muted); font-style: italic; }
.msg-author { font-size: var(--fs-xs); font-weight: 700; color: var(--accent); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--muted); }
.msg-meta button { height: auto; padding: 0; border: 0; background: none; color: var(--muted); font-size: var(--fs-xs); text-decoration: underline; cursor: pointer; }
.msg-compose { display: flex; gap: var(--gap-inline); padding: var(--s3); border-top: 1px solid var(--border); align-items: flex-end; }
.msg-compose textarea { flex: 1 1 auto; min-height: var(--control-h); max-height: 160px; resize: none; padding: var(--s2) var(--s3); font: inherit; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.msg-back { display: none; }
@media (max-width: 1079px) {
  .msg-layout { grid-template-columns: minmax(0, 1fr); }
  .msg-layout.open .msg-chats, .msg-layout:not(.open) .msg-thread { display: none; }
  .msg-thread { height: calc(100vh - 190px); }
  .msg-back { display: inline-flex; }
}

/* Chat: Anhänge und Abstimmungen */
.msg-image img { display: block; max-width: min(100%, 320px); max-height: 320px; border: 1px solid var(--border); }
.msg-file { display: flex; align-items: center; gap: var(--gap-inline); color: var(--text); text-decoration: none; padding: var(--s1) 0; }
.msg-file > span { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.msg-file:hover strong { text-decoration: underline; }
.msg-poll { display: flex; flex-direction: column; gap: var(--s2); min-width: min(260px, 60vw); }
.msg-poll-question { font-weight: 600; }
.msg-poll-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--s3); align-items: center; height: auto; padding: var(--s2) var(--s3); text-align: left; white-space: normal; background: var(--surface); border: 1px solid var(--border-strong); }
.msg-poll-option.chosen { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); font-weight: 600; }
.msg-poll-label { display: inline-flex; align-items: center; gap: var(--s1); overflow-wrap: anywhere; }
.msg-poll-names { grid-column: 1 / -1; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.msg-poll-close { align-self: flex-start; height: auto; padding: 0; border: 0; background: none; color: var(--muted); font-size: var(--fs-xs); text-decoration: underline; cursor: pointer; }

/* ---------- Unterschriftsfeld (UI.signaturePad) ---------- */
.signature-pad { position: relative; border: 1px solid var(--border-strong); background: var(--surface); }
.signature-pad canvas { display: block; width: 100%; height: auto; aspect-ratio: 600 / 180; touch-action: none; cursor: crosshair; color: var(--text); }
.signature-pad::after { content: "Hier unterschreiben"; position: absolute; left: var(--s3); bottom: var(--s2); font-size: var(--fs-xs); color: var(--muted); pointer-events: none; }
.signature-pad.signed::after { content: ""; }
.signature-pad .signature-clear { position: absolute; top: var(--s1); right: var(--s1); height: auto; padding: var(--s1) var(--s2); font-size: var(--fs-xs); }
.signature-image { display: block; max-width: 100%; border: 1px solid var(--border); background: var(--surface); }

/* Entfernen-Kreuz in einem Tag (Empfänger eines Dokuments) */
.tag .tag-remove { height: auto; padding: 0 0 0 var(--s1); border: 0; background: none; color: inherit; font-size: inherit; line-height: 1; cursor: pointer; }

/* Prüfsummen und andere lange Kennungen: brechen um, statt den Behälter zu sprengen */
code.hash { white-space: normal; overflow-wrap: anywhere; word-break: break-all; }

/* Sponsoren-Netzwerk: Logo im Verzeichnis, Kommentare unter einem Beitrag */
.sponsor-logo { flex: none; width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--border); background: var(--surface); }
.sponsor-logo-empty { display: flex; align-items: center; justify-content: center; font-size: var(--fs-xl); font-weight: 700; color: var(--muted); background: var(--surface-2); }
.sponsor-card .panel-list { margin-top: var(--gap-text); border-top: 1px solid var(--border); }
.sponsor-comment { margin-top: var(--gap-text); padding: var(--s2) var(--s3); background: var(--surface-2); border-left: 2px solid var(--border-strong); overflow-wrap: anywhere; }
.sponsor-comment-form { margin-top: var(--gap-text); margin-bottom: 0; }
.sponsor-card .card-body > .row { margin-bottom: var(--gap-text); align-items: flex-start; }
.sponsor-comment-form .field { margin-bottom: var(--gap-inline); }

/* Alltag der Gruppe (Tablet): je Kind eine Zeile mit großen Knöpfen */
.care-day { display: flex; flex-direction: column; }
.care-child { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--gap-text); padding: var(--s3) 0; border-top: 1px solid var(--border); border-left: 4px solid transparent; padding-left: var(--s3); }
.care-child:first-child { border-top: 0; }
.care-child.here { border-left-color: var(--success); }
.care-child.away { border-left-color: var(--warning); background: var(--surface-2); }
.care-child-main { flex: 1 1 280px; min-width: 0; }
.care-child-name { font-size: var(--fs-lg); font-weight: 600; text-align: left; }
.care-child-actions { display: flex; flex-wrap: wrap; gap: var(--gap-inline); }
.care-child-actions button { min-height: 44px; min-width: 76px; }

/* Wissensdatenbank: Seitenbaum als eingerückte Liste, Treffer der Suche hervorgehoben */
ul.wiki-tree { list-style: none; margin: 0; padding: 0; }
ul.wiki-tree ul.wiki-tree { margin-left: var(--s2); padding-left: var(--s3); border-left: 1px solid var(--border); }
.wiki-search { display: flex; align-items: flex-end; gap: var(--gap-inline); margin-bottom: var(--gap-block); }
.wiki-search .field { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }
.card-body > .wiki-search:last-child { margin-bottom: 0; }
ul.wiki-notes { list-style: none; margin: 0; padding: 0; }
ul.wiki-notes li { padding: var(--s3) 0; border-top: 1px solid var(--border); }
ul.wiki-notes li:first-child { border-top: 0; padding-top: 0; }
ul.wiki-notes li:last-child { padding-bottom: 0; }
.wiki-tree li { padding: var(--s1) 0; }
.wiki-tree li > a { display: inline-block; padding: 2px 0; font-weight: 500; }
.wiki-tree li > a.active { color: var(--accent); }
mark { background: var(--accent-soft); color: inherit; padding: 0 2px; }

/* Rechnungen: Positionen des Entwurfs, Summenblock, Logo der Vorlage */
.inv-line { padding: var(--gap-block) 0; border-top: 1px solid var(--border); }
.inv-line:first-child { border-top: 0; padding-top: 0; }
.inv-line:last-child { padding-bottom: 0; }
.inv-line-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--gap-inline) var(--gap-block); }
table.inv-totals { width: auto; min-width: min(360px, 100%); margin: var(--gap-block) 0 var(--gap-block) auto; border-collapse: collapse; border: 0; }
.inv-totals td { padding: var(--s1) 0 var(--s1) var(--s6); text-align: right; border: 0; background: none; }
.inv-totals td:first-child { text-align: left; padding-left: 0; color: var(--muted); }
.inv-totals tr.strong td { border-top: 2px solid var(--border-strong); font-weight: 700; font-size: var(--fs-lg); color: var(--text-strong); padding-top: var(--s2); }
.inv-logo { max-height: 40px; max-width: 160px; display: block; }

/* Dashboard: Übersichten als Karten nebeneinander, Kacheln darin kompakter */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 0 var(--gap-block); align-items: start; }
.dash-tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: var(--gap-block); }
.dash-tiles:last-child { margin-bottom: 0; }
.nav-label:not(:first-child) { margin-top: var(--s3); }
.dash-tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--gap-inline); }
.dash-tiles .tile { padding: var(--s3); }
.dash-tiles .tile .value { font-size: var(--fs-xl); overflow-wrap: anywhere; }

/* Postfach: Ordner links, Liste oder E-Mail rechts; fremdes HTML im abgeschotteten Rahmen */
.mail-layout { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: var(--gap-section); align-items: start; }
.mail-folders { background: var(--surface); border: 1px solid var(--border); }
.mail-unread { font-weight: 700; color: var(--text-strong); }
.mail-frame { display: block; width: 100%; height: 62vh; min-height: 320px; border: 1px solid var(--border); background: #fff; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; margin: 0; padding: var(--s3); border: 1px solid var(--border); background: var(--surface); }
.mail-main > .btn-row { margin-bottom: var(--gap-block); }
@media (max-width: 1079px) { .mail-layout { grid-template-columns: 1fr; gap: var(--gap-block); } }

/* Installationsknopf von Progressier auf der Anmeldeseite: kommt ungestaltet, hier wie ein gewöhnlicher Knopf */
.progressier-install-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--gap-inline); min-height: var(--control-h); }
.progressier-install-button:empty { display: none; }

/* Gelesen-Status: Zeile unter einem Beitrag, Häkchen an eigenen Chatnachrichten */
.read-foot { margin-top: var(--s2); font-size: var(--fs-sm); }
[data-read-new] { margin-left: var(--s2); }
.msg-read { display: inline-flex; align-items: center; gap: 2px; color: var(--success); }

/* Offline-Ansicht (legt sich über alles) und Hinweis auf eine neue Version */
dialog.offline-screen { position: fixed; inset: 0; z-index: 3000; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; border: 0; padding: var(--s5); background: var(--bg); }
dialog.offline-screen[open] { display: flex; align-items: center; justify-content: center; }
.offline-box { max-width: 460px; text-align: center; }
.offline-box h1 { margin: var(--s3) 0 var(--s2); }
.offline-box button { margin-top: var(--s3); min-width: 180px; }
.offline-art { width: min(100%, 300px); height: auto; }
.offline-art path { fill: none; stroke: var(--text-strong); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.offline-art .offline-sail { fill: var(--surface); }
.offline-art .offline-sail.slack { stroke-dasharray: 5 6; }
.offline-art .offline-hull { fill: var(--accent); stroke: var(--accent); }
.offline-art .offline-sun { stroke: var(--warning); }
.offline-art .offline-wave { stroke: var(--primary); stroke-width: 2; }
.update-bar { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); z-index: 2500; display: flex; align-items: center; gap: var(--gap-text); max-width: calc(100vw - 2 * var(--s4)); padding: var(--s3) var(--s4); background: var(--text-strong); color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.update-bar .update-later { background: none; border-color: transparent; color: #fff; text-decoration: underline; }
@media (max-width: 1079px) { .update-bar { flex-wrap: wrap; justify-content: center; width: calc(100vw - 2 * var(--s4)); } }

/* Hauptmenü: aufklappbare Gruppen unter den wichtigsten Bereichen */
.sidebar nav .nav-group { display: flex; align-items: center; gap: var(--s3); width: 100%; height: auto; margin-top: var(--s2); padding: var(--s2) var(--s3); border: 0; border-top: 1px solid rgba(255, 255, 255, 0.14); background: none; color: var(--sidebar-muted); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; text-align: left; cursor: pointer; }
.sidebar nav .nav-group > span:first-child { flex: 1 1 auto; }
.sidebar nav .nav-group:hover { color: var(--sidebar-strong); background: var(--sidebar-2); }
.sidebar nav .nav-group svg { flex: none; transition: transform 0.15s; }
.sidebar nav .nav-group[aria-expanded="true"] svg { transform: rotate(180deg); }
.sidebar nav .nav-group .nav-badge { margin-left: 0; }
.sidebar nav .nav-group[aria-expanded="true"] .nav-badge { display: none; }
.nav-group-items { display: flex; flex-direction: column; }
.nav-group-items[hidden] { display: none; }

/* Suche über alle Bereiche: Feld oben in der Seitenleiste, Trefferliste im Dialog */
.nav-search { display: flex; align-items: center; gap: var(--s2); width: 100%; height: var(--control-h); margin: var(--s3) 0 var(--s2); padding: 0 var(--s3); background: rgba(255, 255, 255, 0.1); color: var(--sidebar-text); border: 1px solid var(--sidebar-border); font: inherit; font-size: var(--fs-sm); cursor: pointer; text-align: left; }
.nav-search:hover, .nav-search:focus-visible { background: rgba(255, 255, 255, 0.18); }
.nav-search span { flex: 1; }
.nav-search kbd { font-size: var(--fs-xs); background: transparent; border: 1px solid var(--sidebar-border); color: inherit; opacity: 0.8; }
.search-results { min-height: 180px; max-height: 52vh; overflow-y: auto; }
.search-results h4 { margin: var(--gap-block) 0 var(--s1); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.search-results .search-hit { display: block; text-decoration: none; color: inherit; padding: var(--s1) 0; }
.search-results .search-hit:focus-visible, .search-results .search-hit:hover { background: var(--surface-2); outline: none; }
/* Schnellzugriff auf dem Dashboard: die häufigsten Handgriffe der eigenen Rolle */
.quick-bar { display: flex; flex-wrap: wrap; gap: var(--gap-inline); margin-bottom: var(--gap-block); }
@media (max-width: 1079px) { .nav-search kbd { display: none; } .quick-bar .btn, .quick-bar button { flex: 1 1 44%; } }

/* Glocke in der Seitenleiste: Zähler der ungelesenen Benachrichtigungen */
.bell-btn { position: relative; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; background: #fff; color: var(--accent); font-size: 11px; font-weight: 700; line-height: 1; }
.notify-item { display: block; text-decoration: none; color: inherit; }
.panel-list li.active .notify-item strong { color: var(--primary); }

/* Kita-Tag: Mitteilung der Eltern am Kind, Übersicht aller Gruppen */
.care-message { margin-top: var(--s1); padding: var(--s1) var(--s2); background: var(--warning-soft, #fff4d6); border-left: 3px solid var(--warning, #b7791f); font-size: var(--fs-sm); }
.care-message.seen { background: transparent; border-left-color: var(--border); color: var(--muted); }

/* Mehrsprachigkeit: Sprachwahl auf der Anmeldeseite; Schreibrichtung von rechts nach links (Arabisch) ist vorbereitet,
   aber noch nicht durchgeprüft: Seitenleiste rechts, Text rechtsbündig, Tabellen und Formulare folgen der Richtung. */
.lang-switch { font-size: var(--fs-sm); color: var(--muted); }
[dir="rtl"] body { text-align: right; }
[dir="rtl"] .app { direction: rtl; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] th.right, [dir="rtl"] td.right { text-align: left; }

/* Balkenliste (UI.barList): Name, Balken in einer Farbe, Wert als Text; mobil steht der Wert unter dem Namen */
.bar-list { display: grid; gap: var(--s2); }
.bar-row { display: grid; grid-template-columns: minmax(120px, 28%) 1fr minmax(48px, auto); align-items: center; gap: var(--s3); font-size: var(--fs-sm); }
.bar-label { overflow-wrap: anywhere; }
.bar-track { height: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--primary); min-width: 0; }
.bar-value { text-align: right; color: var(--muted); white-space: nowrap; }
@media (max-width: 1079px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; order: 3; }
  .bar-value { white-space: normal; }
}

/* Erscheinungsbild: Logo im Markenfeld, Vorlagen-Karten und Vorschau (pages/branding.js) */
.brand-logo { object-fit: contain; background: transparent; padding: 0; }
.brand-logo-preview { max-width: 160px; max-height: 64px; object-fit: contain; border: 1px solid var(--border); background: var(--surface-2); padding: var(--s1); }
.brand-favicon-preview { width: 32px; height: 32px; object-fit: contain; border: 1px solid var(--border); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s3); margin-bottom: var(--gap-block); }
.theme-card { display: grid; gap: var(--s1); padding: var(--s3); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.theme-card.active { outline: 2px solid var(--primary); outline-offset: -2px; }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-card:focus-within { outline: 2px solid var(--primary); }
.theme-swatches { display: flex; gap: 2px; height: 24px; }
.theme-swatch { flex: 1; border: 1px solid var(--border); }
.theme-preview { display: grid; grid-template-columns: 180px 1fr; border: 1px solid var(--border-strong); margin-bottom: var(--gap-block); background: var(--bg); min-height: 150px; }
.theme-preview-side { background: var(--sidebar); color: var(--sidebar-strong); padding: var(--s3); display: grid; gap: var(--s2); align-content: start; }
.theme-preview-nav { color: var(--sidebar-text); padding: var(--s1) var(--s2); }
.theme-preview-nav.active { background: var(--sidebar-active); color: var(--sidebar-strong); }
.theme-preview-main { padding: var(--s4); }
@media (max-width: 1079px) { .theme-preview { grid-template-columns: 1fr; } }

/* Dienstplan: Zelle je Gruppe und Tag mit Besetzung und Schichten als Knöpfe (pages/roster.js) */
.roster-cell { display: grid; gap: var(--s1); min-width: 120px; justify-items: start; }
.roster-state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.roster-chip { display: grid; justify-items: start; text-align: left; width: 100%; padding: var(--s1) var(--s2); height: auto; min-height: 0; line-height: 1.25; border: 1px solid var(--border-strong); border-left: 3px solid var(--primary); background: var(--surface); font-size: var(--fs-sm); font-weight: 400; }
.roster-chip small { color: var(--muted); font-size: var(--fs-xs); }
.roster-chip.other { border-left-color: var(--accent); }
.roster-chip.absent { border-left-color: var(--danger); background: var(--danger-soft); text-decoration: line-through; }
.roster-chip:disabled { opacity: 1; cursor: default; }
