/* === 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; }
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;
}

a { color: var(--color-primary); }
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;
    --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);
    --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);
    --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);
    --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; }

/* 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; }
/* === Navigation === */
.nav {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 60px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: nowrap;
    max-width: 100vw;
    overflow: visible;
    box-sizing: border-box;
}

.nav-brand a {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--color-primary);
    text-decoration: none;
    margin-right: 2.5rem;
    letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 0.25rem; align-items: center; flex: 1; min-width: 0; position: relative; }
.nav-link-group { display: flex; gap: 0.25rem; align-items: center; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.nav-burger { display: none; background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: 0.4rem; border-radius: var(--radius); align-items: center; justify-content: center; }
.nav-burger:hover { background: var(--color-bg); color: var(--color-text); }
.nav-burger-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 200px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 0.4rem; z-index: 200; display: flex; flex-direction: column; gap: 0.15rem; }
.nav-burger-menu[hidden] { display: none; }
.nav-burger-item { color: var(--color-text-muted); text-decoration: none; padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; }
.nav-burger-item:hover { background: var(--color-bg); color: var(--color-text); }
.nav-burger-item--active { background: var(--color-primary-light); color: var(--color-primary); }
.nav.nav--collapsed .nav-link-group { display: none; }
.nav.nav--collapsed .nav-burger { display: inline-flex; }

.nav-link {
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
}

.nav-link:hover { background: var(--color-bg); color: var(--color-text); }
.nav-link--active { background: var(--color-primary-light); color: var(--color-primary); }
.nav-link--right { margin-left: auto; }
.nav-profile { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; text-decoration: none; padding: 0.25rem 0.75rem; border-radius: var(--radius); transition: background 0.15s; }
.nav-profile:hover { background: var(--color-surface-hover); }
.nav-profile--active { background: var(--color-surface-hover); }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: #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; }
.nav-profile-info { display: flex; flex-direction: column; line-height: 1.2; }
.nav-profile-name { color: var(--color-text); font-size: 0.8rem; font-weight: 600; }
.nav-profile-role { color: var(--color-text-muted); font-size: 0.65rem; }
.nav-link--logout { margin-left: auto; color: var(--color-text-muted); }
.nav-link--logout:hover { color: var(--color-error); background: var(--color-error-light); }

/* === 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; }

/* ============================================================
 * 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;
}

body[data-layout="sidebar"] .nav { display: none; }

/* 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;
}
/* Eingeklappt: Chevron der Submenue-Parents entfaellt (kein Platz in der Rail). */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-link-chevron { display: none; }
/* Eingeklappt: Submenue-Liste ausblenden — die Rail zeigt nur die Modul-Icons. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-submenu { display: none; }
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: 4px 10px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.app-sidebar-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-gradient, var(--color-primary));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 15px;
    flex: 0 0 auto;
    text-decoration: none;
}
/* Vollbreiten-Logo (ci_logo_mode = 'full'): Logo oben, Titel darunter — statt
   Logo und Titel nebeneinander. Die Breite kommt als Inline-Style aus ci_logo_width. */
.app-sidebar-brand--full {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}
.app-sidebar-brand-full {
    display: flex;
    justify-content: center;
    text-decoration: none;
}
.app-sidebar-brand-full-img {
    max-width: 100%;
    height: auto;
    display: block;
}
/* Im Vollbreiten-Modus traegt der Titel die Zeile — die kleine Marke waere
   doppelt gemoppelt. */
.app-sidebar-brand--full { position: relative; }
.app-sidebar-brand--full .app-sidebar-brand-mark { display: none; }
.app-sidebar-brand--full .app-sidebar-brand-name {
    flex: none;
    text-align: center;
    align-self: center;
    max-width: 100%;
}
/* Einklapp-Pfeil oben rechts statt in einer eigenen Zeile: sonst kostet er
   Hoehe und schiebt die Navigation nach unten. */
.app-sidebar-brand--full .app-sidebar-collapse-btn {
    position: absolute;
    top: 0;
    right: 0;
}

/* Eingeklappte Icon-Rail (66px): kein Platz fuer ein breites Logo — dort gilt
   wieder die quadratische Marke, unabhaengig vom gewaehlten Modus. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand--full { flex-direction: row; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-full { display: none; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand--full .app-sidebar-brand-mark { display: grid; }

.app-sidebar-brand-letter { display: grid; place-items: center; }
/* Hochgeladenes Logo (CI-Feld ci_logo) fuellt die Marke statt des Buchstabens. */
.app-sidebar-brand-logo { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block; }
.app-sidebar-brand-expand { display: none; place-items: center; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-mark:hover .app-sidebar-brand-logo { display: none; }
/* Eingeklappt: Hover ueber die Marke tauscht Logo/Buchstabe gegen das Aufklapp-Icon
 * (Klick klappt auf, siehe app.js). Ausgeklappt ist die Marke der Dashboard-Link. */
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-mark { cursor: pointer; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-mark:hover .app-sidebar-brand-letter { display: none; }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-brand-mark:hover .app-sidebar-brand-expand { display: grid; }
.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); }
.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); 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;
}

.app-sidebar-module {
    display: block;
}

/* Gruppen-Ueberschrift in der Nav (manifest.nav_group + config app.nav_groups) */
.app-sidebar-group-label {
    padding: 1rem 1.25rem 0.35rem;
    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);
    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: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
/* 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;
}
.app-sidebar-link-chevron {
    transition: transform 0.15s;
    opacity: 0.6;
    font-size: 0.7rem;
}
.app-sidebar-module--expanded > .app-sidebar-link .app-sidebar-link-chevron {
    transform: rotate(90deg);
}

/* Submenue eines Moduls (manifest.sidebar): eingerueckte Pills im GLEICHEN Stil
   wie die Modul-Links — kein Border-Left, kein Fremd-Hintergrund (der frueher die
   dunkle Sidebar als weisse Box durchbrach), abgerundet. Hover = zarter Ink-Wash,
   Active = Primaerfarbe dezent auf Surface. */
