:root {
    color-scheme: light;
    --isms-theme-page: var(--isms-nav-page, #f2f6fc);
    --isms-theme-surface: var(--isms-nav-surface, #ffffff);
    --isms-theme-surface-alt: #f8fafc;
    --isms-theme-surface-raised: #ffffff;
    --isms-theme-heading: var(--isms-nav-heading, #212832);
    --isms-theme-text: var(--isms-nav-text, #4a515b);
    --isms-theme-muted: var(--isms-nav-muted, #69707a);
    --isms-theme-subtle: var(--isms-nav-subtle, #a7aeb8);
    --isms-theme-border: var(--isms-nav-border, #d4dae3);
    --isms-theme-border-soft: #e7ebf0;
    --isms-theme-accent: var(--isms-nav-blue, #054cd4);
    --isms-theme-accent-hover: var(--isms-nav-blue-dark, #043da9);
    --isms-theme-accent-soft: var(--isms-nav-blue-soft, #edf3ff);
    --isms-theme-success: var(--isms-nav-green, #269407);
    --isms-theme-success-soft: #edf8ea;
    --isms-theme-warning: #9a6a08;
    --isms-theme-warning-soft: #fff6df;
    --isms-theme-danger: var(--isms-nav-danger, #e81500);
    --isms-theme-danger-soft: var(--isms-nav-danger-soft, #fde9e7);
    --isms-theme-focus: var(--isms-nav-focus, rgba(5, 76, 212, 0.18));
    --isms-theme-shadow: rgba(33, 40, 50, 0.1);
    --isms-chart-heading: #212832;
    --isms-chart-text: #4a515b;
    --isms-chart-muted: #69707a;
    --isms-chart-grid: #e7ebf0;
    --isms-chart-tooltip: #ffffff;
    --isms-chart-point: #ffffff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --isms-nav-blue: #79a7ff;
    --isms-nav-blue-dark: #a9c5ff;
    --isms-nav-blue-soft: #243654;
    --isms-nav-green: #74c95b;
    --isms-nav-green-soft: #253c2c;
    --isms-nav-page: #151c27;
    --isms-nav-surface: #1c2532;
    --isms-nav-heading: #f3f6fb;
    --isms-nav-text: #d2d9e3;
    --isms-sidebar-label: #b5c0cd;
    --isms-nav-muted: #aab5c3;
    --isms-nav-subtle: #7f8b99;
    --isms-nav-border: #3a4657;
    --isms-nav-danger: #ff8178;
    --isms-nav-danger-soft: #462b30;
    --isms-nav-focus: rgba(121, 167, 255, 0.26);
    --isms-nav-shadow: rgba(0, 0, 0, 0.34);
    --isms-nav-overlay: rgba(5, 9, 15, 0.72);
    --isms-nav-active: #293b56;
    --isms-nav-hover: #243040;

    --isms-theme-page: #151c27;
    --isms-theme-surface: #1c2532;
    --isms-theme-surface-alt: #222d3c;
    --isms-theme-surface-raised: #263244;
    --isms-theme-heading: #f3f6fb;
    --isms-theme-text: #d2d9e3;
    --isms-theme-muted: #aab5c3;
    --isms-theme-subtle: #7f8b99;
    --isms-theme-border: #3a4657;
    --isms-theme-border-soft: #2c3847;
    --isms-theme-accent: #79a7ff;
    --isms-theme-accent-hover: #a9c5ff;
    --isms-theme-accent-soft: #243654;
    --isms-theme-success: #74c95b;
    --isms-theme-success-soft: #253c2c;
    --isms-theme-warning: #e5c36b;
    --isms-theme-warning-soft: #443a22;
    --isms-theme-danger: #ff8178;
    --isms-theme-danger-soft: #462b30;
    --isms-theme-focus: rgba(121, 167, 255, 0.26);
    --isms-theme-shadow: rgba(0, 0, 0, 0.34);
    --isms-chart-heading: #f3f6fb;
    --isms-chart-text: #d2d9e3;
    --isms-chart-muted: #aab5c3;
    --isms-chart-grid: #344154;
    --isms-chart-tooltip: #263244;
    --isms-chart-point: #1c2532;

    --bs-body-color: #d2d9e3;
    --bs-body-color-rgb: 210, 217, 227;
    --bs-body-bg: #151c27;
    --bs-body-bg-rgb: 21, 28, 39;
    --bs-emphasis-color: #f3f6fb;
    --bs-emphasis-color-rgb: 243, 246, 251;
    --bs-secondary-color: #aab5c3;
    --bs-secondary-bg: #222d3c;
    --bs-tertiary-color: #7f8b99;
    --bs-tertiary-bg: #1c2532;
    --bs-link-color: #8db6ff;
    --bs-link-hover-color: #b6ceff;
    --bs-link-color-rgb: 141, 182, 255;
    --bs-link-hover-color-rgb: 182, 206, 255;
    --bs-border-color: #3a4657;
    --bs-border-color-translucent: rgba(231, 237, 246, 0.15);
    --bs-primary: #79a7ff;
    --bs-primary-rgb: 121, 167, 255;
    --bs-success: #74c95b;
    --bs-success-rgb: 116, 201, 91;
    --bs-danger: #ff8178;
    --bs-danger-rgb: 255, 129, 120;

    /* Login and older pages use these established aliases. */
    --isms-blue: #79a7ff;
    --isms-blue-hover: #a9c5ff;
    --isms-blue-light: #8db6ff;
    --isms-blue-soft: #243654;
    --isms-page: #151c27;
    --isms-surface: #1c2532;
    --isms-heading: #f3f6fb;
    --isms-text: #d2d9e3;
    --isms-muted: #aab5c3;
    --isms-border: #3a4657;
    --isms-green: #74c95b;
    --isms-danger: #ff8178;
    --isms-danger-soft: #462b30;
    --isms-success: #74c95b;
    --isms-success-soft: #253c2c;
    --isms-warning: #e5c36b;
    --isms-warning-soft: #443a22;
    --isms-focus: rgba(121, 167, 255, 0.26);
    --isms-shadow: rgba(0, 0, 0, 0.38);
    --isms-shadow-soft: rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] #layoutSidenav,
html[data-theme="dark"] #layoutSidenav_content,
html[data-theme="dark"] #pjax-container {
    background-color: var(--isms-theme-page);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] body.bg-white,
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .page-header-light.bg-white {
    background-color: var(--isms-theme-surface) !important;
}

html[data-theme="dark"] :is(h1, h2, h3, h4, h5, h6, legend),
html[data-theme="dark"] :is(.card-title, .modal-title, .offcanvas-title) {
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] :is(.text-dark, .text-body) {
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] :is(.text-muted, .text-secondary) {
    color: var(--isms-theme-muted) !important;
}

html[data-theme="dark"] :is(.card, .modal-content, .offcanvas, .dropdown-menu,
    .list-group-item, .popover, .accordion-item) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.card-header, .card-footer, .modal-header,
    .modal-footer, .offcanvas-header, .accordion-button) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] :is(.dropdown-item, .list-group-item-action) {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.dropdown-item, .list-group-item-action):hover,
html[data-theme="dark"] :is(.dropdown-item, .list-group-item-action):focus {
    background-color: var(--isms-theme-surface-alt);
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] hr {
    border-color: var(--isms-theme-border);
}

html[data-theme="dark"] :is(.form-control, .form-select, .form-check-input,
    .input-group-text, .datatable-input, .datatable-selector) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] textarea {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] .form-label {
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] :is(.form-control, .form-select, .datatable-input,
    .datatable-selector)::placeholder {
    color: var(--isms-theme-subtle) !important;
    opacity: 1 !important;
}

html[data-theme="dark"] :is(.form-control, .form-select, .form-check-input,
    .datatable-input, .datatable-selector):focus {
    border-color: var(--isms-theme-accent);
    background-color: var(--isms-theme-surface-raised) !important;
    color: var(--isms-theme-heading) !important;
    box-shadow: 0 0 0 0.2rem var(--isms-theme-focus);
}

html[data-theme="dark"] :is(.form-control, .form-select, .form-check-input,
    .datatable-input, .datatable-selector):disabled,
html[data-theme="dark"] :is(.form-control, .form-select, .datatable-input,
    .datatable-selector)[readonly] {
    border-color: var(--isms-theme-border-soft);
    background-color: #18212d !important;
    color: var(--isms-theme-muted) !important;
    opacity: 1;
}

html[data-theme="dark"] :is(select, .form-select, .datatable-selector) option {
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .form-check-input:checked {
    border-color: var(--isms-theme-accent) !important;
    background-color: var(--isms-theme-accent) !important;
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--isms-theme-text);
    box-shadow: 0 0 0 1000px var(--isms-theme-surface-raised) inset;
}

html[data-theme="dark"] :is(.btn-light, .btn-outline-secondary) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.btn-light, .btn-outline-secondary):hover,
html[data-theme="dark"] :is(.btn-light, .btn-outline-secondary):focus {
    border-color: var(--isms-theme-accent);
    background-color: var(--isms-theme-surface-alt);
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(180%);
}

html[data-theme="dark"] :is(.table, .datatable-table) {
    --bs-table-color: var(--isms-theme-text);
    --bs-table-bg: var(--isms-theme-surface);
    --bs-table-border-color: var(--isms-theme-border);
    --bs-table-striped-bg: var(--isms-theme-surface-alt);
    --bs-table-striped-color: var(--isms-theme-text);
    --bs-table-active-bg: var(--isms-theme-surface-raised);
    --bs-table-active-color: var(--isms-theme-heading);
    --bs-table-hover-bg: var(--isms-theme-surface-alt);
    --bs-table-hover-color: var(--isms-theme-heading);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.table, .datatable-table) > :not(caption) > * > * {
    border-color: var(--isms-theme-border);
    background-color: transparent;
    color: inherit;
}

html[data-theme="dark"] :is(.dataTables_wrapper, .datatable-wrapper,
    .dataTables_info, .datatable-info, .dataTables_length, .datatable-dropdown,
    .dataTables_filter, .datatable-search) {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] :is(.paginate_button, .datatable-pagination a) {
    border-color: var(--isms-theme-border) !important;
    background: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] :is(.paginate_button.current,
    .datatable-pagination .active a) {
    border-color: var(--isms-theme-accent) !important;
    background: var(--isms-theme-accent-soft) !important;
    color: var(--isms-theme-accent-hover) !important;
}

html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
html[data-theme="dark"] .select2-container--default .select2-selection {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] .select2-container--bootstrap-5
    .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default
    .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--bootstrap-5
    .select2-selection--multiple .select2-selection__choice {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.select2-dropdown, .select2-search__field) {
    border-color: var(--isms-theme-border) !important;
    background-color: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] .select2-results__option {
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .select2-results__option--highlighted,
html[data-theme="dark"] .select2-results__option[aria-selected="true"] {
    background-color: var(--isms-theme-accent-soft) !important;
    color: var(--isms-theme-heading) !important;
}

html[data-theme="dark"] :is(.alert-light, .toast, .toast-header) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-raised);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .alert-warning {
    border-color: #6d5a2d;
    background-color: var(--isms-theme-warning-soft);
    color: #f2d88c;
}

html[data-theme="dark"] .alert-danger {
    border-color: #754046;
    background-color: var(--isms-theme-danger-soft);
    color: #ffaaa3;
}

html[data-theme="dark"] .alert-success {
    border-color: #3c6544;
    background-color: var(--isms-theme-success-soft);
    color: #a5dd95;
}

html[data-theme="dark"] .modal-backdrop.show,
html[data-theme="dark"] .offcanvas-backdrop.show {
    opacity: 0.72;
}

html[data-theme="dark"] :is(.tooltip-inner, .popover-header) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-raised);
    color: var(--isms-theme-heading);
}

/* Theme toggle shared by authenticated and login topbars. */
.isms-theme-toggle .isms-theme-icon-light {
    display: none;
}

html[data-theme="dark"] .isms-theme-toggle .isms-theme-icon-dark {
    display: none;
}

html[data-theme="dark"] .isms-theme-toggle .isms-theme-icon-light {
    display: inline-block;
}

.isms-topbar .isms-theme-toggle {
    margin-right: 0.25rem;
}

.isms-auth-theme-toggle {
    display: inline-flex;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--isms-border, var(--isms-theme-border));
    border-radius: 0.65rem;
    background-color: var(--isms-page, var(--isms-theme-page));
    color: var(--isms-heading, var(--isms-theme-heading));
    font-size: 1.18rem;
}

.isms-auth-theme-toggle:hover,
.isms-auth-theme-toggle:focus-visible {
    border-color: var(--isms-blue, var(--isms-theme-accent));
    background-color: var(--isms-blue-soft, var(--isms-theme-accent-soft));
    color: var(--isms-blue, var(--isms-theme-accent));
}

.isms-auth-theme-toggle:focus-visible {
    box-shadow: 0 0 0 0.2rem var(--isms-focus, var(--isms-theme-focus));
    outline: 0;
}

/* Shared record list and form tokens. */
html[data-theme="dark"] :is(.isms-pa-page, .isms-cc-page, .isms-cl-page,
    .isms-lz-page, .isms-employee-page, .isms-facility-index,
    .isms-calamity-page, .isms-calamity-affected-page) {
    --record-green-dark: #9cdd89;
    --record-green-soft: var(--isms-theme-success-soft);
    --record-border-soft: var(--isms-theme-border-soft);
    --record-shadow: 0 0.4rem 1.2rem var(--isms-theme-shadow);
}

html[data-theme="dark"] :is(.isms-pa-form-page, .isms-cc-form-page,
    .isms-cl-form-page, .isms-lz-form-page) {
    --record-form-green-dark: #9cdd89;
    --record-form-green-soft: var(--isms-theme-success-soft);
    --record-form-border-soft: var(--isms-theme-border-soft);
    --record-form-shadow: 0 0.4rem 1.2rem var(--isms-theme-shadow);
}

html[data-theme="dark"] :is(.pa-table-toolbar, .cc-table-toolbar,
    .cl-table-toolbar, .lz-table-toolbar, .pa-table-footer, .cc-table-footer,
    .cl-table-footer, .lz-table-footer, .record-form-note,
    .pa-status-control, .cc-status-control, .cl-status-control,
    .lz-status-control, .pa-form-actions, .cc-form-actions,
    .cl-form-actions, .lz-form-actions, .employee-detail-item,
    .employee-password-panel, .calamity-selected-facility,
    .calamity-selected-empty, .calamity-facility-list-heading) {
    border-color: var(--isms-theme-border-soft);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] :is(.pa-data-table, .cc-data-table,
    .cl-data-table, .lz-data-table) tbody tr:hover td,
html[data-theme="dark"] .calamity-affected-table tbody tr:hover td {
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] :is(.calamity-facility-picker-trigger,
    .calamity-facility-option):hover,
html[data-theme="dark"] .calamity-facility-picker-trigger:focus-visible {
    border-color: var(--isms-theme-accent);
    background-color: var(--isms-theme-accent-soft);
}

html[data-theme="dark"] :is(.pa-form-control, .cc-form-control,
    .cl-form-control, .lz-form-control).input-validation-error,
html[data-theme="dark"] :is(.pa-form-control, .cc-form-control,
    .cl-form-control, .lz-form-control) .input-validation-error,
html[data-theme="dark"] .isms-employee-page .employee-alert.is-error {
    border-color: var(--isms-theme-danger);
    background-color: var(--isms-theme-danger-soft) !important;
    color: #ffaaa3 !important;
}

/* Facility list, detail, structure form, and report surfaces. */
html[data-theme="dark"] .isms-facility-index :is(.facility-filter-form,
    .facility-picker-panel),
html[data-theme="dark"] .facility-structure-modal :is(.modal-header, .modal-footer),
html[data-theme="dark"] .structure-edit-actions,
html[data-theme="dark"] .isms-facility-report :is(
    .facility-report-filter-panel > header,
    .facility-report-status-criterion,
    .facility-report-year-criterion,
    .facility-report-picker-panel,
    .facility-report-preview > header) {
    border-color: var(--isms-theme-border-soft);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-facility-index .facility-owner-cell {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-user-dashboard {
    --dashboard-green-dark: #9cdd89;
    --dashboard-green-soft: var(--isms-theme-success-soft);
    --dashboard-teal: #72c7bc;
    --dashboard-teal-soft: #233f3d;
    --dashboard-gold: #e5c36b;
    --dashboard-gold-soft: var(--isms-theme-warning-soft);
    --dashboard-border-soft: var(--isms-theme-border-soft);
}

html[data-theme="dark"] .user-dashboard-actions a:hover {
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-facility-details {
    --details-blue-soft: var(--isms-theme-accent-soft);
    --details-green-soft: var(--isms-theme-success-soft);
    --details-teal: #72c7bc;
    --details-teal-soft: #233f3d;
    --details-gold: #e5c36b;
    --details-gold-soft: var(--isms-theme-warning-soft);
    --details-border-soft: var(--isms-theme-border-soft);
    --details-danger: #ff8178;
    --details-danger-soft: var(--isms-theme-danger-soft);
    --details-shadow: 0 10px 30px var(--isms-theme-shadow);
}

html[data-theme="dark"] .isms-facility-details :is(
    .facility-detail-card, .facility-tenure-items span,
    .facility-structure-search input, .facility-map-action-control,
    .facility-map-action-control button, .facility-map-popup-section) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-facility-details :is(
    .facility-tenure-group, .facility-assessment-grid > div,
    .facility-details-tabs button:hover, .facility-details-table tbody tr:hover,
    .facility-map-record-options button, .facility-map-popup-section > h3,
    .facility-map-popup-group span) {
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-facility-details .facility-details-table th {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-raised);
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] .isms-facility-details :is(
    .facility-details-status.is-active,
    .facility-record-status.is-active) {
    border-color: #3f6548;
    color: #a5dd95;
}

html[data-theme="dark"] .isms-facility-details
    .facility-details-button.is-secondary:hover {
    border-color: var(--isms-theme-accent);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-facility-details :is(.facility-map-state,
    .facility-report-loading) {
    background-color: rgba(21, 28, 39, 0.92);
}

html[data-theme="dark"] .isms-facility-details :is(.facility-map-toolbar,
    .facility-boundary-label) {
    border-color: var(--isms-theme-border);
    background-color: rgba(28, 37, 50, 0.96);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-facility-details .facility-map-popup-header {
    background-color: var(--isms-theme-accent-soft);
}

html[data-theme="dark"] .isms-facility-details .facility-map-popup-body {
    background-color: var(--isms-theme-page);
}

html[data-theme="dark"] :is(.isms-structure-edit-page,
    .facility-structure-edit-modal) {
    --structure-green-soft: var(--isms-theme-success-soft);
    --structure-border-soft: var(--isms-theme-border-soft);
    --structure-danger-soft: var(--isms-theme-danger-soft);
    --structure-shadow: 0 0.4rem 1.2rem var(--isms-theme-shadow);
}

html[data-theme="dark"] .isms-facility-report {
    --report-green-dark: #9cdd89;
    --report-green-soft: var(--isms-theme-success-soft);
    --report-border-soft: var(--isms-theme-border-soft);
    --report-danger-soft: var(--isms-theme-danger-soft);
}

html[data-theme="dark"] .facility-report-viewer {
    background-color: var(--isms-theme-page);
}

html[data-theme="dark"] .facility-report-loading {
    background-color: rgba(21, 28, 39, 0.94);
}

/* Map UI retains the map tiles themselves while theming its controls and overlays. */
html[data-theme="dark"] .isms-map-page {
    --map-navy: #f0f7f3;
    --map-forest: #7dcc9f;
    --map-emerald: #8dd7af;
    --map-sage: #2b4438;
    --map-mist: var(--isms-theme-surface-alt);
    --map-surface: var(--isms-theme-surface);
    --map-charcoal: var(--isms-theme-text);
    --map-muted: var(--isms-theme-muted);
    --map-border: var(--isms-theme-border);
    --map-blue: #8db6ff;
    --map-gold: #e5c36b;
    background-color: var(--isms-theme-page);
}

/* Keep spatial markers identical across themes; only their surrounding UI is themed. */
html[data-theme="dark"] .isms-map-page :is(
    .isms-map-point-icon.is-facility > span,
    .isms-map-legend .is-facility) {
    background-color: #1558c9;
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-point-icon.is-structure > span,
    .isms-map-legend .is-structure) {
    background-color: #2f7d5a;
}

html[data-theme="dark"] .isms-map-page .isms-map-cluster > span {
    border-color: rgba(255, 255, 255, 0.96);
    background-color: #123524;
    box-shadow:
        0 0 0 2px rgba(18, 53, 36, 0.28),
        0 4px 12px rgba(0, 0, 0, 0.48);
    color: #ffffff;
}

html[data-theme="dark"] .isms-map-page .isms-map-cluster:hover > span,
html[data-theme="dark"] .isms-map-page .isms-map-cluster:focus > span {
    background-color: #1558c9;
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-filter-panel, .isms-map-popup-actions, .isms-unlocated-record,
    .isms-map-export-modal .modal-header,
    .isms-map-export-section > header,
    .isms-map-export-range-card, .isms-map-export-picker-panel,
    .isms-map-export-modal .modal-footer) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup > header {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-accent-soft);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup-body {
    background-color: var(--isms-theme-page);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup-section {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup-section > h3 {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
    color: var(--isms-theme-heading);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup-row {
    border-color: var(--isms-theme-border-soft);
}

html[data-theme="dark"] .isms-map-page .isms-map-popup-row dt {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-filter-note, .isms-map-export-picker-icon,
    .isms-map-export-picker-options label:hover, .isms-map-export-note) {
    border-color: #3f5a4b;
    background-color: #24382f;
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-field label, .isms-map-export-field > label,
    .isms-map-filter-note, .isms-map-export-note) {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-export-picker-options label,
    .isms-map-floating-actions button, .isms-map-popup-row dd) {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-map-page :is(
    .isms-map-floating-actions, .isms-map-export-field .form-control,
    .isms-map-export-field .form-select, .isms-map-export-picker,
    .isms-map-export-picker-search input, .isms-map-export-reset,
    .isms-map-export-cancel) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-map-page .isms-map-filter-actions .is-secondary {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-map-page :is(.isms-map-state,
    .isms-map-export-modal .modal-body) {
    background-color: rgba(21, 28, 39, 0.94);
}

html[data-theme="dark"] :is(.leaflet-bar a, .leaflet-control-layers,
    .leaflet-popup-content-wrapper, .leaflet-popup-tip) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-raised);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .leaflet-bar a:hover {
    background-color: var(--isms-theme-surface-alt);
    color: var(--isms-theme-heading);
}

/* Account, audit, password reset, and What's New components. */
html[data-theme="dark"] .isms-account-page {
    --account-navy: var(--isms-theme-heading);
    --account-forest: #7dcc9f;
    --account-emerald: #8dd7af;
    --account-sage: #2b4438;
    --account-mist: var(--isms-theme-surface-alt);
    --account-surface: var(--isms-theme-surface);
    --account-charcoal: var(--isms-theme-text);
    --account-muted: var(--isms-theme-muted);
    --account-border: var(--isms-theme-border);
    --account-gold: #e5c36b;
    background-color: var(--isms-theme-page);
}

html[data-theme="dark"] .isms-account-page :is(
    .account-security-badge, .account-profile-organization,
    .account-security-note, .account-state.is-active,
    .account-form-message.is-success) {
    border-color: #3f5a4b;
    background-color: #24382f;
    color: #a7dfbd;
}

html[data-theme="dark"] .isms-account-page :is(
    .account-state.is-inactive, .account-form-message.is-error) {
    border-color: #754046;
    background-color: var(--isms-theme-danger-soft);
    color: #ffaaa3;
}

html[data-theme="dark"] .isms-account-page :is(
    .account-detail-grid > div, .account-access-panel dl > div) {
    border-color: var(--isms-theme-border-soft);
}

html[data-theme="dark"] .isms-account-page dd {
    color: var(--isms-theme-text);
}

html[data-theme="dark"] .isms-account-page .account-field label {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] .isms-audit-page {
    --audit-navy: var(--isms-theme-heading);
    --audit-forest: #7dcc9f;
    --audit-emerald: #8dd7af;
    --audit-sage: #2b4438;
    --audit-mist: var(--isms-theme-surface-alt);
    --audit-surface: var(--isms-theme-surface);
    --audit-charcoal: var(--isms-theme-text);
    --audit-muted: var(--isms-theme-muted);
    --audit-border: var(--isms-theme-border);
    --audit-accent: #e5c36b;
}

html[data-theme="dark"] .isms-audit-page :is(
    .audit-scope-badge, .audit-module-badge) {
    border-color: #3f5a4b;
    background-color: #24382f;
}

html[data-theme="dark"] .isms-audit-page :is(.audit-filter-form,
    .audit-summary-facility) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-audit-page :is(
    .audit-action-description, .audit-no-action) {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] .isms-password-reset {
    --reset-navy: var(--isms-theme-heading);
    --reset-forest: #7dcc9f;
    --reset-emerald: #8dd7af;
    --reset-muted: var(--isms-theme-muted);
    --reset-border: var(--isms-theme-border);
    --reset-surface: var(--isms-theme-surface);
}

html[data-theme="dark"] .isms-password-reset :is(
    .password-reset-header, .password-reset-rules,
    .password-reset-footer) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-password-reset .password-reset-header > span {
    background-color: #24382f;
}

html[data-theme="dark"] .isms-password-reset .password-reset-notice {
    border-color: #6d5a2d;
    background-color: var(--isms-theme-warning-soft);
    color: #f2d88c;
}

html[data-theme="dark"] .isms-password-reset .password-reset-errors {
    border-color: #754046;
    background-color: var(--isms-theme-danger-soft);
    color: #ffaaa3;
}

html[data-theme="dark"] .isms-password-reset .password-reset-fields label {
    color: var(--isms-theme-muted);
}

html[data-theme="dark"] .isms-password-reset .password-reset-fields input {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface) !important;
    color: var(--isms-theme-text) !important;
}

html[data-theme="dark"] :is(.isms-whats-new-modal,
    .whats-new-confirm-modal) {
    --whats-new-border: var(--isms-theme-border);
    --whats-new-surface: var(--isms-theme-surface);
}

html[data-theme="dark"] :is(.whats-new-modal-header,
    .whats-new-modal-footer, .whats-new-confirm-modal .modal-header) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] :is(.whats-new-entry,
    .whats-new-close:hover, .whats-new-version) {
    border-color: var(--isms-theme-border);
    background-color: var(--isms-theme-surface);
    color: var(--isms-theme-text);
}

html[data-theme="dark"] :is(.whats-new-intro,
    .whats-new-published-note, .whats-new-category.is-feature) {
    border-color: #3c5377;
    background-color: var(--isms-theme-accent-soft);
    color: #b7cefa;
}

html[data-theme="dark"] .whats-new-category.is-improvement {
    background-color: var(--isms-theme-success-soft);
    color: #a5dd95;
}

html[data-theme="dark"] :is(.whats-new-category.is-fix,
    .whats-new-delete-warning, .cc-action-button.is-danger:hover) {
    border-color: #754046;
    background-color: var(--isms-theme-danger-soft);
    color: #ffaaa3;
}

/* The admin dashboard is defined inline in its view, so only its tokens are overridden. */
html[data-theme="dark"] .isms-admin-dashboard {
    --admin-green-dark: #9cdd89;
    --admin-green-soft: var(--isms-theme-success-soft);
    --admin-teal: #72c7bc;
    --admin-teal-soft: #233f3d;
    --admin-gold: #e5c36b;
    --admin-gold-soft: var(--isms-theme-warning-soft);
    --admin-border-soft: var(--isms-theme-border-soft);
    --admin-danger: var(--isms-theme-danger);
    --admin-shadow: 0 0.4rem 1.2rem var(--isms-theme-shadow);
}

html[data-theme="dark"] .isms-admin-dashboard :is(
    .admin-insight-tabs .admin-insight-tab:hover,
    .admin-people-tabs .nav-link:hover,
    .admin-support-item:hover, .admin-action-link) {
    background-color: var(--isms-theme-surface-alt);
}

html[data-theme="dark"] .isms-admin-dashboard .admin-action-link:hover {
    border-color: var(--isms-theme-accent);
    background-color: var(--isms-theme-surface-raised);
    box-shadow: 0 0.35rem 0.9rem var(--isms-theme-shadow);
}

/* Shared toastr notifications. */
#toast-container {
    z-index: 1090;
}

#toast-container.toast-top-right {
    top: 0.9rem;
    right: 0.9rem;
    width: auto;
}

body.nav-fixed #toast-container.toast-top-right {
    top: calc(var(--isms-topbar-height, 4rem) + 0.85rem);
}

body.has-maintenance-notice #toast-container.toast-top-right {
    top: calc(var(--isms-topbar-height, 4rem) + 58px + 0.85rem);
}

#toast-container > div {
    --isms-toast-accent: var(--isms-theme-accent);
    --isms-toast-accent-soft: var(--isms-theme-accent-soft);
    position: relative;
    width: min(22rem, calc(100vw - 1.8rem));
    min-height: 3.7rem;
    margin: 0 0 0.55rem;
    padding: 0.78rem 2.35rem 0.78rem 3.45rem;
    overflow: hidden;
    border: 1px solid var(--isms-theme-border);
    border-left: 4px solid var(--isms-toast-accent);
    border-radius: 0.78rem;
    background-color: var(--isms-theme-surface-raised);
    background-image: none !important;
    color: var(--isms-theme-text);
    box-shadow: 0 0.65rem 1.65rem var(--isms-theme-shadow);
    opacity: 1;
    font-family: inherit;
}

#toast-container > div:hover {
    background-color: var(--isms-theme-surface-raised);
    box-shadow: 0 0.8rem 1.9rem var(--isms-theme-shadow);
    opacity: 1;
}

#toast-container > .toast-success {
    --isms-toast-accent: var(--isms-theme-success);
    --isms-toast-accent-soft: var(--isms-theme-success-soft);
}

#toast-container > .toast-error {
    --isms-toast-accent: var(--isms-theme-danger);
    --isms-toast-accent-soft: var(--isms-theme-danger-soft);
}

#toast-container > .toast-warning {
    --isms-toast-accent: var(--isms-theme-warning);
    --isms-toast-accent-soft: var(--isms-theme-warning-soft);
}

#toast-container > .toast-info {
    --isms-toast-accent: var(--isms-theme-accent);
    --isms-toast-accent-soft: var(--isms-theme-accent-soft);
}

#toast-container > div::before {
    position: absolute;
    top: 50%;
    left: 0.78rem;
    display: inline-flex;
    width: 1.85rem;
    height: 1.85rem;
    align-items: center;
    justify-content: center;
    border-radius: 0.55rem;
    background-color: var(--isms-toast-accent-soft);
    color: var(--isms-toast-accent);
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1;
    transform: translateY(-50%);
}

#toast-container > .toast-success::before {
    content: "\2713";
}

