/* === RESET & BASE === */
/* Inter selbst gehostet (Variable Font, latin-Subset inkl. Umlaute + €) —
   kein Google-Fonts-Request mehr: schneller, offline-faehig, DSGVO-sauber.
   Die Datei deckt als Variable Font alle Gewichte 400–700 ab. */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/assets/fonts/inter-latin.woff2') format('woff2');
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Das hidden-Attribut blendet IMMER aus — auch Elemente, deren Klasse ein
   eigenes display setzt (.actions, .chips, flex/grid-Container). Ohne diese
   Regel gewinnt die Klasse gegen den UA-Default und JS-Toggles per `hidden`
   bleiben wirkungslos; Module mussten dafuer je Klasse eigene Regeln bauen. */
[hidden] { display: none !important; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.5rem 0.75rem; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(91, 75, 196, 0.15); }
/* Suchfelder bleiben beim Fokus dezent — kein Akzent-Ring */
input[type="search"]:focus { border-color: var(--color-border); box-shadow: none; }

/* Strukturelle Tokens — Farben/Schatten definiert ausschliesslich themes.css
   (frueher lag hier ein kompletter Dark-Satz, der nur wegen der Bundle-
   Reihenfolge base→themes unsichtbar blieb) */
:root {
    --radius: 10px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Links (seit 0.75.0, docs/frontend.md → „Links"): interne Textlinks ruhig in Textfarbe ohne
   Unterstreichung — erkennbar an Ort und Hover. Hover/Fokus: Unterstreichung + Linkfarbe,
   sichtbarer Fokusring. Externe Links (neues Fenster, rel=external, absolute http(s)-URL)
   behalten die Linkfarbe. Alle Selektoren per :where() auf Element-Spezifitaet (0,0,1):
   Bausteine mit eigener Klasse (.btn, .badge, .chip, .tab, .tile, .stat, Navigation)
   gewinnen immer und bleiben unveraendert. Fliesstext (.markdown) unterstreicht zusaetzlich. */
a { color: var(--color-text); text-decoration: none; }
a:where(:hover, :focus-visible) {
    color: var(--color-link, var(--color-primary-text, var(--color-primary)));
    text-decoration: underline;
    text-underline-offset: 0.15em;
}
a:where(:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 2px; }
a:where([target="_blank"], [rel~="external"], [href^="http://"], [href^="https://"]) {
    color: var(--color-link, var(--color-primary-text, var(--color-primary)));
}
/* Optionales Kennzeichen fuer externe Links: <a class="link-external" href="https://…" target="_blank" rel="noopener">…</a> */
.link-external::after { content: "\2197"; display: inline-block; margin-left: 0.15em; font-size: 0.8em; text-decoration: none; }
h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; font-weight: 600; }
/* === THEME DEFINITIONEN === */
/* 2 Modi: Light (Default) + Dark */
/* Aktives Theme: data-theme Attribut auf <html> ("light" | "dark") */

/* Brand-Akzent (faictory, themeunabhaengig): zweifarbiger Verlauf wie auf
   faictory.de fuer Primaer-Buttons + Sidebar-Marke/Nav-Avatar. Core-Default;
   ein Projekt-CI kann --accent/--accent-2/--accent-gradient uebersteuern
   (partials/ci-style.php). Konsumiert via var(--accent-gradient, var(--color-primary))
   in components.css (.btn--primary) und layout.css (Marke, Nav-Avatar). */
:root {
    --accent: #f97467;
    --accent-2: #790a0a;
    --accent-gradient: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
}

/* --- LIGHT (Default) --- */
[data-theme="light"], :root {
    --color-primary: #5b4bc4;
    --color-primary-dark: #4d3fa6;
    --color-primary-light: #efedf9;
    --color-bg: #f6f5fa;
    --color-surface: #ffffff;
    --color-surface-hover: #faf9fd;
    --color-text: #211e33;
    --color-text-muted: #6f6d7a;
    --color-text-light: #a8a29e;
    --color-border: #e7e5e4;
    --color-border-light: #f5f5f4;
    --color-success: #059669;
    --color-success-light: #ecfdf5;
    --color-error: #dc2626;
    --color-error-light: #fef2f2;
    --color-warning: #d97706;
    --color-warning-light: #fffbeb;
    --color-info: #2563eb;
    --color-info-light: #eff6ff;
    /* Status als Text auf der hellen Statusflaeche (.alert--*, .badge--*): dunklere
       Stufe, damit AA (>= 4.5:1) auf *-light erreicht wird (tests/ci-contrast.test.php) */
    --color-success-text: #047857;
    --color-error-text: #b91c1c;
    --color-warning-text: #b45309;
    --color-info-text: #1d4ed8;
    /* Schrift auf --color-warning als Flaeche (Nav-Badge, .count--warning) */
    --color-on-warning: #1c1917;
    /* Badge-/Status-Farben (.badge--*, .status-select, .tag): Flaeche + Schrift */
    --badge-muted-bg: #f3f4f6;   --badge-muted-fg: #6f6d7a;
    --badge-gray-bg: #e5e7eb;    --badge-gray-fg: #374151;
    --badge-blue-bg: #dbeafe;    --badge-blue-fg: #1e40af;
    --badge-purple-bg: #ede9fe;  --badge-purple-fg: #6d28d9;
    --badge-teal-bg: #ccfbf1;    --badge-teal-fg: #0f766e;
    --badge-green-bg: #dcfce7;   --badge-green-fg: #166534;
    --badge-yellow-bg: #fef3c7;  --badge-yellow-fg: #92400e;
    --badge-orange-bg: #ffedd5;  --badge-orange-fg: #9a3412;
    --badge-red-bg: #fee2e2;     --badge-red-fg: #991b1b;
    --badge-pink-bg: #fce7f3;    --badge-pink-fg: #9d174d;
    --badge-brown-bg: #f5e8d8;   --badge-brown-fg: #78350f;
    --shadow: 0 1px 2px rgba(33,30,51,0.05), 0 4px 16px rgba(33,30,51,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.03);
    /* Kacheln (.tile): grosser Radius, weicher Schatten, Hover staerker */
    --tile-radius: calc(var(--radius, 10px) + 6px);
    --tile-border: rgba(33,30,51,0.06);
    --shadow-tile: 0 1px 2px rgba(33,30,51,0.04), 0 6px 20px rgba(33,30,51,0.08);
    --shadow-tile-hover: 0 2px 4px rgba(33,30,51,0.05), 0 14px 32px rgba(33,30,51,0.14);
    --login-gradient: linear-gradient(135deg, #faf5ff 0%, #fafaf9 50%, #f5f3ff 100%);
    --color-favorite: #fbbf24;
}

/* --- DARK --- */
[data-theme="dark"] {
    --color-primary: #897dd5;
    --color-primary-dark: #5b4bc4;
    --color-primary-light: rgba(137, 125, 213, 0.12);
    --color-bg: #09090b;
    --color-surface: #18181b;
    --color-surface-hover: #27272a;
    --color-text: #fafafa;
    --color-text-muted: #a1a1aa;
    --color-text-light: #71717a;
    --color-border: #27272a;
    --color-border-light: #1e1e22;
    --color-success: #34d399;
    --color-success-light: rgba(52, 211, 153, 0.12);
    --color-error: #f87171;
    --color-error-light: rgba(248, 113, 113, 0.12);
    --color-warning: #fbbf24;
    --color-warning-light: rgba(251, 191, 36, 0.12);
    --color-info: #60a5fa;
    --color-info-light: rgba(96, 165, 250, 0.12);
    --color-success-text: #34d399;
    --color-error-text: #f87171;
    --color-warning-text: #fbbf24;
    --color-info-text: #60a5fa;
    --color-on-warning: #18181b;
    --badge-muted-bg: rgba(161, 161, 170, 0.12);  --badge-muted-fg: #a1a1aa;
    --badge-gray-bg: rgba(161, 161, 170, 0.18);   --badge-gray-fg: #d4d4d8;
    --badge-blue-bg: rgba(96, 165, 250, 0.16);    --badge-blue-fg: #93c5fd;
    --badge-purple-bg: rgba(167, 139, 250, 0.16); --badge-purple-fg: #c4b5fd;
    --badge-teal-bg: rgba(45, 212, 191, 0.16);    --badge-teal-fg: #5eead4;
    --badge-green-bg: rgba(74, 222, 128, 0.16);   --badge-green-fg: #86efac;
    --badge-yellow-bg: rgba(250, 204, 21, 0.16);  --badge-yellow-fg: #fde68a;
    --badge-orange-bg: rgba(251, 146, 60, 0.16);  --badge-orange-fg: #fdba74;
    --badge-red-bg: rgba(248, 113, 113, 0.16);    --badge-red-fg: #fca5a5;
    --badge-pink-bg: rgba(244, 114, 182, 0.16);   --badge-pink-fg: #f9a8d4;
    --badge-brown-bg: rgba(217, 160, 102, 0.16);  --badge-brown-fg: #e7c9a5;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.45), 0 4px 10px rgba(0,0,0,0.3);
    --tile-border: #27272a;
    --shadow-tile: 0 1px 2px rgba(0,0,0,0.35), 0 6px 20px rgba(0,0,0,0.3);
    --shadow-tile-hover: 0 2px 4px rgba(0,0,0,0.4), 0 14px 32px rgba(0,0,0,0.5);
    --login-gradient: linear-gradient(135deg, #09090b 0%, #0f0a1f 50%, #09090b 100%);
    --color-favorite: #fbbf24;
}

/* Light-Theme Alert-Borders: kraeftigere Border, weil die *-light-Hintergruende
   im Light-Mode fast weiss sind */
[data-theme="light"] .alert--success { border-color: #a7f3d0; }
[data-theme="light"] .alert--error { border-color: #fecaca; }
[data-theme="light"] .alert--warning { border-color: #fde68a; }
[data-theme="light"] .alert--info { border-color: #bfdbfe; }

/* Dark/Light-Switch (Einstellungen → Erscheinungsbild) */
.theme-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: calc(var(--radius) - 3px); }
.theme-switch-opt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: calc(var(--radius) - 3px); font-size: 13px; font-weight: 600; color: var(--color-text-muted); text-decoration: none; transition: all 0.15s; }
.theme-switch-opt:hover { color: var(--color-primary); }
.theme-switch-opt--active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow); }
.theme-switch-opt--active:hover { color: var(--color-text); }
/* === Icon System (SVG inline, Linear-Style) === */
/* Monochrome, 1px stroke, currentColor */

.icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    flex-shrink: 0;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }

/* Icons als background-image SVG (currentColor via filter) */
.icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
/* === Avatar (Sidebar-Benutzer-Chip + Konto-Popover) ===
   Frueher gab es hier die komplette Top-Navigation (.nav*). Die ist entfernt —
   Sidebar ist das einzige Layout. Nur die Avatar-Klassen bleiben, weil sie der
   Benutzer-Chip und das Konto-Menue (partials/_usermenu-popover.php) nutzen. */
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: var(--color-on-primary, #fff); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.nav-avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* Bereichs-Icon im Switcher (main.php, $areaIcon) */
.app-sidebar-area-icon { vertical-align: -2px; margin-right: 5px; }

/* === Main Content === */
.main {
    padding: 0;
    width: 100%;
}

/* Container-Varianten: tragen das Padding, damit .main padding-frei bleibt.
 * So koennen Module mit eigener Sidebar edge-to-edge im .main sitzen,
 * waehrend normaler Content bequem Abstand hat. */
.container { width: 100%; max-width: 1400px; margin: 0 auto; padding: 2rem; }
.container--narrow { width: 100%; max-width: 640px; margin: 0 auto; padding: 2rem; }
.container--wide { width: 100%; max-width: none; margin: 0; padding: 1rem; }

/* === Seitenfluss: Abstand zwischen Bloecken (seit 0.76.0) ========================
 * Jeder sichtbare Block im Seiteninhalt (.container, .page-main, .section) hat Abstand zum
 * vorherigen — auch Bausteine ohne eigenen margin-bottom (.grid, .tiles, .actions, p, form).
 * Nur margin-top mit Spezifitaet 0 (:where): vertikale Margins fallen mit dem margin-bottom
 * von .card/.alert/.page-header zusammen (Maximum, keine Summe); jede Klasse mit eigenem
 * margin-top (.mt-0, .section-lead, .list-pagination) gewinnt. Token: --flow-space.
 * Enge Paare bleiben eng: nach .section-title/-head, Seitenkopf, Toolbar, Chips, Reitern und
 * Filter-Panel gilt der Abstand des Vorgaengers; nach Absatz/Ueberschrift ein kleinerer (--flow-space-sm). */
:root { --flow-space: 1.25rem; --flow-space-sm: 0.75rem; }
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(:not(script, style, template, link, meta, input[type="hidden"], [hidden], dialog, .modal)) ~ :where(*) {
    margin-top: var(--flow-space);
}
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(p, h1, h2, h3, h4) + :where(*) {
    margin-top: var(--flow-space-sm);
}
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(.section-title, .section-head, .page-header, .back-link, .list-toolbar, .list-views, .chips, .tabs, .tabs-select, #filter-panel, .card-head) + :where(*) {
    margin-top: 0;
}
/* Lange Woerter/URLs in Fliesstext brechen um, statt die Seite zu verbreitern */
:where(.container, .container--narrow, .container--wide) :where(p, li, dd, .alert, .section-lead, .page-lead, .page-title, .section-title) { overflow-wrap: break-word; }
/* Aktionsleisten: ein einzelner Button, der breiter als die Zeile ist (Blaettern mit langem Titel),
   bricht um statt die Seite zu verbreitern — normale Buttons passen und bleiben einzeilig */
.actions > .btn, .page-actions .btn, .section-actions .btn { max-width: 100%; white-space: normal; }
/* === Ende Seitenfluss 0.76.0 === */

/* ============================================================
 * Minimal-Layout (body[data-layout="minimal"], layouts/minimal.php, seit 0.67.0)
 * Kopf mit CI/Logo, Inhalt, Fusszeile — keine Sidebar. Default fuer externe
 * Benutzer (docs/extern.md). Glocke/Konto-Menue sind die Core-Komponenten der
 * Sidebar; hier klappen ihre Popover nach unten.
 * ============================================================ */
body[data-layout="minimal"] { min-height: 100vh; display: flex; flex-direction: column; }
.app-minimal-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.app-minimal-header-inner {
    max-width: 1400px; margin: 0 auto; padding: 0.75rem 2rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.app-minimal-brand { display: inline-flex; align-items: center; gap: 0.75rem; min-width: 0; color: var(--color-text); text-decoration: none; }
.app-minimal-brand:hover { text-decoration: none; }
.app-minimal-brand-logo { display: inline-flex; align-items: center; border-radius: calc(var(--radius) - 2px); padding: 2px; }
.app-minimal-brand-logo img { max-height: 40px; max-width: 180px; display: block; }
.app-minimal-brand-name { display: flex; flex-direction: column; font-weight: 700; font-size: 1.05rem; line-height: 1.2; min-width: 0; }
.app-minimal-brand-claim { font-weight: 400; font-size: 0.8rem; color: var(--color-text-muted); }
.app-minimal-actions { display: flex; align-items: center; gap: 0.5rem; }
.app-minimal-tools { margin: 0; }
.app-minimal-tools .app-sidebar-tool { color: var(--color-text-muted); }
.app-minimal-tools .app-sidebar-tool[data-tip]::after { bottom: auto; top: calc(100% + 6px); }
.app-minimal-tools .app-sidebar-bell-menu { bottom: auto; top: calc(100% + 8px); left: auto; right: 0; }
.app-minimal-user {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 4px 8px 4px 4px;
    border-radius: 999px; color: var(--color-text);
}
.app-minimal-user:hover { background: var(--color-surface-hover); }
.app-minimal-user-name { font-weight: 600; font-size: 0.9rem; }
.app-minimal-nav { display: flex; width: fit-content; max-width: calc(100% - 4rem); margin: 0 auto 0.75rem; overflow-x: auto; }
.app-minimal-main { flex: 1; }
.app-minimal-footer {
    padding: 1rem 2rem; text-align: center; font-size: 0.8rem;
    color: var(--color-text-muted); border-top: 1px solid var(--color-border);
}
@media (max-width: 640px) {
    .app-minimal-header-inner { padding: 0.6rem 1rem; }
    .app-minimal-user-name { display: none; }
}

/* ============================================================
 * Sidebar-Layout (body[data-layout="sidebar"])
 * Haupt-Navi wandert in eine fixe linke Spalte, Modul-Submenues
 * werden zu ausklappbaren Unterelementen.
 *
 * Breiten-Management via CSS-Variable --sidebar-width. Beim Collapse
 * wird nur die Variable geaendert, alles andere (Sidebar, Content,
 * Transitions) folgt automatisch.
 * ============================================================ */

body[data-layout="sidebar"] {
    --sidebar-width: 240px;
    --sidebar-gap: 0.5rem;
}

/* Collapsed-Mode: Sidebar schrumpft zur schmalen Icon-Rail (66px), sie bleibt
 * sichtbar. Nur die Variable aendert sich — .main und .app-sidebar folgen.
 * Wieder-Aufklappen ueber die Brand-Marke (app.js). */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] {
    --sidebar-width: 66px;
    --sidebar-gap: 0px;
}


/* Gap wird ueber margin-left erzeugt, NICHT ueber padding-left.
 * Dadurch bleibt .main's Padding einheitlich bei 2rem und alle Views
 * die sich mit 'margin: -2rem' in .main rausziehen funktionieren konsistent. */
body[data-layout="sidebar"] .main {
    margin-left: calc(var(--sidebar-width) + var(--sidebar-gap));
    width: calc(100% - var(--sidebar-width) - var(--sidebar-gap));
    padding: 0;
    min-height: 100vh;
    transition: margin-left 0.2s ease, width 0.2s ease;
}

.app-sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width, 240px); /* folgt der Collapse-Variable: 240px <-> 66px */
    height: 100vh;
    /* --sidebar-* setzt das CI-Theming (partials/ci-style.php); ohne CI gilt das Theme. */
    background: var(--sidebar-bg, var(--color-surface));
    border-right: 1px solid var(--color-border);
    box-shadow: none;
    padding: 20px 12px;
    z-index: 100;
    flex-direction: column;
    gap: 4px;
    transition: width 0.2s ease, padding 0.2s ease;
}

body[data-layout="sidebar"] .app-sidebar {
    display: flex;
}

/* Collapsed: schmale Icon-Rail (Prototyp-Spec) — Labels/Name/Claim/Meta aus,
 * Icons zentriert. Die Sidebar bleibt sichtbar, verschwindet NICHT. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar {
    padding: 20px 10px;
    overflow: visible;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand {
    justify-content: center;
    padding: 4px 0 18px;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-name,
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-group-label { display: none; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link {
    justify-content: center;
    padding: 9px 0;
    gap: 0;
    position: relative;
}
/* Eingeklappt: die Nav darf nicht clippen, sonst wird der Icon-Tooltip abgeschnitten. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-nav { overflow: visible; }
/* Label wird zum Tooltip: weisse Schrift auf schwarzem, abgerundetem "Button" rechts neben dem Icon. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link-label {
    display: block;
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    flex: none;
    padding: 6px 11px;
    background: #1a1a22;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
    z-index: 300;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link:hover .app-sidebar-link-label {
    opacity: 1;
    visibility: visible;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-user {
    justify-content: center;
    margin: 6px -10px 0;
    padding: 12px 0 2px;
    gap: 0;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-user-meta { display: none; }

/* Brand nach Prototyp-Spec: Mark + Name/Claim + Collapse-Pfeil, keine Trennlinie. */
.app-sidebar-brand {
    padding: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
/* Logo-Darstellung: ENTWEDER neben dem Schriftzug (--mark, Default) ODER ueber
   die volle Breite mit Titel darunter (--full). Das Logo kann optional eine eigene
   Hintergrundfarbe bekommen (ci_logo_bg = "Marke"), unabhaengig von der Sidebar-
   Farbe — z. B. ein schwarzes Logo auf gelbem Grund. */
.app-sidebar-brand-logo-link { display: inline-flex; text-decoration: none; min-width: 0; }
.app-sidebar-brand-box { display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.app-sidebar-brand-box--bg { padding: 5px 7px; border-radius: 8px; }
.app-sidebar-brand-img { display: block; max-width: 100%; height: auto; }

/* Modus "neben dem Schriftzug": kompaktes Logo in Zeilenhoehe, Titel daneben. */
.app-sidebar-brand--mark .app-sidebar-brand-box { height: 30px; }
.app-sidebar-brand--mark .app-sidebar-brand-box--bg { height: 36px; }
.app-sidebar-brand--mark .app-sidebar-brand-img { height: 100%; width: auto; max-width: 140px; }

/* Modus "volle Breite": Logo oben, Titel darunter. Die Breite (ci_logo_width)
   steht als Inline-Style am Link; Box und Bild fuellen sie. */
.app-sidebar-brand--full {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    position: relative;
}
.app-sidebar-brand--full .app-sidebar-brand-logo-link { align-self: center; max-width: 100%; }
.app-sidebar-brand--full .app-sidebar-brand-box { width: 100%; }
.app-sidebar-brand--full .app-sidebar-brand-img { width: 100%; }
.app-sidebar-brand--full .app-sidebar-brand-name {
    flex: none;
    text-align: center;
    align-self: center;
    max-width: 100%;
}
/* Linksbuendiges Vollbreiten-Logo (CI ci_logo_align = left): Logo UND Titel an den
   linken Rand statt zentriert — damit Marke und Schriftzug eine Kante teilen. */
.app-sidebar-brand--full.app-sidebar-brand--left .app-sidebar-brand-logo-link { align-self: flex-start; }
.app-sidebar-brand--full.app-sidebar-brand--left .app-sidebar-brand-name { align-self: flex-start; text-align: left; }
/* Einklapp-Pfeil oben rechts statt in einer eigenen Zeile: spart Hoehe. */
.app-sidebar-brand--full .app-sidebar-collapse-btn {
    position: absolute;
    top: 0;
    right: 0;
}

/* Eingeklappte Icon-Rail (66px): kein Platz fuers Logo — ausblenden, die Rail
   zeigt nur den Aufklapp-Button (siehe unten). */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-logo-link { display: none; }

.app-sidebar-brand-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--sidebar-ink-strong, var(--color-text));
    text-decoration: none;
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Claim unter dem App-Namen (CI-Feld ci_claim, z.B. "CRM & Projekte") */
.app-sidebar-brand-claim {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--sidebar-ink, var(--color-text-muted));
    opacity: 0.75;
    margin-top: -2px;
}

/* ---- Bereichs-Switcher (docs/frontend.md "Bereiche") ----------------------
 * 2 Bereiche: Segmented-Pill ueber dem Dashboard-Link. 3+: Combobox-Button
 * mit Popover. Eingeklappte Rail zeigt nur die Initialen (Regeln unten). */
.app-sidebar-areas {
    margin: 0 0 14px;
    flex-shrink: 0;
    position: relative;
}
.app-sidebar-areas--pill {
    display: flex;
    padding: 3px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 3px);
    gap: 2px;
}
/* Textfarben theme-basiert (nicht --sidebar-ink): der Pill-Hintergrund ist
 * --color-bg, nicht die CI-Sidebar-Farbe — sidebar-ink waere darauf unlesbar. */
