/* ==========================================================================
   SOC Panel design system
   Tokens (light + dark), base styles and shared components. Loaded by the
   panel shell and by every full page (Security Alerts, CVE lookup popup).
   ========================================================================== */

:root {
    color-scheme: light;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    /* Text tokens reach at least 4.5:1 on every surface (WCAG AA) */
    --text-3: #5d6b80;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-text: #1d4ed8;
    --ring: rgba(37, 99, 235, 0.35);

    --danger: #c81e1e;
    --danger-soft: #fef2f2;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --company: #7c3aed;
    --company-soft: #f5f3ff;

    --sev-critical: #b91c1c;
    --sev-critical-soft: #fee2e2;
    --sev-high: #c2410c;
    --sev-high-soft: #ffedd5;
    --sev-medium: #a16207;
    --sev-medium-soft: #fef9c3;
    --sev-low: #15803d;
    --sev-low-soft: #dcfce7;
    --sev-none: #64748b;
    --sev-none-soft: #f1f5f9;

    --src-heise: #0f766e;
    --src-heise-soft: #ccfbf1;
    --src-certbund: #1e40af;
    --src-certbund-soft: #dbeafe;

    --sidebar-bg: #ffffff;
    --sidebar-bg-2: #ffffff;
    --sidebar-text: #334155;
    --sidebar-strong: #0f172a;
    --sidebar-muted: #5d6b80;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #eff6ff;
    --sidebar-active-text: #1d4ed8;
    --sidebar-accent: #2563eb;
    --sidebar-border: #e2e8f0;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Liberation Mono', monospace;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0a0f1c;
    --surface: #111827;
    --surface-2: #0f1626;
    --surface-3: #1a2336;
    --border: #1f2a3d;
    --border-strong: #334155;
    --text: #e5e9f0;
    --text-2: #9aa7ba;
    --text-3: #8391a7;

    /* White button text needs the darker blue */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(59, 130, 246, 0.14);
    --primary-text: #93c5fd;
    --ring: rgba(96, 165, 250, 0.45);

    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --company: #a78bfa;
    --company-soft: rgba(167, 139, 250, 0.14);

    --sev-critical: #f87171;
    --sev-critical-soft: rgba(248, 113, 113, 0.16);
    --sev-high: #fb923c;
    --sev-high-soft: rgba(251, 146, 60, 0.15);
    --sev-medium: #facc15;
    --sev-medium-soft: rgba(250, 204, 21, 0.13);
    --sev-low: #4ade80;
    --sev-low-soft: rgba(74, 222, 128, 0.13);
    --sev-none: #94a3b8;
    --sev-none-soft: rgba(148, 163, 184, 0.13);

    --src-heise: #5eead4;
    --src-heise-soft: rgba(45, 212, 191, 0.13);
    --src-certbund: #93c5fd;
    --src-certbund-soft: rgba(96, 165, 250, 0.14);

    --sidebar-bg: #070b15;
    --sidebar-bg-2: #0c1322;
    --sidebar-text: #cbd5e1;
    --sidebar-strong: #ffffff;
    --sidebar-muted: #7c8aa0;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(59, 130, 246, 0.16);
    --sidebar-active-text: #ffffff;
    --sidebar-accent: #60a5fa;
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.mono { font-family: var(--mono); font-feature-settings: 'zero' 1; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.icon {
    width: 16px; height: 16px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong); border-radius: 10px;
    border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

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

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 36px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 500; white-space: nowrap;
    cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

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

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }

/* --- Form controls ------------------------------------------------------------ */

.input, .select {
    height: 36px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > .icon { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 32px; width: 100%; }

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span>Text</label> */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
/* The toggle is the span right after the checkbox (or the first span of a
   link styled as a switch) - other spans in the label are just text */
.switch > input + span, a.switch > span:first-child {
    position: relative; width: 30px; height: 18px; flex: none;
    border-radius: 999px; background: var(--border-strong); transition: background .15s;
}
.switch > input + span::after, a.switch > span:first-child::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }

/* Segmented control made of links or buttons */
.segmented {
    display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 3px; gap: 2px;
    background: var(--surface-3); border-radius: 8px;
}
.segmented > * {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 11px; border: 0; border-radius: 6px;
    background: transparent; color: var(--text-2);
    font-size: 12.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
}
.segmented > *:hover { color: var(--text); text-decoration: none; }
.segmented > .active {
    background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-sm);
}
.segmented .count { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }

