/* U0 shell, loaded after the legacy styles. Palette: approved visual lab style.css
   SHA256 6f295edb8812c4007456e36e4290de701b60c24b0ae38077adfac266b294416d.
   Only --ws-* is global. Legacy modules retain their own colors and layout. */
:root {
    --ws-bg: #11141b;
    --ws-surface: #191e28;
    --ws-soft: #222937;
    --ws-ink: #eef1f7;
    --ws-muted: #b4bed0;
    --ws-line: #424e62;
    --ws-accent: #b9bdff;
    --ws-accent-soft: #343b59;
    --ws-good: #8bd5bc;
    --ws-warn: #efc078;
    --ws-bad: #ffadb5;
    --ws-button-bg: #c1c4ff;
    --ws-button-ink: #202340;
    --ws-scheme: dark;
    --ws-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --ws-space-xs: .25rem;
    --ws-space-sm: .5rem;
    --ws-space-md: 1rem;
    --ws-space-lg: 1.5rem;
    --ws-space-xl: 2rem;
    --ws-space-2xl: 3rem;
    --ws-text-meta: .875rem;
    --ws-text-body: 1rem;
    --ws-text-subheading: 1.25rem;
    --ws-text-heading: 1.75rem;
    --ws-layer-topbar: 100;
    --ws-layer-navigation: 200;
    --ws-layer-skip: 1100;
}
:root[data-workspace-resolved-theme="light"] {
    --ws-bg: #f2f4f8;
    --ws-surface: #ffffff;
    --ws-soft: #edf0f6;
    --ws-ink: #242b3a;
    --ws-muted: #535f73;
    --ws-line: #aab4c5;
    --ws-accent: #4148ac;
    --ws-accent-soft: #e9ecff;
    --ws-good: #216451;
    --ws-warn: #805000;
    --ws-bad: #a0283d;
    --ws-button-bg: #454bbb;
    --ws-button-ink: #ffffff;
    --ws-scheme: light;
}
/* No JS, denied storage, or delayed initialization: follow the OS until resolved. */
@media (prefers-color-scheme: light) {
    :root:not([data-workspace-resolved-theme]) {
        --ws-bg: #f2f4f8;
        --ws-surface: #ffffff;
        --ws-soft: #edf0f6;
        --ws-ink: #242b3a;
        --ws-muted: #535f73;
        --ws-line: #aab4c5;
        --ws-accent: #4148ac;
        --ws-accent-soft: #e9ecff;
        --ws-good: #216451;
        --ws-warn: #805000;
        --ws-bad: #a0283d;
        --ws-button-bg: #454bbb;
        --ws-button-ink: #ffffff;
        --ws-scheme: light;
    }
}

/* These aliases must never move to body, :root, main-wrapper or main-content:
   those ancestors also contain legacy finance/GAEB modules. */
body.workspace-shell :is(.sidebar, .topbar, #erp-logout-feedback, #fibu-berater-view, .fa-evidence-dialog) {
    --bg-primary: var(--ws-bg);
    --bg-secondary: var(--ws-soft);
    --bg-card: var(--ws-surface);
    --bg-card-hover: var(--ws-soft);
    --bg-glass: var(--ws-surface);
    --text-primary: var(--ws-ink);
    --text-secondary: var(--ws-muted);
    --text-muted: var(--ws-muted);
    --border-color: var(--ws-line);
    --border-glow: var(--ws-accent);
    --accent-primary: var(--ws-accent);
    --accent-success: var(--ws-good);
    --accent-warning: var(--ws-warn);
    --accent-danger: var(--ws-bad);
    --accent-info: var(--ws-accent);
    color-scheme: var(--ws-scheme);
    font-family: var(--ws-font);
    color: var(--ws-ink);
}
body.workspace-shell #fibu-berater-view .fa-workspace,
body.workspace-shell .fa-evidence-dialog {
    --fa-surface: var(--ws-surface);
    --fa-soft: var(--ws-soft);
    --fa-line: var(--ws-line);
    --fa-accent: var(--ws-accent);
    --fa-ink: var(--ws-ink);
    --fa-muted: var(--ws-muted);
}
body.workspace-shell[data-workspace-view="fibu-berater"],
body.workspace-shell[data-workspace-view="fibu-berater"] .main-content,
body.workspace-shell #fibu-berater-view { background: var(--ws-bg); }
body.workspace-shell[data-workspace-view="fibu-berater"]::before { display: none; }
/* Async U1 renders replace short loading panels with full views. Their children
   must not become browser scroll anchors competing with explicit view focus. */