.app-sidebar-area-seg {
    flex: 1;
    text-align: center;
    padding: 5px 8px;
    border-radius: calc(var(--radius) - 3px);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-sidebar-area-seg:hover { color: var(--color-primary-text, var(--color-primary)); }
.app-sidebar-area-seg--active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow);
}
.app-sidebar-area-seg--active:hover { color: var(--color-text); }
.app-sidebar-area-seg-initial { display: none; }

/* Combobox (3+ Bereiche): Button mit aktuellem Label + Chevron, Popover-Liste. */
.app-sidebar-area-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 3px);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
}
.app-sidebar-area-btn:hover { border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border)); }
.app-sidebar-area-btn-label {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-sidebar-area-btn-initial { display: none; }
.app-sidebar-area-chevron { flex: 0 0 auto; opacity: 0.6; }
.app-sidebar-area-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 2px);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 300;
}
.app-sidebar-area-item {
    display: block;
    padding: 7px 10px;
    border-radius: calc(var(--radius) - 4px);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
}
.app-sidebar-area-item:hover { background: color-mix(in srgb, var(--color-text-muted) 9%, transparent); }
.app-sidebar-area-item--active { color: var(--color-primary-text, var(--color-primary)); font-weight: 600; }

/* Eingeklappte Icon-Rail: Pill wird zur Initial-Spalte, Combobox zum Initial-Button. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-areas--pill {
    flex-direction: column;
    border-radius: calc(var(--radius) - 3px);
    padding: 3px;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-seg {
    padding: 6px 0;
    border-radius: calc(var(--radius) - 3px);
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-seg-label { display: none; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-seg-initial { display: inline; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-btn {
    justify-content: center;
    padding: 7px 0;
    gap: 0;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-btn-label,
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-chevron { display: none; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-btn-initial { display: inline; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-area-menu {
    left: calc(100% + 8px);
    right: auto;
    top: 0;
    min-width: 180px;
}

.app-sidebar-nav {
    flex: 1;
    min-height: 0;
    /* Viele Reiter bei wenig Hoehe: die Nav scrollt, Elemente darunter
       (Usermenue, Projekt-Buttons) bleiben sichtbar und liegen nie darueber. */
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-sidebar-module {
    display: block;
    line-height: 1.4;
}

/* Gruppen-Ueberschrift in der Nav (manifest.nav_group + config app.nav_groups).
   Standardmaessig NICHT eingerueckt: linksbuendig mit der linken Kante der
   Link-Pills (padding-left 0), einheitlich ueber alle Projekte. */
.app-sidebar-group-label {
    padding: 1.5rem 0.5rem 0.35rem 0;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-ink, var(--color-text-light));
    opacity: 0.75;
}
.app-sidebar-group-label:first-child { padding-top: 0.35rem; }

/* Nav-Reiter als abgerundete Pills (CI-Default aus CRM): kein Border-Left,
   keine eckige Voll-Breite — Hover/Active liegen als abgerundete Flaeche inset
   in der 12px-Sidebar-Polsterung. Hover = zarter Ink-Wash, Active = Primaerfarbe
   dezent auf Surface. */
.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: calc(var(--radius) - 3px);
    color: var(--sidebar-ink, var(--color-text-muted));
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}
.app-sidebar-link:hover {
    background: color-mix(in srgb, var(--sidebar-ink, var(--color-text-muted)) 9%, transparent);
    color: var(--sidebar-ink-strong, var(--color-text));
}
.app-sidebar-link--active {
    background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
    color: var(--color-primary-text, var(--color-primary));
    font-weight: 600;
}
.app-sidebar-link-icon { display: flex; align-items: center; flex: 0 0 auto; opacity: 0.75; }
.app-sidebar-link--active .app-sidebar-link-icon { opacity: 1; }
.app-sidebar-link-label { flex: 1; }
/* Nav-Badge (manifest.nav_badge, z.B. faellige Wiedervorlagen): Pille am rechten Rand. */
.app-sidebar-link-badge {
    flex: 0 0 auto;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--color-warning);
    color: var(--color-on-warning);
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
/* Text-Badge (nav_badge liefert String, z.B. "60 %", seit 0.74.0): neutral statt Warnfarbe —
   ein Stand ist Information, kein offener Punkt. */
