/*
 * Global light/dark theme layer.
 * Loaded after page styles so legacy components remain readable without changing their business markup.
 */
:root {
    --st-theme-bg: #f5f7fa;
    --st-theme-surface: #ffffff;
    --st-theme-surface-2: #f7f9fc;
    --st-theme-surface-3: #edf1f6;
    --st-theme-border: #cbd0dd;
    --st-theme-text: #222222;
    --st-theme-muted: #6b7486;
    --st-theme-primary: #3874ff;
    --st-theme-purple: #8c63e9;
    --st-theme-shadow: 0 10px 30px rgba(31, 39, 57, .10);
}

.theme-toggle {
    align-items: center;
    background: #edf0f5;
    border: 1px solid #cbd2df;
    border-radius: 999px;
    color: #596377;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 58px;
    height: 30px;
    justify-content: space-between;
    margin: 0;
    padding: 3px 6px;
    position: relative;
    transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
    width: 58px;
}
.theme-toggle:hover { border-color: #9ca8bc; box-shadow: 0 4px 14px rgba(31, 39, 57, .12); }
.theme-toggle:focus-visible { box-shadow: 0 0 0 3px rgba(56, 116, 255, .28); outline: none !important; }
.theme-toggle .material-icons-outlined {
    font-size: 15px !important;
    height: 18px;
    line-height: 18px !important;
    position: relative;
    width: 18px;
    z-index: 2;
}
.theme-toggle__sun { color: #7b5411; }
.theme-toggle__moon { color: #7f899b; }
.theme-toggle__thumb {
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 7px rgba(31, 39, 57, .22);
    height: 24px;
    left: 2px;
    position: absolute;
    top: 2px;
    transition: transform .22s cubic-bezier(.22, 1, .36, 1), background-color .2s ease;
    width: 24px;
    z-index: 1;
}
.theme-toggle--floating {
    box-shadow: var(--st-theme-shadow);
    position: fixed;
    right: 18px;
    top: 18px;
    z-index: 1085;
}
html[data-bs-theme="dark"] {
    --st-theme-bg: #0b0f17;
    --st-theme-surface: #121823;
    --st-theme-surface-2: #171f2c;
    --st-theme-surface-3: #202a39;
    --st-theme-border: #2c3748;
    --st-theme-text: #e8edf5;
    --st-theme-muted: #9ba7ba;
    --st-theme-primary: #78a5ff;
    --st-theme-purple: #b89aff;
    --st-theme-shadow: 0 14px 38px rgba(0, 0, 0, .32);
    --bs-body-color: #e8edf5;
    --bs-body-color-rgb: 232, 237, 245;
    --bs-body-bg: #0b0f17;
    --bs-body-bg-rgb: 11, 15, 23;
    --bs-emphasis-color: #ffffff;
    --bs-secondary-color: rgba(220, 227, 238, .72);
    --bs-secondary-bg: #202a39;
    --bs-tertiary-bg: #171f2c;
    --bs-border-color: #2c3748;
    --bs-link-color: #8db4ff;
    --bs-link-hover-color: #b7cfff;
}
html[data-bs-theme="dark"] .theme-toggle {
    background: #242d3d;
    border-color: #3b4860;
    color: #d9e1ec;
}
html[data-bs-theme="dark"] .theme-toggle__thumb {
    background: #6f55d9;
    transform: translateX(28px);
}
html[data-bs-theme="dark"] .theme-toggle__sun { color: #8994a6; }
html[data-bs-theme="dark"] .theme-toggle__moon { color: #ffffff; }

html.theme-transition body,
html.theme-transition .top,
html.theme-transition .sidebar,
html.theme-transition .card,
html.theme-transition .modal-content,
html.theme-transition .dropdown-menu,
html.theme-transition .form-control,
html.theme-transition .form-select,
html.theme-transition .table,
html.theme-transition .accordion-item,
html.theme-transition .list-group-item {
    transition: background-color .22s ease, border-color .22s ease, color .22s ease;
}

html[data-bs-theme="dark"] body {
    background-color: var(--st-theme-bg);
    color: var(--st-theme-text);
}
html[data-bs-theme="dark"] ::selection { background: #315caa; color: #ffffff; }
html[data-bs-theme="dark"] hr { border-color: var(--st-theme-border); opacity: 1; }
html[data-bs-theme="dark"] h1,
html[data-bs-theme="dark"] h2,
html[data-bs-theme="dark"] h3,
html[data-bs-theme="dark"] h4,
html[data-bs-theme="dark"] h5,
html[data-bs-theme="dark"] h6,
html[data-bs-theme="dark"] legend { color: var(--st-theme-text); }
html[data-bs-theme="dark"] a { color: var(--st-theme-primary); }
html[data-bs-theme="dark"] a:hover { color: #a8c4ff; }
html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .form-text,
html[data-bs-theme="dark"] small.text-muted { color: var(--st-theme-muted) !important; }
html[data-bs-theme="dark"] .text-black,
html[data-bs-theme="dark"] .text-body,
html[data-bs-theme="dark"] .text-dark:not(.badge) { color: var(--st-theme-text) !important; }
html[data-bs-theme="dark"] .bg-warning.text-dark,
html[data-bs-theme="dark"] .text-bg-warning.text-dark,
html[data-bs-theme="dark"] .badge.bg-warning.text-dark { color: #231b0d !important; }
html[data-bs-theme="dark"] .border,
html[data-bs-theme="dark"] .border-top,
html[data-bs-theme="dark"] .border-end,
html[data-bs-theme="dark"] .border-bottom,
html[data-bs-theme="dark"] .border-start { border-color: var(--st-theme-border) !important; }

/* Main navigation and sidebar */
.site-brand {
    font-size: 1.35rem !important;
    font-weight: 900;
    letter-spacing: .045em;
    line-height: 1;
    white-space: nowrap;
}

html[data-bs-theme="dark"] .top {
    background-color: #101620;
    border-bottom-color: var(--st-theme-border);
    color: #c9d2e1;
}
html[data-bs-theme="dark"] .top a,
html[data-bs-theme="dark"] .top .navbar-brand { color: #c9d2e1; }
html[data-bs-theme="dark"] .top a:hover { color: #ffffff; }
html[data-bs-theme="dark"] .top-user { border: 1px solid #3a465a; }
html[data-bs-theme="dark"] .sidebar {
    background-color: #101620;
    border-right-color: var(--st-theme-border);
    color: #c4ccda;
}
html[data-bs-theme="dark"] .sidebar a,
html[data-bs-theme="dark"] .sidebar .accordion-button,
html[data-bs-theme="dark"] .sidebar .accordion-button:not(.collapsed) { color: #aeb9ca; }
html[data-bs-theme="dark"] .sidebar a:hover,
html[data-bs-theme="dark"] .sidebar .accordion-button:hover { color: #ffffff; }
html[data-bs-theme="dark"] .sidebar .accordion-button:focus { box-shadow: none; }
html[data-bs-theme="dark"] .sidebar .accordion-button::after { filter: brightness(0) invert(1); opacity: .65; }
html[data-bs-theme="dark"] .sidebar .accordion-item,
html[data-bs-theme="dark"] .sidebar .accordion-button,
html[data-bs-theme="dark"] .sidebar .accordion-body { background-color: transparent; }
html[data-bs-theme="dark"] .navbar.bg-dark { background-color: #101620 !important; border-bottom: 1px solid var(--st-theme-border); }

@media (max-width: 575.98px) {
    .site-brand {
        font-size: 1.05rem !important;
        letter-spacing: .02em;
    }
}

/* Surfaces */
html[data-bs-theme="dark"] .card,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .offcanvas,
html[data-bs-theme="dark"] .popover,
html[data-bs-theme="dark"] .dropdown-menu,
html[data-bs-theme="dark"] .list-group-item,
html[data-bs-theme="dark"] .accordion-item {
    background-color: var(--st-theme-surface);
    border-color: var(--st-theme-border);
    color: var(--st-theme-text);
}
html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .card-footer,
html[data-bs-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .accordion-button {
    background-color: var(--st-theme-surface-2);
    border-color: var(--st-theme-border);
    color: var(--st-theme-text);
}
html[data-bs-theme="dark"] .card a:not(.btn):not(.badge) { color: #d9e2ef; }
html[data-bs-theme="dark"] .card a:not(.btn):not(.badge):hover { color: var(--st-theme-primary); }
html[data-bs-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .bg-light,
html[data-bs-theme="dark"] .bg-lite-grey { background-color: var(--st-theme-surface) !important; color: var(--st-theme-text) !important; }
html[data-bs-theme="dark"] .shadow,
html[data-bs-theme="dark"] .shadow-sm,
html[data-bs-theme="dark"] .shadow-lg { box-shadow: var(--st-theme-shadow) !important; }
html[data-bs-theme="dark"] .dropdown-divider { border-color: var(--st-theme-border); }
html[data-bs-theme="dark"] .dropdown-item { color: #d9e1ed; }
html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus { background-color: #222d3d; color: #ffffff; }
html[data-bs-theme="dark"] .dropdown-item.active,
html[data-bs-theme="dark"] .dropdown-item:active { background-color: #315caa; color: #ffffff; }
html[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(180%); }

/* Forms */
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .form-check-input,
html[data-bs-theme="dark"] .input-group-text {
    background-color: #0f151f;
    border-color: #344156;
    color: #e8edf5;
}
html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus,
html[data-bs-theme="dark"] .form-check-input:focus {
    background-color: #111925;
    border-color: #6f9bff;
    box-shadow: 0 0 0 .2rem rgba(111, 155, 255, .18);
    color: #ffffff;
}
html[data-bs-theme="dark"] .form-control:disabled,
html[data-bs-theme="dark"] .form-select:disabled,
html[data-bs-theme="dark"] .form-control[readonly] {
    background-color: #202938;
    color: #a8b3c4;
    opacity: 1;
}
html[data-bs-theme="dark"] .form-control::placeholder,
html[data-bs-theme="dark"] input::placeholder,
html[data-bs-theme="dark"] textarea::placeholder { color: #788599 !important; opacity: 1; }
html[data-bs-theme="dark"] select option { background-color: #121823; color: #e8edf5; }
html[data-bs-theme="dark"] input[type="date"],
html[data-bs-theme="dark"] input[type="datetime-local"],
html[data-bs-theme="dark"] input[type="time"] { color-scheme: dark; }
html[data-bs-theme="dark"] input:-webkit-autofill,
html[data-bs-theme="dark"] input:-webkit-autofill:hover,
html[data-bs-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: #e8edf5;
    box-shadow: 0 0 0 1000px #111925 inset;
}
html[data-bs-theme="dark"] .form-floating > label { color: #8e9aae; }
html[data-bs-theme="dark"] .form-range::-webkit-slider-runnable-track { background: #344156; }
html[data-bs-theme="dark"] .form-check-input:checked { background-color: #5d87ec; border-color: #5d87ec; }

/* Tables */
html[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #dce3ee;
    --bs-table-border-color: #2a3546;
    --bs-table-striped-bg: rgba(255, 255, 255, .025);
    --bs-table-striped-color: #e8edf5;
    --bs-table-hover-bg: rgba(120, 165, 255, .075);
    --bs-table-hover-color: #ffffff;
    border-color: var(--st-theme-border);
    color: #dce3ee;
}
html[data-bs-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; border-color: #2a3546; color: inherit; }
html[data-bs-theme="dark"] .table thead th,
html[data-bs-theme="dark"] .table tbody > tr:first-child td { color: #a4afc0; }
html[data-bs-theme="dark"] .table a:not(.badge):not(.btn) { color: #dce5f2; }
html[data-bs-theme="dark"] .table a:not(.badge):not(.btn):hover { color: var(--st-theme-primary); }
html[data-bs-theme="dark"] .fade-text::after {
    background: linear-gradient(to right, rgba(18, 24, 35, 0), rgba(18, 24, 35, 1));
}

/* Navigation and utility components */
html[data-bs-theme="dark"] .nav-tabs { border-bottom-color: var(--st-theme-border); }
html[data-bs-theme="dark"] .nav-tabs .nav-link { color: #aeb9ca; }
html[data-bs-theme="dark"] .nav-tabs .nav-link:hover { border-color: #303c4f; color: #ffffff; }
html[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--st-theme-surface);
    border-color: var(--st-theme-border) var(--st-theme-border) var(--st-theme-surface);
    color: #ffffff;
}
html[data-bs-theme="dark"] .breadcrumb-item,
html[data-bs-theme="dark"] .breadcrumb-item.active { color: var(--st-theme-muted); }
html[data-bs-theme="dark"] .breadcrumb-item + .breadcrumb-item::before { color: #778397; }
html[data-bs-theme="dark"] .pagination .page-link {
    background-color: var(--st-theme-surface);
    border-color: var(--st-theme-border);
    color: var(--st-theme-primary);
}
html[data-bs-theme="dark"] .pagination .page-link:hover { background-color: #202b3a; color: #ffffff; }
html[data-bs-theme="dark"] .pagination .active > .page-link { background-color: #426fce; border-color: #426fce; color: #ffffff; }
html[data-bs-theme="dark"] .pagination .disabled > .page-link { background-color: #161d28; color: #667286; }
html[data-bs-theme="dark"] .progress { background-color: #263143; }
html[data-bs-theme="dark"] .tooltip-inner { background-color: #e7ecf4; color: #111722; }
html[data-bs-theme="dark"] pre,
html[data-bs-theme="dark"] code { color: #c7d8ff; }
html[data-bs-theme="dark"] pre { background: #0c121c; border: 1px solid var(--st-theme-border); }
html[data-bs-theme="dark"] mark { background: #66501d; color: #ffffff; }

/* Buttons keep brand meaning and sufficient contrast */
html[data-bs-theme="dark"] .btn-purple,
html[data-bs-theme="dark"] a.btn-purple,
html[data-bs-theme="dark"] button.btn-purple,
html[data-bs-theme="dark"] .poa-page .btn-purple {
    background-color: #6546c7 !important;
    border-color: #7659d2 !important;
    color: #ffffff !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .22);
}
html[data-bs-theme="dark"] .btn-purple:hover,
html[data-bs-theme="dark"] .btn-purple:focus,
html[data-bs-theme="dark"] .btn-purple:active,
html[data-bs-theme="dark"] .poa-page .btn-purple:hover,
html[data-bs-theme="dark"] .poa-page .btn-purple:focus {
    background-color: #583caf !important;
    border-color: #896de0 !important;
    color: #ffffff !important;
}
html[data-bs-theme="dark"] .btn-outline-primary { border-color: #78a5ff; color: #9bbcff !important; }
html[data-bs-theme="dark"] .btn-outline-primary:hover { background-color: #4e7ddd; color: #ffffff !important; }
html[data-bs-theme="dark"] .btn-outline-secondary { border-color: #68758a; color: #d2dae6 !important; }
html[data-bs-theme="dark"] .btn-outline-secondary:hover { background-color: #526075; color: #ffffff !important; }
html[data-bs-theme="dark"] .btn-outline-dark { border-color: #788599; color: #dce3ed !important; }
html[data-bs-theme="dark"] .btn-outline-dark:hover { background-color: #526075; color: #ffffff !important; }
html[data-bs-theme="dark"] .btn-light { background-color: #dfe5ee; border-color: #dfe5ee; color: #18202c !important; }
html[data-bs-theme="dark"] .btn-link { color: #a9c4ff !important; }
html[data-bs-theme="dark"] .btn-success { color: #07120a !important; }

/* Compact actions in the Powers of Attorney header. */
.poa-page .poa-header-actions .btn {
    align-items: center;
    display: inline-flex !important;
    gap: .38rem;
    justify-content: center;
    line-height: 1 !important;
    min-height: 32px;
    padding: .38rem .72rem !important;
}
.poa-page .poa-header-actions .btn .material-icons-outlined {
    color: inherit;
    flex: 0 0 17px;
    font-size: 17px !important;
    height: 17px;
    line-height: 17px !important;
    margin: 0 !important;
    position: static;
    text-align: center;
    width: 17px;
}
.poa-page .poa-header-actions .btn-outline-secondary {
    background-color: transparent;
    border-color: #7b8494;
    color: #465064 !important;
}
.poa-page .poa-header-actions .btn-outline-secondary:hover,
.poa-page .poa-header-actions .btn-outline-secondary:focus {
    background-color: #525d70;
    border-color: #525d70;
    color: #ffffff !important;
}
html[data-bs-theme="dark"] .poa-page .poa-header-actions .btn-outline-secondary {
    background-color: transparent;
    border-color: #718096;
    color: #e2e8f0 !important;
}
html[data-bs-theme="dark"] .poa-page .poa-header-actions .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .poa-page .poa-header-actions .btn-outline-secondary:focus {
    background-color: #526075;
    border-color: #7f8da3;
    color: #ffffff !important;
}

/* Alerts and soft statuses */
html[data-bs-theme="dark"] .alert-primary { background: #17294a; border-color: #294c87; color: #c5d8ff; }
html[data-bs-theme="dark"] .alert-secondary { background: #202733; border-color: #3a4555; color: #d7deea; }
html[data-bs-theme="dark"] .alert-success { background: #102d23; border-color: #235943; color: #bcebd7; }
html[data-bs-theme="dark"] .alert-info { background: #112a38; border-color: #275468; color: #bce7f8; }
html[data-bs-theme="dark"] .alert-warning { background: #382b15; border-color: #6a5126; color: #ffe0a3; }
html[data-bs-theme="dark"] .alert-danger { background: #3b191d; border-color: #723039; color: #ffc5cb; }
html[data-bs-theme="dark"] .badge-soft-primary { background: #1c365f; color: #b7d0ff !important; }
html[data-bs-theme="dark"] .badge-soft-success { background: #163b30 !important; color: #b7ebd5 !important; }
html[data-bs-theme="dark"] .badge-soft-danger { background: #4b2429; color: #ffc2c7 !important; }
html[data-bs-theme="dark"] .badge-soft-warning { background: #4a381a; color: #ffe0a3 !important; }
html[data-bs-theme="dark"] .badge-soft-info { background: #173b4a; color: #bce8f8 !important; }
html[data-bs-theme="dark"] .badge-soft-light { background: #293344; color: #e5ebf4 !important; }

/* Files, widgets and legacy plugins */
html[data-bs-theme="dark"] #drop-area,
html[data-bs-theme="dark"] .drop-area {
    background-color: #121a26;
    border-color: #47546a;
    color: #dce4ef;
}
html[data-bs-theme="dark"] #drop-area:hover,
html[data-bs-theme="dark"] .drop-area:hover { background-color: #182333; }
html[data-bs-theme="dark"] #drop-area.active,
html[data-bs-theme="dark"] .drop-area:active { background-color: #251d38; border-color: var(--st-theme-purple); }
html[data-bs-theme="dark"] #drop-area p,
html[data-bs-theme="dark"] .drop-area p,
html[data-bs-theme="dark"] .file-size { color: var(--st-theme-muted); }
html[data-bs-theme="dark"] .file-item,
html[data-bs-theme="dark"] .file { background-color: #17202d; border-color: var(--st-theme-border); color: var(--st-theme-text); }
html[data-bs-theme="dark"] .ui-widget-content,
html[data-bs-theme="dark"] .ui-menu,
html[data-bs-theme="dark"] .ui-datepicker {
    background: var(--st-theme-surface);
    border-color: var(--st-theme-border);
    color: var(--st-theme-text);
}
html[data-bs-theme="dark"] .ui-state-default {
    background: var(--st-theme-surface-2);
    border-color: var(--st-theme-border);
    color: var(--st-theme-text);
}
html[data-bs-theme="dark"] .ui-state-hover,
html[data-bs-theme="dark"] .ui-state-active { background: #2b3a50; border-color: #5474a7; color: #ffffff; }
html[data-bs-theme="dark"] .ck.ck-editor__main > .ck-editor__editable,
html[data-bs-theme="dark"] .ck.ck-toolbar,
html[data-bs-theme="dark"] .ck.ck-dropdown__panel {
    background: var(--st-theme-surface) !important;
    border-color: var(--st-theme-border) !important;
    color: var(--st-theme-text) !important;
}
html[data-bs-theme="dark"] .ck.ck-button { color: #cfd8e6 !important; }
html[data-bs-theme="dark"] .ck.ck-button:hover { background: #273246 !important; }

/* Release notes, filters and employee tree */
html[data-bs-theme="dark"] .timeline::before { background-color: #354155; }
html[data-bs-theme="dark"] .version-date,
html[data-bs-theme="dark"] .change-author,
html[data-bs-theme="dark"] .modal-node-tree .tree-user { color: var(--st-theme-muted); }
html[data-bs-theme="dark"] .version-marker { background-color: var(--st-theme-surface); border-color: #dce5f2; }
html[data-bs-theme="dark"] .version-number,
html[data-bs-theme="dark"] .type-deprecated { background-color: #2b3545; color: #dce4ef; }
html[data-bs-theme="dark"] .type-added { background-color: #163d2d; color: #b8ebd4; }
html[data-bs-theme="dark"] .type-changed { background-color: #1c3962; color: #c2d6ff; }
html[data-bs-theme="dark"] .type-fixed { background-color: #4a381a; color: #ffe1a5; }
html[data-bs-theme="dark"] .type-removed { background-color: #4a2228; color: #ffc3c9; }
html[data-bs-theme="dark"] .change-table th { background-color: var(--st-theme-surface-2); }
html[data-bs-theme="dark"] .sort-label {
    background: var(--st-theme-surface-2);
    border-color: var(--st-theme-border);
    color: #dce4ef;
}
html[data-bs-theme="dark"] .sort-label:hover,
html[data-bs-theme="dark"] .modal-node-tree .tree-content:hover,
html[data-bs-theme="dark"] .modal-node-tree .tree-toggle:hover { background: #253146; color: #ffffff; }
html[data-bs-theme="dark"] .sort-label.active { background: #7654cf; border-color: #8c6de0; color: #ffffff; }
html[data-bs-theme="dark"] .modal-node-tree .tree-toggle { color: #dce4ef; }
html[data-bs-theme="dark"] .modal-node-tree .tree-item::before,
html[data-bs-theme="dark"] .modal-node-tree .tree-item::after { border-color: #47546a; }
html[data-bs-theme="dark"] .modal-node-tree .tree-photo-placeholder { background: #3b475a; }

/* Company structure screen; generated downloads intentionally remain white. */
html[data-bs-theme="dark"] .team-structure-view { background-color: #0e141e; }
html[data-bs-theme="dark"] .team-structure-export__status {
    background: rgba(18, 24, 35, .98);
    border-color: rgba(184, 154, 255, .35);
    color: #dbe3ef;
}
html[data-bs-theme="dark"] .apextree-node,
html[data-bs-theme="dark"] .apextree-node * { color: #e8edf5 !important; }

/* Powers of Attorney module */
html[data-bs-theme="dark"] .poa-page {
    --poa-text: var(--st-theme-text);
    --poa-muted: var(--st-theme-muted);
    --poa-border: var(--st-theme-border);
    --poa-soft: var(--st-theme-surface-2);
    --poa-blue: var(--st-theme-primary);
    --poa-purple: var(--st-theme-purple);
    --poa-surface: var(--st-theme-surface);
    --poa-surface-alt: var(--st-theme-surface-2);
    --poa-hover: rgba(120, 165, 255, .075);
    --poa-shadow: 0 5px 18px rgba(0, 0, 0, .2);
}
html[data-bs-theme="dark"] .poa-guide,
html[data-bs-theme="dark"] .poa-filter-panel,
html[data-bs-theme="dark"] .poa-table-wrap,
html[data-bs-theme="dark"] .poa-page .card { background: var(--st-theme-surface); border-color: var(--st-theme-border); }
html[data-bs-theme="dark"] .poa-guide-steps,
html[data-bs-theme="dark"] .poa-filter-panel[open] > summary { border-color: var(--st-theme-border); }
html[data-bs-theme="dark"] .poa-guide-steps > div > span,
html[data-bs-theme="dark"] .poa-section-number { background: #2b2344; color: #ccbaff; }
html[data-bs-theme="dark"] .poa-filter-form,
html[data-bs-theme="dark"] .poa-table thead th,
html[data-bs-theme="dark"] .poa-page .table-sm thead th { background: var(--st-theme-surface-2); }
html[data-bs-theme="dark"] .poa-table tbody tr:hover { background: rgba(120, 165, 255, .075); }
html[data-bs-theme="dark"] .poa-table tbody td,
html[data-bs-theme="dark"] .poa-page .table-sm td,
html[data-bs-theme="dark"] .poa-page .table-sm th { border-color: #273243; }
html[data-bs-theme="dark"] .poa-number-cell a { color: #dfe7f3 !important; }
html[data-bs-theme="dark"] .poa-number-cell a:hover { color: var(--st-theme-primary) !important; }
html[data-bs-theme="dark"] .poa-route-preview,
html[data-bs-theme="dark"] .poa-page .alert-info { background: #162a48; border-color: #2d4f7d; color: #c8dcff; }
html[data-bs-theme="dark"] .poa-representative { background: #101720; border-color: var(--st-theme-border) !important; }
html[data-bs-theme="dark"] .poa-form-actions { background: rgba(18, 24, 35, .96); border-color: var(--st-theme-border); }
html[data-bs-theme="dark"] .poa-page .form-label { color: #c2cbd9; }
html[data-bs-theme="dark"] .poa-status--neutral { background: #2a3443; color: #d3dae5; }
html[data-bs-theme="dark"] .poa-status--warning { background: #4a3517; color: #ffdda0; }
html[data-bs-theme="dark"] .poa-status--info,
html[data-bs-theme="dark"] .poa-status--blue { background: #1d3862; color: #bfd3ff; }
html[data-bs-theme="dark"] .poa-status--success { background: #143c2d; color: #afe7ce; }
html[data-bs-theme="dark"] .poa-status--danger { background: #4a2228; color: #ffc0c7; }
html[data-bs-theme="dark"] .poa-status--purple { background: #342653; color: #dac8ff; }
html[data-bs-theme="dark"] .poa-current-action { background: #16243a; border-color: #29496f; }
html[data-bs-theme="dark"] .poa-current-action p { color: #afbdd0; }
html[data-bs-theme="dark"] .poa-current-action--purple { background: #241d38; border-color: #4c3a70; }
html[data-bs-theme="dark"] .poa-current-action--success { background: #102c23; border-color: #245440; }
html[data-bs-theme="dark"] .poa-current-action--warning { background: #352916; border-color: #665027; }
html[data-bs-theme="dark"] .poa-chain-marker { background: var(--st-theme-surface); border-color: #536077; color: #aab5c6; }
html[data-bs-theme="dark"] .poa-chain-body strong,
html[data-bs-theme="dark"] .poa-action-title h2,
html[data-bs-theme="dark"] .poa-file-reminder strong,
html[data-bs-theme="dark"] .poa-document-item strong,
html[data-bs-theme="dark"] .poa-event-list strong { color: var(--st-theme-text); }
html[data-bs-theme="dark"] .poa-chain-body p,
html[data-bs-theme="dark"] .poa-representative-card,
html[data-bs-theme="dark"] .poa-document-item { background: var(--st-theme-surface-2); border-color: var(--st-theme-border); color: var(--st-theme-text); }
html[data-bs-theme="dark"] .poa-chain-body em { background: #342653; color: #dac8ff; }
html[data-bs-theme="dark"] .poa-primary-action { background: linear-gradient(135deg, #121823, #171f2c); }
html[data-bs-theme="dark"] .poa-file-reminder { background: #382b15; border-color: #6a5126; color: #ffe0a3; }
html[data-bs-theme="dark"] .poa-file-reminder p { color: #d2b77f; }
html[data-bs-theme="dark"] .poa-file-reminder--ready { background: #102d23; border-color: #235943; color: #bcebd7; }
html[data-bs-theme="dark"] .poa-file-reminder--ready p { color: #91cbb2; }
html[data-bs-theme="dark"] .poa-document-icon { background: #1d3862; color: #bfd3ff; }
html[data-bs-theme="dark"] .poa-definition-grid > div,
html[data-bs-theme="dark"] .poa-action-footer,
html[data-bs-theme="dark"] .poa-upload-form,
html[data-bs-theme="dark"] .poa-side-status dl > div,
html[data-bs-theme="dark"] .poa-event-list article { border-color: #2a3546; }
html[data-bs-theme="dark"] .poa-definition-grid dd,
html[data-bs-theme="dark"] .poa-representative-card strong { color: var(--st-theme-text); }
html[data-bs-theme="dark"] .poa-representative-card p,
html[data-bs-theme="dark"] .poa-event-list p,
html[data-bs-theme="dark"] .poa-document-item p { color: var(--st-theme-muted); }
html[data-bs-theme="dark"] .poa-empty-documents strong { color: #d5deeb; }
html[data-bs-theme="dark"] .poa-history-card > summary:hover { background: var(--st-theme-surface-2); }
html[data-bs-theme="dark"] .poa-page .btn-light { background: #263246; border-color: #344258; color: #e3e9f2 !important; }
html[data-bs-theme="dark"] .poa-page .text-muted { color: var(--st-theme-muted) !important; }

/* Mobile navigation and narrow page canvas. */
@media (max-width: 991.98px) {
    body > .d-flex.align-items-stretch { min-width: 0; }
    body > .d-flex.align-items-stretch > .container-fluid { min-width: 0; padding-left: .75rem; padding-right: .75rem; width: 100%; }
    .top { position: sticky; top: 0; z-index: 1045; }
    .sidebar {
        background: #fff; bottom: 0; box-shadow: 12px 0 32px rgba(20, 24, 36, .2); height: auto;
        left: 0; min-height: 0 !important; overflow-y: auto; padding-bottom: 1rem; position: fixed;
        top: 70px; width: min(86vw, 280px); z-index: 1040;
    }
    html[data-bs-theme="dark"] .sidebar { background: #101620; box-shadow: 12px 0 34px rgba(0, 0, 0, .45); }
}

/* Login screen */
html[data-bs-theme="dark"] body.bg-fill {
    background: #0b0f17 !important;
    background-image: radial-gradient(circle at 20% 10%, rgba(100, 77, 190, .42), transparent 38%),
        radial-gradient(circle at 85% 80%, rgba(45, 86, 175, .34), transparent 42%) !important;
}
html[data-bs-theme="dark"] body.bg-fill .card { box-shadow: 0 24px 70px rgba(0, 0, 0, .38); }
html[data-bs-theme="dark"] body.bg-fill .text-logo {
    background: linear-gradient(110deg, #d9cbff, #88b0ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Scrollbars */
html[data-bs-theme="dark"] * { scrollbar-color: #435067 #111721; }
html[data-bs-theme="dark"] *::-webkit-scrollbar { height: 10px; width: 10px; }
html[data-bs-theme="dark"] *::-webkit-scrollbar-track { background: #111721; }
html[data-bs-theme="dark"] *::-webkit-scrollbar-thumb { background: #435067; border: 2px solid #111721; border-radius: 999px; }
html[data-bs-theme="dark"] *::-webkit-scrollbar-thumb:hover { background: #596980; }

@media (max-width: 575.98px) {
    .top .theme-toggle { margin-right: .55rem !important; }
    .theme-toggle--floating { right: 12px; top: 12px; }
    .top-menu-user-block > a.me-3 { font-size: 0; margin-right: .55rem !important; }
    .top-menu-user-block > a.me-3 .icon { font-size: 20px !important; }
    .top-menu-user-block .text-small { display: none; }
    .top-user { margin-left: .35rem; }
}
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .theme-toggle__thumb,
    html.theme-transition body,
    html.theme-transition .top,
    html.theme-transition .sidebar,
    html.theme-transition .card { transition: none !important; }
}