/* --- Badges and chips ------------------------------------------------------------ */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 20px; padding: 0 7px; border-radius: 5px;
    font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.badge-critical { background: var(--sev-critical-soft); color: var(--sev-critical); }
.badge-high     { background: var(--sev-high-soft); color: var(--sev-high); }
.badge-medium   { background: var(--sev-medium-soft); color: var(--sev-medium); }
.badge-low      { background: var(--sev-low-soft); color: var(--sev-low); }
.badge-none     { background: var(--sev-none-soft); color: var(--sev-none); }
.badge-danger   { background: var(--danger-soft); color: var(--danger); }
.badge-success  { background: var(--success-soft); color: var(--success); }
.badge-warning  { background: var(--warning-soft); color: var(--warning); }
.badge-company  { background: var(--company-soft); color: var(--company); }
.badge-primary  { background: var(--primary-soft); color: var(--primary-text); }
.badge-heise    { background: var(--src-heise-soft); color: var(--src-heise); }
.badge-certbund { background: var(--src-certbund-soft); color: var(--src-certbund); }
.badge-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-2); }
.badge-new      { background: var(--primary); color: #fff; }
.badge-priority { font-variant-numeric: tabular-nums; }

/* A button that looks like a link (clickable IPs, domains …) */
.link-btn {
    display: inline; padding: 0; border: 0; background: none; cursor: pointer;
    color: var(--primary-text); font: inherit; text-align: left; overflow-wrap: anywhere;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.mono { font-family: var(--mono); }

.chip {
    display: inline-flex; align-items: center; gap: 4px;
    height: 24px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface-2); color: var(--text);
    font-family: var(--mono); font-size: 11.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }

/* --- Cards, panels, notices -------------------------------------------------------- */

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.notice {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
    font-size: 13px;
}
.notice > .icon { margin-top: 2px; }
.notice-warning { background: var(--warning-soft); border-color: transparent; color: var(--text); }
.notice-warning > .icon { color: var(--warning); }
.notice-danger { background: var(--danger-soft); border-color: transparent; color: var(--text); }
.notice-danger > .icon { color: var(--danger); }
.notice-info { background: var(--primary-soft); border-color: transparent; color: var(--text); }
.notice-info > .icon { color: var(--primary); }

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 40px 24px; text-align: center; color: var(--text-2);
}
.empty > .icon { width: 32px; height: 32px; color: var(--text-3); stroke-width: 1.5; }
.empty h3 { font-size: 15px; color: var(--text); font-weight: 600; }

kbd {
    display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
    border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
    background: var(--surface-2); color: var(--text-3);
    font-family: var(--font); font-size: 10.5px; font-weight: 500;
}

/* --- Dialog ------------------------------------------------------------------ */

dialog.dialog {
    margin: auto; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
    padding: 0; overflow: hidden;
}
dialog.dialog::backdrop { background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(2px); }
.dialog-wide { width: min(860px, calc(100vw - 32px)) !important; }
.dialog-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.dialog-header h2 { font-size: 16px; font-weight: 600; flex: 1; display: flex; align-items: center; gap: 8px; }
.dialog-body { padding: 18px 20px; overflow-y: auto; max-height: calc(100vh - 200px); }
.dialog-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
}

/* --- Drawer (slide-over from the right) ------------------------------------------ */

.drawer-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(2, 6, 23, 0.45); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
    width: min(760px, 100vw); display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    /* Closed: out of view and out of the tab order (common.js socDrawer also sets inert) */
    transform: translateX(100%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .22s ease; }
.focus-sentinel { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.drawer.open + .drawer-backdrop, .drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-header {
    display: flex; align-items: center; gap: 8px;
    height: 56px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--border); flex: none;
}
.drawer-header h2 { flex: 1; font-size: 15px; font-weight: 600; }
.drawer-body { flex: 1; min-height: 0; }
.drawer-body iframe { width: 100%; height: 100%; border: 0; background: var(--surface); }