body.workspace-shell[data-workspace-view="fibu-berater"] .main-content { overflow-anchor: none; }

/* Shell only; native controls and existing desktop collapse remain intact. */
body.workspace-shell .sidebar {
    background: var(--ws-surface);
    border-color: var(--ws-line);
    z-index: var(--ws-layer-navigation);
}
body.workspace-shell .sidebar-brand { border-color: var(--ws-line); }
body.workspace-shell .sidebar-brand-logo { filter: none; }
body.workspace-shell .sidebar-nav { padding: var(--ws-space-sm); scrollbar-color: auto; }
body.workspace-shell .sidebar-section-label {
    color: var(--ws-muted);
    font-size: var(--ws-text-meta);
    letter-spacing: normal;
    text-transform: none;
    padding: var(--ws-space-lg) var(--ws-space-sm) var(--ws-space-sm);
}
body.workspace-shell .sidebar-item {
    min-height: 44px;
    width: 100%;
    margin: var(--ws-space-xs) 0;
    padding: var(--ws-space-sm);
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ws-muted);
    white-space: normal;
    font-size: var(--ws-text-meta);
}
body.workspace-shell .sidebar-item-label { color: inherit; overflow-wrap: anywhere; }
body.workspace-shell .sidebar-item:hover { background: var(--ws-soft); color: var(--ws-ink); }
body.workspace-shell .sidebar-item:is(.active, [aria-current="page"]) {
    background: var(--ws-accent-soft);
    color: var(--ws-accent);
    border-color: transparent;
    box-shadow: none;
}
body.workspace-shell .sidebar-badge { background: var(--ws-soft); color: var(--ws-bad); }
body.workspace-shell .sidebar-footer { border-color: var(--ws-line); }
body.workspace-shell .sidebar-collapse-btn { color: var(--ws-muted); min-height: 44px; }
body.workspace-shell .sidebar-collapse-btn:hover { color: var(--ws-ink); background: var(--ws-soft); }
body.workspace-shell .topbar {
    min-height: 72px;
    height: auto;
    padding: var(--ws-space-sm) var(--ws-space-lg);
    gap: var(--ws-space-sm) var(--ws-space-md);
    flex-wrap: wrap;
    background: var(--ws-surface);
    border-color: var(--ws-line);
    backdrop-filter: none;
    z-index: var(--ws-layer-topbar);
}
body.workspace-shell :is(.topbar-left, .topbar-right) {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ws-space-sm) var(--ws-space-md);
    min-width: 0;
    max-width: 100%;
}
body.workspace-shell .topbar-title { color: var(--ws-ink); overflow-wrap: anywhere; }
body.workspace-shell .topbar-breadcrumb { color: var(--ws-muted); }
body.workspace-shell .workspace-theme-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ws-space-sm);
    max-width: 100%;
    color: var(--ws-muted);
    font-size: var(--ws-text-meta);
}
body.workspace-shell :is(#workspace-theme, .workspace-nav-toggle, .topbar button) {
    min-height: 44px;
    max-width: 100%;
    border: 1px solid var(--ws-muted);
    border-radius: 7px;
    padding: var(--ws-space-sm) var(--ws-space-md);
    background: var(--ws-surface);
    color: var(--ws-ink);
    font: inherit;
    white-space: normal;
    box-shadow: none;
}
body.workspace-shell #workspace-theme { width: auto; min-width: 0; }
body.workspace-shell .workspace-nav-toggle { display: none; }
body.workspace-shell :is(#workspace-theme, .workspace-nav-toggle, .topbar button):hover:not(:disabled) { background: var(--ws-soft); }
body.workspace-shell .topbar :is(.cmd-trigger, .notif-btn, kbd) {
    background: var(--ws-surface); color: var(--ws-muted); border-color: var(--ws-muted);
}
body.workspace-shell .topbar .notif-dot { background: var(--ws-bad); border-color: var(--ws-surface); animation: none; }
/* The existing badge deliberately remains owned by app.js. Override only its
   legacy inline colors, not identity or logout behavior. */
body.workspace-shell .topbar #user-badge { max-width: 100%; flex-wrap: wrap; }
body.workspace-shell .topbar #user-badge > div:first-child {
    background: var(--ws-button-bg) !important;
    color: var(--ws-button-ink) !important;
    flex-shrink: 0;
}
body.workspace-shell .topbar #user-badge > div:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
body.workspace-shell .topbar #user-badge button { color: var(--ws-ink) !important; }
body.workspace-shell .topbar #user-badge button:disabled { color: var(--ws-muted) !important; }
body.workspace-shell #erp-logout-feedback[role="alert"] { --text-primary: var(--ws-bad); }
body.workspace-shell #erp-logout-feedback button {
    border: 1px solid var(--ws-muted);
    background: var(--ws-surface);
    color: var(--ws-ink);
    box-shadow: none;
}
body.workspace-shell #erp-logout-feedback button:hover:not(:disabled) { background: var(--ws-soft); }
body.workspace-shell #erp-logout-feedback button:disabled { opacity: 1; color: var(--ws-muted); background: var(--ws-soft); }
body.workspace-shell .workspace-skip-link {
    position: fixed;
    inset-block-start: var(--ws-space-sm);
    inset-inline-start: var(--ws-space-md);
    transform: translateY(calc(-100% - 2rem));
    z-index: var(--ws-layer-skip);
    padding: var(--ws-space-sm) var(--ws-space-md);
    max-width: calc(100vw - 2rem);
    background: var(--ws-surface);
    color: var(--ws-accent);
    border: 1px solid var(--ws-muted);
    border-radius: 7px;
    font: var(--ws-text-body)/1.5 var(--ws-font);
}
body.workspace-shell .workspace-skip-link:focus { transform: none; }