.app-sidebar-link-badge--text {
    /* folgt der Linkfarbe (auch aktiv auf heller Pille in dunkler CI-Sidebar) */
    background: color-mix(in srgb, currentColor 14%, transparent);
    color: inherit;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
/* Eingeklappt: Badge schrumpft zum Punkt oben rechts am Icon — Zahl entfaellt,
   das "hier ist was offen"-Signal bleibt sichtbar. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link-badge {
    position: absolute;
    top: 5px;
    right: 8px;
    min-width: 8px;
    width: 8px;
    height: 8px;
    padding: 0;
    font-size: 0;
    line-height: 0;
}
/* Klickbarer User-Chip unten: oeffnet das Settings-Modal (Button-Reset noetig,
 * da im Core ein <button> statt eines <a>). Nur durch eine feine Linie abgesetzt. */
.app-sidebar-user {
    background: none;
    border: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    width: calc(100% + 24px);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px -12px 0;
    padding: 12px 12px 2px;
    border-top: 1px solid var(--color-border);
    color: var(--sidebar-ink, var(--color-text-muted));
    text-decoration: none;
    flex-shrink: 0;
}
.app-sidebar-user .nav-avatar,
.app-sidebar-user .nav-avatar-img { flex: 0 0 auto; }
.app-sidebar-user .nav-avatar { background: var(--accent-gradient, var(--color-primary)); }
.app-sidebar-user-meta { min-width: 0; }
.app-sidebar-user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--sidebar-ink-strong, var(--color-text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-sidebar-user-role {
    display: block;
    font-size: 11px;
    color: var(--sidebar-ink, var(--color-text-muted));
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Kein Hover-Umfaerben des Namens: er bleibt --sidebar-ink-strong (weiss/schwarz
 * je nach Sidebar-Farbe, core/Color.php readableInk) statt der Primaerfarbe. */

/* Sidebar-Collapse-Button: sitzt rechts in der Brand-Zeile und klappt die
 * Sidebar zur Icon-Rail ein. Wieder-Aufklappen laeuft ueber die Brand-Marke
 * (app.js). Im eingeklappten Zustand ist der Button daher verborgen. */
.app-sidebar-collapse-btn {
    flex: 0 0 auto;
    /* Nach rechts schieben — trug frueher der flex:1-Titel; ohne Titel (leeres
       ci_sidebar_title) muss der Button selbst den Raum nehmen. */
    margin-left: auto;
    width: 26px;
    height: 26px;
    border-radius: calc(var(--radius) - 4px);
    border: 0;
    background: transparent;
    color: var(--sidebar-ink, var(--color-text-muted));
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
}
.app-sidebar-collapse-btn:hover { opacity: 1; background: var(--sidebar-hover, var(--color-bg)); }
/* Eingeklappt: der Button bleibt sichtbar und ist der Aufklapp-Ausloeser (der
   frueher nur bei Hover erschienene Zustand ist jetzt der Standard). Zentriert in
   der Rail, Pfeil nach rechts gedreht (= aufklappen); die --full-Absolutposition
   wird zurueckgenommen. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-collapse-btn {
    margin: 0 auto;
    opacity: 0.85;
}
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand--full .app-sidebar-collapse-btn { position: static; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-collapse-btn svg { transform: rotate(180deg); }

/* Responsive: Bei schmalen Bildschirmen faellt die Sidebar auf die Icon-Rail
 * (66px) zurueck, damit der Inhalt Platz bekommt. app.js setzt zusaetzlich
 * data-sidebar-collapsed (blendet die Labels aus); ohne JS bleibt es eine
 * reine Icon-Spalte. Aufklappen ueber die Brand-Marke. */
@media (max-width: 900px) {
    body[data-layout="sidebar"] {
        --sidebar-width: 66px;
        --sidebar-gap: 0px;
    }
    /* Schmale Viewports = Icon-Rail per Media-Query (ohne data-Attribut):
     * Bereichs-Switcher zeigt auch hier nur die Initialen. */
    body[data-layout="sidebar"] .app-sidebar-areas--pill {
        flex-direction: column;
        border-radius: calc(var(--radius) - 3px);
    }
    body[data-layout="sidebar"] .app-sidebar-area-seg {
        padding: 6px 0;
        border-radius: calc(var(--radius) - 3px);
    }
    body[data-layout="sidebar"] .app-sidebar-area-seg-label { display: none; }
    body[data-layout="sidebar"] .app-sidebar-area-seg-initial { display: inline; }
    body[data-layout="sidebar"] .app-sidebar-area-btn { justify-content: center; padding: 7px 0; gap: 0; }
    body[data-layout="sidebar"] .app-sidebar-area-btn-label,
    body[data-layout="sidebar"] .app-sidebar-area-chevron { display: none; }
    body[data-layout="sidebar"] .app-sidebar-area-btn-initial { display: inline; }
    body[data-layout="sidebar"] .app-sidebar-area-menu {
        left: calc(100% + 8px);
        right: auto;
        top: 0;
        min-width: 180px;
    }
}

/* Embed-Layout (app/views/layouts/fragment.php, Aufruf mit ?embed=1): Wrapper
   fuer eine Settings-Ansicht ohne App-Sidebar. Rest des frueheren Settings-
   Modals — dessen Styles sind entfernt, diese beiden Klassen sind in Gebrauch. */
.settings-fragment {
    display: flex;
    flex: 1;
    min-height: 0;
}
.settings-flash {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 10;
    pointer-events: none;
}
.settings-flash .flash { pointer-events: auto; }


/* Avatar-Farbauswahl: Runde Dots mit Hover/Active/Selected-State. */
.avatar-color-dot {
    cursor: pointer;
    display: inline-block;
}
.avatar-color-dot input { display: none; }
.avatar-color-dot span {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    box-sizing: content-box;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.avatar-color-dot:hover span {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}
.avatar-color-dot--selected span,
.avatar-color-dot input:checked + span {
    border-color: var(--color-text);
    transform: scale(1.1);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* Passwort-Block eingeklappt (details/summary) */
details.section-card > summary::-webkit-details-marker { display: none; }
details.section-card > summary { user-select: none; }
details.section-card[open] > summary svg {
    transform: rotate(180deg);
}

/* === Seitenkopf (partials/page-header.php) ===
 * EIN Kopf fuer jede Vollseite:
 *   <div class="page-header">
 *     <div class="page-heading"><h1 class="page-title">…</h1><p class="page-lead">…</p></div>
 *     <div class="page-actions">Buttons</div>
 *   </div>
 * Detailseite: <a class="back-link"> darueber, .page-header--detail mit
 * optionalem .page-avatar (Logo/Initialen) links. */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;   /* Bestands-Markup ohne .page-heading/.page-actions */
    gap: 0.75rem 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.page-heading { flex: 1 1 16rem; min-width: 0; }
.page-header h1,
.page-title { margin: 0; font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
/* Titelzeile mit Zusatz (Status-Badge, Kennzeichen) */
.page-title-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.page-lead,
.page-subline { color: var(--color-text-muted); font-size: 0.85rem; margin: 0.15rem 0 0; }
.page-lead a { color: inherit; font-weight: 500; }
.page-lead a:hover { color: var(--color-primary-text, var(--color-primary)); }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; margin-left: auto; }
.page-actions form { margin: 0; }

.page-header--detail { align-items: flex-start; }
.page-header--detail .page-actions { align-self: center; }
.page-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex: none;
    overflow: hidden;
    border-radius: 12px;
    background: var(--color-primary-light);
    color: var(--color-primary-text, var(--color-primary));
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}
.page-avatar img { width: 100%; height: 100%; object-fit: contain; }
.page-avatar--logo { background: var(--color-surface); border: 1px solid var(--color-border); padding: 4px; }
.page-avatar--round { border-radius: 50%; }
.page-avatar--round img { object-fit: cover; }

/* === Seiten-Layout mit rechter Spalte (seit 0.74.0, docs/frontend.md → „Seiten-Layout mit Aside") ===
 *   <div class="page-layout page-layout--aside [page-layout--aside-first] [page-layout--aside-sticky]">
 *     <div class="page-main"> … Hauptinhalt … </div>
 *     <aside class="page-aside" aria-label="…"> partials/page-aside-section … </aside>
 *   </div>
 * Breit (> 1200px): zwei Spalten, Aside --page-aside-width (Default 340px), scrollt normal mit der Seite.
 * Schmal: eine Spalte, Aside unter dem Hauptinhalt; --aside-first stellt sie dort VOR den Hauptinhalt.
 * --aside-sticky (opt-in, nur breit): Aside klebt oben und scrollt bei Ueberlaenge in sich.
 * Keine Linie links/rechts als Trenner — Abstand kommt aus gap. */
.page-layout { display: block; }
.page-layout--aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--page-aside-width, 340px);
    gap: var(--page-layout-gap, 1.5rem);
    align-items: start;
}
.page-main, .page-aside { min-width: 0; }
.page-aside {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.page-layout--aside-sticky .page-aside {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    /* Luft fuer Karten-Schatten, die overflow sonst abschneidet */
    padding: 2px 4px 6px;
    margin: -2px -4px 0;
}
.page-aside > * { margin-bottom: 0; }
/* Kompakte Bausteine in der schmalen Spalte: Kennzahlen und Raster enger, gleiche Komponenten */
.page-aside .grid { gap: 0.6rem; }
.page-aside .stat { padding: 0.65rem 0.75rem; gap: 0.15rem; }
.page-aside .stat-label { font-size: 0.68rem; letter-spacing: 0.02em; }
.page-aside .stat-value { font-size: 1.25rem; }
.page-aside .stat-meta { font-size: 0.72rem; }
.page-aside .stat-icon { top: 0.55rem; right: 0.6rem; width: 1.6rem; height: 1.6rem; }
/* Abschnitt der Aside (partials/page-aside-section): Titel ueber der Karte wie ueberall */
.page-aside-section { min-width: 0; }
.page-aside-section > .card { margin-bottom: 0; }
@media (max-width: 1200px) {
    .page-layout--aside { grid-template-columns: minmax(0, 1fr); }
    .page-layout--aside-first .page-aside { order: -1; }
    .page-layout--aside-sticky .page-aside { position: static; max-height: none; overflow: visible; padding: 0; margin: 0; }
}

/* Zurueck-Link ueber dem Kopf einer Detailseite */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}
.back-link:hover { color: var(--color-text); }
.back-link svg { flex: none; }

/* Core-Version rechts oben im Einstellungs-Header — dezente Marke, kein Blickfang:
   sie soll auffindbar sein (Support/Update-Frage), nicht um Aufmerksamkeit buhlen. */
/* Versions-Badges im Einstellungs-Kopf: Core + Module mit eigenem CHANGELOG,
   je mit Bezeichnung, oben rechts nebeneinander (umbricht bei Enge). */
.version-badges {
    flex: 0 0 auto;
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}
.version-badge {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-text-muted) 12%, transparent);
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.version-badge-label {
    text-transform: uppercase;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0.7;
}

/* === Split-Layout (z.B. Einstellungen: Form links, Vorschau rechts) === */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
/* CI-Panel: breiter Formularbereich links (fliesst intern zweispaltig, siehe
   .ci-form-grid in components.css), schmale Vorschau-/Theme-Spalte rechts. */
.split--ci { grid-template-columns: minmax(0, 1fr) 280px; }
.split > div > .card + .card { margin-top: 1rem; }
/* Rechte CI-Spalte scrollt mit, bleibt aber am oberen Rand haengen. */
.split--ci .ci-side { position: sticky; top: 1rem; }
.split--ci .ci-side .card + .card { margin-top: 1rem; }

/* Schmal: Seitenspalte unter den Hauptinhalt (seit 0.76.0 — vorher lief .split auf dem Telefon
   ueber die Viewport-Breite, 340px-Spalte neben dem Inhalt) */
@media (max-width: 900px) {
    .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
    .split--ci { grid-template-columns: 1fr; }
    .split--ci .ci-side { position: static; }
}

/* Konto-Menue (Benutzer-Popover) — der eine Weg zu Einstellungen + Abmelden.
   Trigger: .app-sidebar-user (Benutzer-Chip unten in der Sidebar). Popover
   oeffnet nach oben (--up). */
.app-usermenu { position: relative; }
.app-usermenu > [data-usermenu-toggle] { cursor: pointer; background: none; border: 0; font: inherit; }
.app-usermenu-caret { margin-left: auto; color: var(--color-text-muted); flex-shrink: 0; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-usermenu-caret { display: none; }

.app-usermenu-popover {
    position: absolute;
    min-width: 232px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.16));
    padding: 6px;
    z-index: 400;
}
.app-usermenu--up .app-usermenu-popover { bottom: calc(100% + 8px); left: 0; }
.app-usermenu--down .app-usermenu-popover { top: calc(100% + 8px); right: 0; }

.app-usermenu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.app-usermenu-head-meta { display: flex; flex-direction: column; min-width: 0; }
.app-usermenu-head-name { font-weight: 700; color: var(--color-text); }
.app-usermenu-head-email {
    font-size: 0.8rem; color: var(--color-text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-usermenu-sep { height: 1px; background: var(--color-border); margin: 4px 6px; }
.app-usermenu-logout { margin: 0; }
.app-usermenu-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border-radius: calc(var(--radius) - 2px);
    color: var(--color-text); text-decoration: none;
    background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.app-usermenu-item:hover { background: var(--color-bg, #f5f4f7); }
.app-usermenu-ico { color: var(--color-text-muted); flex-shrink: 0; }

/* ============================================================
 * Werkzeug-Leiste unten in der Sidebar (docs/frontend.md "Werkzeug-Leiste",
 * JS: public/assets/js/sidebar-tools.js): Icons nebeneinander ueber dem
 * Benutzer-Chip, Text nur als Tooltip (data-tip). Projekte haengen eigene
 * Buttons mit class="app-sidebar-tool" an #sidebar-tools an.
 * ============================================================ */
.app-sidebar-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    margin: 6px 0 4px;
    padding: 0 2px;
    flex-shrink: 0;
}
.app-sidebar-tools > * { position: relative; }
.app-sidebar-tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: none;
    border-radius: calc(var(--radius) - 3px);
    color: var(--sidebar-ink, var(--color-text-muted));
    cursor: pointer;
    font: inherit;
}
.app-sidebar-tool-icon { display: inline-flex; }
.app-sidebar-tool:hover,
.app-sidebar-tool[aria-expanded="true"] {
    background: color-mix(in srgb, var(--sidebar-ink, var(--color-text-muted)) 10%, transparent);
    color: var(--sidebar-ink-strong, var(--color-text));
}
.app-sidebar-tool:focus-visible { outline: 2px solid color-mix(in srgb, var(--color-primary) 55%, transparent); outline-offset: 1px; }
/* Tooltip: erscheint erst beim Hovern/Fokus, ueber dem Icon, linksbuendig (kein Abschneiden am Rand). */
.app-sidebar-tool[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-md, 0 4px 14px rgba(0, 0, 0, 0.18));
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 420;
}
.app-sidebar-tool[data-tip]:hover::after,
.app-sidebar-tool[data-tip]:focus-visible::after { opacity: 1; transform: translateY(0); }
.app-sidebar-tool[aria-expanded="true"]::after,
.app-sidebar-tools:has([aria-expanded="true"]) .app-sidebar-tool::after { display: none; }

/* Simulationsmodus (partials/simulation-tool, docs/simulation.md): Warnfarbe + Marke „SIM" am Icon. */
.app-sidebar-tool--simulation {
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 16%, transparent);
    text-decoration: none;
}
.app-sidebar-tool--simulation:hover {
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 26%, transparent);
}
.app-sidebar-tool-flag {
    position: absolute;
    top: 1px;
    right: -3px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--color-warning);
    color: var(--color-on-warning, #1a1a1a);
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 12px;
    pointer-events: none;
}

/* Offline-Warteschlange (partials/offline-tool, docs/pwa.md): Zaehler am Icon,
   offline in Warnfarbe, Fehler in Fehlerfarbe. Sichtbarkeit steuert offline-queue.js. */
.app-sidebar-tool-count {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}
/* Modul-Werkzeuge (manifest.sidebar_tools, partials/sidebar-module-tools): Link ohne Unterstrich,
   Text-Badge neutral und schmal am Icon. */
.app-sidebar-tool--module { text-decoration: none; }
.app-sidebar-tool--module:hover { text-decoration: none; }
.app-sidebar-tool-count--text {
    right: -4px;
    padding: 0 3px;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    font-size: 0.55rem;
    line-height: 13px;
    white-space: nowrap;
}
.app-sidebar-tool--offline.is-offline {
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 16%, transparent);
}
.app-sidebar-tool--offline.has-errors .app-sidebar-tool-count { background: var(--color-error); }

/* Suche: Feld + Live-Treffer in einem Panel ueber der Leiste. */
.app-sidebar-search { margin: 0; }
.app-sidebar-search-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 300px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.16));
    padding: 6px;
    z-index: 400;
}
.app-sidebar-search-panel form { position: relative; margin: 0; }
.app-sidebar-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: var(--color-text-muted);
    opacity: 0.7;
    pointer-events: none;
}
.app-sidebar-search-input {
    width: 100%;
    padding: 8px 10px 8px 30px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 3px);
    font: inherit;
    font-size: 13px;
    color: var(--color-text);
}
.app-sidebar-search-input::placeholder { color: var(--color-text-muted); }
.app-sidebar-search-input:focus { outline: none; border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border)); }
.app-sidebar-search-results {
    margin-top: 6px;
    max-height: 55vh;
    overflow-y: auto;
}
.app-sidebar-search-group + .app-sidebar-search-group { margin-top: 4px; border-top: 1px solid var(--color-border); padding-top: 4px; }
.app-sidebar-search-group-label {
    padding: 4px 8px 2px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}
.app-sidebar-search-item,
.app-sidebar-search-more {
    display: block;
    padding: 6px 8px;
    border-radius: calc(var(--radius) - 4px);
    color: var(--color-text);
    text-decoration: none;
    font-size: 13px;
}
.app-sidebar-search-item:hover,
.app-sidebar-search-item.is-active,
.app-sidebar-search-more:hover { background: color-mix(in srgb, var(--color-text-muted) 9%, transparent); }
.app-sidebar-search-item-title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar-search-item-sub { display: block; font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar-search-more { color: var(--color-primary-text, var(--color-primary)); font-weight: 600; font-size: 12.5px; margin-top: 2px; }
.app-sidebar-search-empty { padding: 8px; font-size: 12.5px; }

/* Glocke: Icon mit Zaehler, Popover nach oben. */
.app-sidebar-bell { position: relative; }
.app-sidebar-bell-count {
    position: absolute;
    top: 3px;
    right: 2px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    pointer-events: none;
}
.app-sidebar-bell-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 300px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(0, 0, 0, 0.16));
    padding: 4px;
    z-index: 400;
}
.app-sidebar-bell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 12.5px;
    color: var(--color-text);
}
.app-sidebar-bell-readall {
    border: 0;
    background: none;
    font: inherit;
    font-size: 11.5px;
    color: var(--color-primary-text, var(--color-primary));
    cursor: pointer;
    padding: 2px 4px;
}
.app-sidebar-bell-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.app-sidebar-bell-link {
    display: block;
    padding: 6px 8px;
    border-radius: calc(var(--radius) - 4px);
    color: var(--color-text);
    text-decoration: none;
}
.app-sidebar-bell-link:hover { background: color-mix(in srgb, var(--color-text-muted) 9%, transparent); }
.app-sidebar-bell-title { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-sidebar-bell-item.is-unread .app-sidebar-bell-title { font-weight: 600; }
/* Ungelesen: fette Zeile + Punkt vor dem Titel (keine Linie links) */
.app-sidebar-bell-item.is-unread .app-sidebar-bell-title::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--color-primary); vertical-align: 2px; }
.app-sidebar-bell-meta { display: block; font-size: 11.5px; color: var(--color-text-muted); }
.app-sidebar-bell-empty { padding: 8px; font-size: 12.5px; }
.app-sidebar-bell-all {
    display: block;
    padding: 6px 8px;
    margin-top: 2px;
    border-top: 1px solid var(--color-border);
    color: var(--color-primary-text, var(--color-primary));
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}

/* Eingeklappte Rail: Text-Badges entfallen (kein Signal "offen", nur Information). */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link-badge--text { display: none; }

/* Eingeklappte Icon-Rail: Leiste untereinander, Panels rechts neben der Rail. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-tools { flex-direction: column; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-search-panel,
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-bell-menu { left: calc(100% + 8px); bottom: 0; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-tool[data-tip]::after { bottom: auto; top: 50%; left: calc(100% + 8px); transform: translateY(-50%); }

/* Suche: Ergebnisseite (/suche). */
.search-page-form { display: flex; gap: 8px; max-width: 640px; }
.search-page-input { flex: 1; }
.search-group { padding: 0; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result + .search-result { border-top: 1px solid var(--color-border); }
.search-result-link { display: block; padding: 10px 16px; color: var(--color-text); text-decoration: none; }
a.search-result-link:hover { background: color-mix(in srgb, var(--color-text-muted) 7%, transparent); }
.search-result-title { display: block; font-weight: 600; }
.search-result-sub { display: block; font-size: 0.85rem; color: var(--color-text-muted); }
.search-result-snippet { display: block; font-size: 0.85rem; color: var(--color-text); margin-top: 2px; }
.search-result-snippet mark { background: var(--color-warning-light); color: inherit; border-radius: 2px; padding: 0 1px; }
.icon--search-type { vertical-align: -3px; margin-right: 6px; color: var(--color-text-muted); }

/* Benachrichtigungen: Inbox (/benachrichtigungen) + Einstellungen. */
.notif-card { padding: 0; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.notif-item + .notif-item { border-top: 1px solid var(--color-border); }
.notif-item--unread { background: color-mix(in srgb, var(--color-primary) 5%, transparent); }
.notif-item-link { flex: 1; min-width: 0; color: var(--color-text); text-decoration: none; }
.notif-item-title { display: block; font-weight: 500; }
.notif-item--unread .notif-item-title { font-weight: 700; }
.notif-item-body { display: block; font-size: 0.85rem; color: var(--color-text); margin-top: 2px; white-space: pre-line; }
.notif-item-meta { display: block; font-size: 0.78rem; color: var(--color-text-muted); margin-top: 2px; }
.notif-item-read { margin: 0; flex: 0 0 auto; }
.notif-prefs td, .notif-prefs th { vertical-align: middle; }
.notif-prefs-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; cursor: pointer; }
/* === Alerts === */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert--success { background: var(--color-success-light); color: var(--color-success-text, var(--color-success)); border: 1px solid rgba(52, 211, 153, 0.2); }
.alert--error   { background: var(--color-error-light); color: var(--color-error-text, var(--color-error));     border: 1px solid rgba(248, 113, 113, 0.2); }
.alert--warning { background: var(--color-warning-light); color: var(--color-warning-text, var(--color-warning)); border: 1px solid rgba(251, 191, 36, 0.2); }
/* Neutraler Hinweis (ersetzt modul-eigene Hinweisboxen wie .bug-hint) */
.alert--info    { background: var(--color-info-light); color: var(--color-info-text, var(--color-info));       border: 1px solid rgba(96, 165, 250, 0.25); }
/* Mehrzeiliger Inhalt (Titel + Absatz, Liste): Block statt Flex-Zeile */
.alert--block { display: block; }
.alert--block > :last-child { margin-bottom: 0; }

/* Flash Toast (fixed bottom center) */
.flash-toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
}
.flash-toast {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: flash-in 0.3s ease, flash-out 0.3s ease 3.5s forwards;
    max-width: 500px;
}
.flash-toast--success { background: var(--color-success); color: #fff; }
.flash-toast--error { background: var(--color-error); color: #fff; }
.flash-toast--warning { background: var(--color-warning); color: #000; }
.flash-toast--info { background: var(--color-text); color: var(--color-surface); }
/* Link im Toast (ct.toast(msg, type, {link})) */
.flash-toast-link { margin-left: 0.75rem; color: inherit; font-weight: 600; text-decoration: underline; }
@keyframes flash-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flash-out { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

/* === Cards === */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    transition: none;
}

/* Ruhige Flaechen (CI-Default): kein Hover-Lift, Karten bleiben auf Ruhe-Schatten. */
.card:hover { box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--color-text); }
.card h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; }
/* Schmale Karte fuer Einstellungs-/Formularseiten ausserhalb eines Popups */
.card--narrow { max-width: 720px; }

/* === Section Cards (Bildgenerator-Style) === */
.section-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: visible;
    box-shadow: var(--shadow);
    /* Core-Default-Abstand zwischen gestapelten Karten (z.B. Settings-Panels).
       Zentral hier statt per Inline-margin in jeder View — Projekte ueber-
       schreiben bei Bedarf via eigenem CSS (.section-card { margin-bottom: ... }).
       Vertikale Margins benachbarter Karten kollabieren, doppeln also nicht. */
    margin-bottom: 1rem;
    min-height: 55px; /* IGEPA_SECTION_MINHEIGHT */
}

