/* ============================================================================
   Office-Tech ERP — Design v2 · Richtung A „Modern Top-Nav" (Linear-Stil)
   Light Theme · Geist · Hairline-Borders · Akzent #ff6b1a
   Komponenten-Klassennamen bleiben kompatibel zu allen bestehenden Views.
   ============================================================================ */

:root {
    /* Design „Klar" (2026-06-27): wärmere, hellere Neutrals + monochrom Orange. */
    --bg:             #faf8f6;
    --surface:        #ffffff;
    --surface-2:      #faf8f6;
    --surface-3:      #f2eeea;

    --border:         #e4ddd6;
    --border-strong:  #cbc2b9;
    --hairline:       #ede7e1;

    --text:           #0c0a08;
    --text-muted:     #6f655d;
    --text-light:     #9d928a;
    --text-body:      #3a332f;

    --accent:         #f26a12;
    --accent-hover:   #c9530b;
    --accent-ember:   #ff8a33;
    --accent-soft:    #fff3ea;
    --accent-border:  #ffe8d6;

    --success: #15803d; --success-soft: #e7f6ed; --success-dot: #22c55e;
    --warning: #b45309; --warning-soft: #fef3c7;
    --danger:  #b91c1c; --danger-soft:  #fee2e2;
    --info:    #1d4ed8; --info-soft:    #dbeafe;

    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow:    0 1px 2px rgba(28,25,23,.04);
    --shadow-rest: 0 8px 20px -10px rgba(13,27,48,.12);
    --shadow-hover: 0 18px 40px -12px rgba(13,27,48,.18);
    --shadow-pop: 0 8px 28px -6px rgba(28,25,23,.18);

    --topbar-h: 64px;
    --maxw: 100%;

    --font: 'Manrope', 'Geist', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Space Grotesk', 'Manrope', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', 'Geist Mono', ui-monospace, SFMono-Regular, monospace;
}

/* Dunkler Modus — überschreibt die Farbvariablen (Akzent/Schrift-Familien bleiben). */
html[data-theme="dark"] {
    --bg:            #15171c;
    --surface:       #1b1e25;
    --surface-2:     #15171c;
    --surface-3:     #22262e;
    --border:        #2a2f3a;
    --border-strong: #3a4150;
    --hairline:      #23272f;
    --text:          #f1f5f9;
    --text-muted:    #9aa1ad;
    --text-light:    #6b7280;
    --text-body:     #cbd2da;
    --accent-soft:   #2c1a0d;
    --accent-border: #3a230f;
    --success-soft:  #14301f;
    --warning-soft:  #2f2410;
    --danger-soft:   #3a1717;
    --info-soft:     #11203a;
    --shadow:        0 1px 2px rgba(0,0,0,.3);
    --shadow-rest:   0 8px 20px -10px rgba(0,0,0,.5);
    --shadow-hover:  0 18px 40px -12px rgba(0,0,0,.6);
    --shadow-pop:    0 8px 28px -6px rgba(0,0,0,.55);
    color-scheme: dark;
}
/* Reine Weiß-/Hellflächen im Dark-Mode abdunkeln (häufige Inline-Stile in Views). */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"] { background-color: var(--surface) !important; }
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f7f7f7"],
html[data-theme="dark"] [style*="background:#fafbfc"],
html[data-theme="dark"] [style*="background:#fafafa"],
html[data-theme="dark"] [style*="background:#f9fafb"] { background-color: var(--surface-2) !important; }
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"],
html[data-theme="dark"] [style*="background:#f3f4f6"],
html[data-theme="dark"] [style*="background:#f2eeea"],
html[data-theme="dark"] [style*="background:#eef2ff"] { background-color: var(--surface-3) !important; }

/* Lokale View-Paletten (auf Wrapper-Klassen definiert) im Dark-Mode auf Theme-Töne
   mappen — fixt alle variablen-basierten Views zentral. Nur neutrale Namen (Flächen/
   Text/Rahmen); Akzent-/Semantikfarben (--acc/--green/--red/--amber/--or/--blue …) bleiben. */
html[data-theme="dark"] * {
    /* Kern-Theme-Vars erzwingen — überstimmt Views, die --surface/--bg/--border/--ink lokal
       auf helle Werte redefinieren (Dark-Literale, identisch zum :root-Dark-Block). */
    --bg: #15171c; --surface: #1b1e25; --surface-2: #15171c; --surface-3: #22262e;
    --border: #2a2f3a; --border-strong: #3a4150; --hairline: #23272f;
    --text: #f1f5f9; --text-muted: #9aa1ad; --text-body: #cbd2da; --text-light: #6b7280;
    /* Lokale View-Alias-Namen auf Theme-Töne mappen (Akzent-/Semantikfarben bleiben) */
    --panel: var(--surface); --panel2: var(--surface-2); --card: var(--surface);
    --soft: var(--surface-2); --tile: var(--surface-2); --field: var(--surface-3);
    --ink: var(--text); --ink2: var(--text-body); --ink3: var(--text-muted); --ink4: var(--text-light);
    --body: var(--text-body); --muted: var(--text-muted); --faint: var(--text-light);
    --bd: var(--border); --line: var(--border); --hair: var(--hairline);
    /* Dense-Pro-Layout v2 (Beleg-Listen + Positions-Formulare Auftrag/Rechnung/Vertrag) nutzt
       dieselben Alias-Namen in camelCase — ohne diese Zeile bleiben rowSel/borderStrong/accentSoft
       trotz Dark Mode hell, weil der Variablen-Name nicht zu --border-strong/--accent-soft passt. */
    --borderStrong: var(--border-strong); --accentSoft: var(--accent-soft); --rowSel: var(--surface-3);
}
/* Dual-Use-Ausnahmen: Elemente, die im Light-Mode „dunkle Fläche + weiße Schrift" per
   var(--ink) bauen — im Dark-Mode würde --ink (jetzt hell) diese unlesbar machen. Daher
   für bekannte geteilte Komponenten (Beleg-Listen) eine dunkle Fläche erzwingen. */
