/* ==========================================================================
   ZiaNeo Corporate Design 2026
   Zentrale CSS-Datei fuer alle Widgets

   Usage: <link rel="stylesheet" href="/zianeo-corporate.css">
   ========================================================================== */

/* Local Fonts (DSGVO - keine Google Fonts) */
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/playfair-display-400.woff2) format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/playfair-display-500.woff2) format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/playfair-display-600.woff2) format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/playfair-display-700.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 300; font-display: swap; src: url(/static/fonts/poppins-300.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url(/static/fonts/poppins-400.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 500; font-display: swap; src: url(/static/fonts/poppins-500.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url(/static/fonts/poppins-600.woff2) format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url(/static/fonts/poppins-700.woff2) format('woff2'); }

/* ==========================================================================
   Konstante Farben (unabhaengig vom Theme-Modus)
   ========================================================================== */
:root {
    /* =====================================================================
       IMMUTABLE Corporate Design Farben
       Diese Variablen werden NIEMALS von widget_theme.js ueberschrieben.
       Fuer alle Elemente die IMMER CD-konform sein muessen.
       ===================================================================== */
    --cd-navy: #1a365d;
    --cd-navy-light: #2d4a7c;
    --cd-navy-dark: #0f2341;
    --cd-sage: #9aaba6;
    --cd-sage-light: #b8c5c1;
    --cd-sage-dark: #7a8f89;
    --cd-light: #f7fafc;
    --cd-dark: #1a202c;
    --cd-border: #e2e8f0;
    --cd-mid: #718096;
    --cd-white: #ffffff;

    /* CD Hintergrund-Varianten */
    --cd-navy-bg: rgba(26, 54, 93, 0.15);
    --cd-sage-bg: rgba(154, 171, 166, 0.15);
    --cd-sage-bg-strong: rgba(154, 171, 166, 0.3);

    /* CD Focus */
    --cd-focus-border: #1a365d;
    --cd-focus-shadow: 0 0 0 3px rgba(26, 54, 93, 0.15);

    /* CD Typografie */
    --cd-font-heading: 'Playfair Display', Georgia, serif;
    --cd-font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;

    /* =====================================================================
       Tenant-ueberschreibbare Variablen (Defaults = CD)
       widget_theme.js darf diese ueberschreiben.
       ===================================================================== */
    --primary: #1a365d;
    --primary-light: #2d4a7c;
    --primary-dark: #0f2341;
    --accent: #9aaba6;
    --accent-light: #b8c5c1;
    --accent-dark: #7a8f89;

    /* Semantisch */
    --success: #48bb78;
    --success-bg: rgba(72, 187, 120, 0.12);
    --warning: #ecc94b;
    --warning-bg: rgba(236, 201, 75, 0.12);
    --error: #f56565;
    --error-bg: rgba(245, 101, 101, 0.12);
    --info: #4299e1;
    --info-bg: rgba(66, 153, 225, 0.12);

    /* Typografie */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Transitions */
    --transition-theme: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ==========================================================================
   Light Mode
   ========================================================================== */
[data-theme="light"],
:root:not([data-theme]) {
    --bg-primary: #f7fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #edf2f7;
    --bg-hover: #e2e8f0;
    --bg-active: #cbd5e0;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-sidebar: #1a365d;
    --bg-sidebar-hover: #2d4a7c;

    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-tertiary: #a0aec0;
    --text-on-primary: #ffffff;
    --text-on-sidebar: #f7fafc;
    --text-heading: #1a365d;
    --text-link: #1a365d;
    --text-link-hover: #2d4a7c;

    --border: #e2e8f0;
    --border-strong: #cbd5e0;
    --border-subtle: #edf2f7;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --scrollbar-track: #edf2f7;
    --scrollbar-thumb: #cbd5e0;
    --scrollbar-thumb-hover: #a0aec0;

    --overlay: rgba(0, 0, 0, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Dark Mode
   Prinzip: Dunkle Navy-Toene, KEIN reines Schwarz.
   Sage + Navy bleiben als Akzente erkennbar.
   ========================================================================== */
[data-theme="dark"] {
    --bg-primary: #0d1520;
    --bg-secondary: #131f2e;
    --bg-tertiary: #182639;
    --bg-hover: #1e3048;
    --bg-active: #254058;
    --bg-card: #161f2e;
    --bg-input: #131f2e;
    --bg-sidebar: #0a1018;
    --bg-sidebar-hover: #162032;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-on-primary: #ffffff;
    --text-on-sidebar: #e2e8f0;
    --text-heading: #e2e8f0;
    --text-link: #b8c5c1;
    --text-link-hover: #9aaba6;

    --border: #1e3048;
    --border-strong: #2d4a7c;
    --border-subtle: #182639;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);

    --scrollbar-track: #0d1520;
    --scrollbar-thumb: #2d4a7c;
    --scrollbar-thumb-hover: #3a5a8c;

    --overlay: rgba(0, 0, 0, 0.7);
    --glass-bg: rgba(13, 21, 32, 0.85);
    --glass-border: rgba(255, 255, 255, 0.06);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-primary: #0d1520;
        --bg-secondary: #131f2e;
        --bg-tertiary: #182639;
        --bg-hover: #1e3048;
        --bg-active: #254058;
        --bg-card: #161f2e;
        --bg-input: #131f2e;
        --bg-sidebar: #0a1018;
        --bg-sidebar-hover: #162032;

        --text-primary: #e2e8f0;
        --text-secondary: #94a3b8;
        --text-tertiary: #64748b;
        --text-on-primary: #ffffff;
        --text-on-sidebar: #e2e8f0;
        --text-heading: #e2e8f0;
        --text-link: #b8c5c1;
        --text-link-hover: #9aaba6;

        --border: #1e3048;
        --border-strong: #2d4a7c;
        --border-subtle: #182639;

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);

        --scrollbar-track: #0d1520;
        --scrollbar-thumb: #2d4a7c;
        --scrollbar-thumb-hover: #3a5a8c;

        --overlay: rgba(0, 0, 0, 0.7);
        --glass-bg: rgba(13, 21, 32, 0.85);
        --glass-border: rgba(255, 255, 255, 0.06);
    }
}

/* ==========================================================================
   Theme Transition
   ========================================================================== */
body,
.widget-header,
.btn, button,
input, select, textarea,
.card, .badge, .modal,
.zn-card, .zn-card-flat, .zn-stat,
.zn-table th, .zn-table td,
nav, aside, header, footer,
table, th, td {
    transition: var(--transition-theme);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 0.5em 0;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

h5, h6 {
    font-family: var(--font-body);
    color: var(--text-primary);
    font-weight: 600;
    margin: 0 0 0.5em 0;
}

h5 { font-size: 0.9rem; }
h6 { font-size: 0.8rem; }

p {
    margin: 0 0 1em 0;
    color: var(--text-primary);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--text-link-hover);
}

/* Ampersand Regel - & in Playfair ist zu verschnoerkelt */
.amp {
    font-family: var(--font-body);
    font-style: normal;
}

small, .text-sm {
    font-size: 0.85rem;
}

.text-secondary {
    color: var(--text-secondary);
}

.text-tertiary {
    color: var(--text-tertiary);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn:active {
    background: var(--bg-active);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    border: 1px solid var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-accent {
    background: var(--accent);
    color: var(--primary-dark);
    border: 1px solid var(--accent);
}

.btn-accent:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border: 1px solid var(--error);
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1rem;
}

/* ==========================================================================
   Inputs / Forms
   ========================================================================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea,
select {
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-strong, #cbd5e0);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    width: 100%;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Tables
   ========================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border);
    background: var(--bg-tertiary);
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-hover);
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}

.badge-accent {
    background: var(--accent);
    color: var(--primary-dark);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab {
    padding: 10px 18px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ==========================================================================
   Widget Header (ersetzt widget_header.css fuer corporate Widgets)
   ========================================================================== */
.zn-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.zn-widget-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.zn-widget-header-icon {
    width: 42px;
    height: 42px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-primary);
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-body);
    flex-shrink: 0;
}

.zn-widget-header-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0;
    line-height: 1.2;
}

.zn-widget-header-subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 2px;
}

