/* ==========================================================================
   Solar & Wärme CRM – Design-System
   Ein Stylesheet für alle Seiten: Tokens → Basis → Shell → Komponenten → Seiten.
   Farben als HSL-Tokens; Dark Mode über html.dark.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    color-scheme: light;

    /* Flächen */
    --c-bg:            220 23% 97%;
    --c-surface:       0 0% 100%;
    --c-surface-2:     220 20% 97.5%;
    --c-surface-hover: 220 18% 95%;
    --c-chrome:        0 0% 100%;
    --c-border:        220 14% 90%;
    --c-border-strong: 220 12% 82%;

    /* Text */
    --c-text:   222 30% 12%;
    --c-text-2: 220 12% 36%;
    --c-text-3: 220 9% 46%;

    /* Marke & Status */
    --c-primary:       228 72% 54%;
    --c-primary-hover: 228 70% 47%;
    --c-primary-soft:  228 90% 96.5%;
    --c-primary-ink:   228 62% 42%;
    --c-success:       152 62% 33%;
    --c-success-soft:  148 60% 94.5%;
    --c-warning:       32 94% 44%;
    --c-warning-soft:  42 96% 93%;
    --c-warning-ink:   28 82% 31%;
    --c-danger:        0 70% 50%;
    --c-danger-soft:   0 86% 96.5%;
    --c-danger-ink:    0 66% 40%;
    --c-pv:            38 92% 50%;
    --c-pv-soft:       42 96% 93%;
    --c-pv-ink:        30 80% 30%;
    --c-wp:            174 72% 32%;
    --c-wp-soft:       170 60% 93%;
    --c-wp-ink:        176 70% 24%;
    --c-violet:        262 66% 56%;
    --c-violet-soft:   262 90% 96.5%;
    --c-violet-ink:    262 52% 42%;

    /* Abgeleitete Werte */
    --bg:            hsl(var(--c-bg));
    --surface:       hsl(var(--c-surface));
    --surface-2:     hsl(var(--c-surface-2));
    --surface-hover: hsl(var(--c-surface-hover));
    --chrome:        hsl(var(--c-chrome));
    --line:          hsl(var(--c-border));
    --line-strong:   hsl(var(--c-border-strong));
    --text:          hsl(var(--c-text));
    --text-2:        hsl(var(--c-text-2));
    --text-3:        hsl(var(--c-text-3));
    --primary:       hsl(var(--c-primary));
    --focus-ring:    0 0 0 3px hsl(var(--c-primary) / .22);

    --shadow-xs: 0 1px 2px hsl(222 30% 12% / .05);
    --shadow-sm: 0 1px 2px hsl(222 30% 12% / .04), 0 2px 6px hsl(222 30% 12% / .04);
    --shadow-md: 0 4px 12px hsl(222 30% 12% / .08), 0 1px 3px hsl(222 30% 12% / .06);
    --shadow-lg: 0 24px 56px hsl(222 30% 12% / .18), 0 4px 12px hsl(222 30% 12% / .08);

    /* Raster (4px-Basis) */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
    --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;

    --header-h: 60px;
    --sidebar-w: 248px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --t-fast: 140ms;
    --t-med: 200ms;
    --t-slow: 400ms;

    /* Aliase für Inline-Styles und Skripte aus der bisherigen Vorlage */
    --bg-void: var(--bg);
    --bg-card: var(--surface);
    --bg-soft: var(--surface-2);
    --border: var(--line);
    --text-primary: var(--text);
    --text-bright: var(--text);
    --text-secondary: var(--text-2);
    --text-muted: var(--text-3);
    --accent-primary: var(--primary);
    --accent-secondary: hsl(var(--c-wp));
    --accent-success: hsl(var(--c-success));
    --accent-danger: hsl(var(--c-danger));
    --accent-warm: hsl(var(--c-warning));
}

html.dark {
    color-scheme: dark;
    --c-bg:            225 16% 7.5%;
    --c-surface:       225 13% 10.5%;
    --c-surface-2:     225 12% 13%;
    --c-surface-hover: 225 11% 16%;
    --c-chrome:        225 15% 9%;
    --c-border:        225 10% 19%;
    --c-border-strong: 225 9% 27%;

    --c-text:   220 22% 94%;
    --c-text-2: 220 12% 74%;
    --c-text-3: 220 9% 60%;

    --c-primary:       228 90% 68%;
    --c-primary-hover: 228 92% 74%;
    --c-primary-soft:  228 50% 20%;
    --c-primary-ink:   228 95% 82%;
    --c-success:       150 55% 52%;
    --c-success-soft:  152 40% 15%;
    --c-warning:       38 92% 58%;
    --c-warning-soft:  36 50% 15%;
    --c-warning-ink:   40 92% 72%;
    --c-danger:        0 80% 64%;
    --c-danger-soft:   0 45% 17%;
    --c-danger-ink:    0 90% 78%;
    --c-pv:            40 92% 58%;
    --c-pv-soft:       38 50% 15%;
    --c-pv-ink:        42 92% 72%;
    --c-wp:            172 60% 50%;
    --c-wp-soft:       174 45% 13%;
    --c-wp-ink:        170 65% 68%;
    --c-violet:        262 80% 72%;
    --c-violet-soft:   262 35% 19%;
    --c-violet-ink:    262 90% 84%;

    --focus-ring: 0 0 0 3px hsl(var(--c-primary) / .32);
    --shadow-xs: 0 1px 2px hsl(0 0% 0% / .3);
    --shadow-sm: 0 1px 2px hsl(0 0% 0% / .3);
    --shadow-md: 0 8px 24px hsl(0 0% 0% / .4), 0 0 0 1px hsl(var(--c-border));
    --shadow-lg: 0 24px 64px hsl(0 0% 0% / .55), 0 0 0 1px hsl(var(--c-border));
}