/* U1: remove hard-coded dark colors, but do not alter month-map density/layout. */
body.workspace-shell #fibu-berater-view :is(.fa-status, .fa-check-state) {
    color: var(--ws-ink); background: var(--ws-soft); border-color: var(--ws-line);
}
body.workspace-shell #fibu-berater-view .fa-check-blocked { color: var(--ws-warn); border-color: var(--ws-warn); }
body.workspace-shell #fibu-berater-view .fa-check-unknown { color: var(--ws-muted); }
body.workspace-shell #fibu-berater-view .fa-month-map-cell-passed .fa-month-map-cell-value { color: var(--ws-good); }
body.workspace-shell #fibu-berater-view .fa-month-map-cell-blocked .fa-month-map-cell-value { color: var(--ws-warn); }
body.workspace-shell #fibu-berater-view :is(.fa-context, .fa-task-coverage) {
    border: 1px solid var(--ws-line);
    background: var(--ws-soft);
    color: var(--ws-muted);
    border-radius: 6px;
}
body.workspace-shell #fibu-berater-view :is(.fa-notice, .fa-message, .fa-error, .fa-empty) {
    background: var(--ws-soft); color: var(--ws-ink); border-color: var(--ws-line); overflow-wrap: anywhere;
}
body.workspace-shell #fibu-berater-view .fa-notice { color: var(--ws-warn); }
body.workspace-shell #fibu-berater-view :is(.fa-error, [role="alert"]) { color: var(--ws-bad); border-color: var(--ws-bad); }
body.workspace-shell #fibu-berater-view :is(.fa-empty, .fa-loading, .fa-table thead th) { color: var(--ws-muted); }
body.workspace-shell #fibu-berater-view :is(.fa-detail, .fa-disclosure) { border-color: var(--ws-line); }
body.workspace-shell #fibu-berater-view .fa-diff pre { background: var(--ws-soft); color: var(--ws-ink); }
body.workspace-shell #fibu-berater-view :is(a, .fa-text-button) { color: var(--ws-accent); }
body.workspace-shell #fibu-berater-view :is(input:not([type="checkbox"]), select, textarea) {
    background: var(--ws-surface);
    color: var(--ws-ink);
    border-color: var(--ws-muted);
    caret-color: var(--ws-ink);
}
body.workspace-shell #fibu-berater-view :is(input, textarea)::placeholder { color: var(--ws-muted); opacity: 1; }
body.workspace-shell #fibu-berater-view :is(input[type="checkbox"], input[type="range"]) { accent-color: var(--ws-accent); }
body.workspace-shell :is(#fibu-berater-view, .fa-evidence-dialog) .btn-ghost { color: var(--ws-ink); background: transparent; border-color: var(--ws-muted); }
body.workspace-shell #fibu-berater-view .fa-tabs button { color: var(--ws-muted); background: transparent; }
body.workspace-shell #fibu-berater-view .fa-tabs button[aria-current] {
    color: var(--ws-accent); background: var(--ws-accent-soft); border-color: var(--ws-accent);
}
body.workspace-shell :is(#fibu-berater-view, .fa-evidence-dialog) :is(button, .btn):hover:not(:disabled) {
    background: var(--ws-accent-soft); color: var(--ws-accent);
}
body.workspace-shell :is(.topbar, #fibu-berater-view, .fa-evidence-dialog) .btn-primary,
body.workspace-shell :is(.topbar, #fibu-berater-view, .fa-evidence-dialog) .btn-primary:hover:not(:disabled) {
    background: var(--ws-button-bg); color: var(--ws-button-ink); border-color: var(--ws-button-bg); box-shadow: none;
}
body.workspace-shell :is(.topbar, #fibu-berater-view, .fa-evidence-dialog) :is(button, input, select, textarea):disabled {
    opacity: 1; color: var(--ws-muted); background: var(--ws-soft); border-color: var(--ws-line); cursor: not-allowed;
}
body.workspace-shell .fa-evidence-dialog { background: var(--ws-surface); color: var(--ws-ink); border-color: var(--ws-muted); }
body.workspace-shell .fa-evidence-dialog::backdrop { background: #10131bb3; }
body.workspace-shell .fa-evidence-hint { color: var(--ws-muted); }
/* The embedded original (PDF/HTML) keeps its own document background. */
body.workspace-shell :is(.sidebar, .topbar, #erp-logout-feedback, #fibu-berater-view, .fa-evidence-dialog) :focus-visible,
body.workspace-shell #erp-logout-feedback:focus,
body.workspace-shell :is(.workspace-skip-link, .workspace-nav-toggle):focus-visible,
body.workspace-shell[data-workspace-view="fibu-berater"] .main-content:focus-visible {
    outline: 3px solid var(--ws-accent);
    outline-offset: 3px;
}
body.workspace-shell #fibu-berater-view .fa-month-map-row > summary:focus-visible { outline-offset: -3px; }
body.workspace-shell :is(.sidebar, .topbar, #fibu-berater-view, .fa-evidence-dialog) [hidden],
body.workspace-shell :is(.sidebar, .workspace-nav-toggle)[hidden] { display: none !important; }

@media (max-width: 900px) {
    /* Topbar → optional logout feedback → native navigation → content.
       The empty feedback row has no height. No overlay or bottom bar. */
    body.workspace-shell .app-shell { display: grid; grid-template-columns: minmax(0, 1fr); }
    body.workspace-shell .app-shell > .main-wrapper { display: contents; margin: 0 !important; }
    body.workspace-shell .topbar { grid-column: 1; grid-row: 1; position: static; padding-inline: var(--ws-space-md); }
    body.workspace-shell #erp-logout-feedback { grid-column: 1; grid-row: 2; min-width: 0; }
    body.workspace-shell :is(.topbar-left, .topbar-right) { flex: 1 1 auto; }
    body.workspace-shell .workspace-nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
    body.workspace-shell :is(.sidebar, .sidebar.collapsed) {
        position: static;
        grid-column: 1;
        grid-row: 3;
        width: auto;
        height: auto;
        min-height: 0;
        max-height: none;
        flex-direction: column;
        border: 0;
        border-bottom: 1px solid var(--ws-line);
        overflow: visible;
    }
    body.workspace-shell .sidebar-nav { display: flex; flex-direction: column; height: auto; overflow: visible; padding: var(--ws-space-sm) var(--ws-space-md); }
    body.workspace-shell .sidebar-item { flex-direction: row; justify-content: flex-start; text-align: left; gap: var(--ws-space-sm); min-width: 0; }
    body.workspace-shell :is(.sidebar, .sidebar.collapsed) .sidebar-item-label {
        flex: 1; width: auto; opacity: 1; overflow: visible; font-size: var(--ws-text-meta); line-height: 1.5;
    }
    body.workspace-shell .sidebar-nav .sidebar-section-label { display: block; opacity: 1; }
    body.workspace-shell.advisor-session .sidebar-section-label { display: none !important; }
    body.workspace-shell :is(.sidebar-brand, .sidebar-footer) { display: none; }
    body.workspace-shell .main-content { grid-column: 1; grid-row: 4; min-width: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    body.workspace-shell :is(.sidebar, .topbar, #fibu-berater-view, .fa-evidence-dialog),
    body.workspace-shell :is(.sidebar, .topbar, #fibu-berater-view, .fa-evidence-dialog) *,
    body.workspace-shell :is(.workspace-skip-link, .main-wrapper) {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
@media (forced-colors: active) {
    body.workspace-shell .sidebar-item:is(.active, [aria-current="page"]) { outline: 1px solid Highlight; outline-offset: -1px; }
    body.workspace-shell :is(.sidebar, .topbar, #fibu-berater-view, .fa-evidence-dialog) :focus-visible { outline-color: Highlight; }
}
