/* ============================================================
   Fehlerdatenbank — Stylesheet (OSP-CI Glass, schlank)
   CI: #0080C9 (Primär) | #DC500F (Akzent) · Radius 10px
   Design-Tokens aus NZA/RMS v2.x übernommen (konsistentes Vokabular)
   ============================================================ */

:root, [data-theme="light"] {
    --primary:        #0080C9;
    --primary-dark:   #005f97;
    --primary-soft:   #e6f3fb;
    --accent:         #DC500F;
    --accent-dark:    #a83b08;
    --accent-soft:    #fdeee5;

    --st-done:         #16a34a;
    --st-done-soft:    #dcfce7;
    --st-work:         #d97706;
    --st-work-soft:    #fef3c7;
    --st-crit:         #dc2626;
    --st-crit-soft:    #fee2e2;
    --st-rejected:     #64748b;
    --st-rejected-soft:#f1f5f9;

    --glass-bg:       rgba(255,255,255,0.72);
    --glass-bg-solid: rgba(255,255,255,0.94);
    --glass-border:   rgba(0,128,201,0.15);
    --glass-shadow:   0 4px 16px rgba(0,128,201,0.08);
    --glass-blur:     blur(18px) saturate(150%);

    --hdr-bg:     rgba(0,128,201,0.92);
    --hdr-border: rgba(220,80,15,0.22);

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:  0 4px 12px rgba(14,30,52,0.08);
    --shadow-xl:  0 12px 36px -8px rgba(0,128,201,0.18);

    --bg:          #f4f7fa;
    --surface:     #ffffff;
    --text:        #0f172a;
    --text-muted:  #475569;
    --text-subtle: #94a3b8;
    --border:      #e2e8f0;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    --motion-base: 180ms;
    --ease:        cubic-bezier(.4,0,.2,1);
    --ease-out:    cubic-bezier(.16,1,.3,1);

    --font-display: 'Montserrat', system-ui, sans-serif;
    --font-body:    'Open Sans', system-ui, sans-serif;
    --font-mono:    'Fira Code', 'JetBrains Mono', monospace;
}

[data-theme="dark"], html.dark {
    --primary:      #1ea3ec;
    --primary-dark: #1580c5;
    --primary-soft: rgba(30,163,236,0.16);
    --accent:       #ff7a3d;
    --accent-dark:  #e0581e;
    --accent-soft:  rgba(255,122,61,0.16);

    --st-done:         #34d399;
    --st-done-soft:    rgba(52,211,153,0.18);
    --st-work:         #fbbf24;
    --st-work-soft:    rgba(251,191,36,0.18);
    --st-crit:         #f87171;
    --st-crit-soft:    rgba(248,113,113,0.20);
    --st-rejected:     #94a3b8;
    --st-rejected-soft:rgba(148,163,184,0.18);

    --glass-bg:       rgba(34,46,64,0.78);
    --glass-bg-solid: rgba(40,55,76,0.96);
    --glass-border:   rgba(255,255,255,0.12);
    --glass-shadow:   0 6px 24px rgba(0,0,0,0.45);
    --glass-blur:     blur(20px) saturate(140%);

    --hdr-bg:     rgba(13,22,38,0.92);
    --hdr-border: rgba(255,122,61,0.20);

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:  0 4px 14px rgba(0,0,0,0.4);
    --shadow-xl:  0 16px 40px -8px rgba(0,0,0,0.55);

    --bg:          #0a1220;
    --surface:     #141d2f;
    --text:        #f1f5f9;
    --text-muted:  #cbd5e1;
    --text-subtle: #a3b3c7;
    --border:      #1f2a3d;
}

html.no-transition * { transition: none !important; }

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); }

a { color: var(--primary); text-decoration: none; }