.section-card-header {
    padding: 1rem 1rem 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
}
.section-card-header h3 { margin: 0; }
.section-card-header p { margin-top: 0.25rem; }

.section-card-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.section-card-body { padding: 1rem; }

/* Karten-Kopf: Titel + optionale Aktionen in einer Zeile */
.card-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.card-head h3 { margin: 0; }

/* === Tab-Leiste (z.B. Einstellungen-Panels) === */
.tabs { display: inline-flex; gap: 2px; background: var(--color-surface-hover); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 3px; margin-bottom: 1rem; }
/* Ein Tab. Der Reset (border/background/appearance/font/cursor) laesst
   <button class="tab"> exakt wie <a class="tab"> aussehen — sonst rendert der
   Button seine native graue Box (Grund fuer "Elemente sieht anders aus als
   Einstellungen"). white-space:nowrap: Labels brechen nie um; passt die Leiste
   nicht mehr in ihren Container, schaltet app.js auf das .tabs-select-Dropdown. */
.tab { display: inline-flex; align-items: center; padding: 0.35rem 0.9rem; border: 0; background: transparent; border-radius: calc(var(--radius) - 3px); font-family: inherit; font-size: 0.85rem; font-weight: 500; line-height: 1.4; white-space: nowrap; color: var(--color-text-muted); text-decoration: none; cursor: pointer; appearance: none; -webkit-appearance: none; }
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab--active { background: var(--color-surface); color: var(--color-text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
/* Eingeklappt (app.js: Overflow erkannt) — die Tab-Leiste weicht dem Dropdown. */
.tabs.is-collapsed { display: none; }
/* Dropdown-Ersatz fuer die horizontale Nav auf schmalen Containern. Gleiche
   Optik wie ein Tab-Feld; native <select>-Pfeil durch eigenes Chevron ersetzt. */
.tabs-select {
    display: block;
    max-width: 100%;
    margin-bottom: 1rem;
    padding: 0.45rem 2.1rem 0.45rem 0.9rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.tabs-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }


/* === Range-Slider mit Endpunkt-Hinweisen (klein ↔ groß) === */
.range-row { display: flex; align-items: center; gap: 0.6rem; }
.range-row input[type="range"] { flex: 1; min-width: 0; }
.range-row .range-hint { font-size: 0.72rem; color: var(--color-text-muted); white-space: nowrap; }

/* === Forms === */
.form-group { margin-bottom: 1.125rem; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-group textarea { min-height: 44px; resize: none; overflow: hidden; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

/* --accent-gradient kommt aus CI (ci-style.php) oder einem Projekt-Theme;
   ohne Wert flacher Primaerfarben-Button. Hover dunkelt per filter ab,
   damit auch ein Verlauf sichtbar reagiert (Background-Tausch wuerde ihn ersetzen). */
.btn--primary { background: var(--accent-gradient, var(--color-primary)); color: var(--btn-text, var(--color-on-primary, #fff)); }
/* Hover bewusst dezent (CI-Default): der Verlauf bleibt sichtbar, nur leicht abgedunkelt. */
.btn--primary:hover { filter: brightness(0.96); color: var(--btn-text, var(--color-on-primary, #fff)); box-shadow: var(--shadow); }

.btn--outline { background: var(--color-surface); color: var(--color-text-muted); border-color: var(--color-border); }
.btn--outline:hover { border-color: var(--color-primary); color: var(--color-primary-text, var(--color-primary)); }

/* Sekundaer-Aktion neben einer Primaer-Aktion ("Bereich anlegen" neben "Funktion anlegen"):
   getoente Flaeche in der Akzentfarbe, ohne das Gewicht von --primary. */
.btn--secondary { background: var(--color-primary-light); color: var(--color-primary-text, var(--color-primary)); border-color: transparent; }
.btn--secondary:hover { border-color: var(--color-primary); color: var(--color-primary-text, var(--color-primary)); }

/* Loeschen/Gefahr. EINE Optik je Ort (docs/frontend.md → Komponenten):
   - Formular/Popup: btn btn--outline btn--danger mit Text „Löschen"
   - Tabellenzeile:  btn btn--icon btn--ghost btn--danger mit Mülleimer-Icon + data-confirm
   - solide (btn btn--danger) nur fuer den finalen Bestaetigungs-Button */
.btn--danger { background: var(--color-error); color: #fff; }
.btn--danger:hover { filter: brightness(0.92); color: #fff; }

.btn--success { background: var(--color-success); color: #fff; }
.btn--success:hover { filter: brightness(0.92); color: #fff; }

/* Ghost: ohne Flaeche und Rahmen — Neben-Aktionen, Icon-Buttons in Zeilen/Kopfzeilen. */
.btn--ghost { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn--ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* Kombinationen mit --danger: Farbe wird rot, Flaeche bleibt die der Grundvariante. */
.btn--outline.btn--danger { background: var(--color-surface); color: var(--color-error); border-color: var(--color-border); filter: none; }
.btn--outline.btn--danger:hover { background: var(--color-error-light); color: var(--color-error); border-color: var(--color-error); }
.btn--ghost.btn--danger { background: transparent; color: var(--color-text-muted); border-color: transparent; filter: none; }
.btn--ghost.btn--danger:hover { background: var(--color-error-light); color: var(--color-error); }

.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn--full { width: 100%; }

/* Quadratischer Icon-Button (ersetzt .btn-icon, .icon-action, .kb-col-add).
   Immer mit Farbvariante (meist --ghost) und aria-label/title. Hoehe = .btn bzw. .btn--sm. */
.btn--icon { width: 2.75rem; height: 2.75rem; padding: 0; gap: 0; flex: none; }
.btn--icon.btn--sm { width: 2.15rem; height: 2.15rem; padding: 0; }
.btn--icon svg { width: 1rem; height: 1rem; flex: none; }
.btn--icon.btn--sm svg { width: 0.9rem; height: 0.9rem; }

.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; filter: none; box-shadow: none; }
/* Formular um einen einzelnen Button (Loeschen in Tabellenzeile) bricht keine Zeile um. */
form.btn-form { display: inline; margin: 0; }

/* === Login === */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: var(--login-gradient, linear-gradient(135deg, #09090b 0%, #0f0a1f 50%, #09090b 100%));
}

/* Fehlerseite (errors/error.php) */
.error-box { text-align: center; }
.error-box-code { margin-bottom: 0.5rem; font-size: 4rem; font-weight: 700; line-height: 1; color: var(--color-accent, var(--color-primary)); }
.error-box-title { margin-bottom: 0.75rem; font-size: 1.25rem; font-weight: 600; }
.error-box-text { margin-bottom: 1.5rem; font-size: 0.9rem; }
.error-box-actions { justify-content: center; }

/* .login-branding* und .login-legal stehen weiter unten ("Login/Auth"). */
.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* === Status & Kennzeichen: .badge (EIN Baustein) ===
 * Farbe ueber Modifier .badge--<farbe>; die Werte sind Tokens aus themes.css
 * (--badge-<farbe>-bg/-fg, mit Dark-Mode-Satz). Jeder Modifier setzt zusaetzlich
 * --tone-bg/--tone-fg, damit .status-select/.tag dieselbe Farbe ueber Variablen
 * ziehen koennen (auch dort, wo spezifischere Formular-Regeln `background` setzen).
 * Punkt vor dem Text: <span class="badge badge--green"><span class="dot"></span>Aktiv</span>.
 * .pill ist ein Alias (Bestand der Produkt-Module: class="pill badge--green"). */
.badge,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    background-color: var(--tone-bg, var(--badge-muted-bg));
    color: var(--tone-fg, var(--badge-muted-fg));
}
.pill { padding: 0.15rem 0.55rem; }
.badge .dot,
.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

/* Semantische Farben */
.badge--success { --tone-bg: var(--color-success-light); --tone-fg: var(--color-success-text, var(--color-success)); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--warning { --tone-bg: var(--color-warning-light); --tone-fg: var(--color-warning-text, var(--color-warning)); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--error   { --tone-bg: var(--color-error-light);   --tone-fg: var(--color-error-text, var(--color-error));   background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--info    { --tone-bg: var(--color-info-light);    --tone-fg: var(--color-info-text, var(--color-info));    background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--primary { --tone-bg: var(--color-primary-light); --tone-fg: var(--color-primary-text, var(--color-primary)); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--simulation { gap: 0.25rem; }
.badge--simulation .icon { flex-shrink: 0; }
.badge--muted   { --tone-bg: var(--badge-muted-bg);      --tone-fg: var(--badge-muted-fg); background-color: var(--tone-bg); color: var(--tone-fg); }

/* Auswahl-Farben (Lead-Phase, Status-Optionen, ListView 'color') */
.badge--gray   { --tone-bg: var(--badge-gray-bg);   --tone-fg: var(--badge-gray-fg);   background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--blue   { --tone-bg: var(--badge-blue-bg);   --tone-fg: var(--badge-blue-fg);   background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--purple { --tone-bg: var(--badge-purple-bg); --tone-fg: var(--badge-purple-fg); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--teal   { --tone-bg: var(--badge-teal-bg);   --tone-fg: var(--badge-teal-fg);   background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--green  { --tone-bg: var(--badge-green-bg);  --tone-fg: var(--badge-green-fg);  background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--yellow { --tone-bg: var(--badge-yellow-bg); --tone-fg: var(--badge-yellow-fg); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--orange { --tone-bg: var(--badge-orange-bg); --tone-fg: var(--badge-orange-fg); background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--red    { --tone-bg: var(--badge-red-bg);    --tone-fg: var(--badge-red-fg);    background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--pink   { --tone-bg: var(--badge-pink-bg);   --tone-fg: var(--badge-pink-fg);   background-color: var(--tone-bg); color: var(--tone-fg); }
.badge--brown  { --tone-bg: var(--badge-brown-bg);  --tone-fg: var(--badge-brown-fg);  background-color: var(--tone-bg); color: var(--tone-fg); }

/* === Filter-Segmente: .chips > .chip(.chip--active) — einziges Muster ===
 * <nav class="chips" aria-label="Status"><a class="chip chip--active" href="?s=offen" aria-current="true">Offen <span class="count">4</span></a> …</nav>
 * Als <a> (Server-Filter) oder <button type="button"> (JS). Reiter, die
 * Ansichten wechseln, bleiben .tabs/.tab. */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.85rem; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.chip:hover { color: var(--color-text); text-decoration: none; }
.chip--active,
.chip--active:hover { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary-text, var(--color-primary)); font-weight: 600; }

/* Zaehler-Pille (ersetzt .tab-count, .tab-badge, .kb-count, .chip-count, .wv-count …) —
   in .chip, .tab, .kb-col-head, .section-title oder frei. */
.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.15rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-text-muted) 14%, transparent);
    color: var(--color-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.tab .count { margin-left: 0.4rem; }
.chip--active .count,
.tab--active .count { background: var(--color-primary); color: var(--color-on-primary, var(--color-surface)); }
/* Handlungsbedarf (faellig, ueberfaellig) */
.count--warning { background: var(--color-warning); color: var(--color-on-warning); }
.count--error { background: var(--color-error); color: var(--color-surface); }

/* === Tag: Kategorie/Typ-Label (umrandet). Farbe optional ueber .badge--<farbe> ===
 * <span class="tag">Funktion</span>  <span class="tag badge--red">Bug</span>  <span class="tag tag--primary">Neu</span> */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.5rem;
    border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
    border-radius: 999px;
    background-color: var(--tone-bg, var(--color-surface-hover));
    color: var(--tone-fg, var(--color-text-muted));
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.tag--primary { --tone-bg: var(--color-primary-light); --tone-fg: var(--color-primary-text, var(--color-primary)); }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* === Kennzeichen: .code (F-001, BUG-003, AUF-12) — ersetzt .kb-nr, .entw-code, .zt-code === */
.code {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
}
a.code:hover { color: var(--color-primary-text, var(--color-primary)); border-color: var(--color-primary); }
.code--lg { padding: 0.2rem 0.6rem; font-size: 0.9rem; }

/* === Status-Auswahl: farbige Auswahlliste auf Basis der .badge--*-Farben ===
 * <select class="status-select badge--blue" name="status">
 *   <option value="neu" data-color="blue" selected>Neu</option><option value="fertig" data-color="green">Fertig</option>
 * </select>   — app.js tauscht die badge--*-Klasse beim Wechsel (data-color der Option). */
.status-select,
.form-group select.status-select {
    width: auto;
    padding: 0.2rem 1.6rem 0.2rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 999px;
    background-color: var(--tone-bg, var(--badge-muted-bg));
    color: var(--tone-fg, var(--badge-muted-fg));
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.status-select:focus,
.form-group select.status-select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; box-shadow: none; border-color: transparent; }
.status-select option { background: var(--color-surface); color: var(--color-text); }

/* Inline-Edit in Tabellen-Zellen */
.db-cell--editable { cursor: pointer; position: relative; }
.db-cell--editable:hover { background: var(--color-surface-hover); }
.db-cell--editable:hover::after {
    content: "▾";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--color-text-muted);
    pointer-events: none;
}

/* === Tables === */
table { width: 100%; border-collapse: collapse; }
/* Tabellenkopf als Uppercase-Label (CI-Default), luftigere Zellen. */
th { text-align: left; padding: 0.625rem 1rem; font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); white-space: nowrap; }
td { padding: 0.7rem 1rem; height: 44px; vertical-align: middle; font-size: 0.85rem; border-bottom: 1px solid var(--color-border-light); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.col-center, td.col-center { text-align: center; }
/* Hover nur, wo die Zeile etwas tut (Klick oeffnet Detail) — nicht auf jeder Tabelle. */
tr.clickable-row, tr[data-href] { cursor: pointer; }
tr.clickable-row:hover td, tr[data-href]:hover td { background: var(--color-surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
tr.is-selected td { background: var(--color-primary-light); }

/* Tabellen-Rahmen: Karte ohne Innenabstand, Tabelle sitzt buendig.
   <div class="card card--table"><div class="list-table-wrap"><table>…</table></div></div> */
.card--table { padding: 0; overflow: hidden; }
.card--table .list-table-wrap { overflow-x: auto; }
.card--table > .card-head { padding: 0.75rem 1rem; margin: 0; border-bottom: 1px solid var(--color-border); }

/* Leerer Zustand — EIN Baustein fuer Tabellen, Karten, Listen (partials/empty.php):
   <div class="empty"><svg class="empty-icon">…</svg><p class="empty-text">…</p><div class="empty-action">…</div></div> */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.empty-icon { color: var(--color-text-light); width: 28px; height: 28px; }
.empty-title { margin: 0; font-weight: 600; color: var(--color-text); font-size: 0.9rem; }
.empty-text { margin: 0; max-width: 32rem; }
.empty-action { margin-top: 0.35rem; }
/* Kompakt: in Zeitleisten, Seitenspalten, kleinen Karten */
.empty--compact { padding: 0.75rem 0.5rem; gap: 0.25rem; font-size: 0.8rem; }
/* In einer Tabellenzeile: Zelle ohne eigenes Padding/Hoehe, .empty traegt den Abstand */
td.empty-cell { padding: 0; height: auto; }

/* === Tabellen: Leerzeile, Spaltenbreiten, Rahmen (seit 0.76.0) ===================
 * Eigener Block — Regeln fuer stabile Tabellen. Doku: docs/frontend.md → „Tabellen".
 * Leerzeile: partials/table-empty (td.empty-cell > .empty). Steht nur Text in der Zelle
 * (Altbestand), traegt die Zelle selbst Abstand, gedaempfte Farbe und Zentrierung. */
td.empty-cell:not(:has(> .empty)) {
    padding: 2rem 1rem;
    text-align: center;
    white-space: normal;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
/* Feste Spaltenbreiten: table.table--fixed (+ <colgroup>) — partials/list setzt beides, sobald
   eine Spalte width/kind traegt. --table-min: darunter scrollt .list-table-wrap horizontal. */
table.table--fixed { table-layout: fixed; min-width: var(--table-min, 36rem); }
/* Kopf darf in festen Tabellen umbrechen (Wortgrenzen) statt abgeschnitten zu werden */
.table--fixed th { white-space: normal; vertical-align: bottom; }
.table--fixed td { overflow-wrap: anywhere; }
.table--fixed td :is(select, input:not([type="checkbox"], [type="radio"]), textarea) { max-width: 100%; }
/* Spaltenarten (ListView::COLUMN_KINDS, gleiche Breiten) — an <col> oder <th>, Ausrichtung an th/td */
:is(col, th).col-id       { width: 5rem; }
:is(col, th).col-date     { width: 7.5rem; }
:is(col, th).col-datetime { width: 10rem; }
:is(col, th).col-time     { width: 5rem; }
:is(col, th).col-money    { width: 9rem; }
:is(col, th).col-number   { width: 6rem; }
:is(col, th).col-percent  { width: 5.5rem; }
:is(col, th).col-status   { width: 9rem; }
:is(col, th).col-badge    { width: 8rem; }
:is(col, th).col-user     { width: 11rem; }
:is(col, th).col-check    { width: 4rem; }
:is(col, th).col-icon     { width: 3rem; }
:is(col, th).col-actions  { width: 7rem; }
/* Ohne feste Tabelle schrumpft die Aktionsspalte auf ihren Inhalt */
table:not(.table--fixed) th.col-actions { width: 1%; }
/* Explizite Breite (width => '12rem' → --col-w) gewinnt ueber die Art */
:is(col, th).col-w { width: var(--col-w); }
:is(th, td):is(.col-id, .col-date, .col-datetime, .col-time, .col-money, .col-number, .col-percent) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table--fixed td:is(.col-id, .col-date, .col-datetime, .col-time, .col-money, .col-number, .col-percent) { overflow: hidden; text-overflow: ellipsis; }
:is(th, td):is(.col-money, .col-number, .col-percent) { text-align: right; }
:is(th, td):is(.col-check, .col-icon) { text-align: center; }
/* 'align' => 'left' gegen die Ausrichtung der Art (z. B. Betrag mit Fortschrittsbalken) */
:is(th, td).col-left { text-align: left; }
:is(th, td).col-actions { text-align: right; white-space: nowrap; }
td.col-actions .actions { justify-content: flex-end; flex-wrap: nowrap; }
td.col-actions .actions > .btn { white-space: nowrap; }
/* Titelspalte: flexibel, Haupttext hoechstens zwei Zeilen */
td.col-title .cell-main {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
    overflow-wrap: anywhere;
}
/* Handgebaute Tabelle ohne Karte: table.table traegt selbst Flaeche, Rahmen und Radius —
   in .card--table/.card bleibt sie buendig (die Karte ist der Rahmen). */
table.table {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-surface);
}
:is(.card, .list-table-wrap, .modal-body) table.table { border: 0; border-radius: 0; background: transparent; }
/* === Ende Tabellen-Block 0.76.0 === */

/* === Datenlisten (partials/list.php + assets/js/list/) === */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.list-toolbar .list-count { font-size: 0.8rem; color: var(--color-text-muted); }
.list-toolbar-spacer { flex: 1; }
/* Live-Suchfeld (partials/list.php 'search' + list-page.js) */
.list-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 3px);
    padding: 0.4rem 0.65rem;
    width: 260px;
    color: var(--color-text-muted);
}
.list-search svg { flex: none; }
.list-search input {
    border: 0;
    background: transparent;
    padding: 0;
    outline: none;
    color: var(--color-text);
    font-size: 0.85rem;
    width: 100%;
}
.list-search input:focus { box-shadow: none; }
.list-search:focus-within { border-color: var(--color-border); }
.list-table-wrap { overflow-x: auto; }
/* Serverseitige Suche (GET): dasselbe Feld in einem Formular, Enter sendet */
.list-search-form { display: contents; }
.list-search input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* Filter-Panel (Markup-Vertrag: assets/js/list/filters.js) */
#filter-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#filter-rows { display: flex; flex-direction: column; gap: 0.4rem; }
#filter-rows .filter-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
#filter-rows .filter-row select,
#filter-rows .filter-row input { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
#filter-panel .filter-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Nutzer-Einstellungen der Liste (partials/list-tools.php, core/ListView.php) */
th.col-w { width: var(--col-w); }
.th-sort { display: inline-flex; align-items: center; gap: 0.3rem; color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--color-text); text-decoration: none; }
.th-sort-icon { font-size: 0.8rem; letter-spacing: 0; opacity: 0.45; }
th[aria-sort] .th-sort { color: var(--color-text); }
th[aria-sort] .th-sort-icon { opacity: 1; color: var(--color-primary-text, var(--color-primary)); }
.list-views .chip .icon { flex: none; }
.list-views .chip-star { color: var(--color-warning); fill: currentColor; }
.list-columns > li { padding: 0.3rem 0; }
.list-columns > li:first-child { padding-top: 0; }
.list-columns .form-check { flex: 1; margin: 0; }
.list-columns-move { gap: 0.15rem; flex-wrap: nowrap; }
.list-columns > li:first-child [data-move="up"],
.list-columns > li:last-child [data-move="down"] { visibility: hidden; }

/* Pagination unter der Liste */
.list-pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.list-pagination a,
.list-pagination span.page-current,
.list-pagination span.page-gap {
    min-width: 30px;
    padding: 0.3rem 0.55rem;
    text-align: center;
    font-size: 0.8rem;
    border-radius: var(--radius-sm, 6px);
    text-decoration: none;
    color: var(--color-text-muted);
}
.list-pagination a:hover { background: var(--color-surface-hover); color: var(--color-text); }
.list-pagination span.page-current {
    background: var(--color-primary);
    color: var(--color-on-primary, #fff);
    font-weight: 600;
}

/* === Charts (core/Chart.php — Inline-SVG) === */
.chart { display: block; width: 100%; height: auto; }
.chart--donut { max-width: 200px; margin: 0 auto; }
.chart--empty {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

/* === Login/Auth === */
/* Branding-Block ueber der .login-box (vormals public.css, eine Definition).
   Genutzt von app/views/auth/ (login, 2fa-challenge, reset-/forgot-password, _branding). */
.login-branding { text-align: center; margin-bottom: 1.5rem; }
.login-branding-logo { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.03em; margin-bottom: 0.25rem; color: var(--color-text); }
.login-branding-logo span { color: var(--color-primary-text, var(--color-primary)); }
/* font-weight/line-height/letter-spacing/margin-top stammen aus der frueheren
   (doppelten) Erst-Definition und wirkten weiter — hier zusammengefuehrt. */
.login-branding-tagline { font-size: 0.85rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.04em; margin-top: 0.75rem; color: var(--color-text-muted); }
/* Login-Logo: Standardgroesse (beide Themes). Die Anzeige-Breite ist per CI
   (ci_login_logo_width) uebersteuerbar — dann setzt das Partial inline max-width. */
.login-branding-logo-img { max-width: 200px; max-height: 90px; height: auto; width: auto; display: block; margin: 0 auto; }
/* Frei editierbarer Login-Text (CI ci_login_text) unter dem Logo — bewusst
   praesent: fett und groesser, als Begruessung/Wortmarke unter dem Logo. */
.login-branding-text { margin: 0.85rem auto 0; max-width: 360px; font-size: 1.6rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--color-text); }
.login-legal { text-align: center; margin-top: 1.25rem; font-size: 0.7rem; color: var(--color-text-muted); line-height: 1.5; max-width: 320px; margin-left: auto; margin-right: auto; }

/* === Modal / Popup (generisch) — Steuerung: assets/js/app.js ===
 * Der kanonische Popup-Baustein. EIN korrektes Verhalten fuer alle Projekte:
 *   - zentriert (Flex align/justify center)
 *   - Hintergrund abgedunkelt + geblurrt
 *   - Hintergrund NICHT scrollbar (body.modal-open sperrt overflow)
 *   - schliesst per X / [data-modal-close] / Backdrop-Klick / ESC
 * Nie wieder pro Projekt neu bauen. Markup-Vertrag siehe app.js. */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow-y: auto;              /* sehr hohe Dialoge scrollen im Overlay ... */
    overscroll-behavior: contain;
}

body.modal-open { overflow: hidden; }   /* ... die Seite dahinter bleibt fix */

/* Bestaetigungs-Dialog (customConfirm() in app.js, u.a. alle .confirm-delete-Forms):
   zentriertes Overlay wie .modal. OHNE diese Regel ist .confirm-dialog
   position:static und haengt unsichtbar am Seitenende — dann scheint "Loeschen"
   wirkungslos. z-index ueber .modal, damit ein Confirm auch im Modal sichtbar ist. */
.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.confirm-dialog-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 400px;
    padding: 1.5rem;
}
.confirm-dialog-box p { margin: 0 0 1.25rem; color: var(--color-text); }
.confirm-btns { display: flex; justify-content: flex-end; gap: 0.5rem; }

.modal-dialog {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 3rem);
    margin: auto;                 /* zentriert auch, wenn hoeher als das Overlay */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* Groessen-Skala: sm 360 · md 480 (Standard, ohne Modifier) · lg 760 · xl 1200 px.
   data-modal-size="sm|md|lg|xl" (app.js) setzt dieselben Klassen. */
.modal-dialog--sm { max-width: 360px; }
.modal-dialog--md { max-width: 480px; }
.modal-dialog--lg { max-width: 760px; }
.modal-dialog--xl { max-width: 1200px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.modal-header h2, .modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
/* Optionale Unterzeile: <div class="modal-titles"><h3>…</h3><p class="modal-subtitle">…</p></div> */
.modal-titles { min-width: 0; }
.modal-subtitle { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--color-text-muted); }
.modal-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--color-bg); color: var(--color-text); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-body > :last-child { margin-bottom: 0; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

/* --- Formulare im Popup (data-modal-url, Controller::viewFragment) ---
   docs/frontend.md → „Formulare im Popup". Ein Modul-Formular braucht damit
   KEIN eigenes CSS: <form> umschliesst .modal-body (Felder in .form-grid) und
   .modal-footer (Aktionen rechtsbuendig). */
/* EINZIG erlaubtes Formular-Muster im Popup:
     <div class="modal-dialog"><div class="modal-header">…</div>
       <form><div class="modal-body">…</div><div class="modal-footer">…</div></form></div>
   Das Formular ist Flex-Spalte: Kopf und Fuss bleiben stehen, nur der Body
   scrollt. Kein .modal-footer IN .modal-body (scrollte mit, doppelt eingerueckt). */
.modal-dialog > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; margin: 0; }
.modal-dialog > form > .modal-body,
.modal-dialog > .modal-body { flex: 1 1 auto; min-height: 0; }
/* Linke Fuss-Aktion (z. B. Loeschen) von den rechtsbuendigen absetzen. */
.modal-footer .modal-footer-start { margin-right: auto; }

/* Lade- und Fehlerzustand des nachgeladenen Popups (app.js, data-modal-url) */
.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 7rem;
    color: var(--color-text-muted);
}
.modal-loading--error { flex-direction: column; text-align: center; }
.modal-loading .ct-busy-spinner { color: var(--color-primary-text, var(--color-primary)); }

/* Meldung im Popup: Server-Fehler, $formError aus modalError() */
.modal-alert {
    margin: 0 0 1rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
    background: var(--color-error-light);
    color: var(--color-error);
    font-size: 0.85rem;
}
.modal-loading .modal-alert { margin: 0; }

/* Formular-Raster: zwei Spalten, .span-2 ueber beide; --3 fuer drei Spalten.
   Vertikalen Abstand liefert .form-group (margin-bottom). Schmal: eine Spalte. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.form-grid--1 { grid-template-columns: minmax(0, 1fr); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid > .span-2 { grid-column: span 2; }
.form-grid > .span-3 { grid-column: span 3; }
.form-grid > .span-full { grid-column: 1 / -1; }
@media (max-width: 640px) {
    .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid > .span-2, .form-grid > .span-3 { grid-column: 1 / -1; }
}
.form-group input[type="checkbox"], .form-group input[type="radio"] { width: auto; }
.form-check,
.form-group label.form-check { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.35rem; font-size: 0.875rem; font-weight: 400; color: var(--color-text); }
.form-check input { width: auto; margin: 0; }
.form-check--all { font-weight: 600; }
/* Feld mit Aktion daneben (z. B. einmal angezeigter Token + „Kopieren", data-copy in app.js) */
.input-action { display: flex; align-items: center; gap: 0.5rem; }
.input-action > input, .input-action > textarea { flex: 1 1 auto; min-width: 0; }
.input-action > .btn { flex: 0 0 auto; }
/* Checkbox-Liste (z. B. Rechte): mehrspaltig, soweit Platz ist */
.form-check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); column-gap: 1rem; padding-left: 1.5rem; }
/* Zwischenueberschrift in laengeren Masken */
.form-section {
    margin: 1.25rem 0 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.modal-body > .form-section:first-child { margin-top: 0; }
.form-hint { display: block; margin-top: 0.3rem; font-size: 0.75rem; color: var(--color-text-muted); }
/* Feldfehler: .form-group.has-error + <small class="form-error"> unter dem Feld */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea { border-color: var(--color-error); }
.form-error { display: block; margin-top: 0.3rem; font-size: 0.75rem; color: var(--color-error); }
.form-group textarea[rows] { min-height: 0; resize: vertical; overflow: auto; }

/* Vollseiten-Rueckfall (partials/modal-page): dieselbe Maske ohne Overlay */
.modal-page { display: flex; justify-content: center; padding: 1rem 0 2rem; }
.modal-page .modal-dialog { max-width: 760px; max-height: none; box-shadow: var(--shadow); }
.modal-page .modal-header h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }

/* Sicherheitsnetz gegen „Popup oben links":
   Der kanonische Weg oeffnet ein Popup ueber [data-modal-open] / das hidden-
   Attribut — nie ueber inline display. Setzt jemand es doch per
   `el.style.display = 'block'`, wuerde inline `block` die Flex-Zentrierung
   aushebeln und der Inhalt klebte oben links. In genau diesem Fall erzwingen
   wir flex zurueck, damit das Popup trotzdem mittig sitzt. `display:none`
   (verstecken) bleibt unberuehrt. */
.modal[style*="display:block"],   .modal[style*="display: block"],
.am-modal[style*="display:block"], .am-modal[style*="display: block"] {
    display: flex !important;
}

/* === Legacy-Popup „.am-modal" (Herkunft: CRM/Automation-Projekt) ===
 * Neue Popups nehmen .modal (siehe oben) — das ist der dokumentierte Weg.
 * Diese Alt-Konvention wird hier trotzdem ZENTRIERT bereitgestellt, damit ein
 * .am-modal in JEDEM Projekt mittig sitzt und nicht nur dort, wo zufaellig eine
 * projekteigene modal.css mitliegt. Getoggelt wird per inline display
 * (JS: `style.display = 'flex'`); die Basis steht daher auf flex, ein inline
 * display:none blendet aus. Markup: .am-modal > (.am-modal-overlay + .am-modal-content). */
.am-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.am-modal-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.am-modal-content {
    position: relative;
    z-index: 1;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    width: 95%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.am-modal-content > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.am-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.am-modal-header h2, .am-modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.am-modal-close:not(.btn) {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius);
}
.am-modal-close:not(.btn):hover { background: var(--color-bg); color: var(--color-text); }
.am-modal-body { padding: 1.25rem; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.am-modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}
body.am-modal-open { overflow: hidden; }

/* === Raster (generisch) ===
 * Gleichmaessige Spalten mit echtem Abstand (gap) — ersetzt handgebaute
 * Flex-/Margin-Konstruktionen. .grid--auto fuellt so viele Spalten wie passen. */
.grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
.grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
/* Kennzahlen-Zeile (seit 0.74.0): 5 gleiche Spalten, ab 1200px Viewport 3, ab 900px 2 */
.grid--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid--cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* min(…, 100%): eine Mindestbreite groesser als der Container (schmale Viewports, Seitenspalte) laeuft nie ueber */
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-min, 220px), 100%), 1fr)); }
/* .grid--fit (seit 0.75.0): wie --auto, aber leere Spuren fallen weg (auto-fit) — wenige Elemente teilen sich
   die ganze Breite statt links zu kleben (Widget-Zeilen: zwei Karten = zwei halbe Spalten, keine Luecke rechts) */
.grid--fit { grid-template-columns: repeat(auto-fit, minmax(min(var(--grid-min, 220px), 100%), 1fr)); }
/* Dashboard-Widgets (partials/dashboard-widgets, seit 0.75.0): Karten einer Rasterzeile gleich hoch */
.dashboard-widget { display: flex; flex-direction: column; min-width: 0; }
.dashboard-widget > .card { flex: 1 1 auto; }
@media (max-width: 900px) {
    .grid--cols-3, .grid--cols-4, .grid--cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .grid--cols-2, .grid--cols-3, .grid--cols-4 { grid-template-columns: 1fr; }
}
/* Telefon: Kennzahlen bleiben zweispaltig, Kacheln ruecken enger (Labels passen ohne Trennung) */
@media (max-width: 600px) {
    .grid--cols-5 { gap: 0.6rem; }
    .grid--cols-5 > .stat { padding: 0.7rem 0.75rem; }
    .grid--cols-5 .stat-label { font-size: 0.66rem; letter-spacing: 0.02em; }
    .grid--cols-5 .stat-value { font-size: 1.3rem; }
    .grid--cols-5 .stat-icon { display: none; }
    .grid--cols-5 .stat:has(> .stat-icon) .stat-label { padding-right: 0; }
}

/* === Abschnitts-Titel: Ueberschrift gehoert UEBER die Box, nicht hinein ===
 * Haeufiger Fehler war die Ueberschrift innerhalb der Card. Kanonisch:
 * <h2 class="section-title">Titel</h2> <div class="card"> Inhalt </div> */
.section-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 0.6rem; color: var(--color-text); }
.section-title .count { margin-left: 0.35rem; vertical-align: 0.1em; }
/* Ueberschrift mit Aktion rechts: <div class="section-head"><h2 class="section-title">…</h2><div class="section-actions">…</div></div> */
.section-head { display: flex; align-items: center; gap: 0.5rem 1rem; flex-wrap: wrap; margin: 0 0 0.6rem; }
.section-head > .section-title { margin: 0; }
.section-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.section-head + .card, .section-head + .section-card { margin-top: 0; }
/* Abstand zwischen gestapelten Abschnitten (statt <div style="height:1.5rem">) */
.section { margin-bottom: 1.75rem; }
.section:last-child { margin-bottom: 0; }
.section-title + .card, .section-title + .section-card { margin-top: 0; }
.section-lead { font-size: 0.85rem; color: var(--color-text-muted); margin: -0.3rem 0 0.9rem; }

/* Karten im Raster: Abstand kommt aus gap, nicht aus margin-bottom */
.grid > .card, .grid > .stat, .grid > .section-card { margin-bottom: 0; }

/* Klickbare Karte (<a class="card card--clickable"> oder mit data-href) */
.card--clickable { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.card--clickable:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); color: inherit; text-decoration: none; }
.card--clickable:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* === Kacheln: Uebersicht von Modulen/Objekten (partials/tile.php) ===
 * Karte mit Kopf (Bild ODER farbige Flaeche + Icon) und Text darunter — nie mit
 * farbiger Linie links (Gate CARD-ACCENT-LEFT).
 * <div class="tiles">
 *   <a class="tile" href="/crm">
 *     <div class="tile-media tile-media--image"><img src="/crm/assets/screenshot.png" alt="" loading="lazy"></div>
 *     <div class="tile-body"><h3 class="tile-title">CRM</h3><p class="tile-text">…</p>
 *       <div class="tile-tags"><span class="badge badge--blue">Software</span></div></div>
 *   </a>
 *   <a class="tile" href="/wissen">
 *     <div class="tile-media tile-media--color" style="--tile-color:#5b4bc4"><span class="tile-icon"><svg …></svg></span></div>
 *     …
 *   </a>
 * </div> */
/* Mindestbreite je Kachel ueberschreibbar (--tiles-min, seit 0.74.0), z. B. dichtere Raster neben einer Seitenspalte */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--tiles-min, 280px), 100%), 1fr)); gap: 1.25rem; }
.tiles + .demo-note { margin-top: 1rem; }
.tile {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--tile-border);
    border-radius: var(--tile-radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-tile);
    color: var(--color-text);
    text-decoration: none;
}
a.tile { cursor: pointer; transition: transform 0.18s ease, box-shadow 0.18s ease; }
a.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-tile-hover); color: var(--color-text); text-decoration: none; }
a.tile:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { a.tile { transition: box-shadow 0.18s ease; } a.tile:hover { transform: none; } }

/* Kopf: 16:9, obere Ecken folgen der Karte (overflow:hidden an .tile) */
.tile-media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--color-surface-hover); }
.tile-media > img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    /* Bildausschnitt ueber partials/tile image_position/image_scale (Default: oben mittig, kein Zoom) */
    object-position: var(--tile-img-x, 50%) var(--tile-img-y, 0%);
    transform: scale(var(--tile-img-scale, 1));
    transform-origin: var(--tile-img-x, 50%) var(--tile-img-y, 0%);
}
.tile-media--image { border-bottom: 1px solid var(--tile-border); }
.tile-media--color {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--tile-color, var(--color-primary)) 0%, color-mix(in srgb, var(--tile-color, var(--color-primary)) 70%, #000) 100%);
    color: #fff;
}
/* Icon-/Logo-Feld mittig auf der Flaeche */
.tile-icon {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(12, 10, 24, 0.42);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 6px 18px rgba(0, 0, 0, 0.18);
    color: #fff;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}
.tile-icon > svg { width: 36px; height: 36px; }
.tile-icon > img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tile-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 0.5rem; padding: 1.25rem 1.5rem 1.5rem; }
.tile-title { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; color: var(--color-text); overflow-wrap: anywhere; }
.tile-text {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    min-height: calc(2 * 1.5em);
    font-size: 0.925rem;
    line-height: 1.5;
    color: var(--color-text-muted);
}
.tile-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.35rem; }
.tile-tags .badge, .tile-tags .tag { padding: 0.25rem 0.75rem; font-size: 0.78rem; }
.tile-tags .code { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; font-size: 0.75rem; }
/* Aktionen am Kachelfuss (partials/tile 'actions', z. B. Integrationen: Verbinden/Trennen) — Kachel ist dann nie ein Link */
.tile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem; }
.tile-tags + .tile-actions { margin-top: 0; }
.tile-actions form { display: inline; margin: 0; }
/* Zeilenliste am Kachelfuss (z. B. mehrere verbundene Konten): volle Breite, Aktionen umbrechen */
.tile-actions > .row-list { flex: 1 1 100%; }
.tile-actions > .row-list > li { flex-wrap: wrap; }