/* --- Feedback ------------------------------------------------------------------ */

.spinner {
    width: 32px; height: 32px; margin: 24px auto;
    border: 3px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite;
}
.loading {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin .7s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .3s ease; }

.toast-stack {
    position: fixed; right: 16px; bottom: 16px; z-index: 200;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}

.toast {
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: #0f172a; color: #f8fafc; box-shadow: var(--shadow-lg);
    font-size: 13px; opacity: 0; transform: translateY(6px);
    transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }

/* A link styled as switch (e.g. a filter that reloads the page) */
a.switch { text-decoration: none; }
a.switch:hover { color: var(--text); }
.switch.is-on > span:first-child { background: var(--primary); }
.switch.is-on > span:first-child::after { transform: translateX(12px); }

.select-sm, .input-sm { height: 30px; font-size: 12.5px; padding: 0 8px; }

/* --- Key figure tiles and panels (Security Alerts, KEV monitor) ------------ */

.kpi {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
    padding: 12px 16px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    position: relative; overflow: hidden;
}
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.kpi-critical::before { background: var(--sev-critical); }
.kpi-exploit::before { background: var(--warning); }
.kpi-company::before { background: var(--company); }
.kpi-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel {
    display: flex; flex-direction: column; min-height: 0; min-width: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.panel-head {
    display: flex; flex-direction: column; gap: 10px; flex: none;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.panel-head h2 .icon { color: var(--text-3); }
.panel-head h2 .count {
    font-size: 11.5px; font-weight: 600; color: var(--text-2);
    background: var(--surface-3); border-radius: 999px; padding: 1px 8px;
}
.panel-search .input { height: 32px; background: var(--surface-2); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; }

/* --- Dropdown menu --------------------------------------------------------- */

/* Dropdown built on <details> */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--surface-3); }
.menu-list {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px;
    display: flex; flex-direction: column; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.menu-list a, .menu-list button {
    padding: 8px 10px; border: 0; border-radius: 6px; background: none;
    color: var(--text); font-size: 13px; text-align: left; cursor: pointer; white-space: nowrap;
}
.menu-list a:hover, .menu-list button:hover { background: var(--surface-3); text-decoration: none; }

/* ==========================================================================
   Shared frontend core (charts.js, table.js, search.js, common.js helpers)
   ========================================================================== */

/* --- Chart tokens (static/js/charts.js) ------------------------------------
   Categorical slots in a fixed order (never cycled); dark steps are selected
   for the dark surface, not flipped. */
:root {
    --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
    --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #4a3aa7; --chart-8: #e34948;
    --chart-grid: #e2e8f0;
    --chart-axis: #5d6b80;
}
:root[data-theme="dark"] {
    --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
    --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
    --chart-grid: #1f2a3d;
    --chart-axis: #8391a7;
}

/* --- High contrast theme (data-theme="contrast") ---------------------------
   Pure black and white, bright accents, thick yellow focus rings, no subtle
   greys. A dark scheme: window.socIsDark() is true for it. */
:root[data-theme="contrast"] {
    color-scheme: dark;

    --bg: #000000;
    --surface: #000000;
    --surface-2: #000000;
    --surface-3: #1c1c1c;
    --border: #ffffff;
    --border-strong: #ffffff;
    --text: #ffffff;
    --text-2: #ffffff;
    --text-3: #ffffff;

    --primary: #0040c0;
    --primary-hover: #002f8f;
    --primary-soft: #000000;
    --primary-text: #8fe3ff;
    --ring: #ffff00;

    --danger: #ff7070;   --danger-soft: #000000;
    --warning: #ffd000;  --warning-soft: #000000;
    --success: #4dff7a;  --success-soft: #000000;
    --company: #d0a8ff;  --company-soft: #000000;

    --sev-critical: #ff7070; --sev-critical-soft: #000000;
    --sev-high: #ffa64d;     --sev-high-soft: #000000;
    --sev-medium: #ffff00;   --sev-medium-soft: #000000;
    --sev-low: #4dff7a;      --sev-low-soft: #000000;
    --sev-none: #ffffff;     --sev-none-soft: #000000;
    --src-heise: #5ff5e0;    --src-heise-soft: #000000;
    --src-certbund: #8fe3ff; --src-certbund-soft: #000000;

    --sidebar-bg: #000000; --sidebar-bg-2: #000000;
    --sidebar-text: #ffffff; --sidebar-strong: #ffffff; --sidebar-muted: #ffffff;
    --sidebar-hover: #1c1c1c; --sidebar-active: #000000;
    --sidebar-active-text: #ffff00; --sidebar-accent: #ffff00; --sidebar-border: #ffffff;

    --shadow-sm: none; --shadow: none; --shadow-lg: 0 0 0 2px #ffffff;

    --chart-1: #8fe3ff; --chart-2: #ffa64d; --chart-3: #4dff7a; --chart-4: #ffff00;
    --chart-5: #ff8fc8; --chart-6: #b0ff4d; --chart-7: #d0a8ff; --chart-8: #ff7070;
    --chart-grid: #5c5c5c;
    --chart-axis: #ffffff;
}
:root[data-theme="contrast"] :focus-visible { outline: 3px solid #ffff00; outline-offset: 2px; }
:root[data-theme="contrast"] .input:focus,
:root[data-theme="contrast"] .select:focus { border-color: #ffff00; box-shadow: 0 0 0 3px #ffff00; }
:root[data-theme="contrast"] .badge { border: 1px solid currentColor; background: #000; }
:root[data-theme="contrast"] .badge-new { background: #ffff00; color: #000; }
:root[data-theme="contrast"] .btn { border-color: #ffffff; }
:root[data-theme="contrast"] .btn-ghost { border-color: transparent; color: #fff; }
:root[data-theme="contrast"] .segmented { border: 1px solid #fff; background: #000; }
:root[data-theme="contrast"] .segmented > .active { background: #fff; color: #000; }
:root[data-theme="contrast"] .nav-item.active { outline: 2px solid #ffff00; outline-offset: -2px; }
:root[data-theme="contrast"] a { text-decoration: underline; }
:root[data-theme="contrast"] .toast { background: #000; border: 2px solid #fff; }
:root[data-theme="contrast"] dialog.dialog::backdrop { background: rgba(0, 0, 0, .85); backdrop-filter: none; }

/* --- Reduced motion and forced colours ------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important; scroll-behavior: auto !important;
    }
    .skeleton, .skeleton-line, .skeleton-card { animation: none !important; }
}
@media (forced-colors: active) {
    .btn, .input, .select, .card, .panel, .kpi, .badge, .chip, .soc-table th,
    .due-chip, .nav-badge, .job-chip { border: 1px solid CanvasText; forced-color-adjust: auto; }
    .nav-item.active, .soc-table tr[aria-selected="true"] { outline: 2px solid Highlight; }
    :focus-visible { outline: 3px solid Highlight !important; }
    .skeleton, .skeleton-line, .skeleton-card { background: GrayText !important; }
    .soc-chart rect, .soc-chart path, .soc-chart circle { forced-color-adjust: none; }
}

/* --- Layout pattern ---------------------------------------------------------
   Every tool page uses the same wrapper:
     <div class="page">                          max-width 1500px, padding 20 24 32, gap 16
       <div class="page-toolbar">…filters, actions…</div>   wraps; .spacer pushes right
       <div class="kpi-row">…<div class="kpi">…</div>…</div> auto-fit tiles (min 170px)
       <div class="page-main">…</div>             one column
       <div class="page-main has-aside">          main + right column (360px)
           <div class="page-content">…</div>
           <aside class="page-aside">…</aside>    stacks below the main column ≤ 1100px
       </div>
     </div>
   .page-wide drops the max-width (tables with many columns).
   Collapsible filters: on ≤ 640px the panel is hidden behind a toggle button
     <div class="filters-collapsible">
       <button class="btn btn-sm filters-toggle" aria-expanded="false" aria-controls="x">Filters <span class="filters-count">2</span></button>
       <div class="filters-panel" id="x">…controls…</div>
     </div>
   socFilters(container) in common.js wires the button and the count. */
.page {
    display: flex; flex-direction: column; gap: 16px;
    max-width: 1500px; margin: 0 auto; padding: 20px 24px 32px; min-width: 0;
}
.page.page-wide { max-width: none; }
.page-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.page-toolbar > .spacer { flex: 1; }
.page-toolbar h2 { font-size: 15px; font-weight: 650; margin-right: 6px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.page-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.page-main.has-aside { grid-template-columns: minmax(0, 1fr) 360px; }
.page-content, .page-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.filters-collapsible { display: contents; }
.filters-collapsible > .filters-toggle { display: none; }
.filters-count::before { content: '('; }
.filters-count::after { content: ')'; }
.filters-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
@media (max-width: 1100px) {
    .page-main.has-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .page { padding: 14px 12px 24px; gap: 12px; }
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .filters-collapsible { display: flex; flex-direction: column; gap: 8px; width: 100%; }
    .filters-collapsible > .filters-toggle { display: inline-flex; align-self: flex-start; }
    .filters-collapsible > .filters-panel { display: none; width: 100%; }
    .filters-collapsible.open > .filters-panel { display: flex; }
    .filters-panel > * { flex: 1 1 140px; }
}

/* --- Skeleton loaders (common.js skeleton()) ------------------------------- */

.skeleton-wrap { display: flex; flex-direction: column; gap: 12px; padding: 20px 24px; max-width: 1500px; margin: 0 auto; }
.skeleton, .skeleton-line, .skeleton-card {
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%; animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
.skeleton-line { height: 12px; width: 100%; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.title { height: 18px; width: 30%; }
.skeleton-card { height: 84px; border-radius: var(--radius); }
.skeleton-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.skeleton-row .skeleton-line:first-child { width: 120px; flex: none; }
.skeleton-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
@keyframes skeleton-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* --- Due / overdue chip (common.js dueChip()) ------------------------------- */

.due-chip {
    display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
    border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.due-chip.due-overdue { background: var(--danger-soft); color: var(--danger); }
.due-chip.due-soon { background: var(--warning-soft); color: var(--warning); }
:root[data-theme="contrast"] .due-chip { border: 1px solid currentColor; }

/* --- Empty state (common.js emptyState()) ----------------------------------- */

.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.empty-recent { margin-top: 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-recent h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.empty-recent ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

/* --- German date input (common.js dateInput()) ------------------------------ */

.date-input { position: relative; display: inline-flex; align-items: center; }
.date-input > .input { width: 130px; padding-right: 34px; font-variant-numeric: tabular-nums; }
.date-input > .date-input-btn {
    position: absolute; right: 3px; height: 28px; width: 28px; padding: 0;
    border: 0; border-radius: 5px; background: transparent; color: var(--text-2); cursor: pointer;
    display: grid; place-items: center;
}
.date-input > .date-input-btn:hover { background: var(--surface-3); color: var(--text); }
.date-input > input[type="date"].date-input-native {
    position: absolute; right: 3px; bottom: 0; width: 28px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0;
}
.date-input.invalid > .input { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* --- Table component (static/js/table.js) ----------------------------------- */

.soc-table-wrap { position: relative; overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.soc-table-wrap.sticky { max-height: var(--soc-table-max-height, none); }
.soc-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.soc-table th, .soc-table td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.soc-table tbody tr:last-child td { border-bottom: 0; }
.soc-table th {
    background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 650;
    letter-spacing: .02em; white-space: nowrap; user-select: none;
}
.soc-table-wrap.sticky th { position: sticky; top: 0; z-index: 2; }
.soc-table th.align-right, .soc-table td.align-right { text-align: right; font-variant-numeric: tabular-nums; }
.soc-table th.align-center, .soc-table td.align-center { text-align: center; }
.soc-table th .soc-sort {
    display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
    color: inherit; font: inherit; letter-spacing: inherit; cursor: pointer; text-transform: inherit;
}
.soc-table th .soc-sort:hover { color: var(--text); }
.soc-table th .soc-sort-icon { width: 10px; opacity: .35; font-size: 10px; }
.soc-table th[aria-sort="ascending"] .soc-sort-icon,
.soc-table th[aria-sort="descending"] .soc-sort-icon { opacity: 1; color: var(--primary-text); }
.soc-table tbody tr { transition: background .1s; }
.soc-table tbody tr:hover { background: var(--surface-2); }
.soc-table tbody tr.clickable { cursor: pointer; }
.soc-table tbody tr:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.soc-table tbody tr[aria-selected="true"] { background: var(--primary-soft); }
.soc-table .soc-check { width: 36px; padding-right: 0; }
.soc-table .soc-check input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.soc-table .soc-empty { padding: 32px 12px; text-align: center; color: var(--text-2); }
.soc-table-wrap.compact .soc-table th, .soc-table-wrap.compact .soc-table td { padding: 5px 10px; }
.soc-table-wrap.compact .soc-table { font-size: 12.5px; }
.soc-table-bulk {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px;
    border: 1px solid var(--primary); border-radius: var(--radius-sm); background: var(--primary-soft); font-size: 13px;
}

/* --- Charts (static/js/charts.js) ------------------------------------------- */

.soc-chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.soc-chart text { font-family: var(--font); font-size: 10.5px; fill: var(--chart-axis); }
.soc-chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.soc-chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.soc-chart .mark:hover, .soc-chart .mark:focus { opacity: .8; }
.soc-chart .hit { fill: transparent; }
.soc-chart .hit:hover + .mark, .soc-chart g.bar:hover .mark { opacity: .8; }
.soc-sparkline { display: inline-block; vertical-align: middle; overflow: visible; }
.soc-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.soc-chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.soc-chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.soc-donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.soc-donut-wrap .soc-chart-legend { flex-direction: column; margin: 0; }
.soc-donut-total { font-size: 18px; font-weight: 650; fill: var(--text) !important; }

/* --- Print ------------------------------------------------------------------
   Black on white, no navigation or controls, external links with their URL.
   Mark anything that must not print with .no-print, force page breaks with
   .page-break-before / .page-break-after. common.js printSection() prints a
   single element (body.printing-section + .print-target). */
.print-only { display: none; }
@media print {
    @page { margin: 14mm 12mm; }
    :root, :root[data-theme] {
        color-scheme: light;
        --bg: #fff; --surface: #fff; --surface-2: #fff; --surface-3: #f2f2f2;
        --border: #bbb; --border-strong: #888; --text: #000; --text-2: #222; --text-3: #333;
        --primary-text: #000; --shadow-sm: none; --shadow: none; --shadow-lg: none;
        --chart-grid: #ccc; --chart-axis: #333;
    }
    html, body { background: #fff !important; color: #000 !important; height: auto !important; overflow: visible !important; }
    body.shell { display: block !important; }
    .sidebar, .sidebar-scrim, .topbar, .toast-stack, .drawer-backdrop, .skeleton-wrap,
    .btn, .btn-icon, .segmented, .menu, .date-input-btn, .job-chip, .no-print, .filters-toggle, input[type="checkbox"],
    .quick-search, .palette, dialog:not([open]) { display: none !important; }
    .print-only { display: block !important; }
    .main, .panes, .pane.active { position: static !important; overflow: visible !important; display: block !important; height: auto !important; }
    .pane:not(.active) { display: none !important; }
    .card, .panel, .kpi, .soc-table-wrap { box-shadow: none !important; border-color: #999 !important; break-inside: avoid; }
    .soc-table-wrap { max-height: none !important; overflow: visible !important; }
    .soc-table th { position: static !important; }
    .soc-table thead { display: table-header-group; }
    .soc-table tr { break-inside: avoid; }
    h1, h2, h3, h4 { break-after: avoid; color: #000 !important; }
    a { color: #000 !important; text-decoration: underline; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 85%; word-break: break-all; }
    a[href^="http"].no-url::after { content: none; }
    .badge, .due-chip, .chip { border: 1px solid #666 !important; background: #fff !important; color: #000 !important; }
    .page-break-before { break-before: page; }
    .page-break-after { break-after: page; }
    .page { max-width: none; padding: 0; }
    /* printSection(): only the target element is printed */
    body.printing-section > *:not(.print-root) { display: none !important; }
    body.printing-section > .print-root { display: block !important; }
    .print-header { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid #000; }
    .print-header h1 { font-size: 18px; }
    .print-header p { font-size: 12px; color: #333; }
}
.print-root { display: none; }