/* ==================== Login Screen ==================== */
.login-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: linear-gradient(135deg, #0080C9 0%, #005a8c 100%);
    display: flex; align-items: center; justify-content: center;
}
html.dark .login-screen { background: linear-gradient(135deg, #1E293B, #0F172A); }
.login-card {
    background: #fff; border-radius: 16px; padding: 48px 40px;
    text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 420px; width: 90%;
}
html.dark .login-card { background: var(--surface); box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.login-logo {
    width: 64px; height: 64px; border-radius: 14px;
    background: linear-gradient(135deg, #0080C9, #005a8c);
    color: #fff; font-family: var(--font-display);
    font-weight: 800; font-size: 1.1rem; letter-spacing: 1px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 20px; overflow: hidden;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.login-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-title { font-size: 1.5rem; color: var(--text); margin-bottom: 4px; }
html.dark .login-title { color: #f1f5f9; }
.login-subtitle { color: #666; font-size: 0.85rem; margin-bottom: 32px; }
html.dark .login-subtitle { color: var(--text-muted); }
.login-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 32px; background: #0080C9; color: #fff;
    border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: background var(--motion-base);
}
.login-btn:hover { background: #006ba8; }
.login-hint { margin-top: 16px; font-size: 0.75rem; color: #999; line-height: 1.5; }
html.dark .login-hint { color: var(--text-muted); }

/* ==================== Header ==================== */
#app-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 10px 22px;
    background: var(--hdr-bg);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--hdr-border);
    box-shadow: 0 4px 16px rgba(0,128,201,.12);
    color: #fff;
}
.hdr-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.hdr-app-favicon-link { display: inline-flex; }
.hdr-app-logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: rgba(255,255,255,0.16);
    object-fit: cover; overflow: hidden; display: block;
    box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.hdr-wordmark { min-width: 0; }
.hdr-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hdr-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: #fff; }
.hdr-subtitle { font-size: 0.72rem; color: rgba(255,255,255,0.82); margin-top: 1px; }
.hdr-version-pill {
    display: inline-flex; align-items: center; gap: 3px;
    background: rgba(255,255,255,0.18); color: #fff;
    border: none; border-radius: 999px; padding: 2px 9px;
    font-size: 0.7rem; font-weight: 700; cursor: pointer;
    font-family: var(--font-mono); transition: background var(--motion-base);
}
.hdr-version-pill:hover { background: rgba(255,255,255,0.3); }

.hdr-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hdr-link {
    color: rgba(255,255,255,0.9); font-size: 0.78rem; font-weight: 700;
    padding: 5px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.08); transition: background var(--motion-base);
}
.hdr-link:hover { background: rgba(255,255,255,0.2); }
/* Icon-Schnellwechsel NZA/RMS (nur Icon) */
.hdr-app-switch {
    width: 34px; height: 34px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.22);
    overflow: hidden; flex-shrink: 0;
    transition: background var(--motion-base), transform var(--motion-base), box-shadow var(--motion-base);
}
.hdr-app-switch img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; display: block; }
.hdr-app-switch:hover { background: rgba(255,255,255,0.28); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.2); }
.hdr-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.28); margin: 0 2px; flex-shrink: 0; }
.hdr-icon-btn {
    width: 34px; height: 34px; border-radius: 9px; border: none;
    background: rgba(255,255,255,0.12); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background var(--motion-base);
}
.hdr-icon-btn:hover { background: rgba(255,255,255,0.24); }
.theme-toggle-btn svg { width: 18px; height: 18px; }
.hdr-user-badge {
    font-size: 0.78rem; font-weight: 700; color: #fff;
    padding: 5px 11px; background: rgba(255,255,255,0.16); border-radius: 8px;
    white-space: nowrap;
}
.hdr-clock { font-size: 0.74rem; color: rgba(255,255,255,0.85); white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
    .hdr-subtitle, .hdr-clock { display: none; }
    .hdr-link { padding: 4px 8px; }
}