html[data-theme="dark"] .bl .btn-primary,
html[data-theme="dark"] .bl .bl-tab.active,
html[data-theme="dark"] .bestellung-detail .ad-sec .idx,
html[data-theme="dark"] .bestellung-detail .ad-totals .box.brutto,
html[data-theme="dark"] .bestellung-detail .btn-primary,
html[data-theme="dark"] .rechnung-detail .ad-sec .idx,
html[data-theme="dark"] .rechnung-detail .ad-totals .box.brutto,
html[data-theme="dark"] .rechnung-detail .btn-primary,
html[data-theme="dark"] .angebot-detail .ad-sec .idx,
html[data-theme="dark"] .angebot-detail .ad-totals .box.brutto,
html[data-theme="dark"] .angebot-detail .btn-primary,
html[data-theme="dark"] .auftrag-form .af-sec .idx,
html[data-theme="dark"] .auftrag-form .af-totals .box.brutto,
html[data-theme="dark"] .auftrag-form .btn-primary,
html[data-theme="dark"] .auftrag-detail .ad-sec .idx,
html[data-theme="dark"] .auftrag-detail .ad-totals .box.brutto,
html[data-theme="dark"] .auftrag-detail .btn-primary,
html[data-theme="dark"] .rmm2-tabs a.akt,
html[data-theme="dark"] .liq .kpi.accent,
html[data-theme="dark"] .taw .kpi.accent,
html[data-theme="dark"] .mrr .kpi.accent,
html[data-theme="dark"] .op .kpi.accent,
html[data-theme="dark"] .op .rank {
    background: var(--surface-3) !important; color: var(--text) !important; border-color: var(--border-strong) !important;
}
/* Info-/Freitext-Zeile in den Positionen-Formularen (Auftrag/Rechnung/Vertrag) — fest verdrahtetes
   Hellgelb (#fffbeb) sticht im Dark Mode grell hervor, hier auf den passenden Dark-Warnton gemappt.
   Selektoren müssen exakt die Original-Regeln überbieten (u.a. #positionen hat eine ID). */
html[data-theme="dark"] .auftrag-form .text-row,
html[data-theme="dark"] #positionen .text-row,
html[data-theme="dark"] #vt-positionen .text-row {
    background: var(--warning-soft) !important;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { background: var(--bg); color: var(--text); }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
.text-muted { color: var(--text-muted); }

/* ----------------------------------------------------------------- Shell */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
    max-width: var(--maxw); margin: 0 auto;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 1.5rem;
    padding: 0 1.5rem;
}
.topbar-logo { display: flex; align-items: center; flex-shrink: 0; }
.topbar-logo img { height: 26px; width: auto; display: block; }

/* Klar-Wortmarke: isometrisches Würfel-Monogramm + „office-tech" */
.topbar-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand svg { display: block; }
.topbar-brand .wm {
    font-family: var(--font-display); font-weight: 700; font-size: 18px;
    letter-spacing: -.01em; color: var(--text);
}
.topbar-brand .wm em { color: var(--accent); font-style: normal; }

.topnav { display: flex; align-items: stretch; gap: .15rem; flex: 1; height: 100%; }