.app-sidebar-submenu {
    display: none;
    margin: 2px 0 4px;
    padding-left: 20px;
}
.app-sidebar-module--expanded .app-sidebar-submenu { display: block; }

.app-sidebar-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: calc(var(--radius) - 3px);
    color: var(--sidebar-ink, var(--color-text-muted));
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}
.app-sidebar-subitem: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-subitem--active {
    background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
    color: var(--color-primary);
    font-weight: 600;
}

.app-sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.app-sidebar-footer-btn {
    background: none;
    border: none;
    padding: 0.4rem;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.app-sidebar-footer-btn:hover { background: var(--color-bg); color: var(--color-text); }
.app-sidebar-footer-profile { margin-left: auto; }

/* 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;
    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)); }
body[data-layout="sidebar"][data-sidebar-collapsed="1"] .app-sidebar-collapse-btn { display: none; }

/* 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);
}

/* Top-Nav Profil-Button (im Topnav-Layout) */
.nav-profile--btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}

/* === Page Header === */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { margin-bottom: 0; }

.page-subline { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* Core-Version rechts oben im Einstellungs-Header — dezente Marke, kein Blickfang:
   sie soll auffindbar sein (Support/Update-Frage), nicht um Aufmerksamkeit buhlen. */
.core-version {
    flex: 0 0 auto;
    align-self: flex-start;
    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;
}

/* === Split-Layout (z.B. Einstellungen: Form links, Vorschau rechts) === */
.split { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; align-items: start; }
.split--ci { grid-template-columns: 1fr 1fr; }
.split > div > .card + .card { margin-top: 1rem; }

@media (max-width: 1100px) {
    .split--ci { grid-template-columns: 1fr; }
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* === Breadcrumb === */
.breadcrumb {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
.breadcrumb a { color: var(--color-text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-primary); }

/* === 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); border: 1px solid rgba(52, 211, 153, 0.2); }
.alert--error   { background: var(--color-error-light); color: var(--color-error);     border: 1px solid rgba(248, 113, 113, 0.2); }
.alert--warning { background: var(--color-warning-light); color: var(--color-warning); border: 1px solid rgba(251, 191, 36, 0.2); }

/* 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; }
@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; }

/* === 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;
}

.section-card-header {
    padding: 1rem 1rem 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.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; }
.tabs-select[hidden] { display: none; }

/* === 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: #fff; }
/* Hover bewusst dezent (CI-Default): der Verlauf bleibt sichtbar, nur leicht abgedunkelt. */
.btn--primary:hover { filter: brightness(0.96); color: #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); }

.btn--danger { background: var(--color-error); color: #fff; }
.btn--danger:hover { background: #dc2626; color: #fff; }

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

.btn--sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn--full { width: 100%; }
.btn--icon { padding: 0.5rem; width: 36px; height: 36px; border-radius: var(--radius); background: var(--color-bg); color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--icon:hover { background: var(--color-border-light); color: var(--color-text); }

/* === 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%));
}

.login-branding { text-align: center; margin-bottom: 1.5rem; }
.login-branding-logo { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.03em; color: var(--color-text); }
.login-branding-logo span { color: var(--color-primary); }
.login-branding-tagline { font-size: 2rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.04em; margin-top: 0.75rem; color: var(--color-text); }
.login-branding-tagline em { font-style: normal; background: linear-gradient(135deg, var(--color-primary), #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.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;
}

.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; }
.login-legal a { color: var(--color-primary); text-decoration: none; }
.login-legal a:hover { text-decoration: underline; }

/* === Tags/Badges === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge--success { background: var(--color-success-light); color: var(--color-success); }
.badge--warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge--error   { background: var(--color-error-light); color: var(--color-error); }
.badge--muted   { background: #f3f4f6; color: var(--color-text-muted); }

/* Farben fuer Auswahl-Options (Lead-Phase etc.) — bewusst heller Hintergrund + sattere Textfarbe */
.badge--blue    { background: #dbeafe; color: #1e40af; }
.badge--purple  { background: #ede9fe; color: #6d28d9; }
.badge--teal    { background: #ccfbf1; color: #0f766e; }
.badge--green   { background: #dcfce7; color: #166534; }
.badge--yellow  { background: #fef3c7; color: #92400e; }
.badge--orange  { background: #ffedd5; color: #9a3412; }
.badge--red     { background: #fee2e2; color: #991b1b; }
.badge--pink    { background: #fce7f3; color: #9d174d; }
.badge--brown   { background: #f5e8d8; color: #78350f; }
.badge--gray    { background: #e5e7eb; color: #374151; }

/* Dot-Pille (CI-Default): Status-Optik mit vorangestelltem Punkt. Die Farbe
   kommt ueber die .badge--*-Klassen (z.B. class="pill badge--green"), currentColor
   faerbt den Punkt mit. */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

/* 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; }
tr:hover td { background: var(--color-surface-hover); }

/* === 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; }
tr.clickable-row { 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; }

/* 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: #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);
}

/* Abstand zwischen Settings-Boxen kommt jetzt zentral vom .section-card-Default
   (margin-bottom, siehe oben); der fruehere .settings-content-Adjacency-Block
   war toter Code (kein View nutzt .settings-content). */
.section-card { min-height: 55px; } /* IGEPA_SECTION_MINHEIGHT */

/* === Login/Auth === */
/* Auth-spezifische Overrides (vormals public.css); ergaenzen den Login-Block oben.
   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; }
.login-branding-logo span { color: var(--color-primary); }
.login-branding-tagline { font-size: 0.85rem; color: var(--color-text-muted); }
.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; }
.login-legal a { color: var(--color-primary); text-decoration: none; }
.login-legal a:hover { text-decoration: underline; }

/* === 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;
}
.modal[hidden] { display: none; }
body.modal-open { overflow: hidden; }   /* ... die Seite dahinter bleibt fix */

.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;
}
.modal-dialog--sm { max-width: 360px; }
.modal-dialog--lg { max-width: 760px; }

.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; }
.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;
}

/* === 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); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 220px), 1fr)); }
@media (max-width: 900px) {
    .grid--cols-3, .grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .grid--cols-2, .grid--cols-3, .grid--cols-4 { grid-template-columns: 1fr; }
}

/* === 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 + .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; }

/* === Tab-Panels (Reiter-Inhalt; .tabs/.tab existieren bereits oben) === */
.tab-panel[hidden] { display: none; }

/* === Element-Katalog (showcase/index.php): Demo-Bausteine === */
.demo-swatch {
    height: 44px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
}
.demo-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.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); }

/* --- 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-left: 3px solid var(--color-primary, #4f46e5);
    border-radius: var(--radius, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.85rem;
    line-height: 1.3;
}
.ct-job.is-done { border-left-color: var(--color-success, #16a34a); }
.ct-job.is-failed { border-left-color: 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;
}
/* === Responsive === */
@media (max-width: 768px) {
    .nav { padding: 0 1rem; }
    .nav-link--logout { margin-left: 0; }
    .container, .container--narrow, .container--wide { padding: 1rem; }
    .module-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .lp-hero h1 { font-size: 2.25rem; }
    .lp-hero-grid { grid-template-columns: 1fr !important; text-align: center; }
    .lp-hero-grid .lp-hero-cta { justify-content: center; }
    .lp-grid--3, .lp-grid--4, .lp-grid--5 { grid-template-columns: 1fr; }
    .lp-feature-grid { grid-template-columns: 1fr !important; }
    .lp-feature-grid .lp-card { grid-column: span 1 !important; grid-template-columns: 1fr !important; }
    .lp-steps { grid-template-columns: 1fr 1fr; gap: 1.5rem; }
    .lp-stats { grid-template-columns: repeat(2, 1fr); }
    .lp-footer-grid { grid-template-columns: 1fr 1fr !important; }
    .lp-contact-grid { grid-template-columns: 1fr !important; gap: 2rem !important; }
    .lp-funktionen-grid { grid-template-columns: 1fr !important; }
    .lp-nav-center { display: none; }
    .lp-nav-right { gap: 0.25rem; }
}
/* =========================================================================
 * 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.
 * ========================================================================= */

@media (display-mode: standalone) {
    /* Safe-Area-Padding fuer fixierte Kopf-/Fussleisten und 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 Topnav unter die Statusbar/Notch schieben. */
    .topnav,
    .app-header {
        padding-top: calc(env(safe-area-inset-top) + 0.25rem);
    }

    /* Lange Listen/Scrollbereiche unten frei vom Home-Indicator halten. */
    .main-content,
    .app-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 .topnav,
.pwa-standalone .app-header {
    padding-top: calc(env(safe-area-inset-top) + 0.25rem);
}

/* 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;
    }
}
/* URACA Dokumentenportal — Projekt-CSS (Erweiterungspunkt, kommt als letzte
   Datei ins Bundle und darf Core-Variablen ueberschreiben). */

/* Marken-Variablen leiten sich aus den CI-Einstellungen ab (app_settings →
   core/CiStyle.php, injiziert als [data-theme="light"]/[dark] nach dem Bundle).
   Aendert der Betreiber die CI-Farben, ziehen Bibliothek + Portal automatisch
   nach. Die Hex-Werte sind nur Fallback, falls keine CI-Werte gesetzt sind. */
:root {
    --uraca-red: var(--color-primary, #C8102E);
    --uraca-ink: var(--color-text, #1F2429);
    --uraca-steel: var(--color-text-muted, #5A6570);
    --uraca-bg: var(--color-bg, #F5F6F7);
}

/* ==== Oeffentliches Layout (layouts/public.php) ==== */

.public-body {
    margin: 0;
    background: var(--uraca-bg);
    color: var(--uraca-ink);
    font-family: 'Inter', system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.public-header {
    background: #fff;
    border-bottom: 3px solid var(--uraca-red);
}
.public-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.public-brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
    text-decoration: none;
}
.public-brand-logo {
    display: block;
    height: 40px;
    width: auto;
    max-width: 220px;
}
.public-brand-mark {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--uraca-red);
}
.public-brand-claim {
    font-size: 13px;
    color: var(--uraca-steel);
    letter-spacing: .5px;
    text-transform: uppercase;
}
.public-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}
.public-nav a {
    text-decoration: none;
    color: var(--uraca-ink);
    font-size: 14px;
    font-weight: 500;
}
.public-nav a:hover { color: var(--uraca-red); }
.public-nav-login {
    border: 1px solid var(--uraca-red);
    color: var(--uraca-red) !important;
    padding: 6px 14px;
    border-radius: 6px;
}
.public-nav-login:hover { background: var(--uraca-red); color: #fff !important; }

.public-main {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    box-sizing: border-box;
}

.public-flash {
    max-width: 1100px;
    margin: 12px auto 0;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
}
.public-flash-success { background: #e6f4ea; color: #1e6b3a; }
.public-flash-error   { background: #fdecec; color: #a12626; }
.public-flash-info    { background: #eaf1f8; color: #2a5a8c; }

.public-footer {
    background: var(--uraca-ink);
    color: #cfd5da;
    font-size: 13px;
}
.public-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.public-footer-links { display: flex; gap: 16px; }
.public-footer a { color: #cfd5da; text-decoration: none; }
.public-footer a:hover { color: #fff; }

@media (max-width: 640px) {
    .public-header-inner { flex-direction: column; align-items: flex-start; }
}

/* ==== Oeffentliche Bibliothek (Modul bibliothek) ==== */

.lib-hero { text-align: center; padding: 32px 0 40px; }
.lib-hero h1 { font-size: 30px; margin: 0 0 10px; }
.lib-hero p { color: var(--uraca-steel); max-width: 620px; margin: 0 auto 20px; }
.lib-hero-hint { font-size: 13px; }
.lib-hero-hint a { color: var(--uraca-red); }

.lib-search-form {
    display: flex;
    gap: 8px;
    max-width: 620px;
    margin: 0 auto;
    flex-wrap: wrap;
}
.lib-search-form input[type="search"] {
    flex: 1;
    min-width: 220px;
    padding: 11px 14px;
    border: 1px solid #cfd5da;
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
}
.lib-search-form select {
    padding: 10px 12px;
    border: 1px solid #cfd5da;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
}
.lib-search-form button {
    background: var(--uraca-red);
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 11px 22px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.lib-search-form button:hover { filter: brightness(.92); }
.lib-search-form-page { margin: 0 0 20px; max-width: none; }

.lib-groups h2 { font-size: 20px; margin: 8px 0 16px; }
.lib-group-grid, .lib-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.lib-group-card, .lib-product-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 8px;
    padding: 18px;
    text-decoration: none;
    color: var(--uraca-ink);
    transition: border-color .12s, box-shadow .12s;
}
.lib-group-card:hover, .lib-product-card:hover {
    border-color: var(--uraca-red);
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.lib-group-icon { width: 34px; height: 34px; color: var(--uraca-red); }
.lib-group-icon svg { width: 100%; height: 100%; }
.lib-group-name { font-size: 16px; font-weight: 700; }
.lib-group-desc { font-size: 13px; color: var(--uraca-steel); }
.lib-group-count, .lib-product-count {
    margin-top: auto;
    font-size: 12px;
    color: var(--uraca-steel);
    text-transform: uppercase;
    letter-spacing: .4px;
}
.lib-product-model {
    font-size: 12px;
    font-weight: 700;
    color: var(--uraca-red);
    letter-spacing: .6px;
}
.lib-product-name { font-size: 16px; font-weight: 700; }
.lib-product-subtitle { font-size: 13px; color: var(--uraca-steel); }

.lib-breadcrumb { font-size: 13px; color: var(--uraca-steel); margin-bottom: 14px; }
.lib-breadcrumb a { color: var(--uraca-steel); text-decoration: none; }
.lib-breadcrumb a:hover { color: var(--uraca-red); }
.lib-breadcrumb span { margin: 0 6px; }
.lib-lead { color: var(--uraca-steel); }

.lib-product-head {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.lib-product-head h1 { margin: 2px 0 8px; }
.lib-product-model-big {
    font-size: 13px;
    font-weight: 700;
    color: var(--uraca-red);
    letter-spacing: 1px;
}
.lib-specs {
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 8px;
    font-size: 13px;
    min-width: 260px;
}
.lib-specs th, .lib-specs td { padding: 7px 12px; text-align: left; border-bottom: 1px solid #eef1f3; }
.lib-specs tr:last-child th, .lib-specs tr:last-child td { border-bottom: 0; }
.lib-specs th { color: var(--uraca-steel); font-weight: 500; white-space: nowrap; }

.lib-docs { margin-top: 22px; }
.lib-docs-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.lib-docs-head h2 { font-size: 20px; margin: 0; }
.lib-lang-pills { display: flex; gap: 6px; }
.lib-lang-pill {
    border: 1px solid #cfd5da;
    background: #fff;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
}
.lib-lang-pill.is-active {
    background: var(--uraca-red);
    border-color: var(--uraca-red);
    color: #fff;
}
.lib-doc-type { font-size: 15px; margin: 18px 0 8px; color: var(--uraca-steel); }
.lib-doc-list { list-style: none; margin: 0; padding: 0; }
.lib-doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 8px;
    padding: 11px 14px;
    margin-bottom: 8px;
}
.lib-doc-lang {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    background: var(--uraca-bg);
    border: 1px solid #e2e6e9;
    border-radius: 4px;
    padding: 3px 7px;
    color: var(--uraca-steel);
}
.lib-doc-title { flex: 1; font-size: 14px; font-weight: 500; }
.lib-doc-number { color: var(--uraca-steel); font-weight: 400; font-size: 12px; margin-left: 6px; }
.lib-doc-meta { display: block; font-size: 12px; color: var(--uraca-steel); font-weight: 400; margin-top: 2px; }
.lib-doc-meta a { color: var(--uraca-red); text-decoration: none; }
.lib-doc-actions { display: flex; gap: 12px; font-size: 13px; }
.lib-doc-actions a { color: var(--uraca-red); text-decoration: none; font-weight: 600; }
.lib-doc-actions a:hover { text-decoration: underline; }

.lib-result-count { color: var(--uraca-steel); font-size: 13px; }
.lib-pagination { display: flex; gap: 6px; margin-top: 14px; }
.lib-pagination a {
    border: 1px solid #cfd5da;
    border-radius: 6px;
    padding: 5px 11px;
    text-decoration: none;
    color: var(--uraca-ink);
    font-size: 13px;
}
.lib-pagination a.is-active {
    background: var(--uraca-red);
    border-color: var(--uraca-red);
    color: #fff;
}

/* ==== Kundenportal (Modul portal, eingeloggtes App-Layout) ==== */
.portal-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.portal-head h1 { margin: 0 0 4px; }
.portal-sub { color: var(--uraca-steel); font-size: 13px; margin: 0; }

.portal-toggle { display: flex; gap: 6px; }
.portal-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #cfd5da;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--uraca-ink);
}
.portal-toggle-btn svg { width: 15px; height: 15px; }
.portal-toggle-btn.is-active {
    background: var(--uraca-red);
    border-color: var(--uraca-red);
    color: #fff;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.portal-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 10px;
    padding: 16px;
    text-decoration: none;
    color: var(--uraca-ink);
    transition: border-color .15s, box-shadow .15s;
}
.portal-card:hover {
    border-color: var(--uraca-red);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
}
.portal-card-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 96px;
    border-radius: 8px;
    background: var(--uraca-bg);
    color: var(--uraca-steel);
    margin-bottom: 4px;
    overflow: hidden;
}
.portal-card-visual svg { width: 44px; height: 44px; }
.portal-card-visual img { width: 100%; height: 100%; object-fit: cover; }
.portal-card-name { font-size: 15px; font-weight: 600; }
.portal-card-meta { font-size: 12px; color: var(--uraca-steel); }
.portal-card-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--uraca-red);
    margin-top: 2px;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 10px;
    overflow: hidden;
    font-size: 14px;
}
.portal-table th, .portal-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #eef1f3;
}
.portal-table tr:last-child td { border-bottom: 0; }
.portal-table th {
    color: var(--uraca-steel);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.portal-table td a { color: var(--uraca-red); text-decoration: none; font-weight: 600; }
.portal-table td a:hover { text-decoration: underline; }
.portal-table-num { text-align: right; }

/* ===== Verwaltung (Admin-Backoffice) ===== */
.vw-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.vw-head h1 { font-size: 22px; margin: 0; }
.vw-h2 { font-size: 16px; margin: 0 0 10px; }
.vw-sub { font-size: 13px; color: var(--uraca-steel); margin: 4px 0 0; }

.vw-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.vw-stat {
    display: block;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 10px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.vw-stat:hover { border-color: var(--uraca-red); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.vw-stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.vw-stat-label { font-size: 12px; color: var(--uraca-steel); margin-top: 2px; }

/* ---- Dashboard: Verteilungs-Balken + Aktivitaets-Feeds ---- */
.vw-dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; align-items: start; }
@media (max-width: 820px) { .vw-dash-grid { grid-template-columns: 1fr; } }
.vw-dash-grid .section-card { margin-bottom: 0; }
.vw-muted { font-size: 12px; color: var(--uraca-steel); }
.vw-link { font-size: 12px; font-weight: 600; color: var(--uraca-red); text-decoration: none; }
.vw-link:hover { text-decoration: underline; }
.vw-hint { font-size: 12px; color: var(--uraca-steel); margin: 10px 0 0; }

.vw-bar-row { margin-bottom: 12px; }
.vw-bar-row:last-child { margin-bottom: 0; }
.vw-bar-label { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 5px; }
.vw-bar-label strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.vw-bar { height: 8px; background: #eef1f2; border-radius: 5px; overflow: hidden; }
.vw-bar-fill { display: block; height: 100%; background: var(--uraca-steel); border-radius: 5px; min-width: 2px; }
.vw-bar-fill--blue { background: #2f6fb0; }
.vw-bar-fill--orange { background: #d68a2e; }

.vw-feed { list-style: none; margin: 0; padding: 0; }
.vw-feed-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #eef1f2; font-size: 13px; }
.vw-feed-item:first-child { border-top: 0; padding-top: 0; }
.vw-feed-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vw-feed-meta { margin-left: auto; color: var(--uraca-steel); font-size: 12px; white-space: nowrap; }

.vw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.vw-table th, .vw-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #eef1f3;
}
/* Zellen vertikal mittig, damit Text und Buttons auf einer Linie sitzen. */
.vw-table td { vertical-align: middle; }
.vw-table th { vertical-align: bottom; }
.vw-table th {
    color: var(--uraca-steel);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.vw-table tr:last-child td { border-bottom: 0; }
.vw-table .vw-num { text-align: right; }
.vw-table .vw-actions { text-align: right; white-space: nowrap; }
.vw-table td a { color: var(--uraca-red); text-decoration: none; font-weight: 600; }
.vw-table td a:hover { text-decoration: underline; }
.vw-table td a.btn { color: inherit; font-weight: 500; }

.vw-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 14px;
}
.vw-filter .form-group { margin-bottom: 0; }
.vw-filter input[type="text"], .vw-filter input[type="search"] { min-width: 220px; }

.vw-form-card { max-width: 720px; }
.vw-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 640px) { .vw-form-row { grid-template-columns: 1fr; } }
.vw-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}
.vw-check input[type="checkbox"] { width: auto; margin: 0; }

.vw-checklist {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #e2e6e9;
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
}
.vw-checklist label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
}
.vw-checklist input[type="checkbox"] { width: auto; margin: 0; }

.vw-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.vw-inline-form input { max-width: 260px; }

.portal-preview-banner {
    background: #fff7e6;
    border: 1px solid #f0c36d;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}
.portal-preview-banner a { color: var(--uraca-red); font-weight: 600; }
.portal-preview-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.portal-preview-pick select {
    border: 1px solid #e2c48a; border-radius: 6px; padding: 5px 8px; font-size: 13px; background: #fff;
}

/* ==== Produktzentriertes Kundenportal (v0.2) ==== */
.portal-card-group {
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--uraca-steel); font-weight: 600;
}
.portal-card-cta { margin-top: auto; font-size: 12px; font-weight: 600; color: var(--uraca-red); }

.portal-empty {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 48px 20px; color: var(--uraca-steel); text-align: center;
    border: 1px dashed #d3d8dc; border-radius: 12px; background: #fff;
}
.portal-empty svg { width: 42px; height: 42px; opacity: .5; }

/* Sprach-Pills */
.portal-lang { display: inline-flex; gap: 4px; }
.portal-lang-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 30px; padding: 0 8px; border-radius: 6px;
    border: 1px solid #d8dde1; background: #fff; color: var(--uraca-steel);
    font-size: 12px; font-weight: 700; text-decoration: none; letter-spacing: .03em;
}
.portal-lang-pill:hover { border-color: var(--uraca-red); color: var(--uraca-red); }
.portal-lang-pill.is-active { background: var(--uraca-red); border-color: var(--uraca-red); color: #fff; }

/* Detailseite */
.portal-detail-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.portal-back { color: var(--uraca-steel); text-decoration: none; font-size: 14px; font-weight: 600; }
.portal-back:hover { color: var(--uraca-red); }
.portal-detail-head { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 26px; }
.portal-detail-visual {
    flex: 0 0 140px; height: 140px; border-radius: 12px; background: var(--uraca-bg);
    display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--uraca-steel);
}
.portal-detail-visual svg { width: 60px; height: 60px; }
.portal-detail-visual img { width: 100%; height: 100%; object-fit: cover; }
.portal-detail-group { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--uraca-steel); font-weight: 600; }
.portal-detail-head h1 { margin: 4px 0 6px; }
.portal-detail-model { margin: 0 0 4px; font-size: 14px; color: var(--uraca-ink); font-weight: 600; }
.portal-detail-sub { margin: 0; color: var(--uraca-steel); font-size: 14px; }
.portal-section-title { font-size: 16px; margin: 0 0 14px; }

.portal-variant { margin-bottom: 22px; }
.portal-variant-title { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.portal-variant-code { font-size: 11px; font-weight: 600; color: var(--uraca-steel); background: var(--uraca-bg); border-radius: 5px; padding: 2px 7px; }
.portal-variant-empty { color: var(--uraca-steel); font-size: 13px; margin: 0 0 4px; }

.portal-doclist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.portal-doc {
    display: flex; align-items: center; gap: 12px; background: #fff;
    border: 1px solid #e2e6e9; border-radius: 10px; padding: 12px 14px;
}
.portal-doc-icon { flex: 0 0 auto; color: var(--uraca-red); }
.portal-doc-icon svg { width: 22px; height: 22px; }
.portal-doc-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.portal-doc-title { font-weight: 600; font-size: 14px; }
.portal-doc-meta { font-size: 12px; color: var(--uraca-steel); }
.portal-doc-lang { font-weight: 700; color: var(--uraca-ink); }
.portal-doc-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.portal-doc-btn {
    display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 7px;
    font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
    background: var(--uraca-red); color: #fff; border: 1px solid var(--uraca-red);
}
.portal-doc-btn:hover { filter: brightness(.94); }
.portal-doc-btn--ghost { background: #fff; color: var(--uraca-red); }

/* Immer sichtbare Bedienelemente (Kontakt + Chat) */
.portal-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 60;
    display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.portal-fab-btn {
    display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px;
    border-radius: 24px; border: 0; cursor: pointer; font-size: 14px; font-weight: 600;
    box-shadow: 0 6px 18px rgba(0,0,0,.16);
}
.portal-fab-btn svg { width: 18px; height: 18px; }
.portal-fab-contact { background: var(--uraca-red); color: #fff; }
.portal-fab-chat { background: #fff; color: var(--uraca-ink); border: 1px solid #dfe3e6; }
.portal-fab-btn:hover { filter: brightness(.96); }

/* Modal (Kontakt) */
.portal-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; }
/* hidden-Attribut muss das display der Overlays schlagen (Attribut-Spezifitaet). */
.portal-modal[hidden], .portal-chat[hidden] { display: none; }
.portal-modal-backdrop { position: absolute; inset: 0; background: rgba(20,24,28,.45); }
.portal-modal-box {
    position: relative; background: #fff; border-radius: 14px; padding: 26px 28px;
    width: min(440px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
.portal-modal-box h2 { margin: 0 0 8px; font-size: 19px; }
.portal-modal-intro { margin: 0 0 16px; color: var(--uraca-steel); font-size: 14px; }
.portal-modal-x {
    position: absolute; top: 12px; right: 14px; background: none; border: 0; cursor: pointer;
    font-size: 24px; line-height: 1; color: var(--uraca-steel);
}
.portal-contact-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; }
.portal-contact-list dt { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--uraca-steel); font-weight: 600; align-self: center; }
.portal-contact-list dd { margin: 0; font-size: 15px; }
.portal-contact-list a { color: var(--uraca-red); text-decoration: none; font-weight: 600; }
.portal-contact-addr { margin: 0; font-size: 12px; color: var(--uraca-steel); }

/* Chat-Assistent */
.portal-chat {
    position: fixed; right: 22px; bottom: 22px; z-index: 85;
    width: min(380px, 94vw); height: min(520px, 76vh);
    background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.28);
    display: flex; flex-direction: column; overflow: hidden; border: 1px solid #e2e6e9;
}
.portal-chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; background: var(--uraca-red); color: #fff;
}
.portal-chat-head .portal-modal-x { position: static; color: #fff; }
.portal-chat-log { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--uraca-bg); }
.portal-chat-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-line; }
.portal-chat-msg--bot { align-self: flex-start; background: #fff; border: 1px solid #e2e6e9; }
.portal-chat-msg--user { align-self: flex-end; background: var(--uraca-red); color: #fff; }
.portal-chat-msg.is-pending { opacity: .6; font-style: italic; }
.portal-chat-sources { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #eceef0; }
.portal-chat-sources a { font-size: 12px; color: var(--uraca-red); text-decoration: none; font-weight: 600; }
.portal-chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e6e9; }
.portal-chat-form input { flex: 1 1 auto; border: 1px solid #d8dde1; border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.portal-chat-form button { border: 0; background: var(--uraca-red); color: #fff; border-radius: 8px; padding: 0 16px; font-weight: 600; cursor: pointer; }

/* Ansichtsswitch in der Sidebar (per project.js injiziert).
   Farben aus den Core-Sidebar-Tokens (--sidebar-ink*), damit der Switch auf
   heller wie dunkler Sidebar lesbar bleibt — der Core kontrastiert diese
   Tokens automatisch zur gewaehlten Sidebar-Farbe. */
.portal-viewswitch {
    display: flex; gap: 4px; margin: 10px 12px 6px; padding: 4px;
    background: color-mix(in srgb, var(--sidebar-ink, var(--color-text-muted)) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--sidebar-ink, var(--color-text-muted)) 14%, transparent);
    border-radius: 9px;
}
.portal-viewswitch-seg {
    flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; border-radius: 6px; text-decoration: none; font-size: 12px; font-weight: 600;
    color: var(--sidebar-ink, var(--color-text-muted)); opacity: .85;
}
.portal-viewswitch-seg svg { width: 15px; height: 15px; }
.portal-viewswitch-seg:hover {
    opacity: 1;
    background: color-mix(in srgb, var(--sidebar-ink, var(--color-text-muted)) 9%, transparent);
    color: var(--sidebar-ink-strong, var(--color-text));
}
.portal-viewswitch-seg.is-active {
    background: var(--uraca-red); color: #fff; opacity: 1;
}
.portal-viewswitch-seg.is-active:hover { color: #fff; }

/* ---- Dokumente: Ordnerbaum (Gruppe > Produkt > Variante > Sprachvariante) ---- */
.vw-head-actions { display: flex; gap: 8px; }
.lang-pill {
    display: inline-block; min-width: 30px; text-align: center;
    padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 700;
    background: var(--uraca-red); color: #fff; letter-spacing: .3px;
}

/* Eine durchgehende Box; Einrueckung pro Ebene via --d; Akkordeon via <details name>. */
.doc-tree {
    --dt-indent: 22px;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 12px;
    overflow: hidden;
}
.dt-folder { border: 0; }
.dt-row, .dt-empty, .dt-doc, .dt-actions, .dt-newvariant-toggle, .dt-newvariant-form {
    padding-left: calc(16px + var(--d, 0) * var(--dt-indent));
    border-top: 1px solid #eef1f2;
}
.doc-tree > .dt-folder:first-child > .dt-row { border-top: 0; }

.dt-row {
    display: flex; align-items: center; gap: 9px;
    padding-top: 10px; padding-bottom: 10px; padding-right: 16px;
    cursor: pointer; list-style: none; user-select: none; font-size: 14px;
}
.dt-row { list-style: none; }
.dt-row::-webkit-details-marker { display: none; }
.dt-row::marker { content: ""; }
.dt-row:hover { background: #f7f8f9; }
.dt-row--group { background: #fbfcfc; }
details[open] > .dt-row--group { background: #f4f6f7; }
.dt-caret { flex: 0 0 auto; color: var(--uraca-steel); transition: transform .15s; }
details[open] > .dt-row > .dt-caret { transform: rotate(90deg); }
.dt-icon { flex: 0 0 auto; color: var(--uraca-red); }
.dt-icon--variant { color: var(--uraca-steel); }
.dt-label { font-weight: 600; }
.dt-row--group > .dt-label { font-weight: 700; }
.dt-row code { font-size: 12px; color: var(--uraca-steel); }

.dt-empty { color: var(--uraca-steel); font-size: 13px; margin: 0; padding: 9px 16px; }

.dt-actions {
    display: flex; align-items: center; gap: 8px;
    padding-top: 9px; padding-bottom: 9px; padding-right: 16px;
    background: #fcfcfd;
}
.dt-inline { display: inline; margin: 0; }

.dt-doc {
    display: flex; align-items: center; gap: 10px;
    padding-top: 8px; padding-bottom: 8px; padding-right: 16px;
    font-size: 13px;
}
.dt-doc-title { font-weight: 600; }
.dt-doc-type { color: var(--uraca-steel); }
.dt-doc-actions { margin-left: auto; display: flex; gap: 6px; white-space: nowrap; }

.dt-newvariant-toggle {
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--uraca-red);
    list-style: none; padding-top: 9px; padding-bottom: 9px; padding-right: 16px;
}
.dt-newvariant-toggle { list-style: none; }
.dt-newvariant-toggle::-webkit-details-marker { display: none; }
.dt-newvariant-toggle::marker { content: ""; }
.dt-newvariant-form {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding-top: 10px; padding-bottom: 12px; padding-right: 16px; background: #fcfcfd;
}
.dt-newvariant-form input { font-size: 13px; }

/* ---- Zwei-Spalten-Raster (Upload-Maske, Mail-Vorschau) ---- */
.doc-upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .doc-upload-grid { grid-template-columns: 1fr; } }

/* ---- Gestapeltes Formular ---- */
.vw-form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.vw-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--uraca-steel); }
.vw-form input, .vw-form select, .vw-form textarea { font-size: 14px; font-weight: 400; }
.vw-form textarea { resize: vertical; font-family: inherit; }
.vw-form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---- Kundenverwaltung: Produkt-Zuordnungsraster ---- */
.assign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.assign-group { border: 1px solid #e2e6e9; border-radius: 8px; padding: 10px 12px; margin: 0; }
.assign-group legend { font-size: 12px; font-weight: 700; color: var(--uraca-steel); text-transform: uppercase; letter-spacing: .4px; padding: 0 4px; }
.assign-item { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 14px; cursor: pointer; }
.assign-item input[type="checkbox"] { width: auto; margin: 0; }
.assign-item-name { font-weight: 500; }
.assign-item code { font-size: 12px; color: var(--uraca-steel); }

/* ---- Mail-Vorschau ---- */
.mail-preview { border: 1px solid #e2e6e9; border-radius: 8px; overflow: hidden; }
.mail-preview-meta { background: #f7f8f9; padding: 10px 14px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.mail-preview-key { display: inline-block; min-width: 62px; color: var(--uraca-steel); font-weight: 600; }
.mail-preview-body { padding: 14px; font-size: 14px; white-space: pre-wrap; line-height: 1.55; }


/* ============================================================================
 * Dokumentenbaum v2 — Inline-Aktionen, Auto-Einklapp-Schalter, Drag&Drop,
 * plus zentrierte Bearbeiten-Popups (.uv-modal). Additiv zum Baum oben.
 * ========================================================================== */

/* Auto-Einklapp-Schalter im Kopf */
.vw-head-actions { align-items: center; }
.dt-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--uraca-steel); cursor: pointer; user-select: none;
    white-space: nowrap;
}
.dt-toggle input[type="checkbox"] { width: auto; margin: 0; }

/* Datei-Icon dezenter als Ordner/Produkt */
.dt-icon--file { color: var(--uraca-steel); }

/* Rechtsbuendige Mini-Aktionen je Ordner-/Produktzeile */
.dt-actions-inline {
    margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
    opacity: 0; transition: opacity .12s;
}
.dt-row:hover .dt-actions-inline,
.dt-row:focus-within .dt-actions-inline { opacity: 1; }
.dt-act {
    border: 1px solid #d5dade; background: #fff; color: var(--uraca-steel);
    font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
    padding: 5px 9px; border-radius: 6px; white-space: nowrap;
}
.dt-act:hover { border-color: var(--uraca-red); color: var(--uraca-red); }

/* Drag&Drop-Zustaende */
.dt-row[draggable="true"] { cursor: grab; }
.dt-row.dt-dragging { opacity: .45; }
.dt-drop-target { outline: 2px dashed var(--uraca-red); outline-offset: -2px; background: #fdf2f4 !important; }
.dt-rootzone {
    padding: 11px 16px; font-size: 13px; color: var(--uraca-steel);
    text-align: center; border-top: 1px dashed #d5dade; background: #fbfcfc;
    cursor: default;
}
.dt-rootzone.dt-drop-target { color: var(--uraca-red); }

/* Status-Zeile im Bearbeiten-Popup (Status ganz oben) */
.vw-status-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap;
}

/* ---- Zentriertes Popup (.uv-modal) ---- */
body.modal-open { overflow: hidden; }
.uv-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow-y: auto;
    background: rgba(20, 26, 32, .55);
}
.uv-modal-box {
    position: relative; width: 100%; max-width: 760px;
    background: var(--color-bg, #fff); border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    padding: 22px 24px 26px;
}
.uv-modal-close {
    position: absolute; top: 10px; right: 12px;
    border: 0; background: transparent; cursor: pointer;
    font-size: 26px; line-height: 1; color: var(--uraca-steel);
    width: 34px; height: 34px; border-radius: 8px;
}
.uv-modal-close:hover { background: #eef1f2; color: var(--uraca-red); }
/* Fragment-Wrapper ist im Core fuer die 2-spaltige Settings-Modal flex;
   in unserem Popup sollen die Karten normal untereinander stehen. */
.uv-modal-body .settings-fragment { display: block; }
.uv-modal-body .vw-head { margin-bottom: 14px; }
.uv-modal-body .vw-form-card { max-width: none; }
.uv-modal-body .section-card { box-shadow: none; border: 1px solid #e2e6e9; }
.uv-modal-loading { color: var(--uraca-steel); padding: 30px 0; text-align: center; }

/* Produktauswahl im Popup: Suchfeld + scrollbare Gruppenliste */
.kp-search { margin-bottom: 12px; }
.kp-search input { width: 100%; padding: 9px 12px; border: 1px solid #d5dade; border-radius: 8px; font-size: 14px; }
.kp-groups { max-height: 48vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.kp-group { border: 1px solid #e2e6e9; border-radius: 8px; padding: 10px 12px; margin: 0; }
.kp-group legend { font-size: 12px; font-weight: 700; color: var(--uraca-steel); text-transform: uppercase; letter-spacing: .4px; padding: 0 4px; }
.kp-item { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 14px; cursor: pointer; }
.kp-item input[type="checkbox"] { width: auto; margin: 0; }
.kp-item-name { font-weight: 500; }
.kp-item code { font-size: 12px; color: var(--uraca-steel); }
.kp-actions { margin-top: 16px; display: flex; justify-content: flex-end; }

/* Passwortsperre Verwaltung (Prototyp) */
.vw-lock { display: flex; justify-content: center; padding: 48px 16px; }
.vw-lock-card { max-width: 420px; width: 100%; }
.vw-lock-card .section-card-body { text-align: center; }
.vw-lock-icon { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.vw-lock-card h1 { font-size: 20px; margin: 0 0 6px; }
.vw-lock-hint { color: var(--uraca-steel); margin: 0 0 20px; font-size: 14px; }
.vw-lock-card .form-group { text-align: left; }

/* ==== Dokument-Viewer (PDF eingebettet, statt Download) ====
   Gemeinsame View document-viewer.php fuer Bibliothek (public) + Portal (main). */
.doc-viewer {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    min-height: 420px;
    background: #fff;
    border: 1px solid #e2e6e9;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(20, 26, 32, .06);
}
.doc-viewer-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e6e9;
    background: var(--uraca-bg);
}
.doc-viewer-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--uraca-steel);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.doc-viewer-back:hover { color: var(--uraca-red); }
.doc-viewer-back svg { width: 18px; height: 18px; }
.doc-viewer-title {
    flex: 1;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--uraca-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doc-viewer-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.doc-viewer-download svg { width: 17px; height: 17px; }
.doc-viewer-frame {
    flex: 1;
    width: 100%;
    border: 0;
    background: #525659;
}
@media (max-width: 640px) {
    .doc-viewer-title { display: none; }
}

/* ==== QR-Liste: simuliertes QR-Bild + Download ==== */
.qr-cell { display: flex; align-items: center; gap: 10px; }
.qr-thumb {
    display: inline-block;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border: 1px solid #e2e6e9;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}
.qr-thumb svg { display: block; width: 100%; height: 100%; }
.qr-dl { font-size: 13px; white-space: nowrap; }

/* ==== Sprach-Flaggen (statt DE/EN/FR-Text) ==== */
.flag {
    display: inline-block;
    width: 22px;
    height: 11px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
    vertical-align: middle;
}
/* Sprachwaehler: Flagge etwas groesser, Pill enger; "Alle" bleibt Text-Pill. */
.lib-lang-pill .flag, .portal-lang-pill .flag { display: block; width: 26px; height: 13px; }
.lib-lang-pill:has(.flag), .portal-lang-pill:has(.flag) { padding: 5px 9px; line-height: 0; }
/* Doc-Sprachbadge + Admin-lang-pill: Flagge ersetzt den Text-Kasten. */
.lib-doc-lang:has(.flag), .portal-doc-lang:has(.flag), .lang-pill:has(.flag) {
    padding: 0; background: transparent; border: 0; box-shadow: none;
}
.lib-doc-lang .flag, .portal-doc-lang .flag, .lang-pill .flag { display: block; width: 22px; height: 11px; }
.vw-lock-card .btn--primary { width: 100%; }