/* Kompakt: flacher Kopf (3:1), kleinerer Titel — fuer dichte Uebersichten */
.tile--compact .tile-media { aspect-ratio: 3 / 1; }
.tile--compact .tile-icon { width: 48px; height: 48px; border-radius: 12px; font-size: 1.25rem; }
.tile--compact .tile-icon > svg { width: 24px; height: 24px; }
.tile--compact .tile-body { gap: 0.35rem; padding: 0.9rem 1rem 1rem; }
.tile--compact .tile-title { font-size: 1rem; letter-spacing: -0.01em; }
.tile--compact .tile-text { font-size: 0.82rem; }
.tile--compact .tile-tags { padding-top: 0.2rem; }
.tile--compact .tile-tags .badge, .tile--compact .tile-tags .tag { padding: 0.15rem 0.55rem; font-size: 0.7rem; }
/* Dicht (seit 0.74.0, 'dense' => true, immer mit --compact): niedriges Farbband statt 3:1-Kopf, kleines Icon —
   fuer Navigations-Kacheln unter Kennzahlen. Farbige Flaeche bleibt, keine Linie links. */
.tile--dense .tile-media { aspect-ratio: auto; height: 3.25rem; }
.tile--dense .tile-icon { width: 34px; height: 34px; border-radius: 9px; font-size: 1rem; }
.tile--dense .tile-icon > svg { width: 18px; height: 18px; }
.tile--dense .tile-body { gap: 0.25rem; padding: 0.7rem 0.85rem 0.8rem; }
.tile--dense .tile-title { font-size: 0.95rem; }
.tile--dense .tile-text { font-size: 0.8rem; }
.tile--compact .tile-tags .code { padding: 0.1rem 0.45rem; font-size: 0.68rem; }