.zn-widget-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ==========================================================================
   SVG Icons (Lucide-Style)
   ========================================================================== */
.icon-svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}

.icon-svg.icon-sm { width: 16px; height: 16px; }
.icon-svg.icon-lg { width: 24px; height: 24px; }
.icon-svg.icon-xl { width: 32px; height: 32px; }

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.gap-lg { gap: 20px; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   Status Dot
   ========================================================================== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot-success { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.status-dot-error { background: var(--error); }
.status-dot-info { background: var(--info); }
.status-dot-neutral { background: var(--text-tertiary); }

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--text-tertiary);
    margin-bottom: 12px;
}

.empty-state h3 {
    font-family: var(--font-heading);
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

/* ==========================================================================
   ZN Layout Components (Theme Nr. 1)
   Wiederverwendbare Klassen fuer einheitliches Widget-Layout.
   Referenz: Emotia/ImmoZia-Standard
   ========================================================================== */

/* --- Cards --- */
.zn-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-theme);
}

.zn-card-flat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: var(--transition-theme);
}

.zn-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.zn-card-header h3,
.zn-card-header .zn-card-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zn-card-header h3 .mdi,
.zn-card-header .zn-card-title .mdi {
    color: var(--cd-sage);
}

.zn-card-body {
    padding: 0;
}