/* ── Basis ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-2);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--text); line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }

a { color: inherit; text-decoration: none; }
b, strong { font-weight: 600; color: var(--text); }
img, video, canvas, svg { max-width: 100%; }
input, select, textarea, button { max-width: 100%; font: inherit; color: inherit; }
table { max-width: 100%; }

::selection { background: hsl(var(--c-primary) / .2); color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.erp-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--s-4);
    height: var(--header-h);
    padding: 0 var(--s-5) 0 0;
    background: hsl(var(--c-chrome) / .86);
    backdrop-filter: saturate(1.6) blur(12px);
    -webkit-backdrop-filter: saturate(1.6) blur(12px);
    border-bottom: 1px solid var(--line);
}

.client-branding {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-width: 0;
    height: 100%;
    padding: 0 var(--s-5);
}
.client-branding > a { min-width: 0; }
.brand-text h1 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.header-search-form { width: 100%; max-width: 520px; margin: 0; }
.header-search-wrap { position: relative; }
.header-search-wrap .header-search-input {
    width: 100%;
    height: 36px;
    padding: 0 40px 0 36px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.5px;
    transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.header-search-wrap .header-search-input::placeholder { color: var(--text-3); }
.header-search-wrap .header-search-input:hover { border-color: var(--line-strong); }
.header-search-wrap .header-search-input:focus { outline: none; background: var(--surface); border-color: var(--primary); box-shadow: var(--focus-ring); }
.header-search-icon-btn {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}
.header-search-icon-btn:hover { color: var(--text); }
.header-search-icon-btn svg { width: 16px; height: 16px; display: block; }

._search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 300;
    max-height: min(440px, calc(100vh - 120px));
    overflow-y: auto;
    padding: var(--s-1);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}
._search-dropdown._open { display: block; animation: pop-in var(--t-med) var(--ease-out); }
._search-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    color: var(--text);
}
._search-item:hover, ._search-item._active { background: var(--surface-hover); }
._search-item-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    font-size: 11px;
    font-weight: 700;
}
._si-person  { background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); }
._si-car     { background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); }
._si-receipt { background: hsl(var(--c-warning-soft)); color: hsl(var(--c-warning-ink)); }
._si-lead    { background: hsl(var(--c-violet-soft)); color: hsl(var(--c-violet-ink)); }
._si-box     { background: var(--surface-2); color: var(--text-2); }
._search-item-body { flex: 1; min-width: 0; }
._search-item-label { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
._search-item-meta { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
._search-item-typ { font-size: 11px; color: var(--text-3); white-space: nowrap; }
._search-more, ._search-loading {
    display: block;
    margin-top: var(--s-1);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
}
._search-loading { color: var(--text-3); font-weight: 400; }
._search-more:hover { background: hsl(var(--c-primary-soft)); }

.user-menu { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); min-width: 0; }

.nav-clock {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-right: var(--s-2);
    line-height: 1.25;
}
.nav-clock-time { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.nav-clock-date { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* Icon-Buttons der Topbar: Theme, Glocke, Logout */
.nav-dm-btn, .nav-bell-btn, .logout-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.nav-dm-btn:hover, .nav-bell-btn:hover, .logout-btn:hover { background: var(--surface-hover); color: var(--text); }
.nav-dm-btn:active, .nav-bell-btn:active, .logout-btn:active { transform: scale(.94); }
.nav-dm-btn svg, .nav-bell-btn svg { width: 18px; height: 18px; display: block; fill: currentColor; }
.logout-btn svg { width: 18px; height: 18px; display: block; }
.logout-btn:hover { color: hsl(var(--c-danger)); }
.nav-dm-btn svg.dm-icon-hidden { display: none; }

.nav-bell-wrap { position: relative; }
.nav-bell-badge { position: absolute; width: 0; height: 0; overflow: hidden; }
.nav-bell-num {
    position: absolute;
    top: 1px;
    left: 19px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-full);
    border: 2px solid var(--chrome);
    background: hsl(var(--c-danger));
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.nav-bell-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 300;
    width: 360px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    transform-origin: top right;
}
.nav-bell-dropdown.open { display: block; animation: pop-in var(--t-med) var(--ease-out); }
.nav-bell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
#navBellList { max-height: min(420px, calc(100vh - 180px)); overflow-y: auto; overscroll-behavior: contain; padding: var(--s-1); }
.nav-bell-item {
    display: flex;
    gap: var(--s-3);
    align-items: flex-start;
    padding: 10px var(--s-3);
    border-radius: var(--r-md);
    color: inherit;
}
a.nav-bell-item:hover { background: var(--surface-hover); }
.nav-bell-dot { width: 7px; height: 7px; margin-top: 7px; flex-shrink: 0; border-radius: 50%; background: var(--primary); }
.nav-bell-dot.read { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.nav-bell-text { font-size: 13px; color: var(--text); line-height: 1.45; }
.nav-bell-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.nav-bell-empty { padding: var(--s-5) var(--s-4); text-align: center; font-size: 13px; color: var(--text-3); }
.nav-bell-footer { padding: 10px var(--s-4); border-top: 1px solid var(--line); text-align: center; }
.nav-bell-footer a { font-size: 12.5px; font-weight: 600; color: var(--primary); }
.nav-bell-footer a:hover { text-decoration: underline; text-underline-offset: 3px; }

.nav-user { display: flex; align-items: center; gap: var(--s-2); min-width: 0; padding-left: var(--s-2); margin-left: var(--s-1); border-left: 1px solid var(--line); }
.user-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: inset 0 0 0 1px hsl(0 0% 100% / .18);
}
.nav-username { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.nav-role-switch {
    height: 32px;
    max-width: 220px;
    padding: 0 28px 0 10px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    appearance: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background-color var(--t-fast), border-color var(--t-fast);
}
.nav-role-switch:hover { background-color: var(--surface-hover); }
.nav-role-switch:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

._hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    cursor: pointer;
}
._hamburger-btn:hover { background: var(--surface-hover); }
._hamburger-btn span { display: block; width: 16px; height: 1.5px; border-radius: 2px; background: var(--text); }

