/* Theme corrections from the full source review; preserve original geometry.
   Evidence and remaining findings: .design/full-theme-review.md. */
@media screen {
    html[data-bs-theme="light"] { color-scheme: light; }
    html[data-bs-theme="dark"] {
        color-scheme: dark;
        /* Shared dark palette. Standalone screens may load this without the
           master layout; light styles remain owned by their original sources. */
        --ium-canvas: #13151b;
        --ium-surface: #1e2129;
        --ium-raised: #2b303b;
        --ium-ink: #e8eaf0;
        --ium-title: #f5f5f5;
        --ium-muted: #b5bdce;
        --ium-line: #414858;
        --ium-accent: #80d6e5;
        --ium-input: #1b1c22;
        --ium-input-line: #565967;
        --ium-disabled: #262831;
        --ium-success: #a1efc7;
        --ium-danger: #ffc2cf;
        --ium-warning: #ffe0a0;
        --ium-chat-canvas: #171b23;
        --light-bg: #2b303b;
        /* Workflow copy uses text utilities as well as component tokens.
           Keep those utilities readable without changing base surface grays. */
        --bs-text-gray-400: var(--ium-muted);
        --bs-text-gray-500: var(--ium-muted);
    }

    /* Foreground/fill pairs belong together in portal-button-colors.css or the owning module.
       A late text-only primary override broke dark custom fills, including the
       control-management save action. The forced-fill utility owns a complete
       pair, including inside a module with inherited light-background tokens. */
    .btn.btn-primary.bg-primary,
    .btn.btn-primary.bg-primary:is(:hover, :focus, :active, .active, .show) {
        --ium-button-fill: #023243;
        --ium-button-ink: #fff;
        --ium-button-hover-fill: var(--ium-button-fill);
        --ium-button-hover-ink: var(--ium-button-ink);
        color: var(--ium-button-ink);
        background-color: var(--ium-button-fill) !important;
        border-color: var(--ium-button-fill) !important;
    }
    [data-bs-theme="light"] .text-muted { color: #667085 !important; }
    [data-bs-theme="light"] :is(.stu-acad-lbl, .stu-kpi-label, .prof-kpi-label, .prof-lecture-more, .prof-no-data, .prof-exam-lbl) { color: #667085; }
    [data-bs-theme="light"] .week-selector-select { color: #1857c7; }
    [data-bs-theme="light"] .inactive-step { color: #535f6b; }
    [data-bs-theme="light"] .consultation-page { --ci-muted: #5c6c80; }
    .btn:focus-visible { outline: 2px solid #087b98 !important; outline-offset: 2px; }
    [data-bs-theme="dark"] .btn:focus-visible { outline-color: var(--ium-accent) !important; }
    /* Keyboard focus must survive custom page backgrounds and dynamic fields.
       Entry points are the master/auth/exam shells and standalone Zoom pages. */
    [data-bs-theme="dark"] :is(a, .form-control, .form-select, .form-check-input, .select2-selection):focus-visible {
        outline: 2px solid var(--ium-accent);
        outline-offset: 2px;
    }

    /* Drawers, appeal cards and chat popovers share this legacy white utility. */
    [data-bs-theme="dark"] .app-default .bg-white { background-color: var(--ium-surface) !important; }
    [data-bs-theme="dark"] .app-default .text-black { color: var(--ium-ink) !important; }
    /* Profile helper copy and calendar controls are shared by student, faculty
       and staff pages. Their vendor gray was too dim on the dark surfaces. */
    [data-bs-theme="dark"] .app-default .form-text { color: var(--ium-muted) !important; }
    [data-bs-theme="dark"] .app-default :is(.text-secondary, .form-check-label, .select2-selection__placeholder) { color: var(--ium-muted) !important; }
    [data-bs-theme="dark"] .app-default .professor-avatar-frame {
        color: var(--ium-ink);
        background: var(--ium-raised);
        border-color: var(--ium-line);
    }
    [data-bs-theme="dark"] .app-default .sidebar.bg-white .nav-link i { color: inherit; }
    [data-bs-theme="dark"] .app-default a.text-reset .symbol-label {
        background-color: var(--ium-raised);
        color: var(--ium-muted);
    }
    [data-bs-theme="dark"] .app-default a.text-reset .symbol-label i { color: inherit; }
    [data-bs-theme="dark"] .app-default .dues-breadcrumb { color: var(--ium-muted); }
    /* Outside-month dates remain navigation links, not disabled content. */
    [data-bs-theme="dark"] .app-default .fc .fc-day-other .fc-daygrid-day-top { opacity: 1; }
    [data-bs-theme="dark"] .app-default .fc .fc-day-other .fc-daygrid-day-number { color: var(--ium-muted); }
    [data-bs-theme="dark"] .app-default .fc .fc-button {
        color: var(--ium-ink) !important;
        background: var(--ium-raised) !important;
        border-color: var(--ium-line) !important;
    }
    [data-bs-theme="dark"] .app-default .fc .fc-button:is(:hover, :focus-visible, .fc-button-active) {
        background: #203c53 !important;
        border-color: var(--ium-accent) !important;
    }
    [data-bs-theme="dark"] .header-job-title { color: var(--ium-muted) !important; }
    /* The minimized wordmark reaches the sidebar edge. Keep the toggle outside
       that edge and draw focus inside its own surface so neither covers it. */
    [data-bs-theme="dark"] #kt_app_sidebar_toggle {
        background-color: var(--ium-raised) !important;
        color: var(--ium-ink) !important;
        border: 1px solid var(--ium-line) !important;
        border-radius: 8px !important;
        box-shadow: none !important;
    }
    [data-bs-theme="dark"] #kt_app_sidebar_toggle i { color: inherit !important; }
    [data-bs-theme="dark"] #kt_app_sidebar_toggle [class^="path"]::before { opacity: 1; }
    [data-bs-theme="dark"] #kt_app_sidebar_toggle:is(:hover, :focus-visible) { color: var(--ium-accent) !important; }
    [data-bs-theme="dark"] #kt_app_sidebar_toggle:focus-visible { outline-offset: -3px !important; }
    [data-bs-theme="dark"] body[data-kt-app-sidebar-minimize="on"] #kt_app_sidebar_toggle { transform: translate(0, -50%) !important; }
    /* Header controls must remain visible against the dark shell, including
       the fixed-fill SVG images used by the language and notification buttons. */
    [data-bs-theme="dark"] #kt_app_header .app-navbar .btn.btn-icon,
    [data-bs-theme="dark"] #kt_app_header .app-navbar .btn.btn-icon :is(i, svg) { color: var(--ium-muted) !important; }
    [data-bs-theme="dark"] #kt_app_header .app-navbar .btn.btn-icon:is(:hover, :focus-visible),
    [data-bs-theme="dark"] #kt_app_header .app-navbar .btn.btn-icon:is(:hover, :focus-visible) :is(i, svg) { color: var(--ium-accent) !important; }
    [data-bs-theme="dark"] #kt_app_header .app-navbar .ki-duotone [class^="path"]::before { opacity: 1; }
    /* Account identifiers and navigation arrows need dark ink on the white shell. */
    [data-bs-theme="light"] #kt_app_header .username-span { color: #0d6377 !important; }
    [data-bs-theme="light"] #kt_app_header .header-separator { color: #5c6678 !important; }
    [data-bs-theme="light"] #kt_app_header .btn.btn-icon,
    [data-bs-theme="light"] #kt_app_header .btn.btn-icon :is(i, svg) { color: #0d6377 !important; }
    [data-bs-theme="light"] #kt_app_header .ki-duotone [class^="path"]::before { opacity: 1; }
    [data-bs-theme="light"] #kt_app_sidebar_toggle,
    [data-bs-theme="light"] #kt_app_sidebar_toggle i { color: #0d6377 !important; }
    [data-bs-theme="light"] #kt_app_sidebar_toggle .ki-duotone [class^="path"]::before { opacity: 1; }
    [data-bs-theme="dark"] #kt_app_header .app-navbar :is(.header_icon, .header_icon_notifications, .angle-small-up) { filter: brightness(0) saturate(100%) invert(86%); }
    [data-bs-theme="dark"] #kt_app_header .app-navbar .btn-light-warning { color: #ffe0a0 !important; background-color: #40351e !important; }
    /* The header's generic span color otherwise overrides the unread count. */
    #kt_app_header .app-navbar .badge.badge-danger {
        color: #fff1f4 !important;
        background-color: #b5294d !important;
        border: 1px solid #f295ac;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }
    /* DataTable action menus are appended outside their table. Scope their
       palette to dropdown menus, preserving the separate sidebar theme. */
    [data-bs-theme="dark"] .menu-sub-dropdown { background-color: var(--ium-surface); }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-link { color: var(--ium-ink) !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-link :is(.menu-title, .menu-icon, .menu-arrow, i, .svg-icon) { color: inherit !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-arrow::after { background-color: currentColor !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-link:is(:hover, :focus-visible, .active, .here),
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-item:is(.hover, .show, .here) > .menu-link { background-color: var(--ium-raised) !important; color: var(--ium-accent) !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-link:focus-visible { outline: 2px solid var(--ium-accent) !important; outline-offset: -2px; }
    [data-bs-theme="dark"] .menu-sub-dropdown :is(.menu-link, .menu-title, .menu-icon, i).text-danger { color: var(--ium-danger) !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown :is(.menu-link, .menu-title, .menu-icon, i).text-warning { color: var(--ium-warning) !important; }
    [data-bs-theme="dark"] .menu-sub-dropdown .menu-link:is(.disabled, [aria-disabled="true"], :disabled) { background-color: transparent !important; color: var(--ium-muted) !important; opacity: 1; }
    /* Role permission actions are inline table menus, outside dropdowns. */
    [data-bs-theme="dark"] .app-default .role-permission-action { color: var(--ium-accent) !important; }
    [data-bs-theme="dark"] .app-default .role-permission-action :is(i, .menu-icon, .svg-icon) { color: inherit !important; }
    [data-bs-theme="dark"] .app-default .role-permission-action .ki-duotone [class^="path"]::before { opacity: 1; }
    /* Shared semantic utilities appear in AI training, course specifications,
       status badges and row actions. Keep each foreground paired with its fill. */
    [data-bs-theme="dark"] .app-default .text-primary { color: #9dc6ff !important; }
    [data-bs-theme="dark"] .app-default .text-info { color: #d5b5ff !important; }
    [data-bs-theme="dark"] .app-default .text-success { color: var(--ium-success) !important; }
    [data-bs-theme="dark"] .app-default .text-warning { color: var(--ium-warning) !important; }
    [data-bs-theme="dark"] .app-default .text-danger { color: var(--ium-danger) !important; }
    [data-bs-theme="dark"] .app-default :is(.text-primary, .text-info, .text-success, .text-warning, .text-danger) > :is(i, .svg-icon) { color: inherit !important; }

    /* Exam reports and other role-independent actions use solid Bootstrap
       variants. Pair their status foreground with a matching dark surface. */
    [data-bs-theme="dark"] .app-default .btn.btn-success { --ium-action-ink: var(--ium-success); --ium-action-fill: #173e31; }
    [data-bs-theme="dark"] .app-default .btn.btn-info { --ium-action-ink: #d5b5ff; --ium-action-fill: #352744; }
    [data-bs-theme="dark"] .app-default .btn.btn-warning { --ium-action-ink: var(--ium-warning); --ium-action-fill: #40351e; }
    [data-bs-theme="dark"] .app-default .btn.btn-danger { --ium-action-ink: var(--ium-danger); --ium-action-fill: #4d2734; }
    [data-bs-theme="dark"] .app-default .btn:is(.btn-success, .btn-info, .btn-warning, .btn-danger) {
        color: var(--ium-action-ink) !important;
        background: var(--ium-action-fill) !important;
        border-color: var(--ium-action-ink) !important;
    }
    [data-bs-theme="dark"] .app-default .btn:is(.btn-success, .btn-info, .btn-warning, .btn-danger):is(:hover, :focus-visible, :active, .active) {
        color: var(--ium-action-ink) !important;
        background: var(--ium-raised) !important;
    }
    [data-bs-theme="dark"] .app-default .btn:is(.btn-success, .btn-info, .btn-warning, .btn-danger) :is(i, .svg-icon) { color: inherit !important; }

    [data-bs-theme="dark"] .app-default :is(.alert-primary, .alert-light-primary, .badge-primary, .badge-light-primary, .badge.bg-primary, .badge.bg-light-primary, .badge.text-primary, .btn-light-primary, .btn.actions, .btn.btn-light[data-kt-menu-trigger]) { --ium-state-ink: #9dc6ff; --ium-state-fill: #203c53; }
    [data-bs-theme="dark"] .app-default :is(.alert-info, .alert-light-info, .badge-info, .badge-light-info, .badge.bg-info, .badge.bg-light-info, .badge.text-info, .btn-light-info) { --ium-state-ink: #d5b5ff; --ium-state-fill: #352744; }
    [data-bs-theme="dark"] .app-default :is(.alert-success, .alert-light-success, .badge-success, .badge-light-success, .badge.bg-success, .badge.bg-light-success, .badge.text-success, .btn-light-success) { --ium-state-ink: var(--ium-success); --ium-state-fill: #173e31; }
    [data-bs-theme="dark"] .app-default :is(.alert-warning, .alert-light-warning, .badge-warning, .badge-light-warning, .badge.bg-warning, .badge.bg-light-warning, .badge.text-warning, .btn-light-warning) { --ium-state-ink: var(--ium-warning); --ium-state-fill: #40351e; }
    [data-bs-theme="dark"] .app-default :is(.alert-danger, .alert-light-danger, .badge-danger, .badge-light-danger, .badge.bg-danger, .badge.bg-light-danger, .badge.text-danger, .btn-light-danger) { --ium-state-ink: var(--ium-danger); --ium-state-fill: #4d2734; }
    [data-bs-theme="dark"] .app-default :is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger,
        .badge-primary, .badge-light-primary, .badge-info, .badge-light-info, .badge-success, .badge-light-success, .badge-warning, .badge-light-warning, .badge-danger, .badge-light-danger,
        .badge.bg-primary, .badge.bg-light-primary, .badge.text-primary, .badge.bg-info, .badge.bg-light-info, .badge.text-info, .badge.bg-success, .badge.bg-light-success, .badge.text-success, .badge.bg-warning, .badge.bg-light-warning, .badge.text-warning, .badge.bg-danger, .badge.bg-light-danger, .badge.text-danger,
        .btn-light-primary, .btn-light-info, .btn-light-success, .btn-light-warning, .btn-light-danger, .btn.actions, .btn.btn-light[data-kt-menu-trigger]) {
        color: var(--ium-state-ink) !important;
        background-color: var(--ium-state-fill) !important;
    }
    [data-bs-theme="dark"] .app-default :is(.badge-light, .btn-light):not([data-kt-menu-trigger]) { color: var(--ium-ink) !important; background-color: var(--ium-raised) !important; }
    [data-bs-theme="dark"] .app-default :is(.badge-light-dark, .badge-dark, .badge.bg-dark) {
        color: var(--ium-ink) !important;
        background-color: var(--ium-raised) !important;
    }
    [data-bs-theme="dark"] .app-default [data-assignment-state="open"] { color: var(--ium-success) !important; background-color: #173e31 !important; }
    [data-bs-theme="dark"] .app-default [data-assignment-state="closed"] { color: var(--ium-danger) !important; background-color: #4d2734 !important; }
    [data-bs-theme="dark"] .app-default .exam-finished-count { color: var(--ium-success) !important; }
    [data-bs-theme="dark"] .app-default .exam-assigned-count { color: var(--ium-danger) !important; }
    [data-bs-theme="dark"] .app-default .btn:is(.btn-light, .btn-light-primary, .btn-light-info, .btn-light-success, .btn-light-warning, .btn-light-danger, .actions):is(:hover, :focus-visible, :active, .active, .show) {
        background-color: var(--ium-raised) !important;
        color: var(--ium-state-ink, var(--ium-ink)) !important;
    }
    [data-bs-theme="dark"] .app-default .btn:is(.btn-light, .btn-light-primary, .btn-light-info, .btn-light-success, .btn-light-warning, .btn-light-danger):is(:disabled, .disabled, [aria-disabled="true"]) {
        background-color: var(--ium-raised) !important;
        color: var(--ium-muted) !important;
        opacity: 1;
    }
    /* Action buttons retain their semantic dark defaults while custom modules
       can replace the same foreground/fill pair used by primary buttons. */
    [data-bs-theme="dark"] .app-default .btn.actions {
        color: var(--ium-button-ink, var(--ium-state-ink, var(--ium-ink))) !important;
        background-color: var(--ium-button-fill, var(--ium-state-fill, var(--ium-raised))) !important;
    }
    [data-bs-theme="dark"] .app-default .btn.actions:is(:hover, :focus-visible, :active, .active, .show) {
        color: var(--ium-button-hover-ink, var(--ium-button-ink, var(--ium-state-ink, var(--ium-ink)))) !important;
        background-color: var(--ium-button-hover-fill, var(--ium-button-fill, var(--ium-raised))) !important;
    }
    /* The common disabled rule neutralizes hover tokens with light defaults.
       Read the normal pair here so disabled dark actions keep semantic fallbacks. */
    [data-bs-theme="dark"] .app-default .btn.actions:is(:disabled, .disabled, [aria-disabled="true"]),
    [data-bs-theme="dark"] .app-default fieldset:disabled .btn.actions {
        color: var(--ium-button-ink, var(--ium-state-ink, var(--ium-ink))) !important;
        background-color: var(--ium-button-fill, var(--ium-state-fill, var(--ium-raised))) !important;
    }

    /* Icons and utility spans use the component's foreground, including when
       Bootstrap assigns a separate text color to an inner element. */
    [data-bs-theme="dark"] .app-default :is(.btn, .badge) :is(i, .svg-icon, [class*="text-"]) { color: inherit !important; }
    [data-bs-theme="dark"] .app-default :is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger)
        :is(h1, h2, h3, h4, h5, h6, p, li, strong, small, span, i, .svg-icon, a):not(.btn, .badge, [class*="badge-"], .btn *, .badge *, [class*="badge-"] *, .text-primary, .text-info, .text-success, .text-warning, .text-danger) { color: inherit !important; }

    /* Long notices use neutral reading surfaces. Keep the semantic cue in
       their heading, icon and border while preserving nested action controls. */
    :root[data-bs-theme="dark"] body.app-default .alert:is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger):where(:not(.portal-library-notice)) {
        background: var(--ium-surface) !important;
        color: var(--ium-ink) !important;
        border-color: var(--ium-state-ink, var(--ium-line)) !important;
    }
    :root[data-bs-theme="dark"] body.app-default .alert:is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger):where(:not(.portal-library-notice))
        :where(:not(.btn, .badge, [class*="badge-"], button, input, select, textarea):not(.btn *, .badge *, [class*="badge-"] *, button *, input *, select *, textarea *)) { color: inherit !important; }
    :root[data-bs-theme="dark"] body.app-default .alert:is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger):where(:not(.portal-library-notice))
        :is(h1, h2, h3, h4, h5, h6, .alert-heading, .alert-title, i, svg, .svg-icon):where(:not(.btn *, .badge *, [class*="badge-"] *, button *)) { color: var(--ium-state-ink, var(--ium-accent)) !important; }
    :root[data-bs-theme="dark"] body.app-default .alert:is(.alert-primary, .alert-light-primary, .alert-info, .alert-light-info, .alert-success, .alert-light-success, .alert-warning, .alert-light-warning, .alert-danger, .alert-light-danger):where(:not(.portal-library-notice))
        .rounded-circle:has(> svg, > i):where(:not(.btn, .badge, [class*="badge-"], button, .btn *, .badge *, [class*="badge-"] *, button *)) { background: var(--ium-raised) !important; }
    :root[data-bs-theme="dark"] body.app-default .alert .ki-duotone [class^="path"]::before { opacity: 1; }

    /* Session flashes use bg-* rather than alert-* variants. Theme the whole
       reading surface, including inner text-light spans and dismiss icons. */
    [data-bs-theme="dark"] .app-default .alert.bg-primary { --ium-flash-accent: #9dc6ff; }
    [data-bs-theme="dark"] .app-default .alert.bg-info { --ium-flash-accent: #d5b5ff; }
    [data-bs-theme="dark"] .app-default .alert.bg-success { --ium-flash-accent: var(--ium-success); }
    [data-bs-theme="dark"] .app-default .alert.bg-warning { --ium-flash-accent: var(--ium-warning); }
    [data-bs-theme="dark"] .app-default .alert.bg-danger { --ium-flash-accent: var(--ium-danger); }
    [data-bs-theme="dark"] .app-default .alert:is(.bg-primary, .bg-info, .bg-success, .bg-warning, .bg-danger) {
        background: var(--ium-surface) !important;
        color: var(--ium-ink) !important;
        border-color: var(--ium-flash-accent) !important;
    }
    [data-bs-theme="dark"] .app-default .alert:is(.bg-primary, .bg-info, .bg-success, .bg-warning, .bg-danger) :is(div, span, p) { color: inherit !important; }
    [data-bs-theme="dark"] .app-default .alert:is(.bg-primary, .bg-info, .bg-success, .bg-warning, .bg-danger) :is(h4, i) { color: var(--ium-flash-accent) !important; }

    /* The shared account form initializes intl-tel-input after page load.
       These selectors cover its real popup, including the highlighted row. */
    [data-bs-theme="dark"] .app-default .iti :is(.iti__dropdown-content, .iti__country-list) {
        color: var(--ium-ink);
        background: var(--ium-surface);
        border-color: var(--ium-line);
    }
    [data-bs-theme="dark"] .app-default .iti .iti__country-name { color: var(--ium-ink); }
    [data-bs-theme="dark"] .app-default .iti .iti__dial-code { color: var(--ium-muted); }
    [data-bs-theme="dark"] .app-default .iti .iti__country:is(.iti__highlight, :hover, [aria-selected="true"]) {
        color: var(--ium-ink);
        background: var(--ium-raised);
    }
    [data-bs-theme="dark"] .app-default .iti .iti__search-input {
        color: var(--ium-ink);
        background: var(--ium-input);
        border-color: var(--ium-input-line);
    }
    [data-bs-theme="dark"] .app-default .iti .iti__search-input::placeholder { color: var(--ium-muted); opacity: 1; }
    [data-bs-theme="dark"] .app-default .iti .iti__divider { border-color: var(--ium-line); }
    [data-bs-theme="dark"] .app-default .iti .iti__arrow { border-top-color: var(--ium-muted); }
    [data-bs-theme="dark"] .app-default .iti .iti__arrow--up { border-bottom-color: var(--ium-muted); }

    /* A long identity and the impersonation action can exceed a phone width.
       Keep controls in flow and let the content flex items actually shrink;
       only off-canvas drawer overflow is clipped at the viewport edge. */
    @media (max-width: 991.98px) {
        html body.app-default { overflow-x: clip; }
        .app-default :is(.app-root, .app-page, .app-wrapper, .app-main, .app-content, .app-container) { min-width: 0; }
        #kt_app_header { height: auto; min-height: var(--bs-app-header-height); }
        #kt_app_header_container { flex-wrap: wrap; row-gap: 8px; padding-block: 8px; }
        #kt_app_header_wrapper { flex: 1 1 100%; min-width: 0; }
        #kt_app_header .app-navbar {
            width: 100%;
            max-width: 100%;
            flex-wrap: wrap;
            justify-content: flex-end;
            gap: 6px;
        }
        #kt_app_header .app-navbar-item { margin-inline: 0 !important; }
        .portal-student-dashboard #kt_app_content_container > .row { margin-inline: 0; }
        .portal-student-dashboard :is(.flex-row-container-card, .user-info, .college-info) { min-width: 0; max-width: 100%; }
        .portal-student-dashboard .info-item { overflow-wrap: anywhere; }
    }

    /* The library promotion shares alert-info markup across all roles. Keep
       its neutral palette above both the semantic and student alert layers. */
    html[data-bs-theme="dark"] body.app-default .portal-library-notice.alert.alert-info {
        background: var(--ium-surface) !important;
        color: var(--ium-ink) !important;
        border-color: var(--ium-line) !important;
    }
    html[data-bs-theme="dark"] body.app-default .portal-library-notice.alert.alert-info :is(h2, .text-gray-700) { color: var(--ium-ink) !important; }
    html[data-bs-theme="dark"] body.app-default .portal-library-notice.alert.alert-info > div > i { color: var(--ium-accent) !important; }
    html[data-bs-theme="dark"] body.app-default .portal-library-notice.alert.alert-info .btn-close {
        --bs-btn-close-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M3 3l10 10M13 3L3 13' stroke='%23e8eaf0' stroke-width='2' stroke-linecap='round'/%3e%3c/svg%3e");
        filter: none;
        opacity: 1;
    }
    html[data-bs-theme="dark"] body.app-default .portal-library-notice.alert.alert-info .btn-close:focus-visible { outline: 2px solid var(--ium-accent); outline-offset: 2px; }

    /* The portal uses Bootstrap pagination by default. Published legacy and
       Tailwind templates keep the same state palette when selected by a view. */
    [data-bs-theme="dark"] .app-default .pagination {
        --bs-pagination-color: var(--ium-ink);
        --bs-pagination-bg: var(--ium-surface);
        --bs-pagination-border-color: var(--ium-line);
        --bs-pagination-hover-color: var(--ium-accent);
        --bs-pagination-hover-bg: var(--ium-raised);
        --bs-pagination-focus-color: var(--ium-accent);
        --bs-pagination-focus-bg: var(--ium-raised);
        --bs-pagination-active-color: #9dc6ff;
        --bs-pagination-active-bg: #203c53;
        --bs-pagination-disabled-color: var(--ium-muted);
        --bs-pagination-disabled-bg: var(--ium-raised);
    }
    [data-bs-theme="dark"] .app-default .pagination .page-link,
    [data-bs-theme="dark"] .app-default .pagination > li > :is(a, span),
    [data-bs-theme="dark"] .app-default .ui.pagination > .item,
    [data-bs-theme="dark"] .app-default nav[aria-label="Pagination Navigation"] :is(a, span.bg-white) {
        color: var(--ium-ink) !important;
        background-color: var(--ium-surface) !important;
        border-color: var(--ium-line) !important;
    }
    [data-bs-theme="dark"] .app-default :is(.pagination a, .pagination button, .ui.pagination > .item, nav[aria-label="Pagination Navigation"] a):is(:hover, :focus-visible) {
        color: var(--ium-accent) !important;
        background-color: var(--ium-raised) !important;
    }
    [data-bs-theme="dark"] .app-default :is(.pagination .active, .pagination [aria-current="page"]) > :is(a, span),
    [data-bs-theme="dark"] .app-default .pagination .page-link.active,
    [data-bs-theme="dark"] .app-default .ui.pagination > .item.active,
    [data-bs-theme="dark"] .app-default nav[aria-label="Pagination Navigation"] [aria-current="page"] > span {
        color: #9dc6ff !important;
        background-color: #203c53 !important;
    }
    [data-bs-theme="dark"] .app-default :is(.pagination .disabled, .pagination [aria-disabled="true"]) > :is(a, span),
    [data-bs-theme="dark"] .app-default .pagination .page-link.disabled,
    [data-bs-theme="dark"] .app-default .ui.pagination > .item.disabled,
    [data-bs-theme="dark"] .app-default nav[aria-label="Pagination Navigation"] :is([aria-disabled="true"] > span, span.cursor-default:not([aria-current="page"] *)) {
        color: var(--ium-muted) !important;
        background-color: var(--ium-raised) !important;
        opacity: 1;
    }
    [data-bs-theme="dark"] .app-default :is(.pagination a, .pagination button, nav[aria-label="Pagination Navigation"] a):focus-visible { outline: 2px solid var(--ium-accent) !important; outline-offset: 2px; }
    [data-bs-theme="dark"] .app-default .pagination .page-link :is(i, .svg-icon, .previous, .next) { color: inherit !important; }
    [data-bs-theme="dark"] .app-default .pagination .page-link > :is(.previous, .next) { background-color: currentColor !important; }
    [data-bs-theme="dark"] .app-default nav[aria-label="Pagination Navigation"] :is(p, p > span) { color: var(--ium-muted) !important; }

    /* Placeholder chips keep their semantic badge palette. Plain source names
       and code blocks use a neutral pair instead of Bootstrap's magenta. */
    [data-bs-theme="dark"] .app-default :is(code:not(.badge), pre) { color: var(--ium-ink) !important; background-color: var(--ium-raised) !important; }
    [data-bs-theme="dark"] .app-default pre code:not(.badge) { color: inherit !important; background-color: transparent !important; }
    [data-bs-theme="dark"] .login-app-download__title { color: var(--ium-ink); }
    [data-bs-theme="dark"] .login-recording-links a { color: var(--ium-accent); }

    [data-bs-theme="dark"] :is(.form-select, .input-group-text) {
        background-color: var(--ium-surface);
        color: var(--ium-ink);
        border-color: var(--ium-line);
    }
    [data-bs-theme="dark"] .form-control::placeholder { color: var(--ium-muted); }
    /* Bootstrap solid fields restore muted text on focus. Keep typed search
       text and its caret at the portal's readable foreground. */
    [data-bs-theme="dark"] .app-default .form-control.form-control-solid:focus {
        color: var(--ium-ink) !important;
        caret-color: var(--ium-ink) !important;
    }
    [data-bs-theme="dark"] .app-default .ki-magnifier:has(+ .form-control.form-control-solid) { color: var(--ium-muted) !important; }
    [data-bs-theme="dark"] .app-default .ki-magnifier:has(+ .form-control.form-control-solid) [class^="path"]::before { opacity: 1; }
    [data-bs-theme="dark"] .form-select:disabled { background-color: var(--ium-raised); color: var(--ium-muted); }

    /* Academic and graduate editors share this stylesheet and palette. */
    [data-bs-theme="dark"] .faculty-profile-editor {
        --profile-ink: var(--ium-ink);
        --profile-teal: var(--ium-accent);
        --profile-cyan: var(--ium-accent);
        --profile-mist: #253c47;
        --profile-line: var(--ium-line);
        --profile-muted: var(--ium-muted);
    }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.profile-review-panel, .profile-section-nav, .profile-editor-section, .profile-editor-section--derived, .profile-photo-frame, .profile-current-position__grid div, .profile-switch-field, .profile-repeater, .profile-course-columns > div, .profile-editor-actions) {
        background: var(--ium-surface);
        border-color: var(--ium-line);
    }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.profile-subsection--muted, .profile-repeater__header, .profile-file-field, .profile-empty-state) { background: var(--ium-raised); }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.profile-section-nav a, .profile-derived-summary__stats strong, .profile-current-position__grid dd, .profile-inline-check, .profile-empty-state strong) { color: var(--ium-ink); }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.profile-section-nav a > span, .profile-repeater__header > div > span, .profile-course-row > span, .profile-course-row--history > div > span) { color: var(--ium-muted); }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.profile-current-position__badge, .profile-language-field__tag, .profile-derived-badge, .profile-section-nav a > small, .profile-file-field__icon) { background: #253c47; color: var(--ium-accent); }
    [data-bs-theme="dark"] .faculty-profile-editor :is(.form-control, .form-select):disabled { background: var(--ium-raised); color: var(--ium-muted); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .faculty-profile-editor .btn-light-primary { background: #253c47; color: var(--ium-accent); }
    [data-bs-theme="dark"] .faculty-profile-editor .btn-light-primary:is(:hover, :focus-visible) { background: #314c5a; color: #e8f9ff; }
    [data-bs-theme="dark"] .profile-editor-actions__state { color: #ffe0a0; }

    /* Dashboard notices and their existing lecture dialog. */
    /* Admin KPI, daily totals and linked/read-only student status cards share
       colors. Inline status gradients resolve the same token as bg-light cards.
       Evidence: .design/dashboard-theme-follow-up.md. */
    .dashboard-stat-card-primary { --ium-stat-accent: #075985; }
    .dashboard-stat-card-success { --ium-stat-accent: #146c43; }
    .dashboard-stat-card-warning { --ium-stat-accent: #805d00; }
    .dashboard-stat-card-info { --ium-stat-accent: #6634a6; }
    .dashboard-stat-card :is(.text-primary, .text-success, .text-warning, .text-info):not(.text-white) { color: var(--ium-stat-accent) !important; }
    .dashboard-stat-card :is(.badge-light-primary, .badge-light-success, .badge-light-warning, .badge-light-info) { color: var(--ium-stat-accent) !important; }
    [data-bs-theme="light"] :is(.dashboard-stat-card, .dashboard-activity-card) .text-gray-500 { color: #5c6678 !important; }
    .dashboard-activity-card .badge-light-primary { color: #075985; }
    .dashboard-activity-card .badge-light-success { color: #146c43; }
    .dashboard-activity-card .badge-light-warning { color: #805d00; }
    .dashboard-activity-card .badge-light-info { color: #6634a6; }
    .dashboard-activity-card .badge-light-danger { color: #b42318; }
    [data-bs-theme="dark"] .dashboard-activity-card .badge-light-primary { color: #80d6e5; }
    [data-bs-theme="dark"] .dashboard-activity-card .badge-light-success { color: #a1efc7; }
    [data-bs-theme="dark"] .dashboard-activity-card .badge-light-warning { color: #ffe0a0; }
    [data-bs-theme="dark"] .dashboard-activity-card .badge-light-info { color: #d5b5ff; }
    [data-bs-theme="dark"] .dashboard-activity-card .badge-light-danger { color: #ffc2cf; }
    [data-bs-theme="dark"] .dashboard-stat-card-primary { --ium-stat-background: linear-gradient(135deg, #203c49, #1e2933); --ium-stat-accent: #80d6e5; }
    [data-bs-theme="dark"] .dashboard-stat-card-success { --ium-stat-background: linear-gradient(135deg, #193e31, #202f29); --ium-stat-accent: #a1efc7; }
    [data-bs-theme="dark"] .dashboard-stat-card-warning { --ium-stat-background: linear-gradient(135deg, #40351e, #30291f); --ium-stat-accent: #ffe0a0; }
    [data-bs-theme="dark"] .dashboard-stat-card-info { --ium-stat-background: linear-gradient(135deg, #352744, #292333); --ium-stat-accent: #d5b5ff; }
    [data-bs-theme="dark"] .dashboard-stat-card { background: var(--ium-stat-background) !important; }
    [data-bs-theme="dark"] .dashboard-stat-card :is(.text-gray-500, .text-gray-600) { color: #c5ccda !important; }
    [data-bs-theme="dark"] .dashboard-activity-card .text-gray-500 { color: #c5ccda !important; }
    [data-bs-theme="dark"] .dashboard-stat-card .text-gray-900 { color: var(--ium-ink) !important; }
    [data-bs-theme="dark"] .dashboard-stat-card .border-top { border-color: #616b7c !important; }
    .dashboard-stat-card :is(.bg-warning, .bg-success) .text-white { color: #07303e !important; }
    .dashboard-stat-card .symbol-label.bg-primary .text-primary { color: #b5e8ff !important; }
    [data-bs-theme="dark"] .dashboard-stat-card-link:focus-visible { outline-color: var(--ium-stat-accent); }
    [data-bs-theme="dark"] :is(.stu-acad-stats, .stu-notif-item, .today-lectures-dialog, .weekly-lectures-card .card-header) { background: var(--ium-surface); border-color: var(--ium-line); }
    [data-bs-theme="dark"] :is(.stu-detail-title, .stu-radial-pct, .stu-notif-item, .today-lectures-title h3) { color: var(--ium-ink); }
    [data-bs-theme="dark"] :is(.stu-acad-lbl, .stu-fin-msg, .lectures-empty-state) { color: var(--ium-muted); }
    [data-bs-theme="dark"] .stu-notif-item:hover { background: var(--ium-raised); color: var(--ium-ink); }
    [data-bs-theme="dark"] :is(.stu-notif-btn, .today-lectures-close, .week-selector-wrapper) { background: var(--ium-raised); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .week-selector-select { color: #9dc6ff; }
    [data-bs-theme="dark"] .prof-weekly-card .card-header { background: var(--ium-surface) !important; border-color: var(--ium-line); }

    /* Keep intentional image-preview backdrops unchanged; theme the message UI. */
    [data-bs-theme="dark"] :is(.chat-react-trigger, .chat-react-bar, .chat-react-chip, .chat-react-who, .chat-react-sheet) { background: var(--ium-surface); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .chat-mentioned-bubble { background-color: #4a3b21 !important; }
    [data-bs-theme="dark"] .app-default .chat-mentioned-bubble { background-color: #4a3b21 !important; }
    [data-bs-theme="dark"] .chat-room-root .card { background: var(--ium-surface) !important; }
    [data-bs-theme="dark"] :is(.chat-reply-quote, .chat-reply-banner, .chat-code) { background: var(--ium-raised); }
    [data-bs-theme="dark"] .chat-reply-quote-text { color: var(--ium-muted); }
    [data-bs-theme="dark"] :is(.chat-react-more, .chat-react-sheet-title) { color: var(--ium-muted); }
    [data-bs-theme="dark"] .chat-react-who:hover { color: var(--ium-ink); }
    /* Keep the deterministic sender palette. Mix each original color with white
       on dark surfaces; the base inline color stays unchanged for the light UI. */
    [data-bs-theme="dark"] [style*="--ium-chat-name:"] {
        color: #b5e8ff !important;
        color: color-mix(in srgb, var(--ium-chat-name) 40%, white) !important;
    }
    [data-bs-theme="dark"] .ai-chat-log { background: #171b23; }
    [data-bs-theme="dark"] .ai-bubble-assistant { background: var(--ium-surface); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .ai-bubble-error { background: #4d2734; color: #ffc2cf; }
    /* Links are created dynamically by assistant/_chat; cover both message roles
       and citations without changing their safe-URL rendering or bubble layout. */
    [data-bs-theme="dark"] :is(.ai-bubble-body a.ai-link, .ai-citations a) { color: var(--ium-accent) !important; }
    [data-bs-theme="dark"] :is(.ai-bubble-body a.ai-link, .ai-citations a):is(:hover, :focus-visible) { color: #e8f9ff !important; }
    .ai-bubble-user .ai-bubble-body a.ai-link { color: #fff !important; }
    .ai-bubble-user .ai-bubble-body a.ai-link:is(:hover, :focus-visible) { color: #fff !important; }
    [data-bs-theme="dark"] .ai-citations { border-color: var(--ium-line); }

    /* Student/professor consultation inboxes reuse one view. */
    [data-bs-theme="dark"] .consultation-page { --ci-ink: var(--ium-ink); --ci-muted: var(--ium-muted); --ci-line: var(--ium-line); --ci-accent: var(--ium-accent); --ci-deep: var(--ium-accent); }
    [data-bs-theme="dark"] :is(.consultation-count, .consultation-list-count, .consultation-alert-link, .consultation-filter-label, .consultation-avatar) { background: var(--ium-raised); color: var(--ium-accent); border-color: var(--ium-line); }
    [data-bs-theme="dark"] :is(.consultation-list-head, .consultation-ticket, .consultation-chat-head, .consultation-composer, .consultation-composer-inner, .consultation-message-avatar) { border-color: var(--ium-line); }
    [data-bs-theme="dark"] :is(.consultation-search, .consultation-composer textarea)::placeholder { color: var(--ium-muted); }
    [data-bs-theme="dark"] .consultation-page :is(a, button, select, input, textarea):focus-visible { outline: 2px solid var(--ium-accent); outline-offset: 2px; }
    [data-bs-theme="dark"] :is(.consultation-panel, .consultation-toolbar select, .consultation-search, .consultation-composer textarea) { background: var(--ium-surface); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .consultation-messages { background: #171b23; }
    [data-bs-theme="dark"] .consultation-message.visitor .consultation-bubble { background: var(--ium-surface); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .consultation-message.admin .consultation-bubble { background: #253c47; }
    [data-bs-theme="dark"] :is(.consultation-bubble, .consultation-message-meta, .consultation-message-avatar) { color: var(--ium-ink); }
    [data-bs-theme="dark"] .consultation-message-avatar { background: var(--ium-raised); }
    [data-bs-theme="dark"] .consultation-ticket:is(:hover, .active) { background: var(--ium-raised); }
    [data-bs-theme="dark"] .consultation-actions .btn-light-danger { background: #4d2734 !important; color: #ffc2cf !important; }

    /* Lecture recovery dialogs render outside the page's content container. */
    [data-bs-theme="dark"] .swal2-container .swal2-html-container.lecture-reopen-content { color: var(--ium-ink); }
    [data-bs-theme="dark"] .lecture-reopen-hint { color: var(--ium-muted); }
    [data-bs-theme="dark"] :is(.lecture-reopen-check, .lecture-reopen-result) { background: var(--ium-surface); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .lecture-reopen-result[data-state="ready"] { background: #173e31; color: #a1efc7; }
    [data-bs-theme="dark"] .lecture-reopen-result:is([data-state="blocked"], [data-state="error"]) { background: #4d2734; color: #ffc2cf; }

    /* Question review and results: preserve correctness colors and expanded state. */
    [data-bs-theme="dark"] :is(.faq-item, .question-text, .option-item, .true-false-item, .question, .answer-card, .question-content-card, .options-container, .actions-card, .students-card) {
        background: var(--ium-surface);
        color: var(--ium-ink);
        border-color: var(--ium-line);
    }
    [data-bs-theme="dark"] body:has(.faq-container) { background: #13151b; }
    [data-bs-theme="dark"] .faq-question:not(.active) { background: var(--ium-surface); color: var(--ium-ink); }
    [data-bs-theme="dark"] :is(.faq-answer, .review-summary, .question-review-panel, .change-request, .students-header) { background: var(--ium-raised); border-color: var(--ium-line); }
    [data-bs-theme="dark"] :is(.option-text, .true-false-item .label, .question-content-card label, .answer-card label, .options-container label, .student-name, .actions-info h4, .students-header h4, .review-summary h3, .question-review-panel__heading h4) { color: var(--ium-ink); }
    [data-bs-theme="dark"] :is(.review-summary p, .review-progress__label, .student-meta, .score-label, .actions-info p) { color: var(--ium-muted); }
    [data-bs-theme="dark"] :is(.option-item.correct, .true-false-item.correct, .correct-answer-container .accordion-button.collapsed) { background: #173e31; }
    [data-bs-theme="dark"] .wrong-answer-container .accordion-button.collapsed { background: #4d2734; }
    [data-bs-theme="dark"] .student-answer-text { background: #203c53; color: #b5e8ff; }
    [data-bs-theme="dark"] .score-input-card { background: #4a3b21; border-color: #8b7346; }
    [data-bs-theme="dark"] .score-input-card label { color: #ffe0a0; }
    [data-bs-theme="dark"] .score-input-card input { background: var(--ium-surface); color: var(--ium-ink); }
    [data-bs-theme="dark"] .readonly-input { background-color: var(--ium-raised) !important; }
    [data-bs-theme="dark"] .question-review-state--reviewed { background: #173e31; color: #a1efc7; }
    [data-bs-theme="dark"] :is(.question-review-state--change, .question-review-note, .essay-note) { background: #4a3b21; color: #ffe0a0; }
    [data-bs-theme="dark"] .question-review-state--pending { background: var(--ium-raised); color: var(--ium-muted); }

    /* Nested financial detail/filter panels use their own surfaces, outside tables. */
    [data-bs-theme="dark"] :is(.due-card, .due-card-header, .filter-bar, .dues-filter-card) { background: var(--ium-surface); border-color: var(--ium-line); }
    [data-bs-theme="dark"] :is(.due-card-header h6, .expand-row .inner-title, .dues-filter-card label, .filter-bar select, .filter-bar label) { color: var(--ium-ink); }
    [data-bs-theme="dark"] .student-row:hover { background: var(--ium-raised); }

    /* File-upload and assignment panels must not become white islands. */
    [data-bs-theme="dark"] :is(.solution-section, .history-item, .photo-upload-box) { background-color: var(--ium-raised); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .photo-upload-box:hover { background-color: #253c47; }
    [data-bs-theme="dark"] .photo-upload-box.has-image { background-color: #173e31; }
    [data-bs-theme="dark"] .inactive-step { background-color: var(--ium-raised); color: var(--ium-muted); }

    /* Independent lecture recovery/help pages share the saved portal preference. */
    [data-bs-theme="dark"] body.portal-standalone { background: #13151b; color: var(--ium-ink); }
    [data-bs-theme="dark"] .portal-standalone :is(main, #lecture-launch, .lecture-window, .lecture-help, .lecture-external, .lecture-recovery) { background: var(--ium-surface); color: var(--ium-ink); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .portal-standalone :is(.hint, .lecture-help-note) { color: var(--ium-muted); }
    [data-bs-theme="dark"] .portal-standalone .brand { color: var(--ium-accent); }
    [data-bs-theme="dark"] .portal-standalone a { color: var(--ium-accent); border-color: var(--ium-line); }
    [data-bs-theme="dark"] .portal-standalone a:hover { background-color: var(--ium-raised); }
    [data-bs-theme="dark"] .portal-standalone .lecture-stream-dismiss { background: var(--ium-raised); color: var(--ium-ink); }
}