.zn-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

/* --- Grids --- */
.zn-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.zn-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.zn-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.zn-grid-sidebar {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
}

@media (max-width: 968px) {
    .zn-grid-2,
    .zn-grid-3,
    .zn-grid-4,
    .zn-grid-sidebar {
        grid-template-columns: 1fr;
    }
}

/* --- Tabellen --- */
.zn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.zn-table th {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border);
    background: var(--bg-tertiary);
}

.zn-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.zn-table tr:hover td {
    background: var(--bg-hover);
}

.zn-table tr {
    transition: background 0.15s ease;
}

/* --- Toolbar (Action-Bar ueber Tabellen/Listen) --- */
.zn-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.zn-toolbar-spacer {
    flex: 1;
}

/* --- Formular-Gruppen --- */
.zn-form-group {
    margin-bottom: 1rem;
}

.zn-form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.zn-form-row {
    display: flex;
    gap: 1rem;
}

.zn-form-row > * {
    flex: 1;
}

@media (max-width: 640px) {
    .zn-form-row {
        flex-direction: column;
    }
}

/* --- Stat Cards (Kennzahlen) --- */
.zn-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    transition: var(--transition-theme);
}

.zn-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
    font-family: var(--font-body);
}

.zn-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.zn-stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

.zn-stat-trend.up { color: var(--success); }
.zn-stat-trend.down { color: var(--error); }
.zn-stat-trend.neutral { color: var(--text-tertiary); }

/* ==========================================================================
   ZN Sidebar Layout (ImmoZia-Referenz)
   Wiederverwendbar fuer alle Widgets mit Sidebar-Navigation.
   ========================================================================== */

/* Container: Sidebar + Content */
.zn-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    gap: 0;
}

@media (max-width: 900px) {
    .zn-layout { grid-template-columns: 1fr; }
    .zn-layout > .zn-sidebar { display: none; }
}

/* Sidebar */
.zn-sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.zn-sidebar-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    min-height: 56px;
    box-sizing: border-box;
    background: var(--cd-navy);
}

.zn-sidebar-header .logo {
    width: 32px;
    height: 32px;
    background: rgba(154, 171, 166, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cd-sage);
    flex-shrink: 0;
}

.zn-sidebar-header h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cd-white);
    font-family: var(--cd-font-heading);
    margin: 0;
}

.zn-sidebar-nav {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    overflow-y: auto;
}

.zn-sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.zn-sidebar-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 8px 12px 4px;
    letter-spacing: 0.05em;
    font-weight: 600;
}

/* Nav Items */
.zn-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.92rem;
    font-family: var(--font-body);
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.zn-nav-item:hover {
    background: var(--cd-sage-bg);
    color: var(--cd-navy);
}

.zn-nav-item.active {
    background: rgba(154, 171, 166, 0.15);
    color: var(--cd-navy);
    font-weight: 600;
    border-left-color: var(--cd-sage);
}

.zn-nav-item .mdi {
    width: 18px;
    text-align: center;
    font-size: 1rem;
}

.zn-nav-item span {
    font-size: 0.92rem;
}