/* ── Layout & Sidebar ───────────────────────────────────────────────────── */
.hw-body { display: flex; align-items: stretch; min-height: calc(100vh - var(--header-h)); }

.erp-sidebar {
    position: sticky;
    top: var(--header-h);
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    padding: var(--s-4) var(--s-3);
    overflow-y: auto;
    background: var(--chrome);
    border-right: 1px solid var(--line);
}
.sidebar-section h3 {
    margin: 0 0 var(--s-1);
    padding: 0 var(--s-2);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--text-3);
}
.sidebar-nav { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; }
.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 6px var(--s-2);
    border-radius: var(--r-md);
    color: var(--text-2);
    font-size: 13.5px;
    font-weight: 500;
    transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-nav a:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-nav a:active { transform: scale(.985); }
.sidebar-nav a.active { background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); font-weight: 600; }
.sidebar-nav svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .75; }
.sidebar-nav a.active svg, .sidebar-nav a:hover svg { opacity: 1; }
.sidebar-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.sidebar-nav a.active .sidebar-badge { background: var(--surface); box-shadow: none; color: hsl(var(--c-primary-ink)); }

.quick-actions { display: grid; gap: 1px; }
.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 32px;
    padding: 6px var(--s-2);
    border-radius: var(--r-md);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--t-fast), color var(--t-fast);
}
.quick-action-btn:hover { background: var(--surface-hover); color: var(--primary); }
.quick-action-btn:active { transform: scale(.985); }

.sidebar-bottom { margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--line); }
.sidebar-bottom .sidebar-nav a { font-size: 13px; color: var(--text-3); }

#_sidebarOverlay { backdrop-filter: blur(2px); }

.hw-main { flex: 1 1 auto; min-width: 0; padding: var(--s-6) var(--s-6) var(--s-7); }
.hw-main > * { max-width: 1440px; margin-left: auto; margin-right: auto; }

/* ── Seitenkopf ─────────────────────────────────────────────────────────── */
.hw-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s-4);
    margin-bottom: var(--s-5);
}
.hw-page-head > :first-child { min-width: 0; }
.hw-eyebrow {
    margin: 0 0 var(--s-1);
    font-size: 13px;
    font-weight: 400;
    color: var(--text-3);
}
.hw-title {
    margin: 0;
    font-size: 24px;
    font-weight: 650;
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text);
}
.hw-subtitle { margin: 6px 0 0; font-size: 14px; color: var(--text-2); max-width: 75ch; }
.hw-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); }
.hw-section-label { margin: var(--s-5) 0 var(--s-3); font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.hw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 var(--s-3);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.hw-btn:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.hw-btn:active { transform: scale(.97); }
.hw-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--primary); }
.hw-btn:disabled, .hw-btn[disabled], .hw-btn.disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hw-btn svg { width: 15px; height: 15px; }

.hw-btn.primary {
    border-color: transparent;
    background: var(--primary);
    color: #fff;
    box-shadow: inset 0 1px 0 hsl(0 0% 100% / .16), 0 1px 2px hsl(var(--c-primary) / .35);
}
.hw-btn.primary:hover { background: hsl(var(--c-primary-hover)); }
html.dark .hw-btn.primary { color: hsl(225 30% 8%); }
.hw-btn.primary:focus-visible { box-shadow: var(--focus-ring); }
.hw-btn.danger { color: hsl(var(--c-danger)); }
.hw-btn.danger:hover { background: hsl(var(--c-danger-soft)); border-color: hsl(var(--c-danger) / .35); }
.hw-btn.success { color: hsl(var(--c-success)); }
.hw-btn.success:hover { background: hsl(var(--c-success-soft)); border-color: hsl(var(--c-success) / .35); }
.hw-btn.small { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.hw-btn.xs { min-height: 26px; padding: 0 var(--s-2); font-size: 12px; border-radius: var(--r-sm); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ── Karten & Raster ────────────────────────────────────────────────────── */
.hw-grid { display: grid; gap: var(--s-4); }
.hw-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hw-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hw-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hw-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hw-grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.hw-row { display: grid; gap: var(--s-4); margin-bottom: var(--s-4); }
.hw-row.r-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.hw-row.r-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.hw-row.r-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hw-row.r-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hw-split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr); gap: var(--s-4); align-items: start; }
.hw-stack { display: grid; gap: var(--s-4); }
.mb-16 { margin-bottom: var(--s-4); }
.mt-16 { margin-top: var(--s-4); }