/* === Schluessel/Wert-Liste: <dl class="kv"><dt>Telefon</dt><dd>…</dd></dl> === */
.kv { display: grid; grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr); gap: 0.5rem 1rem; margin: 0; }
.kv dt { color: var(--color-text-muted); font-size: 0.85rem; }
.kv dd { margin: 0; font-size: 0.9rem; color: var(--color-text); overflow-wrap: anywhere; }
.kv--compact { grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr); gap: 0.25rem 0.75rem; }
.kv--compact dt, .kv--compact dd { font-size: 0.8rem; }
@media (max-width: 480px) {
    .kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
    .kv dd { margin-bottom: 0.5rem; }
}

/* === KPI-Kachel: .stat (Zahl, Label, optional klickbar als <a class="stat">) ===
 * <div class="stat"><span class="stat-label">Offen</span><span class="stat-value">128</span><span class="stat-meta">+12 diese Woche</span></div> */
.stat {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    padding: 1rem 1.1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow);
    color: var(--color-text);
    text-decoration: none;
}
.stat-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: 0.78rem; color: var(--color-text-muted); }
.stat-meta--up { color: var(--color-success); }
.stat-meta--down { color: var(--color-error); }
a.stat, .stat--clickable { cursor: pointer; transition: border-color 0.15s; }
a.stat:hover, .stat--clickable:hover { border-color: var(--color-primary); color: var(--color-text); text-decoration: none; }
.stat--active { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
/* Status-Kacheln: Farbe der Kennzahl + optional kleines Icon-Feld (.stat-icon) oben
 * rechts in der hellen Statusflaeche — nie eine farbige Linie links.
 * <div class="stat stat--warning"><span class="stat-icon"><svg …></svg></span><span class="stat-label">Faellig</span>… */
.stat--success { --stat-tone: var(--color-success); --stat-tone-bg: var(--color-success-light); }
.stat--warning { --stat-tone: var(--color-warning); --stat-tone-bg: var(--color-warning-light); }
.stat--error   { --stat-tone: var(--color-error);   --stat-tone-bg: var(--color-error-light); }
.stat--primary { --stat-tone: var(--color-primary-text, var(--color-primary)); --stat-tone-bg: var(--color-primary-light); }
.stat--success .stat-value, .stat--warning .stat-value, .stat--error .stat-value, .stat--primary .stat-value { color: var(--stat-tone); }
.stat-icon {
    position: absolute;
    top: 0.85rem;
    right: 0.9rem;
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--stat-tone-bg, var(--color-primary-light));
    color: var(--stat-tone, var(--color-primary-text, var(--color-primary)));
}
.stat-icon > svg { width: 16px; height: 16px; }
.stat:has(> .stat-icon) .stat-label { padding-right: 2.5rem; }

/* === Fortschritt: .progress (Balken + Beschriftung) ===
 * <div class="progress" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="--progress:40%">
 *   <div class="progress-head"><span>Umgesetzt</span><span class="progress-value">4 / 10</span></div>
 *   <div class="progress-track"><div class="progress-bar"></div></div>
 * </div>   Wert als Custom-Property (--progress) — erlaubter dynamischer Inline-Style. */
.progress { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; font-size: 0.8rem; color: var(--color-text-muted); }
.progress-value { font-weight: 600; color: var(--color-text); font-variant-numeric: tabular-nums; }
.progress-track { height: 0.5rem; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--color-text-muted) 16%, transparent); }
.progress-bar { width: var(--progress, 0%); max-width: 100%; height: 100%; border-radius: inherit; background: var(--color-primary); transition: width 0.3s; }
.progress--success .progress-bar { background: var(--color-success); }
.progress--warning .progress-bar { background: var(--color-warning); }
.progress--error .progress-bar { background: var(--color-error); }
.progress--lg .progress-track { height: 0.85rem; }
@media (prefers-reduced-motion: reduce) { .progress-bar { transition: none; } }

/* === Gerendertes Markdown: <div class="markdown">…</div> (ersetzt .md-doc, .entw-md) === */
.markdown { font-size: 0.9rem; line-height: 1.65; color: var(--color-text); overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1 { font-size: 1.3rem; margin: 1.5rem 0 0.6rem; }
.markdown h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.markdown h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }
.markdown h4 { font-size: 0.875rem; margin: 0.9rem 0 0.35rem; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown blockquote, .markdown table { margin: 0 0 0.75rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li { margin-bottom: 0.2rem; }
.markdown li > ul, .markdown li > ol { margin: 0.2rem 0 0; }
/* Links im Fliesstext: Textfarbe wie ueberall, aber unterstrichen — mitten im Satz waere ein Link
   sonst nur an der Farbe (gar nicht) erkennbar (WCAG 1.4.1). Hover/Fokus: Linkfarbe. Extern: Linkfarbe. */
.markdown a { color: var(--color-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 0.15em; }
.markdown a:where(:hover, :focus-visible) { color: var(--color-link, var(--color-primary-text, var(--color-primary))); text-decoration-color: currentColor; }
.markdown a:where([target="_blank"], [rel~="external"], [href^="http://"], [href^="https://"]) { color: var(--color-link, var(--color-primary-text, var(--color-primary))); }
.markdown code { padding: 0.05rem 0.3rem; border: 1px solid var(--color-border-light); border-radius: 4px; background: var(--color-surface-hover); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.markdown pre { padding: 0.75rem; overflow-x: auto; border: 1px solid var(--color-border-light); border-radius: var(--radius); background: var(--color-surface-hover); font-size: 0.8rem; }
.markdown pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.markdown blockquote { padding: 0.25rem 0 0.25rem 0.9rem; border-left: 3px solid var(--color-border); color: var(--color-text-muted); }
.markdown hr { margin: 1.25rem 0; border: 0; border-top: 1px solid var(--color-border); }
.markdown img { max-width: 100%; height: auto; border-radius: calc(var(--radius) - 3px); }
.markdown table { width: auto; font-size: 0.85rem; }
.markdown th, .markdown td { height: auto; padding: 0.35rem 0.75rem; border: 1px solid var(--color-border); }

/* === Tabellenzellen: Haupttext, Unterzeile, Avatar === */
.cell-main { display: block; font-weight: 600; color: var(--color-text); line-height: 1.35; }
a.cell-main { text-decoration: none; }
a.cell-main:hover { color: var(--color-primary-text, var(--color-primary)); }
.cell-sub { display: block; margin-top: 0.1rem; font-size: 0.75rem; color: var(--color-text-muted); line-height: 1.35; }
.cell-avatar { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.cell-avatar > :last-child { min-width: 0; }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: none;
    overflow: hidden;
    border-radius: 9px;
    background: var(--color-primary-light);
    color: var(--color-primary-text, var(--color-primary));
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--round { border-radius: 50%; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; border-radius: 7px; }
.avatar--logo { background: var(--color-surface); border: 1px solid var(--color-border); }
.avatar--logo img { object-fit: contain; }

/* === Einfache Zeilenliste in einer Karte (Verlauf, Ereignisse, kurze Listen) ===
 * <ul class="row-list"><li><span>…Text…</span><span class="badge …">…</span></li></ul>
 * Fuer Daten mit Spalten: Tabelle (.card--table). */
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list > li { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--color-border-light); }
.row-list > li:first-child { padding-top: 0; }
.row-list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.row-list-meta { margin-right: 0.75rem; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
/* === Kompakte Objektliste: .item-list / partials/item-list (seit 0.75.0) ===
 * Widgets in Haupt- und Seitenspalte: Titel-Link auf eigener Zeile (Textfarbe, max. 2 Zeilen),
 * darunter gedaempfte Meta-Zeile (Ampel-Punkt, relative Faelligkeit, Bezug, Kennzeichen) —
 * Teile per „·" getrennt, nie im Link-Text. Gruppen-Label klein und gedaempft (.item-list davor: schlaegt .card h3), Fuss-Links ruhig. */
.item-list { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.item-list-summary { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; margin: 0; font-size: 0.75rem; color: var(--color-text-muted); }
.item-list .item-list-group { display: flex; align-items: center; gap: 0.35rem; margin: 0.35rem 0 -0.15rem; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-muted); }
.item-list .item-list-group:first-child { margin-top: 0; }
.item-list-items { list-style: none; margin: 0; padding: 0; }
.item-list-item { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; padding: 0.5rem 0; border-bottom: 1px solid var(--color-border-light); }
.item-list-item:first-child { padding-top: 0.15rem; }
.item-list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.item-list-title {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
    font-size: 0.875rem; font-weight: 500; line-height: 1.35; color: var(--color-text); overflow-wrap: anywhere;
}
.item-list-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.4rem; min-width: 0; font-size: 0.75rem; line-height: 1.4; color: var(--color-text-muted); }
.item-list-part + .item-list-part::before { content: "·"; margin-right: 0.4rem; color: var(--color-text-muted); }
.item-list-due--overdue { color: var(--color-error-text, var(--color-error)); }
.item-list-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.7rem; letter-spacing: 0.01em; }
.item-list-dot { flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--color-text-muted); }
.item-list-dot--error   { background: var(--color-error); }
.item-list-dot--warning { background: var(--color-warning); }
.item-list-dot--success { background: var(--color-success); }
.item-list-dot--info    { background: var(--color-info); }
.item-list-dot--primary { background: var(--color-primary); }
.item-list-more { margin: 0; font-size: 0.75rem; color: var(--color-text-muted); }
.item-list-footer { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0.25rem 0 0; font-size: 0.8rem; font-weight: 500; }
/* Aufzaehlung mit Abstand (Regeln, Hinweise) */
.bullet-list { margin: 0; padding-left: 1.2rem; }
.bullet-list > li + li { margin-top: 0.4rem; }

/* Objekt-Verlauf (partials/audit-history.php) */
.audit-history-title { margin: 0 0 0.5rem; }
.audit-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.audit-history-item { padding: 0.25rem 0 0.25rem 0.75rem; border-left: 2px solid var(--color-border); }
.audit-history-diff { list-style: none; margin: 0.25rem 0 0; padding: 0; }
.audit-history-more { margin-top: 0.25rem; }
.audit-history-more > summary { cursor: pointer; }
.audit-history .mono { font-size: 0.8rem; }

/* Kommentar-Thread (partials/comments.php, core/Comments.php) — nur Layout, Farben aus den Tokens */
.comments-title { margin: 0 0 0.75rem; }
.comments-empty { margin: 0 0 0.75rem; }
.comments-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.comment { padding-bottom: 0.75rem; border-bottom: 1px solid var(--color-border-light); }
.comment:last-child { border-bottom: 0; padding-bottom: 0; }
.comment-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.75rem; }
.comment-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.comment-author { font-size: 0.85rem; }
.comment-body { font-size: 0.9rem; line-height: 1.55; overflow-wrap: anywhere; }
.comment-revisions { margin-top: 0.35rem; }
.comment-revisions > summary { cursor: pointer; }
.comment-revisions .row-list { margin-top: 0.35rem; }
.mention { font-weight: 600; color: var(--color-primary-text, var(--color-primary)); }
.mention-field { position: relative; }
.mention-field textarea { min-height: 5rem; resize: vertical; overflow: auto; }
/* @-Autovervollstaendigung (public/assets/js/comments.js) */
.mention-list { position: absolute; left: 0; right: 0; z-index: 20; margin-top: 0.25rem; max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; padding: 0.25rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12)); }
.mention-option { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; width: 100%; padding: 0.4rem 0.6rem; border: 0; border-radius: var(--radius); background: transparent; color: var(--color-text); text-align: left; cursor: pointer; font-size: 0.85rem; }
.mention-option:hover, .mention-option.is-active { background: var(--color-primary-light); }