.zn-nav-item .badge {
    margin-left: auto;
    background: var(--cd-sage-bg);
    color: var(--cd-navy);
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-md);
    font-weight: 600;
}

[data-theme="dark"] .zn-nav-item {
    color: var(--text-secondary);
}

[data-theme="dark"] .zn-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

[data-theme="dark"] .zn-nav-item.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: var(--cd-sage);
}

/* Content Area */
.zn-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.zn-content-header {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    min-height: 56px;
    box-sizing: border-box;
    background: var(--cd-navy);
}

.zn-content-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--cd-white);
    font-family: var(--cd-font-heading);
    margin: 0;
}

.zn-content-header .subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.78rem;
    margin-top: 1px;
}

.zn-content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: rgba(154, 171, 166, 0.06);
}

[data-theme="dark"] .zn-content-scroll {
    background: var(--bg-primary);
}

/* ==========================================================================
   ZN Icon-Standards
   KI/Automatisierung: mdi-auto-fix (Zauberstab) in Sage
   Manuell: mdi-account in Navy
   ========================================================================== */
.zn-icon-ki {
    color: var(--cd-sage);
}

.zn-icon-ki::before {
    content: "\F0068"; /* mdi-auto-fix */
}

.zn-icon-manual {
    color: var(--cd-navy);
}

[data-theme="dark"] .zn-icon-ki {
    color: var(--cd-sage-light);
}

[data-theme="dark"] .zn-icon-manual {
    color: var(--text-secondary);
}

/* ==========================================================================
   Dark Mode Overrides fuer bestehende Komponenten
   ========================================================================== */
[data-theme="dark"] .zn-card,
[data-theme="dark"] .zn-card-flat,
[data-theme="dark"] .zn-stat,
[data-theme="dark"] .card {
    border-color: var(--border);
}

[data-theme="dark"] .badge-accent {
    color: var(--text-primary);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: var(--cd-sage);
    box-shadow: 0 0 0 3px rgba(154, 171, 166, 0.2);
}

/* Dark Mode: Inline-Style Overrides (fuer hardcoded Farben in Widgets) */
[data-theme="dark"] [style*="background: #f7fafc"],
[data-theme="dark"] [style*="background:#f7fafc"],
[data-theme="dark"] [style*="background-color: #f7fafc"] {
    background: var(--bg-tertiary) !important;
}

[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background-color: #ffffff"] {
    background: var(--bg-card) !important;
}

[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background-color: white"] {
    background: var(--bg-card) !important;
}

[data-theme="dark"] [style*="color: #1a202c"],
[data-theme="dark"] [style*="color:#1a202c"] {
    color: var(--text-primary) !important;
}

[data-theme="dark"] [style*="color: #718096"],
[data-theme="dark"] [style*="color:#718096"] {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] [style*="border: 1px solid #e2e8f0"],
[data-theme="dark"] [style*="border:1px solid #e2e8f0"],
[data-theme="dark"] [style*="border-color: #e2e8f0"],
[data-theme="dark"] [style*="border-bottom: 1px solid #e2e8f0"],
[data-theme="dark"] [style*="border-top: 1px solid #e2e8f0"] {
    border-color: var(--border) !important;
}

[data-theme="dark"] [style*="background: #edf2f7"],
[data-theme="dark"] [style*="background:#edf2f7"],
[data-theme="dark"] [style*="background-color: #edf2f7"] {
    background: var(--bg-tertiary) !important;
}

[data-theme="dark"] [style*="background: #e2e8f0"],
[data-theme="dark"] [style*="background:#e2e8f0"] {
    background: var(--bg-hover) !important;
}

/* Dark Mode: Box-Shadow auf Widgets neutralisieren */
[data-theme="dark"] [style*="box-shadow: 0 2px"],
[data-theme="dark"] [style*="box-shadow: 0 4px"],
[data-theme="dark"] [style*="box-shadow: 0 1px"] {
    box-shadow: var(--shadow-sm) !important;
}

/* ==========================================================================
   Animations (Theme Nr. 1 Standard)
   ========================================================================== */
@keyframes zn-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.zn-fade-in {
    animation: zn-fade-in 0.3s ease;
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .zn-card, .zn-card-flat, .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}