.hw-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
a.hw-card { display: block; color: inherit; }
.hw-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--s-3);
    min-height: 52px;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
}
.hw-card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.hw-card-sub { font-size: 12px; font-weight: 400; color: var(--text-3); }
.hw-card-body { padding: var(--s-4); }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 215px; }
.chart-box.lg { height: 300px; }

/* KPI */
.hw-kpi { position: relative; padding: var(--s-4); }
a.hw-kpi { transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease-out); }
a.hw-kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
a.hw-kpi:active { transform: scale(.985); }
.hw-kpi-label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hw-kpi-value {
    margin-top: var(--s-2);
    font-size: 26px;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.hw-kpi-value small { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--text-3); }
.hw-kpi-value.sm { font-size: 21px; }
.hw-kpi-note { margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.hw-kpi-note b { color: var(--text-2); }
.kpi-trend { display: inline-flex; align-items: center; gap: 2px; padding: 0 5px; border-radius: var(--r-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-trend.up { background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); }
.kpi-trend.down { background: hsl(var(--c-danger-soft)); color: hsl(var(--c-danger)); }
.kpi-icon {
    position: absolute;
    top: var(--s-4);
    right: var(--s-4);
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--r-md);
    background: hsl(var(--c-primary-soft));
    color: hsl(var(--c-primary-ink));
}
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-icon.green  { background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); }
.kpi-icon.amber  { background: hsl(var(--c-warning-soft)); color: hsl(var(--c-warning-ink)); }
.kpi-icon.red    { background: hsl(var(--c-danger-soft)); color: hsl(var(--c-danger)); }
.kpi-icon.teal   { background: hsl(var(--c-wp-soft)); color: hsl(var(--c-wp-ink)); }
.kpi-icon.violet { background: hsl(var(--c-violet-soft)); color: hsl(var(--c-violet-ink)); }
.kpi-split { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.kpi-split b { color: var(--text); font-variant-numeric: tabular-nums; }
.pos { color: hsl(var(--c-success)); }
.neg { color: hsl(var(--c-danger)); }

/* Status-Pipeline */
.pipeline-tiles { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--s-2); margin-bottom: var(--s-4); }
.pipeline-tiles .hw-kpi { padding: var(--s-3); box-shadow: none; }
.pipeline-tiles .hw-kpi-label { font-size: 12px; line-height: 1.3; }
.pipeline-tiles .hw-kpi-value { margin-top: var(--s-1); font-size: 20px; }
.pipeline-tiles .hw-kpi.active { border-color: var(--primary); background: hsl(var(--c-primary-soft)); }
.pipeline-tiles .hw-kpi.active .hw-kpi-label { color: hsl(var(--c-primary-ink)); }

/* Fortschritt */
.hw-progress { height: 6px; overflow: hidden; border-radius: var(--r-full); background: var(--surface-hover); }
.hw-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transform-origin: left; animation: grow-x var(--t-slow) var(--ease-out) both; }
.hw-progress.green > span { background: hsl(var(--c-success)); }
.upload-progress-wrap { display: none; margin-top: 10px; padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.upload-progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; font-size: 12px; color: var(--text-3); }
.upload-progress-header span:first-child { font-weight: 600; color: var(--text); }
.upload-progress-track { height: 6px; overflow: hidden; border-radius: var(--r-full); background: var(--surface-hover); }
.upload-progress-fill { width: 0%; height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s var(--ease-out); }

/* Prognose */
.forecast-value { font-size: 32px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.forecast-list { display: grid; gap: 10px; margin: var(--s-4) 0; }
.forecast-list div { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.forecast-list span { color: var(--text-2); }
.forecast-list b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Formulare ──────────────────────────────────────────────────────────── */
.hw-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); }
.hw-form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hw-form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hw-field.full { grid-column: 1 / -1; }
.hw-field label, label { color: var(--text); font-size: 12.5px; font-weight: 500; }
.hw-field label { display: block; margin-bottom: 6px; }
.hw-field .hint { margin-top: var(--s-1); font-size: 12px; color: var(--text-3); }

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="search"], input[type="url"], input[type="month"],
input:not([type]), select, textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background-color: var(--surface);
    box-shadow: var(--shadow-xs);
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.4;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
select {
    appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}
select[multiple] { background-image: none; padding-right: 10px; }
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
input[type="file"] { font-size: 13px; color: var(--text-2); }
input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.hw-filterbar { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, 180px) auto; gap: var(--s-2); margin-bottom: var(--s-4); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-form select, .inline-form input { width: auto; min-height: 30px; max-width: 200px; padding: 4px 8px; font-size: 12.5px; }
.inline-form select { padding-right: 26px; background-position: right 8px center; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); padding-top: 6px; }
.check-row label { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 500; cursor: pointer; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-4); }

.switch { position: relative; display: inline-block; flex-shrink: 0; width: 36px; height: 20px; margin-top: 2px; }
.switch input { width: 0; height: 0; opacity: 0; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-full); background: var(--line-strong); cursor: pointer; transition: background var(--t-med) var(--ease-out); }
.switch span::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px hsl(0 0% 0% / .2);
    transition: transform var(--t-med) var(--ease-out);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus-ring); }