.navitem {
    display: inline-flex; align-items: center; gap: .4rem;
    height: 100%; padding: 0 .75rem;
    font-size: 13.5px; font-weight: 500; color: var(--text-muted);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.navitem:hover { color: var(--text); text-decoration: none; }
.navitem.active { color: var(--text); border-bottom-color: var(--accent); }

/* Dropdown-Gruppen über natives <details> (kein JS) */
.navdrop { position: relative; display: flex; align-items: stretch; }
.navdrop > summary {
    /* iOS-Safari-Workaround: NICHT inline-flex/flex auf <summary> — sonst klappt
       <details> auf iOS nicht auf. display:list-item ist der native Default
       und garantiert konsistentes Klick-Verhalten auf allen Browsern. */
    display: list-item;
    list-style: none; cursor: pointer;
    line-height: var(--topbar-h);
    height: 100%; padding: 0 .75rem;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
    border-bottom: 2px solid transparent; user-select: none;
    white-space: nowrap;
}
.navdrop > summary::-webkit-details-marker { display: none; }
.navdrop > summary::marker { content: ""; }
.navdrop > summary::after {
    content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 6px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-1px); opacity: .6;
    vertical-align: middle;
}
.navdrop:hover > summary { color: var(--text); }
.navdrop[open] > summary { color: var(--text); border-bottom-color: var(--accent); }
.navdrop.has-active > summary { color: var(--text); border-bottom-color: var(--accent); }
.navdrop-menu {
    position: absolute; top: calc(var(--topbar-h) - 1px); left: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: .35rem;
    display: flex; flex-direction: column;
}
.navdrop-menu a {
    padding: .5rem .65rem; border-radius: var(--radius-sm);
    font-size: 13px; color: var(--text); font-weight: 500;
}
.navdrop-menu a:hover { background: var(--surface-3); text-decoration: none; }
.navdrop-menu a.active { color: var(--accent); background: var(--accent-soft); }

.topbar-user { display: flex; align-items: center; gap: .85rem; flex-shrink: 0; }
.topbar-user .u-name { font-size: 13.5px; font-weight: 700; line-height: 1.15; }
.topbar-user .u-role { font-family: var(--mono); font-size: 10px; color: var(--text-light); text-transform: uppercase; letter-spacing: .12em; }

/* Klar-Topbar: Such-/Glocken-Icons + Avatar */
.topbar-icons { display: flex; align-items: center; gap: 1rem; }
.topbar-icon {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer; position: relative;
    background: none; border: none; padding: 0; line-height: 0;
}
.topbar-icon:hover, .topbar-icon.active { color: var(--accent); }
.topbar-icon .dot {
    position: absolute; top: -2px; right: -2px; width: 7px; height: 7px;
    border-radius: 50%; background: var(--accent); border: 1.5px solid var(--surface);
}
.topbar-icon .badge {
    position: absolute; top: -7px; right: -8px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff;
    font-family: var(--font-display); font-size: 10px; font-weight: 700; line-height: 16px;
    text-align: center; border: 1.5px solid var(--surface);
}
.u-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-border); color: var(--accent-hover);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 13px;
    flex-shrink: 0; vertical-align: middle;
}
/* iOS-Workaround beachten: KEIN flex auf <summary>. Avatar + Meta inline ausrichten. */
.usermenu > summary .u-meta { display: inline-flex; flex-direction: column; vertical-align: middle; margin-left: 9px; }
.logout-form { display: inline; }
.logout-btn {
    border: 1px solid var(--border-strong); background: var(--surface);
    color: var(--text-muted); font-size: 12px; font-weight: 500;
    padding: .4rem .7rem; border-radius: var(--radius-sm); cursor: pointer;
}
.logout-btn:hover { background: var(--surface-3); color: var(--text); }

.content { max-width: var(--maxw); margin: 0 auto; width: 100%; padding: 1.75rem 1.5rem 4rem; flex: 1; }

/* ----------------------------------------------------------- Page header */

.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem;
}
.page-header h1 { font-size: 22px; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: .15rem; }
.page-actions { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.breadcrumb { font-size: 12px; color: var(--text-light); margin-bottom: .25rem; }
.breadcrumb a { color: var(--text-muted); }

/* --------------------------------------------------------------- Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    height: 36px; padding: 0 .95rem;
    font-size: 13px; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #991b1b; color: #fff; }
.btn-block { width: 100%; }
.btn-right { margin-left: auto; }

.btn-icon {
    display: inline-flex; align-items: center; height: 28px; padding: 0 .55rem;
    font-size: 12px; font-weight: 600; color: var(--accent);
    border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    background: none; font-family: inherit;
}
.btn-icon:hover { background: var(--accent-soft); text-decoration: none; }
.btn-icon-danger {
    border: none; background: none; color: var(--danger);
    font-size: 16px; line-height: 1; cursor: pointer; padding: .25rem .45rem; border-radius: var(--radius-sm);
}
.btn-icon-danger:hover { background: var(--danger-soft); }

/* ----------------------------------------------------------------- Cards */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-header h2 { font-size: 15px; margin: 0; }
.card-action { font-size: 12px; color: var(--accent); font-weight: 600; }
.card-meta { color: var(--text-muted); font-size: 12px; }

/* ----------------------------------------------------------------- Stats */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats-compact { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.1rem 1.2rem; display: block;
}
a.stat-card:hover { border-color: var(--accent-border); text-decoration: none; }
.stat-card.wide { grid-column: span 2; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: .35rem; font-family: var(--mono); }
.stat-meta { font-size: 12px; color: var(--text-light); margin-top: .25rem; }

/* --------------------------------------------------------------- Filters */

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-form { display: flex; gap: .5rem; }
.search-input, input[type="search"] {
    height: 36px; padding: 0 .7rem; font-size: 13px; font-family: inherit;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); min-width: 240px;
}
.search-input:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.filter-tabs { display: inline-flex; gap: .15rem; background: var(--surface-3); padding: .25rem; border-radius: var(--radius); }
.filter-tab { padding: .4rem .8rem; font-size: 13px; font-weight: 500; color: var(--text-muted); border-radius: var(--radius-sm); }
.filter-tab:hover { color: var(--text); text-decoration: none; }
.filter-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filter-ma { display: inline-flex; align-items: center; gap: .4rem; font-size: 13px; color: var(--text-muted); }
.filter-ma select { height: 36px; padding: 0 .6rem; font-size: 13px; font-family: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

/* ---------------------------------------------------------------- Tables */

.table-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
    text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-light);
    padding: .7rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.data-table tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num, .num { text-align: right; font-family: var(--mono); }