/* Tabellenzelle ohne Umbruch (Datum/Uhrzeit) und kleine Monospace-Zelle (IP, Aktion) */
.nowrap { white-space: nowrap; }
.audit-log-details { max-width: 32rem; overflow-wrap: anywhere; }
td.mono { font-size: 0.82rem; }

/* Tabellarische Ziffern (Betraege, Datumsspalten, Zaehler) */
.tabular { font-variant-numeric: tabular-nums; }

/* === Kanban (Board) — Drag&Drop: assets/js/kanban.js ===
 * <div class="kanban" data-kanban-move-url="/modul/verschieben">
 *   <section class="kb-col">
 *     <header class="kb-col-head"><span class="kb-col-title">Offen</span><span class="count" data-kanban-count>2</span>
 *       <button type="button" class="btn btn--icon btn--ghost btn--sm" aria-label="Neu in Offen">+</button></header>
 *     <div class="kb-col-body" data-drop="offen">
 *       <article class="kb-card" data-drag="12"><div class="kb-card-top"><span class="code">F-012</span></div>
 *         <div class="kb-card-title">Titel</div><div class="kb-card-meta">…</div></article>
 *     </div>
 *   </section>
 * </div> */
.kanban { display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; padding-bottom: 0.5rem; }
.kb-col { flex: 1 1 0; min-width: 218px; padding: 0.5rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); }
.kb-col--done { border-style: dashed; }
.kb-col-head { display: flex; align-items: center; gap: 0.4rem; min-height: 2.15rem; padding: 0 0.35rem 0.4rem; font-size: 0.82rem; font-weight: 600; color: var(--color-text); }
.kb-col-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Aktion im Spaltenkopf (Plus): rechts, erst bei Hover/Fokus sichtbar — auf Touch immer */
.kb-col-head .btn--icon { margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.kb-col:hover .kb-col-head .btn--icon, .kb-col-head .btn--icon:focus-visible { opacity: 1; }
@media (hover: none) { .kb-col-head .btn--icon { opacity: 1; } }
.kb-col-body { display: flex; flex-direction: column; gap: 0.5rem; min-height: 60px; border-radius: calc(var(--radius) - 2px); }
.kb-col-body.dragover { background: var(--color-primary-light); outline: 2px dashed var(--color-primary); outline-offset: -2px; }
.kb-card { padding: 0.6rem 0.7rem; border: 1px solid var(--color-border); border-radius: calc(var(--radius) - 2px); background: var(--color-surface); box-shadow: var(--shadow); color: var(--color-text); cursor: pointer; }
.kb-card[draggable="true"] { cursor: grab; }
.kb-card:hover { border-color: var(--color-primary); }
.kb-card.dragging { opacity: 0.45; }
.kb-card.is-saving { opacity: 0.7; }
/* Markierung: Farbpunkt .kb-card-dot im Kartenkopf (plus leicht getoenter Rahmen) — keine Linie links.
 * <div class="kb-card-top"><span class="kb-card-dot" role="img" aria-label="Dringend"></span><span class="code">F-012</span><span class="tag">Bug</span></div> */
.kb-card--primary { --kb-tone: var(--color-primary); }
.kb-card--error   { --kb-tone: var(--color-error); }
.kb-card--warning { --kb-tone: var(--color-warning); }
.kb-card--primary, .kb-card--error, .kb-card--warning { border-color: color-mix(in srgb, var(--kb-tone) 40%, var(--color-border)); }
.kb-card-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--kb-tone, var(--color-text-light)); }
.kb-card-dot + * { margin-right: auto; }
.kb-card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; margin-bottom: 0.3rem; }
.kb-card-title { margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 600; line-height: 1.3; color: var(--color-text); }
.kb-card-title:last-child { margin-bottom: 0; }
.kb-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.45rem; font-size: 0.72rem; color: var(--color-text-muted); }
.kb-card-meta .icon { vertical-align: -1px; }
.kb-card-meta-end { margin-left: auto; white-space: nowrap; }
.kb-empty { padding: 0.75rem 0; text-align: center; font-size: 0.78rem; color: var(--color-text-light); }

/* === Tab-Panels (Reiter-Inhalt; .tabs/.tab existieren bereits oben) === */


/* === Utilities (einzweckige Klassen) ===
 * Ersetzen die haeufigsten Inline-Styles in Views (style="color:var(--color-text-muted)",
 * margin-top:1rem, display:inline ...). Bewusst klein: nur was wiederholt vorkam. */
.text-muted { color: var(--color-text-muted); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.inline { display: inline; }
/* Vertikaler Stapel mit gleichmaessigem Abstand (statt margin je Kind) */
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.stack--sm { gap: 0.4rem; }
/* Aktionen nebeneinander (Formular-Fuss ausserhalb eines Popups, Button-Gruppen) */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.actions--end { justify-content: flex-end; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
/* Nur fuer Screenreader sichtbar (seit 0.75.0) — z. B. Text zu einem Farbpunkt */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* === Element-Katalog (showcase/index.php): Demo-Bausteine === */
.demo-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.demo-row + .demo-row { margin-top: 0.9rem; }
.demo-row > .demo-note { flex: 1 1 20rem; margin-top: 0; }
.demo-narrow { max-width: 520px; }
.demo-lead { max-width: 680px; }
/* Rahmen um ein Seiten-Beispiel (Seitenkopf), damit es nicht wie der echte Kopf wirkt */
.demo-frame { padding: 1.25rem 1.25rem 0.25rem; border: 1px dashed var(--color-border); border-radius: var(--radius); margin-bottom: 1rem; }
.demo-frame .page-header { margin-bottom: 1rem; }
.demo-note { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 0.5rem; }
.demo-note code, code.inline-code {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    padding: 0.05rem 0.35rem;
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- Kompaktes Formular-Grid (Settings-Panels: SMTP, Team, Profil, 2FA) ---
   Basis-Primitive fuer Label-ueber-Feld-Formulare. base.css stylt zwar jedes
   input/select generisch (Rahmen/Padding), aber ohne diese Regeln stehen Labels
   inline in Default-Groesse und die Felder stapeln full-width statt im 2-Spalten-
   Grid. Aus dem faictory-igepa-Projekt (project.css, "Golden-Master modules.css")
   in den Core zurueckportiert, damit alle Feature-Panels sauber rendern. Die
   spezifischeren .stammdaten-grid-Regeln weiter unten ueberschreiben das Label-
   Layout dort bewusst (Label links neben Feld). */
.crm-compact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.375rem 0.75rem; }
@media (max-width: 640px) { .crm-compact-grid { grid-template-columns: 1fr; } }
.crm-field label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--color-text); margin-bottom: 0.3rem; }
.crm-field input, .crm-field select, .crm-field textarea { width: 100%; padding: 0.4rem 0.625rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 0.85rem; background: var(--color-bg); color: var(--color-text); }
/* Checkbox/Radio nie full-width ziehen (die generische .crm-field-input-Regel
   oben wuerde sie sonst strecken → Label rutscht weg, Kontrollkaestchen mittig).
   Betrifft z. B. den Button-Farbverlauf-Schalter im CI-Panel. */
.crm-field input[type="checkbox"], .crm-field input[type="radio"] { width: auto; }
.crm-field textarea { resize: vertical; min-height: 2.5rem; font-family: inherit; }
.crm-field input:focus, .crm-field select:focus, .crm-field textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15); }

/* --- CI-Panel: Formular in thematische Abschnitte, zweispaltig (Masonry) ---
   Jeder .ci-section-Block bleibt beim Umbruch ganz (break-inside: avoid). Bei
   Platzmangel faellt columns auf eine Spalte zurueck. */
.ci-form-grid { columns: 2 17rem; column-gap: 1rem; }
.ci-section {
    break-inside: avoid;
    margin: 0 0 1rem;
    padding: 0.9rem 1rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}
.ci-section > h4 {
    margin: 0 0 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-light, var(--color-border));
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-text);
}
.ci-section .crm-field + .crm-field { margin-top: 0.9rem; }
/* Farben im Raster statt untereinander: zwei Spalten, Abstand ueber gap
   (die Abschnitts-Adjacency-Regel oben wird hier neutralisiert). */
.ci-color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem 0.75rem; margin-bottom: 0.9rem; }
.ci-color-grid .crm-field + .crm-field { margin-top: 0; }
/* Farbfeld (ci.php $colorPair): nativer Farbwaehler + Hex-Textfeld nebeneinander.
   .crm-field-Praefix, damit die Regeln die generische .crm-field-input-Regel
   (width:100%, padding) ueberstimmen. --compact = feste 100px fuer Verlauf/Marke. */
.crm-field .ci-color-pair { display: flex; gap: 0.5rem; align-items: center; }
.crm-field .ci-color-input {
    width: 42px;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) - 3px);
    background: var(--color-surface);
    cursor: pointer;
    flex-shrink: 0;
}
.crm-field .ci-color-hex { min-width: 0; width: 100%; font-family: ui-monospace, monospace; }
.crm-field .ci-color-pair--compact .ci-color-hex { width: 100px; }
.ci-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.25rem; }

/* Klickbares Logo-Feld: die Anzeige (Label) oeffnet den Dateidialog; Hover
   zeigt „Ändern". Kein separater Datei-Button. Selektoren mit .crm-field-Praefix,
   damit sie die generischen .crm-field label/input-Regeln ueberstimmen. */
.crm-field .logo-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    min-height: 56px;
    max-width: 220px;
    margin-bottom: 0;
    padding: 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: inherit;
    font-weight: 400;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s, background .15s;
}
.crm-field .logo-picker:hover { border-color: var(--color-primary); }
.crm-field .logo-picker:not(.logo-picker--filled) { border-style: dashed; }
.crm-field .logo-picker:not(.logo-picker--filled):hover { background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface)); }
.crm-field .logo-picker--sm { min-width: 52px; min-height: 52px; }
.crm-field .logo-picker-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.crm-field .logo-picker-img { max-width: 100%; max-height: 64px; height: auto; width: auto; object-fit: contain; }
.crm-field .logo-picker--sm .logo-picker-img { max-height: 40px; }
.crm-field .logo-picker-empty { color: var(--color-text-muted); font-size: 0.85rem; padding: 0.35rem 0.55rem; text-align: center; }
.crm-field .logo-picker-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity .15s;
    pointer-events: none;
}
.crm-field .logo-picker--filled:hover .logo-picker-overlay { opacity: 1; }
.crm-field .logo-picker-remove { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0.4rem 0 0; font-weight: 400; font-size: 0.8rem; color: var(--color-text-muted); cursor: pointer; }

/* --- Stammdaten (Settings): Split-Layout + Beleg-Fusszeilen-Vorschau --- */
.stammdaten-split { display: grid; grid-template-columns: 1fr 360px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .stammdaten-split { grid-template-columns: 1fr; } }
.stammdaten-intro { color: var(--color-text-muted); font-size: 0.8rem; margin: 0 0 1.25rem; line-height: 1.5; }
.stammdaten-sub { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin: 1.5rem 0 0.85rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border-light); }
.stammdaten-grid { display: flex; flex-direction: column; }
.stammdaten-grid .crm-field { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: center; gap: 0.5rem 1.25rem; padding: 0.6rem 0; border-bottom: 1px solid var(--color-border-light); }
.stammdaten-grid .crm-field:last-child, .stammdaten-grid .stammdaten-check:last-child { border-bottom: 0; }
.stammdaten-grid .crm-field label { margin: 0; font-size: 0.82rem; font-weight: 500; color: var(--color-text); }
.stammdaten-grid .crm-field input, .stammdaten-grid .crm-field select { width: 100%; }
.stammdaten-check { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--color-border-light); font-size: 0.85rem; color: var(--color-text-muted); cursor: pointer; }
.stammdaten-check input { flex-shrink: 0; }
.stammdaten-actions { display: flex; align-items: center; gap: 0.75rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border-light); }
@media (max-width: 640px) { .stammdaten-grid .crm-field { grid-template-columns: 1fr; align-items: start; gap: 0.3rem; } }
.beleg-foot-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; font-size: 0.75rem; line-height: 1.55; color: var(--color-text-muted); padding-top: 12px; border-top: 1px solid var(--color-border-light); }
.beleg-foot-preview strong { color: var(--color-text); }

/* === Busy-State (Ladeanimation fuer Aktions-Buttons/Forms, siehe app.js ctBusy) === */
/* Opt-in per data-busy. Der Spinner ersetzt den Button-Text, waehrend eine Aktion
   laeuft (synchron bis Seitenwechsel oder AJAX-Abschluss). Verhindert Doppel-Klick. */
.ct-busy {
    cursor: progress !important;
    opacity: 0.85;
}
.ct-busy .ct-busy-spinner,
.ct-busy-spinner {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ct-spin 0.6s linear infinite;
    vertical-align: -0.1em;
    box-sizing: border-box;
}
.ct-busy-text { margin-left: 0.5em; }
@keyframes ct-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .ct-busy-spinner { animation-duration: 1.4s; }
}

/* === Job-Tray (Hintergrund-Jobs Stufe 2, siehe app.js ctJobs) === */
/* Persistente Anzeige aktiver Hintergrund-Jobs unten rechts. Ueberlebt
   Navigation (ctJobs.resume() holt offene Jobs nach jedem Seitenladen). */