/* ── Tabellen ───────────────────────────────────────────────────────────── */
.hw-table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hw-table, table:not(.calendar-table) { width: 100%; border-collapse: collapse; font-size: 13px; }
.hw-table th, table:not(.calendar-table) th {
    padding: 9px var(--s-3);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}
.hw-table td, table:not(.calendar-table) td {
    padding: 11px var(--s-3);
    border-bottom: 1px solid var(--line);
    color: var(--text);
    vertical-align: middle;
}
.hw-table tbody tr:last-child td { border-bottom: 0; }
.hw-table tbody tr { transition: background var(--t-fast); }
.hw-table tbody tr:hover td { background: var(--surface-2); }
.hw-card > .hw-table-wrap:last-child .hw-table, .hw-card > .hw-table:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.hw-table td.num, .hw-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hw-table td.nowrap { white-space: nowrap; }
.hw-table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.hw-table tr.row-warn td { background: hsl(var(--c-danger-soft) / .55); }
.hw-table .row-link, .row-link { color: var(--text); font-weight: 600; }
.row-link:hover { color: var(--primary); }
.hw-muted { color: var(--text-3); }
.text-muted { color: var(--text-3); }
.hw-strong { color: var(--text); font-weight: 600; }
.small { font-size: 12.5px; }
.ico-inline { width: 14px; height: 14px; margin: 0 6px 0 2px; vertical-align: -2px; fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.hw-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-1); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); }
.hw-pagination .hw-btn { min-width: 32px; box-shadow: none; }
.hw-pagination .hw-btn.active { border-color: var(--primary); background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); }

.rank-badge {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--text-2);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rank-badge.r1 { background: hsl(var(--c-pv-soft)); box-shadow: none; color: hsl(var(--c-pv-ink)); }
.rank-badge.r2 { background: var(--surface-hover); box-shadow: none; color: var(--text); }
.rank-badge.r3 { background: hsl(24 80% 93%); box-shadow: none; color: hsl(20 70% 34%); }
html.dark .rank-badge.r3 { background: hsl(22 40% 17%); color: hsl(24 90% 74%); }
.mini-avatar {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px hsl(0 0% 100% / .18);
}
.person-cell { display: flex; align-items: center; gap: var(--s-2); }
.bar-cell { display: flex; align-items: center; gap: var(--s-2); min-width: 120px; }
.bar-cell .hw-progress { flex: 1; }

/* ── Badges, Hinweise, Leerzustände ─────────────────────────────────────── */
.hw-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 var(--s-2);
    border-radius: var(--r-full);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}
.hw-badge::before { content: ''; width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: currentColor; opacity: .85; }
.hw-badge.neutral::before { background: var(--text-3); }
.hw-badge.info, .hw-badge.primary { background: hsl(var(--c-primary-soft)); box-shadow: none; color: hsl(var(--c-primary-ink)); }
.hw-badge.accent, .hw-badge.wp { background: hsl(var(--c-wp-soft)); box-shadow: none; color: hsl(var(--c-wp-ink)); }
.hw-badge.warning { background: hsl(var(--c-warning-soft)); box-shadow: none; color: hsl(var(--c-warning-ink)); }
.hw-badge.pv { background: hsl(var(--c-pv-soft)); box-shadow: none; color: hsl(var(--c-pv-ink)); }
.hw-badge.success { background: hsl(var(--c-success-soft)); box-shadow: none; color: hsl(var(--c-success)); }
.hw-badge.danger { background: hsl(var(--c-danger-soft)); box-shadow: none; color: hsl(var(--c-danger-ink)); }

.hw-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--s-4);
    padding: 10px var(--s-3);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 500;
    animation: slide-down var(--t-med) var(--ease-out);
}
.hw-alert::before { content: ''; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: currentColor; }
.hw-alert.success { background: hsl(var(--c-success-soft)); border-color: hsl(var(--c-success) / .25); color: hsl(var(--c-success)); }
.hw-alert.error { background: hsl(var(--c-danger-soft)); border-color: hsl(var(--c-danger) / .25); color: hsl(var(--c-danger-ink)); }

.hw-callout {
    padding: var(--s-3) var(--s-4);
    border: 1px solid hsl(var(--c-primary) / .2);
    border-radius: var(--r-md);
    background: hsl(var(--c-primary-soft));
    color: var(--text);
    font-size: 13.5px;
}
.hw-callout.warn { background: hsl(var(--c-warning-soft)); border-color: hsl(var(--c-warning) / .3); }
.hw-callout.ok { background: hsl(var(--c-success-soft)); border-color: hsl(var(--c-success) / .25); }
.hw-callout a { color: var(--primary); font-weight: 600; }

.hw-empty {
    padding: var(--s-6) var(--s-5);
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 13.5px;
    text-align: center;
}
.search-hit { padding: 0 2px; border-radius: 3px; background: hsl(var(--c-warning) / .28); color: var(--text); }

/* Listen */
.hw-list { display: grid; }
.hw-list-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line); }
.hw-list-row:last-child { border-bottom: 0; }

/* Tabs */
.hw-tabs { display: flex; gap: var(--s-1); margin-bottom: var(--s-4); overflow-x: auto; border-bottom: 1px solid var(--line); }
.hw-tab {
    position: relative;
    padding: 10px var(--s-3);
    border: 0;
    background: transparent;
    color: var(--text-3);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--t-fast);
}
.hw-tab::after {
    content: '';
    position: absolute;
    left: var(--s-2);
    right: var(--s-2);
    bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--text);
    transform: scaleX(0);
    transition: transform var(--t-med) var(--ease-out);
}
.hw-tab:hover { color: var(--text); }
.hw-tab.active { color: var(--text); font-weight: 600; }
.hw-tab.active::after { transform: scaleX(1); }
.hw-tab-panel { display: none; }
.hw-tab-panel.active { display: block; animation: fade-in var(--t-med) var(--ease-out); }