/* ==================== KPI-Hero ==================== */
.kpi-hero { padding: 22px 22px 8px; max-width: 1500px; margin: 0 auto; }
.kpi-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 18px;
}
.kpi-card {
    position: relative;
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px;
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
}
.kpi-card-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon-total { background: var(--primary-soft); color: var(--primary); }
.kpi-icon-split { background: var(--accent-soft); color: var(--accent); }
.kpi-icon-cost  { background: var(--st-done-soft); color: var(--st-done); }
.kpi-card-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-card-value { font-family: var(--font-display); font-weight: 800; font-size: 1.75rem; color: var(--text); line-height: 1.1; }
.kpi-card-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.kpi-split-nza { color: var(--primary); }
.kpi-split-rms { color: var(--accent); }
.kpi-split-sep { color: var(--text-subtle); margin: 0 4px; font-weight: 400; }

/* ==================== Filterleiste ==================== */
.filter-section {
    max-width: 1500px; margin: 0 auto; padding: 8px 22px 4px;
}
.filter-row {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 14px 16px;
}
.search-box { position: relative; flex: 1 1 300px; min-width: 220px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search-box input {
    width: 100%; padding: 9px 12px 9px 36px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font-family: inherit; font-size: 0.9rem;
}
.filter-group { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-section select, .filter-section input[type="date"] {
    padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font-family: inherit; font-size: 0.85rem;
    cursor: pointer;
}
.filter-section select:focus, .filter-section input:focus {
    outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary);
}
.filter-dates { align-items: center; }
.date-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); }

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: background var(--motion-base), border-color var(--motion-base), transform var(--motion-base);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ==================== Tabelle ==================== */
.main-content { max-width: 1500px; margin: 0 auto; padding: 8px 22px 40px; }
.table-section {
    background: var(--glass-bg-solid);
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
}
.table-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.table-header h2 { font-size: 1.05rem; color: var(--text); }
.table-header-actions { display: flex; align-items: center; gap: 14px; }
.table-count { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.btn-export { padding: 7px 13px; font-size: 0.8rem; gap: 6px; }
.btn-export svg { flex-shrink: 0; }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead th {
    text-align: left; padding: 11px 12px; white-space: nowrap;
    background: var(--primary-soft); color: var(--primary-dark);
    font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 2px solid var(--glass-border);
    position: sticky; top: 0; z-index: 2;
}
html.dark thead th { background: rgba(30,163,236,0.12); color: var(--text-muted); }
th.sortable { cursor: pointer; user-select: none; transition: color var(--motion-base); }
th.sortable:hover { color: var(--primary); }
th.sortable .sort-icon::after { content: ' ↕'; opacity: 0.35; font-size: 0.8em; }
th.sortable.sort-asc  .sort-icon::after { content: ' ↑'; opacity: 1; }
th.sortable.sort-desc .sort-icon::after { content: ' ↓'; opacity: 1; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background var(--motion-base); }
tbody tr:hover { background: var(--primary-soft); }
html.dark tbody tr:hover { background: rgba(30,163,236,0.1); }
/* Fehlerursache (Fehlerkategorie-Badge) — Fehlerbeschreibung lebt seit v1.9.0 nur noch
   im Detail-Modal (voller Text, Liste bleibt scanbar). */
.col-fehler { min-width: 140px; }
.col-kosten { text-align: right; }
.cell-kosten { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-link { width: 36px; }
.col-kst, .col-quelle { white-space: nowrap; }
.col-verursacher { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fehler-id-cell { font-weight: 700; color: var(--primary); font-family: var(--font-mono); white-space: nowrap; }
.row-link-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); cursor: pointer;
    transition: background var(--motion-base), color var(--motion-base);
}
.row-link-btn:hover { background: var(--primary-soft); color: var(--primary); }
.loading-row td, .empty-row td { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-row .empty-icon { display: block; margin: 0 auto 10px; color: var(--text-subtle); }
.empty-row .empty-sub { display: block; font-size: 0.82rem; color: var(--text-subtle); margin-top: 6px; }

/* ==================== Badges ==================== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px;
    font-size: 0.72rem; font-weight: 700; white-space: nowrap; line-height: 1.4;
}
.badge-sm { padding: 1px 7px; font-size: 0.66rem; }
.badge-nza { background: var(--primary-soft); color: var(--primary-dark); }
.badge-rms { background: var(--accent-soft); color: var(--accent-dark); }
html.dark .badge-nza { color: var(--primary); }
html.dark .badge-rms { color: var(--accent); }
.badge-kat { background: var(--st-rejected-soft); color: var(--text-muted); }
.badge-status { background: var(--st-rejected-soft); color: var(--st-rejected); }
.badge-status.st-done   { background: var(--st-done-soft); color: var(--st-done); }
.badge-status.st-work   { background: var(--st-work-soft); color: var(--st-work); }
.badge-status.st-crit   { background: var(--st-crit-soft); color: var(--st-crit); }
.badge-status.st-reject { background: var(--st-rejected-soft); color: var(--st-rejected); }

/* ==================== Pagination ==================== */
.pagination {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 6px; padding: 16px 20px;
}
.pagination button {
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
    transition: background var(--motion-base), color var(--motion-base);
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:hover:not(.active):not(:disabled) { background: var(--primary-soft); }
.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination .page-info { font-size: 0.8rem; color: var(--text-muted); padding: 0 8px; }

/* ==================== Modal ==================== */
.modal {
    display: none; position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,0.55); backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl); width: 100%; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid var(--glass-border);
    animation: modal-in 0.22s var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-sm { max-width: 440px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 820px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
}
.modal-header h2 { font-size: 1.1rem; color: #fff; }
.modal-header-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.modal-header-right { display: flex; align-items: center; gap: 8px; }
.modal-header .badge-nza, .modal-header .badge-rms { background: rgba(255,255,255,0.22); color: #fff; }
.nav-btn {
    width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.12); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    transition: background var(--motion-base);
}
.nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.26); }
.nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.detail-position { font-size: 0.78rem; color: rgba(255,255,255,0.9); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }
.modal-close {
    background: rgba(255,255,255,0.14); border: none; color: #fff;
    width: 32px; height: 32px; border-radius: 8px; font-size: 1.4rem; line-height: 1;
    cursor: pointer; transition: background var(--motion-base);
}
.modal-close:hover { background: rgba(255,255,255,0.3); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 14px 22px; border-top: 1px solid var(--border);
}

/* Tab-Bar im Detail-Modal (Stammdaten/Fehler/Maßnahme/Kosten/ERP-Daten) */
.tabs {
    display: flex; gap: 2px; margin-bottom: 20px; overflow-x: auto;
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm); padding: 4px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.tabs::-webkit-scrollbar { height: 3px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.tab-btn {
    padding: 7px 14px; border: none; background: transparent; font-size: 0.8rem;
    cursor: pointer; color: var(--text-muted); border-radius: var(--radius-sm);
    transition: background var(--motion-base) var(--ease), color var(--motion-base) var(--ease);
    font-family: var(--font-body); font-weight: 500; white-space: nowrap; flex-shrink: 0;
}
.tab-btn:hover { background: var(--primary-soft); color: var(--primary); }
.tab-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Detail-Modal-Inhalt */
.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title {
    font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    color: var(--primary); margin-bottom: 10px; padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 20px; }
.detail-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-field.full { grid-column: 1 / -1; }
.detail-field-label { font-size: 0.72rem; color: var(--text-subtle); font-weight: 600; }
.detail-field-value { font-size: 0.9rem; color: var(--text); word-break: break-word; }
.detail-field-value.mono { font-family: var(--font-mono); }
.detail-field-value.note { white-space: pre-wrap; line-height: 1.55; }
.detail-field-value.muted { color: var(--text-subtle); font-style: italic; }
.detail-field-value.verursacher-id { position: relative; cursor: help; width: fit-content;
    border-bottom: 1px dotted var(--text-subtle); outline: none; }
.detail-field-value.verursacher-id::after {
    content: attr(data-name); position: absolute; left: 0; bottom: calc(100% + 6px);
    background: #1e293b; color: #fff; padding: 5px 9px; border-radius: 6px;
    font-size: 0.78rem; font-weight: 600; white-space: nowrap; letter-spacing: .2px;
    box-shadow: 0 6px 18px rgba(0,0,0,.3); opacity: 0; transform: translateY(4px);
    pointer-events: none; transition: opacity .12s ease, transform .12s ease; z-index: 60; }
.detail-field-value.verursacher-id:hover::after,
.detail-field-value.verursacher-id:focus::after { opacity: 1; transform: translateY(0); }

/* ERP-Daten-Abschnitt (Stückliste/Arbeitsgänge, gepinnter Snapshot — js/erp-render.js) */
.empty-state { color: var(--text-subtle); font-style: italic; font-size: 0.85rem; margin: 4px 0; }
.erp-subhead { font-size: 0.82rem; font-weight: 700; color: var(--text-muted); margin: 14px 0 4px; }
.erp-subhead:first-of-type { margin-top: 10px; }
.erp-count { font-weight: 400; color: var(--text-subtle); font-size: 0.85em; }
.erp-quelle { margin-top: 10px; font-size: 0.75rem; color: var(--text-subtle); }
.erp-tbl { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 0.85rem; }
.erp-tbl th { background: var(--primary); color: #fff; text-align: left; padding: 4px 8px; font-weight: 600; }
.erp-tbl td { padding: 3px 8px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text); }
.erp-head td:first-child { font-weight: 600; color: var(--text-muted); background: var(--bg); width: 150px; }
.erp-tbl .mono, .erp-num { font-family: var(--font-mono); }
.erp-num { text-align: right; white-space: nowrap; }
.erp-exp-cell { text-align: center; width: 30px; }
.erp-exp { border: none; background: var(--bg); color: var(--primary); cursor: pointer; border-radius: 4px; padding: 0 7px; font-size: 0.9rem; }
.erp-detrow > td { background: var(--bg); padding: 8px 12px; }
.erp-txt { margin-bottom: 6px; font-size: 0.82rem; }
.erp-txt pre, .erp-afo-ltext { margin: 3px 0 0; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; white-space: pre-wrap; font-family: inherit; font-size: 0.8rem; color: var(--text-muted); }
.erp-sub { margin-top: 4px; }
.erp-sub > b { font-size: 0.82rem; color: var(--primary); }
.erp-bg-badge { display: inline-block; background: var(--primary); opacity: 0.85; color: #fff; border-radius: 8px; padding: 0 6px; font-size: 0.7rem; font-weight: 600; }
.erp-afo-ref { display: inline-block; background: var(--bg); color: var(--primary); border-radius: 6px; padding: 0 5px; font-size: 0.75rem; font-weight: 600; }
.erp-afo-bez { font-weight: 600; color: var(--text); }
.erp-txt-det { display: inline-block; margin-left: 6px; }
.erp-txt-det summary { cursor: pointer; color: var(--primary); font-size: 0.8rem; }
.erp-txt-det pre { margin: 4px 0; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; white-space: pre-wrap; font-size: 0.8rem; color: var(--text); }

/* Top-3-Fehlerkategorien (KPI-Card) */
.kpi-top3-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.kpi-top3-list li { display: flex; align-items: baseline; gap: 6px; font-size: 0.8rem; line-height: 1.3; min-width: 0; }
.kpi-top3-rank { color: var(--accent, #DC500F); font-weight: 800; font-size: 0.74rem; flex: 0 0 auto; }
.kpi-top3-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kpi-top3-count { margin-left: auto; padding-left: 6px; font-weight: 700; color: var(--text-subtle); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.kpi-top3-empty { color: var(--text-subtle); }

/* Archiv-Dialog */
.archive-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.55; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.form-group input {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font-family: inherit; font-size: 0.95rem;
}
.form-group input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

/* Versions-Modal */
.version-entry { padding: 14px 0; border-bottom: 1px solid var(--border); }
.version-entry:last-child { border-bottom: none; }
.version-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.version-num { font-family: var(--font-mono); font-weight: 700; color: var(--primary); }
.version-date { font-size: 0.78rem; color: var(--text-subtle); }
.version-title { font-weight: 700; font-size: 0.92rem; color: var(--text); flex-basis: 100%; }
.version-entry ul { margin: 0; padding-left: 20px; }
.version-entry li { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; line-height: 1.5; }

/* ==================== Toasts ==================== */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px;
    max-width: calc(100vw - 48px); pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px 10px 14px; border-radius: 8px;
    background: #fff; color: #1f2937;
    border: 1px solid #e5e7eb; border-left: 4px solid var(--primary);
    box-shadow: 0 12px 32px rgba(0,0,0,0.16), 0 2px 8px rgba(0,0,0,0.08);
    font-size: 0.88rem; font-weight: 500; min-width: 240px; max-width: 420px;
    pointer-events: all; transform: translateX(24px); opacity: 0;
    transition: transform 0.24s var(--ease-out), opacity 0.24s var(--ease-out);
}
.toast.toast-visible { transform: translateX(0); opacity: 1; }
.toast.toast-leaving { transform: translateX(28px); opacity: 0; }
html.dark .toast, [data-theme="dark"] .toast { background: #1e293b; color: #f1f5f9; border-color: rgba(148,163,184,0.18); }
.toast .toast-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0; }
.toast .toast-text { flex: 1; line-height: 1.35; word-break: break-word; }
.toast .toast-close { background: transparent; border: none; color: inherit; font-size: 1.2rem; line-height: 1; width: 22px; height: 22px; border-radius: 4px; cursor: pointer; opacity: 0.55; flex-shrink: 0; transition: opacity 0.15s, background 0.15s; }
.toast .toast-close:hover { opacity: 1; background: rgba(0,0,0,0.06); }
html.dark .toast .toast-close:hover { background: rgba(255,255,255,0.08); }
.toast.toast-success { border-left-color: #16a34a; }
.toast.toast-success .toast-icon { background: rgba(22,163,74,0.14); color: #16a34a; }
.toast.toast-error   { border-left-color: #dc2626; }
.toast.toast-error   .toast-icon { background: rgba(220,38,38,0.14); color: #dc2626; }
.toast.toast-info    { border-left-color: #0080C9; }
.toast.toast-info    .toast-icon { background: rgba(0,128,201,0.14); color: #0080C9; }
.toast.toast-loading { border-left-color: #0080C9; }
.toast.toast-loading .toast-icon { background: rgba(0,128,201,0.14); color: #0080C9; }
.toast .toast-spinner { animation: toast-spin 0.9s linear infinite; }
@keyframes toast-spin { to { transform: rotate(360deg); } }

/* ==================== Admin-Only ==================== */
.admin-only { display: none !important; }
.admin-only.visible { display: inline-flex !important; }

/* ==================== Responsive ==================== */
@media (max-width: 700px) {
    .kpi-hero, .filter-section, .main-content { padding-left: 12px; padding-right: 12px; }
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-group, .filter-dates { width: 100%; }
    table { font-size: 0.78rem; }
    tbody td, thead th { padding: 8px; }
    .col-fehler { min-width: 100px; }
}

/* ============================================================
   Reiter „KI-Analyse" (js/ki-render.js) — Datenlauf 18.07.2026.
   Kompakt-Einschätzung + Detail-Klappen; portiert aus NZA v2.x
   (ki-analyse.js), theme-aware über FehlerDB-CSS-Vars.
   Tabellen erben .erp-tbl. --bg-soft existiert hier nicht →
   durch var(--bg) ersetzt (wie .erp-detrow).
   ============================================================ */
.ki-einschaetzung p { margin: 0 0 10px; line-height: 1.55; font-size: 0.88rem; }
.ki-einschaetzung p:last-child { margin-bottom: 0; }
.ki-review-hinweis { margin-top: 10px; padding: 7px 11px; border-radius: 8px; font-size: 0.8rem;
    background: rgba(220, 80, 15, .09); color: #c2410c; border: 1px solid rgba(220, 80, 15, .3); }
[data-theme="dark"] .ki-review-hinweis, html.dark .ki-review-hinweis { color: #fdba74; }
.ki-det { margin: 0 0 8px; border: 1px solid var(--border, rgba(148, 163, 184, .3));
    border-radius: 10px; padding: 8px 12px; background: var(--bg); }
.ki-det summary { cursor: pointer; user-select: none; font-weight: 600; font-size: 0.84rem;
    color: var(--text); list-style: none; display: flex; align-items: baseline; gap: 6px; }
.ki-det summary::-webkit-details-marker { display: none; }
.ki-det summary::before { content: '▸'; color: var(--primary, #0080C9); flex: 0 0 auto; }
.ki-det[open] summary::before { content: '▾'; }
.ki-det-body { margin-top: 8px; }
.ki-status-hinweis { margin: 0 0 8px; font-size: 0.82rem; color: var(--text-muted); }
.ki-conf { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem;
    font-weight: 600; white-space: nowrap; }
.ki-conf-hoch { background: rgba(22, 163, 74, .13); color: #15803d; }
.ki-conf-mittel { background: rgba(0, 128, 201, .13); color: #0369a1; }
.ki-conf-niedrig { background: rgba(220, 80, 15, .14); color: #c2410c; }
[data-theme="dark"] .ki-conf-hoch, html.dark .ki-conf-hoch { background: rgba(34, 197, 94, .2); color: #4ade80; }
[data-theme="dark"] .ki-conf-mittel, html.dark .ki-conf-mittel { background: rgba(56, 189, 248, .18); color: #7dd3fc; }
[data-theme="dark"] .ki-conf-niedrig, html.dark .ki-conf-niedrig { background: rgba(251, 146, 60, .2); color: #fdba74; }
.ki-primaer { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px;
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    background: rgba(0, 128, 201, .12); color: var(--primary, #0080C9); }
.ki-indiz { font-size: 0.76rem; color: var(--text-muted); margin-top: 3px; line-height: 1.45; }
.ki-row { display: flex; gap: 10px; margin: 0 0 8px; font-size: 0.84rem; align-items: baseline; }
.ki-row:last-child { margin-bottom: 0; }
.ki-row-label { flex: 0 0 128px; color: var(--text-muted); font-weight: 600; font-size: 0.74rem;
    text-transform: uppercase; letter-spacing: 0.05em; }
.ki-row-wert { min-width: 0; }
.ki-ok { color: #15803d; font-weight: 600; }
.ki-warn { color: #c2410c; font-weight: 600; }
[data-theme="dark"] .ki-ok, html.dark .ki-ok { color: #4ade80; }
[data-theme="dark"] .ki-warn, html.dark .ki-warn { color: #fdba74; }
.ki-aehnlich, .ki-empf { margin: 0; padding: 0; list-style: none; }
.ki-aehnlich li, .ki-empf li { margin: 0 0 8px; font-size: 0.83rem; line-height: 1.5; }
.ki-aehnlich li:last-child, .ki-empf li:last-child { margin-bottom: 0; }
.ki-empf li { display: flex; gap: 8px; align-items: baseline; }
.ki-wdh-id { font-family: 'Fira Code', monospace; font-size: 0.8rem; font-weight: 600;
    color: var(--primary, #0080C9); text-decoration: none; }
a.ki-wdh-id:hover { text-decoration: underline; }
.ki-sys { font-size: 0.72rem; color: var(--text-subtle); }
.ki-prio { flex: 0 0 auto; display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ki-prio-hoch { background: rgba(220, 80, 15, .14); color: #c2410c; }
.ki-prio-mittel { background: rgba(0, 128, 201, .13); color: #0369a1; }
.ki-prio-niedrig { background: rgba(148, 163, 184, .18); color: #64748b; }
[data-theme="dark"] .ki-prio-hoch, html.dark .ki-prio-hoch { background: rgba(251, 146, 60, .2); color: #fdba74; }
[data-theme="dark"] .ki-prio-mittel, html.dark .ki-prio-mittel { background: rgba(56, 189, 248, .18); color: #7dd3fc; }
[data-theme="dark"] .ki-prio-niedrig, html.dark .ki-prio-niedrig { background: rgba(148, 163, 184, .22); color: #cbd5e1; }