#toast-container > .toast-error::before {
    content: "\00D7";
    font-size: 1.15rem;
}

#toast-container > .toast-warning::before {
    content: "!";
}

#toast-container > .toast-info::before {
    content: "i";
}

#toast-container .toast-title {
    margin: 0 0 0.15rem;
    color: var(--isms-theme-heading);
    font-size: 0.76rem;
    font-weight: 750;
    line-height: 1.35;
}

#toast-container .toast-message {
    color: var(--isms-theme-text);
    font-size: 0.73rem;
    font-weight: 550;
    line-height: 1.45;
}

#toast-container .toast-message :is(a, label) {
    color: var(--isms-toast-accent);
}

#toast-container .toast-close-button {
    position: absolute;
    top: 0.48rem;
    right: 0.58rem;
    float: none;
    margin: 0;
    padding: 0.15rem;
    color: var(--isms-theme-muted);
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1;
    text-shadow: none;
    opacity: 1;
}

#toast-container .toast-close-button:hover,
#toast-container .toast-close-button:focus-visible {
    color: var(--isms-theme-heading);
    opacity: 1;
    outline: 0;
}

#toast-container .toast-progress {
    height: 3px;
    background-color: var(--isms-toast-accent);
    opacity: 0.45;
}

@media (max-width: 575.98px) {
    #toast-container.toast-top-right {
        right: 0.55rem;
        left: 0.55rem;
    }

    #toast-container > div {
        width: 100%;
        margin-bottom: 0.45rem;
    }
}

/* Preserve the login photograph while adapting its form and status surfaces. */
html[data-theme="dark"] .isms-auth-page {
    --isms-cover-top: rgba(5, 13, 25, 0.18);
    --isms-cover-bottom: rgba(5, 13, 25, 0.94);
    --isms-white-muted: rgba(255, 255, 255, 0.82);
    --isms-white-border: rgba(255, 255, 255, 0.28);
}

html[data-theme="dark"] .isms-auth-page :is(
    .isms-cover-panel, .isms-cover-kicker, .isms-cover-heading,
    .isms-detail-item i, .isms-detail-title) {
    color: #ffffff;
}

@media (prefers-reduced-motion: reduce) {
    .isms-theme-toggle {
        transition: none !important;
    }
}