/* ── Modal & Lightbox ───────────────────────────────────────────────────── */
.hw-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh var(--s-4) var(--s-4);
    overflow-y: auto;
    background: hsl(222 30% 8% / .45);
}
.hw-modal-overlay.open { display: flex; animation: fade-in var(--t-med) var(--ease-out); }
.hw-modal {
    width: min(720px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
}
.hw-modal-overlay.open .hw-modal { animation: modal-in var(--t-med) var(--ease-out); }
.hw-modal.sm { width: min(480px, 100%); }
.hw-modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.hw-modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.hw-modal-body { padding: var(--s-5); }
.hw-modal-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--text-3);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}
.hw-modal-close:hover { background: var(--surface-hover); color: var(--text); }

.lightbox { display: none; position: fixed; inset: 0; z-index: 600; align-items: center; justify-content: center; padding: var(--s-6); background: hsl(222 40% 4% / .92); }
.lightbox.open { display: flex; animation: fade-in var(--t-med) var(--ease-out); }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: var(--r-md); background: #fff; box-shadow: 0 20px 60px hsl(0 0% 0% / .5); }
.lightbox-bar { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 13px; color: hsl(220 20% 86%); }
.lightbox-bar a { margin-left: 10px; font-weight: 600; color: hsl(228 95% 80%); }
.lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; border-radius: 50%; background: hsl(0 0% 100% / .12); color: #fff; font-size: 22px; cursor: pointer; transition: background var(--t-fast); }
.lightbox-nav:hover { background: hsl(0 0% 100% / .24); }
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-close { position: absolute; top: 14px; right: 18px; border: 0; background: transparent; color: #fff; font-size: 28px; cursor: pointer; }

/* ── Upload, Galerie, Dokumente ─────────────────────────────────────────── */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: 150px;
    padding: var(--s-5);
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: hsl(var(--c-primary-soft)); }
.dropzone svg { width: 28px; height: 28px; color: var(--primary); }
.dropzone strong { font-size: 14px; color: var(--text); }
.dropzone span { font-size: 12.5px; color: var(--text-3); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-queue { display: grid; gap: 6px; max-height: 220px; margin-top: 10px; overflow-y: auto; }
.file-queue-item { display: flex; align-items: center; gap: 10px; padding: 6px var(--s-2); border-radius: var(--r-md); background: var(--surface-2); font-size: 12.5px; color: var(--text); }
.file-queue-item img, .file-queue-item .fq-ico { width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--r-sm); object-fit: cover; }
.file-queue-item .fq-ico { display: grid; place-items: center; background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); font-size: 9px; font-weight: 700; }
.file-queue-item .fq-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-queue-item .fq-size { color: var(--text-3); white-space: nowrap; }
.file-queue-item button { border: 0; background: transparent; color: var(--text-3); font-size: 16px; cursor: pointer; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gal-item { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.gal-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; cursor: zoom-in; transition: transform var(--t-slow) var(--ease-out); }
.gal-item:hover img { transform: scale(1.04); }
.gal-cap { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px var(--s-2); font-size: 12px; color: var(--text-2); }
.gal-cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-cap a { flex-shrink: 0; font-weight: 600; color: var(--primary); }
.gal-group { margin-bottom: var(--s-4); }
.gal-group h4 { margin: 0 0 var(--s-2); font-size: 13px; font-weight: 600; color: var(--text); }
.doc-row { display: flex; align-items: center; gap: var(--s-3); padding: 10px 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-ico { display: grid; place-items: center; width: 34px; height: 40px; flex-shrink: 0; border-radius: var(--r-sm); background: hsl(var(--c-danger-soft)); color: hsl(var(--c-danger-ink)); font-size: 9.5px; font-weight: 700; }
.doc-ico.doc { background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); }
.doc-ico.xls { background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); }
.doc-ico.zip { background: var(--surface-2); color: var(--text-2); }
.doc-body { flex: 1; min-width: 0; }
.doc-body .hw-strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Steckbrief, Timeline, Meldungen ────────────────────────────────────── */
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4) var(--s-5); margin: 0; }
.kv-grid div { min-width: 0; }
.kv-grid dt { font-size: 12.5px; font-weight: 400; color: var(--text-3); }
.kv-grid dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }

.timeline { display: grid; }
.tl-item { position: relative; display: flex; gap: var(--s-3); padding-bottom: var(--s-4); }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: 2px; width: 1px; background: var(--line); }
.tl-dot { width: 11px; height: 11px; margin-top: 4px; flex-shrink: 0; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2.5px var(--primary); }
.tl-dot.status { box-shadow: inset 0 0 0 2.5px hsl(var(--c-warning)); }
.tl-dot.upload { box-shadow: inset 0 0 0 2.5px hsl(var(--c-wp)); }
.tl-dot.zuweisung { box-shadow: inset 0 0 0 2.5px hsl(var(--c-violet)); }
.tl-dot.system { box-shadow: inset 0 0 0 2.5px var(--text-3); }
.tl-text { font-size: 13.5px; line-height: 1.45; color: var(--text); white-space: pre-line; }
.tl-meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