.ct-jobs-tray {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(22rem, calc(100vw - 2rem));
    pointer-events: none;
}
.ct-job {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--color-surface, #fff);
    color: var(--color-text, #1a1a2e);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
    border-radius: var(--radius, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.85rem;
    line-height: 1.3;
}
/* Ergebnis als Farbpunkt statt Linie links (laufend: Spinner) */
.ct-job.is-done::before, .ct-job.is-failed::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--color-success, #16a34a); }
.ct-job.is-failed::before { background: var(--color-error, #dc2626); }
.ct-job.is-clickable { cursor: pointer; }
.ct-job-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ct-job-meta {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    opacity: 0.7;
}

/* SMTP-Verbindungsstatus (Feature smtp): dauerhaftes Badge je Konto im Panel.
   Zustand kommt als Modifier smtp-status--never|ok|fail aus der View. */
.smtp-status {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-bg, #f5f4f7);
}
.smtp-status strong { font-size: 0.85rem; }
.smtp-status--never strong { color: var(--color-text-muted, #6b7280); }
.smtp-status--ok strong { color: var(--color-success, #1a7f4b); }
.smtp-status--fail strong { color: var(--color-error, #b42318); }
.smtp-status-when { color: var(--color-text-muted); font-size: 0.78rem; }
.smtp-status-error { flex-basis: 100%; color: var(--color-error); font-size: 0.78rem; }

/* Team-Benutzerliste (Feature team): kompakte Spalten-Zeilen + Akkordeon.
   Spalten: Kürzel · Name · E-Mail (mittig) · Rolle (rechts) · Chevron. */
.team-member { border: 1px solid var(--color-border-light); border-radius: var(--radius); margin-bottom: 0.5rem; }
.team-row {
    display: grid;
    grid-template-columns: 56px minmax(110px, 1.1fr) minmax(150px, 1.6fr) 160px 20px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
}
.team-row--head {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--color-text-muted); font-weight: 600; padding: 0.3rem 0.85rem;
}
.team-row--summary { cursor: pointer; list-style: none; }
.team-row--summary::-webkit-details-marker { display: none; }
.team-row--summary:hover { background: var(--color-bg, #f5f4f7); border-radius: calc(var(--radius) - 2px); }
.team-kuerzel {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; height: 30px; padding: 0 6px;
    border-radius: calc(var(--radius) - 3px); background: var(--color-bg, #f5f4f7);
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; color: var(--color-text-muted);
}
.team-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-email { color: var(--color-text-muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-row-role { text-align: right; }
.team-chevron { color: var(--color-text-muted); font-size: 0.8rem; transition: transform 0.15s; text-align: right; }
.team-member[open] .team-chevron { transform: rotate(180deg); }
@media (max-width: 640px) {
    .team-row { grid-template-columns: 44px 1fr auto; }
    .team-row--head, .team-email { display: none; }
}

/* === Schmale Viewports: nichts verbreitert die Seite (seit 0.76.0) ==========================
 * Eigener Block am Dateiende (gewinnt gegen gleich spezifische Regeln oben). Gefunden per
 * Seiten-Audit bei 390 px: Raster-Spalten mit breiter Tabelle, Aktions-/Kopfleisten ohne
 * Umbruch, Datei-Eingabe, Auswahlfelder und lange Links in Hinweisen. */
.grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .grid--cols-3, .grid--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .grid--cols-2, .grid--cols-3, .grid--cols-4 { grid-template-columns: minmax(0, 1fr); }
}
.grid > * { min-width: 0; }
.section-actions { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.page-actions { min-width: 0; max-width: 100%; }
.page-actions :is(select, input:not([type="checkbox"], [type="radio"])) { max-width: 100%; }
.version-badges { flex: 0 1 auto; min-width: 0; max-width: 100%; }
.attachments-input, input[type="file"] { max-width: 100%; }
.alert > * { min-width: 0; }
.alert { overflow-wrap: anywhere; }
.search-page-form { flex-wrap: wrap; }
.search-page-input { min-width: 0; }
.section-actions, .page-actions { overflow-wrap: anywhere; }
.chip { max-width: 100%; }
:is(.chips, .actions) > .chip { white-space: normal; }
.list-toolbar :is(select, input:not([type="checkbox"], [type="radio"])), .actions > select { max-width: 100%; min-width: 0; }
.page-title-row > .page-title { min-width: 0; overflow-wrap: anywhere; }
/* === Ende Schmale Viewports 0.76.0 === */

/* === Seitenfluss fuer Abschnittsueberschriften (seit 0.76.0) ===
 * .section-title/.section-head setzen margin: 0 0 … (Spezifitaet 0,1,0) und schlugen damit den
 * Seitenfluss aus layout.css — eine Ueberschrift direkt nach .grid/.tiles/.split klebte daran.
 * Gleiche Selektoren wie layout.css → „Seitenfluss", hier mit :is() auf Klassen-Spezifitaet;
 * Abstands-Utilities (.mt-0/1/2) an der Ueberschrift gewinnen weiter. */
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(:not(script, style, template, link, meta, input[type="hidden"], [hidden], dialog, .modal)) ~ :is(.section-title, .section-head):not(.mt-0, .mt-1, .mt-2) {
    margin-top: var(--flow-space);
}
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(p, h1, h2, h3, h4) + :is(.section-title, .section-head):not(.mt-0, .mt-1, .mt-2) {
    margin-top: var(--flow-space-sm);
}
:where(.container, .container--narrow, .container--wide, .page-main, .section) > :where(.section-title, .section-head, .page-header, .back-link, .list-toolbar, .list-views, .chips, .tabs, .tabs-select, #filter-panel, .card-head) + :is(.section-title, .section-head):not(.mt-0, .mt-1, .mt-2) {
    margin-top: 0;
}
/* === Ende Seitenfluss Abschnittsueberschriften 0.76.0 === */
/* === Responsive === */
@media (max-width: 768px) {
    .container, .container--narrow, .container--wide { padding: 1rem; }
    .page-actions { margin-left: 0; justify-content: flex-start; }
}
/* =========================================================================
 * PWA / Standalone — systemweit, unabhaengig vom Modul.
 *
 * Greift NUR, wenn die App vom Homescreen als installierte App laeuft
 * (display-mode: standalone bzw. iOS legacy navigator.standalone -> .pwa-standalone).
 * Im normalen Browser-Tab bleibt alles unveraendert.
 *
 * Ziel: Inhalte aus den Geraete-"Notches"/Home-Indicator-Bereichen halten
 * (safe-area-insets) und Touch-Bedienung angenehm machen.
 *
 * Layout-Container (app/views/layouts/main.php): die fixe linke Spalte ist
 * <aside class="app-sidebar"> (position: fixed, top 0, eigenes Padding 20px),
 * der Inhalt steht in <main class="main">. Eine Topnav gibt es nicht mehr.
 * ========================================================================= */

@media (display-mode: standalone) {
    /* Safe-Area-Padding fuer den Body-Rand. */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        /* Kein Pull-to-Refresh / Overscroll-Bounce in der App-Huelle. */
        overscroll-behavior-y: none;
    }

    /* Fixierte Sidebar unter die Statusbar/Notch schieben (Body-Padding wirkt
       auf position:fixed nicht). 20px = das normale Sidebar-Padding oben. */
    .app-sidebar {
        padding-top: calc(env(safe-area-inset-top) + 20px);
    }

    /* Lange Listen/Scrollbereiche unten frei vom Home-Indicator halten. */
    .main {
        padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
    }
}

/* iOS Safari (Legacy) meldet display-mode unzuverlaessig -> Body-Klasse als Fallback,
 * gesetzt per JS aus navigator.standalone. Gleiche Regeln wie oben. */
.pwa-standalone {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior-y: none;
}
.pwa-standalone .app-sidebar {
    padding-top: calc(env(safe-area-inset-top) + 20px);
}
.pwa-standalone .main {
    padding-bottom: calc(env(safe-area-inset-bottom) + 0.5rem);
}

/* Touch-Komfort in der installierten App: keine versehentliche Text-Selektion
 * auf Bedien-Elementen, aber Eingabefelder/Inhalte bleiben selektierbar. */
@media (display-mode: standalone) {
    button, .btn, a.btn, nav a {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    input, textarea, select, [contenteditable] {
        -webkit-user-select: text;
        user-select: text;
    }
}
/*
 * project.css — Produkt-Styles faictory-hirn (Erweiterungspunkt, kommt als
 * letzte Datei ins CSS-Bundle; nach Aenderung: bash bin/build-css.sh).
 *
 * Nur produktweite Kleinigkeiten. Modul-Styles liegen im jeweiligen Modul
 * (z. B. modules/entwicklung/assets/entwicklung.css) und werden von den
 * Modul-Views geladen. Kundeninstanzen ergaenzen public/assets/css/kunde.css.
 */

/* === Produkt-Tokens (F-023) ==============================================
   Schichten, spaetere gewinnen:
     1. public/assets/css/themes.css        Core-Themes light/dark
     2. project.css (hier)                   neutrale Produkt-CI Unternehmenshirn
     3. <style id="ci-theme">                CI-Panel /einstellungen?tab=ci (partials/ci-style,
                                             nach dem Bundle) — ueberschreibt Farben und --radius
     4. public/assets/css/kunde.css          Kunden-Gebiet (nach dem CI-Block)
   Die Farbwerte entsprechen app.ci_defaults (config/config.local.php) und
   deploy/ci-presets/neutral.json: Navy-Akzent, neutrales Grau statt Violett.
   Module und Produkt-CSS nutzen die --hirn-*-Aliasse (Typo-Skala, Radien,
   Schatten, semantische Farben) — sie folgen automatisch Theme und CI. */
:root {
    /* Typo-Skala (rem, Basis 16px; body bleibt Core: Inter, line-height 1.6) */
    --hirn-font-xs: 0.75rem;
    --hirn-font-sm: 0.8125rem;
    --hirn-font-base: 0.875rem;
    --hirn-font-md: 1rem;
    --hirn-font-lg: 1.125rem;
    --hirn-font-xl: 1.375rem;   /* = h1 im Core */
    --hirn-font-2xl: 1.75rem;
    --hirn-line-tight: 1.3;
    --hirn-line-normal: 1.5;
    --hirn-weight-strong: 600;

    /* Radien: --radius setzt das CI-Panel (ci_radius 0–18) */
    --radius: 10px;
    --hirn-radius-sm: max(calc(var(--radius) - 4px), 2px);
    --hirn-radius: var(--radius);
    --hirn-radius-lg: calc(var(--radius) + 6px);
    --hirn-radius-pill: 999px;

    /* Button-Verlauf neutral: flach in der Akzentfarbe (CI ci_gradient ueberschreibt) */
    --accent: #1f3a5f;
    --accent-2: #1f3a5f;
    --accent-gradient: var(--color-primary);
}

[data-theme="light"], :root {
    --color-primary: #1f3a5f;
    --color-primary-dark: #1a3151;
    --color-primary-light: #e9ebef;
    --color-chart2: #2a9d8f;
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-hover: #fafafb;
    --color-text: #1b1f2a;
    --color-text-muted: #6b6d75;
    --color-text-light: #989a9f;
    --color-border: #e3e5e9;
    --color-border-light: #f0f1f4;
    --shadow: 0 1px 2px rgba(27, 31, 42, 0.05), 0 4px 16px rgba(27, 31, 42, 0.06);
    --shadow-md: 0 4px 6px rgba(27, 31, 42, 0.06), 0 2px 4px rgba(27, 31, 42, 0.04);
    --shadow-lg: 0 10px 15px rgba(27, 31, 42, 0.06), 0 4px 6px rgba(27, 31, 42, 0.03);
    --tile-border: rgba(27, 31, 42, 0.06);
    --shadow-tile: 0 1px 2px rgba(27, 31, 42, 0.04), 0 6px 20px rgba(27, 31, 42, 0.08);
    --shadow-tile-hover: 0 2px 4px rgba(27, 31, 42, 0.05), 0 14px 32px rgba(27, 31, 42, 0.14);
    --login-gradient: linear-gradient(135deg, #eef2f7 0%, #f8f9fb 50%, #eef1f5 100%);
}

/* Dark: der Light-Block oben matcht ueber :root auch im Dark-Mode und steht nach
   themes.css — deshalb hier JEDE dort gesetzte Variable erneut (Grautoene und
   Schatten = Core-Dark-Werte aus themes.css). */
[data-theme="dark"] {
    /* Ableitung wie core/CiStyle.php, Akzent aber staerker aufgehellt (Text-Kontrast
       auf --color-surface 5.7:1 statt 3.6:1); --color-primary-dark = Akzent als Flaeche */
    --color-primary: #8493a7;
    --color-primary-dark: #1f3a5f;
    --color-primary-light: rgba(132, 147, 167, 0.15);
    --color-chart2: #62b8ae;
    --accent-gradient: var(--color-primary-dark);
    --color-bg: #09090b;
    --color-surface: #18181b;
    --color-surface-hover: #27272a;
    --color-text: #fafafa;
    --color-text-muted: #a1a1aa;
    --color-text-light: #71717a;
    --color-border: #27272a;
    --color-border-light: #1e1e22;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.3);
    --tile-border: #27272a;
    --shadow-tile: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.3);
    --shadow-tile-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 14px 32px rgba(0, 0, 0, 0.5);
    --login-gradient: linear-gradient(135deg, #09090b 0%, #0d1119 50%, #09090b 100%);
}

:root {
    /* Semantische Aliasse fuer Produkt- und Modul-CSS */
    --hirn-accent: var(--color-primary);
    --hirn-accent-fill: var(--accent-gradient, var(--color-primary));
    --hirn-ink: var(--color-text);
    --hirn-ink-muted: var(--color-text-muted);
    --hirn-surface: var(--color-surface);
    --hirn-ground: var(--color-bg);
    --hirn-line: var(--color-border);
    --hirn-warning: var(--color-warning);
    --hirn-danger: var(--color-error);
    --hirn-shadow-sm: var(--shadow);
    --hirn-shadow-md: var(--shadow-md);
    --hirn-shadow-lg: var(--shadow-lg);
}

/* Dark-Mode-Kontrast CI-abgeleiteter Farben (WCAG AA >= 4.5:1). Der CI-Block leitet
   im Dark-Mode --color-primary = lighten(Akzent, 0.28) ab — fuer dunkle Akzente
   (Navy, Weinrot) nur ~3:1 als Textfarbe. Korrektur auf body-Ebene, damit die
   Werte des CI-Blocks (am <html>) als Eingang dienen, ohne Zyklus:
   - Links: Akzent (--color-primary-dark = Roh-Akzent im CI-Dark-Set) zu 45 % mit Weiss
     -> >= 4.5:1 auf --color-surface auch fuer #000000. Ein CI-Linkfarbwert (ci_link)
     gilt damit nur noch im Light-Mode.
   - Sidebar-Text gedaempft: 88 % der starken Sidebar-Tinte ueber der Sidebar-Flaeche
     (helle CI-Sidebar wird im Dark-Mode mittelgrau, gedaempfte Tinte dort 3.7:1).
     Ohne CI-Sidebar ist --sidebar-ink-strong ungesetzt -> Deklaration ungueltig,
     der Core-Fallback --color-text-muted greift. */
[data-theme="dark"] body {
    --color-link: color-mix(in srgb, var(--color-primary-dark) 45%, #ffffff);
    --sidebar-ink: color-mix(in srgb, var(--sidebar-ink-strong) 88%, var(--sidebar-bg));
}

/* „Bug melden" in der Core-Werkzeugleiste (manifest.sidebar_tools des Moduls entwicklung, Core 0.74);
   Größe, Hover und Tooltip kommen aus .app-sidebar-tool. project.js setzt --loading, solange bug-mode.js lädt. */
.app-sidebar .hirn-bug-btn--loading { opacity: 0.5; cursor: progress; }

/* Lizenzbanner (F-011): Markup app/views/hirn/lizenz-banner.php, eingesetzt von project.js.
   Text in --color-text statt --color-warning — .alert--warning erreicht auf der hellen
   Warnflaeche kein WCAG AA (3.0:1); die Warnfarbe traegt nur der (umlaufende) Rahmen —
   keine farbige Linie links. In Entwicklungs-/Demo-Instanzen erscheint das Banner nie. */
.hirn-lizenz-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    border: 1px solid var(--hirn-warning);
    border-radius: var(--hirn-radius);
    background: var(--hirn-surface);
    color: var(--hirn-ink);
    box-shadow: var(--hirn-shadow-sm);
    font-size: var(--hirn-font-base);
    line-height: var(--hirn-line-normal);
}
.hirn-lizenz-banner--kulanz_vorbei,
.hirn-lizenz-banner--ungueltig { border-color: var(--hirn-danger); }
.hirn-lizenz-banner-close { flex: 0 0 auto; }