.link-strong { font-weight: 600; }
.link-strong a { color: var(--text); }
.link-strong a:hover { color: var(--accent); }
.row-actions { text-align: right; white-space: nowrap; }
.empty-state { padding: 2.5rem; text-align: center; color: var(--text-light); font-size: 14px; }

/* ---------------------------------------------------------------- Badges */

.badge {
    display: inline-block; padding: .15rem .5rem; font-size: 11px; font-weight: 600;
    border-radius: 999px; background: var(--surface-3); color: var(--text-muted);
    border: 1px solid var(--border); text-transform: capitalize;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-lieferant { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-kreditor  { background: var(--warning-soft); color: var(--warning); border-color: transparent; }

.status-badge {
    display: inline-block; padding: .2rem .6rem; font-size: 11px; font-weight: 600;
    border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-3); color: var(--text-muted); text-transform: capitalize;
}
.status-badge.large { padding: .35rem .85rem; font-size: 13px; }
.status-neu, .status-offen        { background: var(--info-soft); color: var(--info); border-color: transparent; }
.status-in_bearbeitung, .status-versendet { background: var(--info-soft); color: var(--info); border-color: transparent; }
.status-wartet_kunde, .status-wartet_intern { background: #f3e8ff; color: #7e22ce; border-color: transparent; }
.status-geloest, .status-bezahlt, .status-erledigt, .status-angenommen { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-geschlossen, .status-storniert, .status-verworfen { background: #f3f4f6; color: #6b7280; border-color: transparent; }
.status-entwurf                   { background: #f3f4f6; color: #6b7280; border-color: transparent; }
.status-teilweise_bezahlt, .status-abgelaufen { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
/* Beschaffungs-Kette (Aufträge): bestellt → teilgeliefert → Ware komplett */
.status-bestellt                  { background: #e0e7ff; color: #4338ca; border-color: transparent; }
.status-teilgeliefert             { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-ware_komplett, .status-geliefert { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-mahnung_1, .status-mahnung_2, .status-mahnung_3, .status-abgelehnt { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ----------------------------------------------------------------- Forms */

.entity-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-section {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
}
.form-section legend, .form-section > legend {
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-light); padding: 0 0 .6rem;
}
.form-section { border: 1px solid var(--border); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.form-row:last-child { margin-bottom: 0; }
.form-group { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.form-row .form-group { margin-bottom: 0; }
.form-group.flex-2 { flex: 2; }
.form-group.small { flex: .6; min-width: 110px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea,
.entity-form input, .entity-form select, .entity-form textarea {
    height: 38px; padding: 0 .7rem; font-size: 13px; font-family: inherit;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); width: 100%;
}
.entity-form textarea, .form-group textarea { height: auto; padding: .55rem .7rem; line-height: 1.5; }
.entity-form input:disabled { background: var(--surface-3); color: var(--text-muted); }
.checkbox-label { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; font-size: 13px; }
.checkbox-label input { width: auto; height: auto; }
/* Radio-/Checkbox-Optionen nicht auf Textfeld-Größe aufblasen und klar als
   Gruppe zum Label gehörig darstellen (Typ Firma/Person, Rollen …). */
.form-group input[type="checkbox"], .form-group input[type="radio"],
.entity-form input[type="checkbox"], .entity-form input[type="radio"] {
    width: auto; height: auto; min-width: 0; margin: 0; padding: 0;
    border: 0; background: none; flex: none; accent-color: var(--accent, #2563eb);
}
.radio-group, .checkbox-group {
    display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; margin-top: .35rem;
}
.radio-group .radio, .checkbox-group .checkbox {
    display: inline-flex; align-items: center; gap: .45rem; margin: 0;
    font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; cursor: pointer;
}
.form-hint { display: block; color: var(--text-light); font-size: 12px; margin-top: .25rem; }
.form-actions { display: flex; align-items: center; gap: .6rem; }
.status-form { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.positionen-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 1rem; }
.positionen-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); padding: .5rem .5rem; border-bottom: 1px solid var(--border); }
.positionen-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--border); }
.positionen-table input { height: 34px; }
.pos-summe { font-family: var(--mono); white-space: nowrap; }

/* --------------------------------------------------------------- Flash */

.flash-container { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.25rem; }
.flash {
    padding: .7rem 1rem; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
    border: 1px solid;
}
.flash-success { background: var(--success-soft); border-color: #86efac; color: var(--success); }
.flash-error   { background: var(--danger-soft);  border-color: #fca5a5; color: var(--danger); }
.flash-info    { background: var(--info-soft);    border-color: #93c5fd; color: var(--info); }
.flash-warning { background: var(--warning-soft); border-color: #fcd34d; color: var(--warning); }

/* ------------------------------------------------------------- HelpToggle */

.hilfe { margin: -.25rem 0 1.25rem; }
.hilfe-toggle {
    display: inline-flex; align-items: center; gap: .4rem; width: max-content; cursor: pointer;
    list-style: none; user-select: none; font-size: 12px; font-weight: 600;
    color: var(--accent); background: var(--accent-soft);
    border: 1px solid var(--accent-border); border-radius: 999px; padding: .3rem .8rem;
}
.hilfe-toggle::-webkit-details-marker { display: none; }
.hilfe-toggle::before { content: "\24D8"; font-size: 14px; line-height: 1; }
.hilfe[open] .hilfe-toggle { border-radius: var(--radius) var(--radius) 0 0; }
.hilfe-box {
    max-width: 920px; background: var(--accent-soft); border: 1px solid var(--accent-border);
    border-top: none; border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 1rem 1.1rem; font-size: 13px; line-height: 1.55; color: #7c2d12;
}
.hilfe-box h4 { margin: 0 0 .5rem; font-size: 13px; color: var(--accent-hover); }
.hilfe-box p { margin: .4rem 0; }
.hilfe-box p:last-child { margin-bottom: 0; }
.hilfe-box code { background: var(--surface); padding: .05rem .3rem; border-radius: 3px; font-size: 12px; }

/* ------------------------------------------------------ Invoice document */

.invoice-document { max-width: 880px; }
.invoice-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.invoice-to, .invoice-from { font-size: 13px; line-height: 1.6; }
.invoice-meta { display: flex; flex-wrap: wrap; gap: .35rem 1.5rem; font-size: 13px; padding: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.invoice-subject { font-size: 16px; margin-bottom: .75rem; }
.text-block { font-size: 13px; line-height: 1.6; margin: .75rem 0; white-space: normal; }
.invoice-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 1rem 0; }
.invoice-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); padding: .55rem .6rem; border-bottom: 1px solid var(--border-strong); }
.invoice-table th.num { text-align: right; }
.invoice-table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.invoice-table tfoot td { border: none; padding: .3rem .6rem; }
.invoice-table tfoot tr.total td { border-top: 2px solid var(--text); font-size: 15px; padding-top: .6rem; }
.invoice-footer { color: var(--text-muted); }

/* ----------------------------------------------------------------- Auth */

.auth-body { background: var(--bg); min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-pop); }
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-logo-panel { display: inline-block; padding: .5rem; }
.auth-logo-panel img { display: block; width: 100%; max-width: 230px; height: auto; margin: 0 auto; }
.auth-subtitle { color: var(--text-muted); font-size: 13px; margin: .75rem 0 0; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: .5rem; }
.auth-form label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: .35rem; }
.auth-form input { width: 100%; height: 40px; padding: 0 .7rem; font-size: 14px; font-family: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
/* Checkbox/Radio nicht auf Feld-Größe aufblasen (sonst riesige „Angemeldet bleiben"-Box) */
.auth-form input[type="checkbox"], .auth-form input[type="radio"] { width: auto; height: auto; min-width: 0; padding: 0; border: 0; flex: none; accent-color: var(--accent, #2563eb); }
.auth-form .checkbox-label { display: flex; flex-direction: row; align-items: center; gap: .5rem; margin: 0; font-size: 13px; color: var(--text, inherit); font-weight: 500; }
.auth-form .checkbox-label input { margin: 0; }

/* --------------------------------------------------------------- Errors */

.error-body { background: var(--bg); min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.error-container { text-align: center; max-width: 480px; }
.error-code { font-size: 96px; font-weight: 800; color: var(--accent); line-height: 1; margin-bottom: .5rem; font-family: var(--mono); }
.error-container h1 { font-size: 22px; margin-bottom: .5rem; }
.error-container p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ----------------------------------------------------------- Responsive */

@media (max-width: 1000px) {
    .topbar-inner { gap: .75rem; overflow-x: auto; }
    .navitem, .navdrop > summary { padding: 0 .55rem; }
    .topbar-user .u-meta { display: none; }
    .form-row { flex-direction: column; gap: 0; }
}

/* ----------------------------- Mobile / PWA-Touch (Phones · Tablets) */
@media (max-width: 760px) {
    :root { --topbar-h: 50px; }

    .topbar-inner { padding: 0 .75rem; gap: .35rem; }
    .topbar-logo img { height: 22px; }
    .topnav { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .topnav::-webkit-scrollbar { display: none; }
    .navitem, .navdrop > summary { padding: 0 .55rem; font-size: 12.5px; }
    .navdrop[open] .navdrop-menu { position: fixed; left: .5rem; right: .5rem; top: calc(var(--topbar-h) + 4px); min-width: 0; max-height: 70vh; overflow-y: auto; }

    .topbar-user .u-meta { display: none; }
    .topbar-user { gap: .4rem; }
    .logout-btn { padding: .35rem .5rem; font-size: 11.5px; }

    .content { padding: 1rem .75rem 5rem; }

    .page-header { flex-direction: column; align-items: stretch; gap: .75rem; }
    .page-header h1 { font-size: 19px; }
    .page-actions { flex-wrap: wrap; gap: .4rem; }
    .page-actions .btn, .page-actions .btn-icon { flex: 1 1 auto; justify-content: center; }

    .card { padding: 1rem; }
    .kpi-strip { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
    .kpi { padding: .65rem .75rem; }
    .kpi-value { font-size: 18px; }

    /* Tabellen scrollen horizontal */
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
    .data-table { font-size: 12.5px; min-width: 560px; }
    .data-table thead th, .data-table tbody td { padding: .55rem .65rem; }

    /* Forms */
    .form-row { flex-direction: column; gap: 0; }
    .form-group { min-width: 0; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; /* verhindert iOS-Zoom beim Fokus */ }

    /* Buttons mit Touch-Mindestmaß */
    .btn { min-height: 40px; }

    /* PWA: Safe-Area-Insets respektieren (iOS Notch / Home-Indicator) */
    .topbar { padding-top: env(safe-area-inset-top, 0); }
    .content { padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0)); }
}

@media (max-width: 480px) {
    .kpi-strip { grid-template-columns: 1fr; }
    .data-table { min-width: 480px; }
}

/* Standalone-PWA-spezifisch: kleine Visuelle Verbesserungen, wenn als Web-App installiert */
@media (display-mode: standalone) {
    body { -webkit-user-select: none; user-select: none; }
    .form-group input, .form-group select, .form-group textarea { -webkit-user-select: text; user-select: text; }
    .data-table tbody { -webkit-user-select: text; user-select: text; }
}

/* ----------------------------------------------------- Preisverlauf (SVG) */

.preisverlauf { width: 100%; }
.preisverlauf svg { background: var(--surface); border-radius: var(--radius-sm); }
.preisverlauf-legende { display: flex; gap: 1.25rem; margin-top: .6rem; font-size: 12px; color: var(--text-muted); }
.preisverlauf-legende span { display: inline-flex; align-items: center; gap: .4rem; }
.preisverlauf-legende i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Artikel-Picker im Positions-Editor */
.artikel-picker { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap; }
.artikel-picker .form-group { margin-bottom: 0; }
.artikel-picker input { min-width: 280px; }

/* Auftrags-Status-Badges */
.status-erstellt  { background: var(--info-soft);    color: var(--info);    border-color: transparent; }
.status-berechnet { background: var(--success-soft); color: var(--success); border-color: transparent; }

/* Vertrags-Status-Badges */
.status-vt-aktiv    { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-vt-pausiert { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-vt-beendet  { background: #f3f4f6; color: #6b7280; border-color: transparent; }

/* Knowledge-Base: gerendertes Markdown */
.md-body { font-size: 14px; line-height: 1.7; color: var(--text); }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { margin: 1.4em 0 .5em; line-height: 1.3; }
.md-body h1 { font-size: 22px; } .md-body h2 { font-size: 18px; } .md-body h3 { font-size: 16px; }
.md-body h1:first-child, .md-body h2:first-child, .md-body h3:first-child { margin-top: 0; }
.md-body p { margin: .7em 0; }
.md-body ul, .md-body ol { margin: .7em 0 .7em 1.4rem; }
.md-body li { margin: .25em 0; }
.md-body a { color: var(--accent); }
.md-body code { background: var(--surface-3); padding: .1rem .35rem; border-radius: 4px; font-family: var(--mono); font-size: 13px; }
.md-body pre { background: #0f172a; color: #e7e5e4; padding: 1rem; border-radius: var(--radius); overflow-x: auto; margin: 1em 0; }
.md-body pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
/* Rich-Text-Artikel (Editor-HTML): eingegebene Zeilenumbrueche + Einrueckung 1:1 erhalten.
   Nur fuer HTML-Inhalt setzen (nicht fuer aus Markdown gerendertes HTML, das sonst
   strukturelle Newlines als Leerzeilen zeigen wuerde). .md-body--pre pre behaelt sein eigenes Verhalten. */
.md-body--pre { white-space: pre-wrap; overflow-wrap: break-word; }
.md-body--pre pre { white-space: pre; }
.md-body blockquote { border-left: 3px solid var(--accent); margin: 1em 0; padding: .3rem 0 .3rem 1rem; color: var(--text-muted); }
.md-body table { border-collapse: collapse; margin: 1em 0; font-size: 13px; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: .45rem .7rem; text-align: left; }
.md-body th { background: var(--surface-2); }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-body img { max-width: 100%; height: auto; }

/* TE-Cockpit Balken */
.te-bar { background: var(--surface-3); border-radius: 999px; height: 12px; overflow: hidden; }
.te-bar-track { display: flex; height: 100%; min-width: 2px; }
.te-seg { height: 100%; }
.te-qual      { background: var(--accent); }
.te-berechnet { background: var(--success); }
.te-offen     { background: var(--warning); }
.te-cap { display: block; font-size: 11px; color: var(--text-muted); margin-top: .25rem; font-family: var(--mono); }

/* Geräte-Status-Badges */
.status-ge-aktiv        { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-ge-lager        { background: var(--info-soft);    color: var(--info);    border-color: transparent; }
.status-ge-defekt       { background: var(--danger-soft);  color: var(--danger);  border-color: transparent; }
.status-ge-ausgemustert { background: #f3f4f6; color: #6b7280; border-color: transparent; }

/* Arbeitsbericht-Status-Badges */
.status-ab-entwurf            { background: #f3f4f6; color: #6b7280; border-color: transparent; }
.status-ab-offen              { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.status-ab-berechnet          { background: var(--success-soft); color: var(--success); border-color: transparent; }
.status-ab-nicht_berechenbar  { background: #f3f4f6; color: #6b7280; border-color: transparent; }

/* ===== Kundendetail v2: KPI-Strip ===== */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin: 1rem 0 1.25rem; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .85rem 1rem; box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-light); font-weight: 600; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: .2rem; font-family: var(--mono); }
.kpi.is-warn  .kpi-value { color: var(--warning); }
.kpi.is-accent .kpi-value { color: var(--accent); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: .1rem; }

/* ===== JS-freie Tabs (Radio-Pattern) ===== */
.tabs { margin-top: 1rem; }
.tabs > .tab-radio { position: absolute; opacity: 0; pointer-events: none; }
.tab-bar {
    display: flex; flex-wrap: wrap; gap: .25rem;
    border-bottom: 1px solid var(--border); margin-bottom: 1.1rem;
}
.tab-label {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .6rem .95rem; font-size: 13px; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; cursor: pointer; user-select: none;
    margin-bottom: -1px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: background .12s, color .12s;
}
.tab-label:hover { color: var(--text); background: var(--surface-2); }
.tab-count {
    font-size: 11px; font-weight: 700; min-width: 18px; text-align: center;
    background: var(--surface-3); color: var(--text-muted);
    border-radius: 999px; padding: .05rem .4rem;
}
.tab-panel { display: none; }
#kdtab-ap:checked    ~ .tab-bar label[for="kdtab-ap"],
#kdtab-bk:checked    ~ .tab-bar label[for="kdtab-bk"],
#kdtab-ge:checked    ~ .tab-bar label[for="kdtab-ge"],
#kdtab-pv:checked    ~ .tab-bar label[for="kdtab-pv"],
#kdtab-or:checked    ~ .tab-bar label[for="kdtab-or"],
#kdtab-au:checked    ~ .tab-bar label[for="kdtab-au"],
#kdtab-ti:checked    ~ .tab-bar label[for="kdtab-ti"],
#kdtab-lr:checked    ~ .tab-bar label[for="kdtab-lr"],
#kdtab-te:checked    ~ .tab-bar label[for="kdtab-te"] {
    color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-soft);
}
#kdtab-ap:checked ~ .tab-panels .tab-panel[data-tab="ap"],
#kdtab-bk:checked ~ .tab-panels .tab-panel[data-tab="bk"],
#kdtab-ge:checked ~ .tab-panels .tab-panel[data-tab="ge"],
#kdtab-pv:checked ~ .tab-panels .tab-panel[data-tab="pv"],
#kdtab-or:checked ~ .tab-panels .tab-panel[data-tab="or"],
#kdtab-au:checked ~ .tab-panels .tab-panel[data-tab="au"],
#kdtab-ti:checked ~ .tab-panels .tab-panel[data-tab="ti"],
#kdtab-lr:checked ~ .tab-panels .tab-panel[data-tab="lr"],
#kdtab-te:checked ~ .tab-panels .tab-panel[data-tab="te"] { display: block; }

/* ===== Kontakt-Karten ===== */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .85rem; }
.contact-card {
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    padding: 1rem 1.1rem; box-shadow: var(--shadow); position: relative;
}
.contact-card.is-main { border-color: var(--accent-border); background: var(--accent-soft); }
.contact-card h3 { font-size: 15px; margin: 0 0 .15rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.contact-card .cc-role { font-size: 12px; color: var(--text-muted); margin-bottom: .6rem; }
.contact-card .cc-line { font-size: 13px; margin: .15rem 0; }
.contact-card .cc-line a { color: var(--accent); }
.contact-card .cc-actions { display: flex; gap: .6rem; margin-top: .85rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.contact-card .cc-actions form { display: inline; }
.cc-btn { background: none; border: none; padding: 0; font: inherit; font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer; }
.cc-btn.danger { color: var(--danger); }
.cc-btn:hover { text-decoration: underline; }
.cc-portal { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .7rem; padding-top: .6rem; border-top: 1px dashed var(--border); font-size: 12px; }
.cc-portal form { display: inline; }
.cc-portal-state { color: var(--text-muted); }
.cc-portal-state strong.ok  { color: var(--success); }
.cc-portal-state strong.off { color: var(--text-light); }

/* ===== Detail-Liste (dl) ===== */
.detail-list { margin: 0; }
.detail-list > div { display: flex; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.detail-list > div:last-child { border-bottom: none; }
.detail-list dt { flex: 0 0 140px; color: var(--text-muted); font-size: 13px; }
.detail-list dd { margin: 0; font-size: 13px; }
.detail-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); column-gap: 2rem; }
.detail-cols > div { border-bottom: 1px solid var(--border); }

/* ===== Badge-Varianten ===== */
.badge-kunde       { background: var(--accent-soft); color: var(--accent-hover); border-color: transparent; }
.badge-interessent { background: var(--info-soft);   color: var(--info);   border-color: transparent; }
.badge-inaktiv     { background: #f3f4f6; color: #6b7280; border-color: transparent; }
.badge-primary     { background: var(--accent); color: #fff; border-color: transparent; }

/* ===== Aufgaben-/Ticket-Liste ===== */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .25rem; border-bottom: 1px solid var(--border); font-size: 13px; }
.task-item:last-child { border-bottom: none; }
.task-title { flex: 1; font-weight: 500; }
.task-due { color: var(--text-muted); font-size: 12px; font-family: var(--mono); }
.ticket-nr { font-family: var(--mono); font-size: 12px; color: var(--text-muted); margin-right: .3rem; }
.priority-badge { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--text-light); }
.priority-badge.prio-niedrig  { background: #94a3b8; }
.priority-badge.prio-normal   { background: var(--info); }
.priority-badge.prio-hoch     { background: var(--warning); }
.priority-badge.prio-kritisch { background: var(--danger); }

/* ===== Telefonate-Liste ===== */
.phone-list { list-style: none; margin: 0; padding: 0; }
.phone-list li { display: flex; align-items: center; gap: 1rem; padding: .6rem .25rem; border-bottom: 1px solid var(--border); font-size: 13px; }
.phone-list li:last-child { border-bottom: none; }
.phone-meta { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: 12px; min-width: 170px; }
.phone-dir { font-weight: 700; }
.phone-dir.phone-eingehend { color: var(--success); }
.phone-dir.phone-ausgehend { color: var(--info); }
.phone-thema { font-weight: 500; }

/* ===== data-table compact ===== */
.data-table.compact thead th { padding: .5rem .7rem; font-size: 11px; }
.data-table.compact tbody td { padding: .5rem .7rem; }
.data-table tfoot td { padding: .55rem .7rem; border-top: 2px solid var(--border-strong); }

/* ===== Kundenwahl-Widget (Autocomplete + Lupe-Dialog) ===== */
.kw-input { display: flex; gap: .4rem; }
.kw-input input { flex: 1; }
.kw-lupe {
    flex: 0 0 auto; width: 40px; border: 1px solid var(--border-strong);
    background: var(--surface-2); border-radius: var(--radius-sm); cursor: pointer;
    font-size: 15px; line-height: 1;
}
.kw-lupe:hover { background: var(--accent-soft); border-color: var(--accent-border); }
.kw-dlg {
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 1rem; width: min(560px, 92vw); box-shadow: var(--shadow-pop);
}
.kw-dlg::backdrop { background: rgba(28,25,23,.45); }
.kw-dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.kw-dlg-close { border: none; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.kw-dlg-close:hover { color: var(--text); }
.kw-dlg input { width: 100%; }
.kw-results { list-style: none; margin: .75rem 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.kw-results li { padding: .55rem .7rem; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; border-radius: var(--radius-sm); }
.kw-results li:hover, .kw-results li:focus { background: var(--accent-soft); outline: none; }
.kw-results li.kw-hint { color: var(--text-light); cursor: default; }
.kw-results li.kw-hint:hover { background: none; }

/* ===== Pagination (Seitennavigation) ===== */
.pagination { display: flex; flex-wrap: wrap; gap: .35rem; margin: 1rem 0 .5rem; justify-content: center; }
.pagination .page-link {
    display: inline-block; padding: .25rem .6rem; min-width: 2rem; text-align: center;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font-size: 13px; text-decoration: none;
}
.pagination .page-link:hover { background: var(--accent-soft); border-color: var(--accent-border); }
.pagination .page-link.active {
    font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
    background: var(--surface); color: var(--accent); border-color: var(--accent-border);
}

/* ----------------------------------------------------------- User-Menü (Topbar rechts) */
.usermenu { margin-left: .25rem; }
.usermenu .u-meta { display: inline-flex; flex-direction: column; align-items: flex-end; vertical-align: middle; line-height: 1.15; }
.usermenu .u-name { font-size: 13px; font-weight: 600; color: var(--text); }
.usermenu .u-role { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: .04em; }
.usermenu > .navdrop-menu { left: auto; right: 0; }
.usermenu-logout { margin-top: .25rem; border-top: 1px solid var(--border); padding-top: .25rem; }
.usermenu-logout button {
    display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
    padding: .5rem .65rem; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
    color: var(--text); font-family: inherit;
}
.usermenu-logout button:hover { background: var(--surface-3); }
@media (max-width: 760px) { .usermenu .u-role { display: none; } }