.notice { display: flex; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice-ico { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border-radius: var(--r-md); background: hsl(var(--c-primary-soft)); color: hsl(var(--c-primary-ink)); font-size: 12px; font-weight: 700; }
.notice-ico.schulung { background: hsl(var(--c-violet-soft)); color: hsl(var(--c-violet-ink)); }
.notice-ico.lead { background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); }
.notice-ico.warn { background: hsl(var(--c-danger-soft)); color: hsl(var(--c-danger-ink)); }
.notice-text { font-size: 13.5px; line-height: 1.45; color: var(--text); }
.notice-text.unread { font-weight: 600; }
.notice-meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

/* Projekt-Fortschritt */
.steps { display: flex; align-items: flex-start; padding: var(--s-4) var(--s-3); overflow-x: auto; }
.step { position: relative; flex: 1; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); text-align: center; }
.step:not(:last-child)::after { content: ''; position: absolute; top: 13px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; border-radius: 2px; background: var(--line); }
.step.done:not(:last-child)::after { background: hsl(var(--c-success)); }
.step-dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--line-strong);
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
}
.step.done .step-dot { background: hsl(var(--c-success)); box-shadow: none; color: #fff; }
.step.current .step-dot { background: var(--primary); box-shadow: 0 0 0 4px hsl(var(--c-primary) / .18); color: #fff; }
.step.lost .step-dot { background: hsl(var(--c-danger)); box-shadow: none; color: #fff; }
.step-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.step.current .step-label { color: var(--text); font-weight: 600; }

/* ── Kalender ───────────────────────────────────────────────────────────── */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.cal-head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); }
.calendar-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar-table th { padding: var(--s-2); border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 12px; font-weight: 500; color: var(--text-3); text-align: left; }
.calendar-table td { height: 118px; padding: 6px; vertical-align: top; border: 1px solid var(--line); background: var(--surface); }
.calendar-table tr td:first-child { border-left: 0; }
.calendar-table tr td:last-child { border-right: 0; }
.calendar-table tr:last-child td { border-bottom: 0; }
.calendar-table td.other { background: var(--surface-2); }
.calendar-table td.other .cal-day span { color: var(--text-3); opacity: .6; }
.calendar-table td.weekend { background: var(--surface-2); }
.calendar-table td.today .cal-day span { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: var(--r-full); background: var(--primary); color: #fff; }
html.dark .calendar-table td.today .cal-day span { color: hsl(225 30% 8%); }
.cal-day { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-1); font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-day a { display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-sm); color: var(--text-3); font-weight: 600; opacity: 0; transition: opacity var(--t-fast), background var(--t-fast); }
.cal-day a:hover { background: var(--surface-hover); color: var(--text); }
.calendar-table td:hover .cal-day a, .cal-day a:focus-visible { opacity: 1; }
.cal-ev {
    --ev: hsl(var(--c-primary));
    display: block;
    margin-bottom: 2px;
    padding: 2px 6px;
    border-radius: 5px;
    background: color-mix(in oklab, var(--ev) 13%, var(--surface));
    color: color-mix(in oklab, var(--ev) 62%, var(--text));
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background var(--t-fast);
}
.cal-ev::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 5px; vertical-align: 1px; border-radius: 50%; background: var(--ev); }
.cal-ev:hover { background: color-mix(in oklab, var(--ev) 22%, var(--surface)); }
.cal-ev.schulung { --ev: hsl(var(--c-violet)); }
.cal-ev.done { opacity: .55; text-decoration: line-through; }
.cal-ev.offen { box-shadow: inset 0 0 0 1px hsl(var(--c-danger) / .7); }
.cal-more { display: inline-block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.cal-more:hover { color: var(--primary); }
.legend-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--r-full);
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
    transition: background var(--t-fast), box-shadow var(--t-fast);
}
a.legend-chip:hover { background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text); }
.legend-chip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.agenda-day { margin: var(--s-4) 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.agenda-day:first-child { margin-top: 0; }

/* ── Posteingang & Parser ───────────────────────────────────────────────── */
.mail-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: var(--s-4); }
.mail-item { display: block; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); color: inherit; transition: background var(--t-fast); }
.mail-item:hover { background: var(--surface-2); }
.mail-item.active { background: hsl(var(--c-primary-soft)); }
.mail-item .m-from { display: flex; justify-content: space-between; gap: var(--s-2); font-size: 13px; font-weight: 600; color: var(--text); }
.mail-item .m-subj { margin-top: 2px; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item .m-prev { margin-top: 2px; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.unread .m-subj { font-weight: 600; }
.mail-body { max-height: 420px; overflow-y: auto; padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; }
.parse-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.parse-chip { display: inline-flex; align-items: center; gap: 6px; padding: var(--s-1) 10px; border-radius: var(--r-md); background: hsl(var(--c-success-soft)); color: hsl(var(--c-success)); font-size: 12.5px; font-weight: 500; }
.parse-chip b { font-weight: 600; color: inherit; }
.parse-chip.miss { background: var(--surface-2); color: var(--text-3); }
.rule-row { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.rule-row:last-child { border-bottom: 0; }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--s-6) var(--s-4); background: var(--bg); }
.login-card { display: grid; grid-template-columns: 1fr 1.1fr; width: min(980px, 100%); overflow: hidden; border-radius: var(--r-xl); box-shadow: var(--shadow-md); animation: modal-in var(--t-slow) var(--ease-out); }
.login-side { padding: var(--s-7) var(--s-6); }
.login-brand { margin: 0 0 var(--s-6); font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.login-side .hw-title { font-size: 26px; }
.login-demo { padding: var(--s-7) var(--s-6); border-left: 1px solid var(--line); background: var(--surface-2); }
.demo-role {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    margin-bottom: var(--s-2);
    padding: var(--s-3);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease-out);
}
button.demo-role:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
button.demo-role:active { transform: scale(.98); }
.demo-role .dr-ico { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--r-md); color: #fff; font-size: 12px; font-weight: 700; }
.demo-role b { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.demo-role small { display: block; margin-top: 1px; font-size: 12.5px; line-height: 1.4; color: var(--text-3); }

/* ── Rechnung (Papier, immer hell) ──────────────────────────────────────── */
.invoice-paper { max-width: 820px; margin: 0 auto; padding: 48px 56px; border-radius: var(--r-md); background: #fff; color: #1f2937; box-shadow: var(--shadow-md); font-size: 13px; }
.invoice-paper h1 { margin: 0 0 4px; font-size: 26px; color: #111827; }
.invoice-paper b, .invoice-paper strong { color: #111827; }
.invoice-paper table { width: 100%; margin-top: 24px; border-collapse: collapse; }
.invoice-paper th { padding: 8px; background: #fff; border-bottom: 2px solid #e5e7eb; color: #6b7280; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; text-align: left; }
.invoice-paper td { padding: 10px 8px; background: #fff; border-bottom: 1px solid #f1f5f9; color: #1f2937; }
.invoice-paper .sum td { font-weight: 700; border-top: 2px solid #111827; }

/* ── Bewegung ───────────────────────────────────────────────────────────── */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
    :root { --t-fast: 1ms; --t-med: 1ms; --t-slow: 1ms; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1366px) {
    :root { --sidebar-w: 224px; }
    .nav-role-switch { max-width: 180px; }
    .hw-main { padding: var(--s-5) var(--s-5) var(--s-7); }
}

@media (max-width: 1280px) {
    .hw-grid.cols-5, .hw-grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pipeline-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .nav-clock-date { display: none; }
}

@media (max-width: 1100px) {
    .erp-header { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 var(--s-3); gap: var(--s-3); }
    .client-branding { padding: 0; }
    ._hamburger-btn { display: flex; }
    .erp-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 200;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        height: 100dvh;
        box-shadow: var(--shadow-lg);
        transform: translateX(-100%);
        transition: transform var(--t-med) var(--ease-out);
    }
    .erp-sidebar._open { transform: translateX(0); }
    .hw-body { display: block; }
    .hw-main { padding: var(--s-5) var(--s-4) var(--s-7); }
    .hw-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hw-row.r-2-1, .hw-row.r-1-2, .hw-row.r-3, .hw-split, .mail-layout { grid-template-columns: minmax(0, 1fr); }
    .hw-filterbar { grid-template-columns: 1fr 1fr; }
    .nav-clock { display: none; }
}

@media (max-width: 820px) {
    .login-card { grid-template-columns: 1fr; }
    .login-demo { border-left: 0; border-top: 1px solid var(--line); }
    .login-side, .login-demo { padding: var(--s-6) var(--s-5); }
}

@media (max-width: 760px) {
    .erp-header {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "brand actions" "search search";
        row-gap: var(--s-2);
        height: auto;
        padding: var(--s-2) var(--s-3);
    }
    .client-branding { grid-area: brand; }
    .user-menu { grid-area: actions; gap: var(--s-1); }
    .header-search-form { grid-area: search; max-width: none; }
    .erp-sidebar { top: 0; }
    .nav-role-switch { max-width: 120px; }
    .nav-user { padding-left: var(--s-1); margin-left: 0; border-left: 0; }
    .hw-page-head { flex-direction: column; align-items: stretch; }
    .hw-actions { justify-content: flex-start; }
    .hw-title { font-size: 21px; }
    .hw-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
    .hw-grid.cols-2, .hw-grid.cols-3,
    .hw-form-grid, .hw-form-grid.cols-3, .hw-form-grid.cols-4,
    .hw-filterbar, .hw-row.r-1-1 { grid-template-columns: minmax(0, 1fr); }
    .hw-grid.cols-5, .hw-grid.cols-6, .pipeline-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hw-kpi { padding: var(--s-3); }
    .hw-kpi-value { font-size: 20px; }
    .kv-grid { grid-template-columns: minmax(0, 1fr); }
    .calendar-table td { height: 72px; padding: 3px; }
    .cal-ev { height: 6px; padding: 0; font-size: 0; }
    .cal-ev::before { display: none; }
    .cal-ev { background: var(--ev); }
    .invoice-paper { padding: var(--s-5); }
}

@media (max-width: 540px) {
    .user-avatar { display: none; }
    .nav-role-switch { max-width: 104px; padding-left: 6px; }
    .nav-bell-wrap { position: static; }
    .nav-bell-dropdown { position: fixed; top: 100px; left: var(--s-3); right: var(--s-3); width: auto; }
    #navBellList { max-height: calc(100dvh - 160px); }
}

@media print {
    .erp-header, .erp-sidebar, .no-print, .hw-page-head { display: none; }
    .hw-main { padding: 0; }
    .invoice-paper { box-shadow: none; padding: 0; }
    body { background: #fff; }
}
