:root {
    color-scheme: light;
    --primary: #047857;
    --imi-primary: #047857;
    --imi-primary-hover: #065f46;
    --imi-primary-active: #064e3b;
    --imi-on-primary: #ffffff;
    --imi-accent-text: #047857;
    --imi-accent-hover: #065f46;
    --imi-accent-soft: #ecfdf5;
    --imi-accent-border: #10b981;
    --imi-focus-ring: rgba(16, 185, 129, .24);
    --imi-bg: #f6f8f7;
    --imi-surface: #ffffff;
    --imi-surface-soft: #f8faf9;
    --imi-surface-muted: #edf2ef;
    --imi-border: #dce5e0;
    --imi-text: #47524d;
    --imi-text-strong: #1f2925;
    --imi-text-muted: #6b7771;
    --imi-input-bg: #ffffff;
    --imi-input-border: #a7b5ae;
    --imi-input-text: #33473e;
    --imi-sidebar-start: #059669;
    --imi-sidebar-end: #064e3b;
    --imi-shadow: 0 .35rem 1.25rem rgba(31, 41, 37, .08);
    --imi-row-hover: #f0faf5;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --primary: #10b981;
    --imi-primary: #10b981;
    --imi-primary-hover: #047857;
    --imi-primary-active: #065f46;
    --imi-on-primary: #052e24;
    --imi-accent-text: #6ee7b7;
    --imi-accent-hover: #a7f3d0;
    --imi-accent-soft: #15342b;
    --imi-accent-border: #34d399;
    --imi-focus-ring: rgba(52, 211, 153, .35);
    --imi-bg: #0d1210;
    --imi-surface: #171d1a;
    --imi-surface-soft: #1d2521;
    --imi-surface-muted: #28322d;
    --imi-border: #38453f;
    --imi-text: #cbd5d0;
    --imi-text-strong: #f1f5f3;
    --imi-text-muted: #9eaaa4;
    --imi-input-bg: #111714;
    --imi-input-border: #53635b;
    --imi-input-text: #edf3f0;
    --imi-sidebar-start: #047857;
    --imi-sidebar-end: #052e24;
    --imi-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .32);
    --imi-row-hover: #1b352b;
}

body {
    background-color: var(--imi-bg);
    color: var(--imi-text);
}

body, .card, .modal-content, .dropdown-menu, .form-control, .custom-select,
.input-group-text, .table, .page-link, .list-group-item {
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.card,
.modal-content,
.dropdown-menu {
    border-color: var(--imi-border);
    background-color: var(--imi-surface);
    color: var(--imi-text);
}

.card,
.topbar,
.dropdown-menu {
    box-shadow: var(--imi-shadow);
}

.card-header, .card-footer, .modal-header, .modal-footer {
    background-color: var(--imi-surface-soft);
    border-color: var(--imi-border);
}

.form-control, .custom-select, .custom-file-label, .input-group-text {
    background-color: var(--imi-input-bg);
    border-color: var(--imi-input-border);
    color: var(--imi-input-text);
}

.theme-toggle {
    border: 0;
    line-height: 1;
    min-width: 2.75rem;
}

.theme-toggle:focus {
    box-shadow: 0 0 0 .2rem var(--imi-focus-ring);
}

.theme-toggle-light-icon,
html[data-theme="dark"] .theme-toggle-dark-icon {
    display: none;
}

html[data-theme="dark"] .theme-toggle-light-icon {
    display: inline-block;
    color: #fbbf24;
}

html[data-theme="dark"] body,
html[data-theme="dark"] #wrapper,
html[data-theme="dark"] #content-wrapper,
html[data-theme="dark"] #content,
html[data-theme="dark"] .container-fluid {
    background-color: var(--imi-bg) !important;
    color: var(--imi-text);
}

html[data-theme="dark"] .bg-gradient-primary {
    background-color: var(--imi-sidebar-start);
    background-image: linear-gradient(180deg, var(--imi-sidebar-start) 10%, var(--imi-sidebar-end) 100%) !important;
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .navbar,
html[data-theme="dark"] .sticky-footer,
html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .collapse-inner,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .jumbotron {
    background-color: var(--imi-surface) !important;
    color: var(--imi-text);
    border-color: var(--imi-border);
}

html[data-theme="dark"] .shadow,
html[data-theme="dark"] .shadow-sm,
html[data-theme="dark"] .shadow-lg {
    box-shadow: var(--imi-shadow) !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
    background-color: var(--imi-surface) !important;
}

html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .dropdown-header,
html[data-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--imi-surface-soft) !important;
    border-color: var(--imi-border);
    color: var(--imi-text-strong);
}

html[data-theme="dark"] .text-gray-100,
html[data-theme="dark"] .text-gray-200,
html[data-theme="dark"] .text-gray-300,
html[data-theme="dark"] .text-gray-400,
html[data-theme="dark"] .text-gray-500,
html[data-theme="dark"] .text-gray-600,
html[data-theme="dark"] .text-gray-700,
html[data-theme="dark"] .text-gray-800,
html[data-theme="dark"] .text-gray-900,
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .collapse-item,
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link,
html[data-theme="dark"] .navbar-light .navbar-brand {
    color: var(--imi-text-strong) !important;
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .breadcrumb,
html[data-theme="dark"] .dataTables_info,
html[data-theme="dark"] .dataTables_length,
html[data-theme="dark"] .dataTables_filter {
    color: var(--imi-text-muted) !important;
}

html[data-theme="dark"] a:not([class]) {
    color: #6ee7b7;
}

html[data-theme="dark"] a:not([class]):hover {
    color: #a7f3d0;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .collapse-item:hover,
html[data-theme="dark"] .collapse-item:focus {
    background-color: var(--imi-surface-muted) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] .sidebar-divider,
html[data-theme="dark"] hr,
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-right,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-left {
    border-color: var(--imi-border) !important;
}

html[data-theme="dark"] .table,
html[data-theme="dark"] .table-bordered,
html[data-theme="dark"] .table-striped,
html[data-theme="dark"] .table-hover {
    color: var(--imi-text);
    background-color: var(--imi-surface);
}

html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table-bordered th,
html[data-theme="dark"] .table-bordered td {
    border-color: var(--imi-border) !important;
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .thead-light th {
    background-color: var(--imi-surface-soft) !important;
    color: var(--imi-text-strong) !important;
    border-color: var(--imi-border) !important;
}

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, .035);
}

html[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: var(--imi-row-hover);
    color: var(--imi-text-strong);
}

html[data-theme="dark"] .table td .btn-link,
html[data-theme="dark"] .dataTable td .btn-link {
    color: #a7f3d0 !important;
    background-color: rgba(52, 211, 153, .12);
    border: 1px solid rgba(110, 231, 183, .28);
    border-radius: .35rem;
    text-decoration: none;
}

html[data-theme="dark"] .table td .btn-link:hover,
html[data-theme="dark"] .table td .btn-link:focus,
html[data-theme="dark"] .dataTable td .btn-link:hover,
html[data-theme="dark"] .dataTable td .btn-link:focus {
    color: #ffffff !important;
    background-color: rgba(52, 211, 153, .26);
    border-color: rgba(167, 243, 208, .58);
    box-shadow: 0 0 0 .12rem rgba(52, 211, 153, .18);
}

html[data-theme="dark"] .table td .btn-link.text-danger,
html[data-theme="dark"] .dataTable td .btn-link.text-danger {
    color: #fca5a5 !important;
    background-color: rgba(248, 113, 113, .12);
    border-color: rgba(252, 165, 165, .28);
}

html[data-theme="dark"] .table td .btn-link.text-danger:hover,
html[data-theme="dark"] .table td .btn-link.text-danger:focus,
html[data-theme="dark"] .dataTable td .btn-link.text-danger:hover,
html[data-theme="dark"] .dataTable td .btn-link.text-danger:focus {
    color: #ffffff !important;
    background-color: rgba(248, 113, 113, .28);
    border-color: rgba(254, 202, 202, .62);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] .custom-file-label,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"])) {
    background-color: var(--imi-input-bg) !important;
    border-color: var(--imi-input-border) !important;
    color: var(--imi-input-text) !important;
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--imi-text-muted) !important;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .custom-select:focus {
    background-color: var(--imi-input-bg) !important;
    border-color: var(--imi-accent-border) !important;
    color: var(--imi-input-text) !important;
    box-shadow: 0 0 0 .2rem var(--imi-focus-ring);
}

html[data-theme="dark"] .page-link {
    background-color: var(--imi-surface);
    border-color: var(--imi-border);
    color: var(--imi-accent-text);
}

html[data-theme="dark"] .page-link:hover {
    background-color: var(--imi-surface-muted);
    border-color: var(--imi-border);
    color: #ffffff;
}

html[data-theme="dark"] .alert {
    border-color: transparent;
}

html[data-theme="dark"] .alert-success {
    background-color: #12372a;
    border-color: #276749;
    color: #d1fae5;
}

html[data-theme="dark"] .alert-success.border-left-success {
    border-left-color: #34d399 !important;
}

html[data-theme="dark"] .alert-success .close {
    color: #d1fae5;
    opacity: .85;
}

html[data-theme="dark"] .alert-success .close:hover,
html[data-theme="dark"] .alert-success .close:focus {
    color: #ffffff;
    opacity: 1;
}

html[data-theme="dark"] .support-ticket-guide {
    background-color: #1f2937 !important;
    border-color: #374151;
    border-left-color: #38bdf8 !important;
}

html[data-theme="dark"] .support-ticket-guide .card-header {
    background-color: #155e75 !important;
    border-bottom-color: #0891b2;
}

html[data-theme="dark"] .support-ticket-guide .card-header h6 {
    color: #ffffff !important;
}

html[data-theme="dark"] .support-ticket-guide .text-primary {
    color: #6ee7b7 !important;
}

html[data-theme="dark"] .support-ticket-guide .text-success {
    color: #6ee7b7 !important;
}

html[data-theme="dark"] .support-ticket-guide .text-gray-600 {
    color: #d1d5db !important;
}

html[data-theme="dark"] .support-ticket-guide .badge-primary {
    background-color: #047857;
    color: #ffffff !important;
}

html[data-theme="dark"] .support-ticket-guide .badge-success {
    background-color: #047857;
    color: #ffffff !important;
}

html[data-theme="dark"] .support-ticket-guide a.badge-success:hover,
html[data-theme="dark"] .support-ticket-guide a.badge-success:focus {
    background-color: #059669;
    color: #ffffff !important;
}

html[data-theme="dark"] .close {
    color: #ffffff;
    text-shadow: none;
}

html[data-theme="dark"] .scroll-to-top {
    background-color: rgba(55, 65, 81, .9);
}

html[data-theme="dark"] .progress {
    background-color: var(--imi-surface-muted);
}

html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple,
html[data-theme="dark"] .select2-dropdown {
    background-color: var(--imi-input-bg);
    border-color: var(--imi-border);
    color: var(--imi-input-text);
}

html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice,
html[data-theme="dark"] .select2-results__option {
    color: var(--imi-input-text);
}

html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #047857;
    color: #ffffff;
}

/* Shared brand states use one emerald identity with mode-aware contrast. */
a, .btn-link, .page-link { color: var(--imi-accent-text); }
a:hover, .btn-link:hover, .page-link:hover { color: var(--imi-accent-hover); }
.text-primary, a.text-primary { color: var(--imi-accent-text) !important; }
a.text-primary:hover, a.text-primary:focus { color: var(--imi-accent-hover) !important; }
.bg-primary { background-color: var(--imi-primary) !important; color: var(--imi-on-primary); }
.bg-gradient-primary {
    background-color: var(--imi-sidebar-start);
    background-image: linear-gradient(180deg, var(--imi-sidebar-start) 10%, var(--imi-sidebar-end) 100%);
}
.border-primary { border-color: var(--imi-accent-border) !important; }
.border-left-primary { border-left-color: var(--imi-accent-border) !important; }
.border-bottom-primary { border-bottom-color: var(--imi-accent-border) !important; }
.btn-primary, .badge-primary, .page-item.active .page-link,
.nav-pills .nav-link.active, .nav-pills .show > .nav-link,
.list-group-item.active, .dropdown-item.active, .dropdown-item:active {
    color: var(--imi-on-primary);
    background-color: var(--imi-primary);
    border-color: var(--imi-primary);
}
.btn-primary:hover, .btn-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled).active, .show > .btn-primary.dropdown-toggle,
a.badge-primary:hover, a.badge-primary:focus {
    color: #fff;
    background-color: var(--imi-primary-hover);
    border-color: var(--imi-primary-active);
}
.btn-primary.disabled, .btn-primary:disabled {
    color: var(--imi-on-primary);
    background-color: var(--imi-primary);
    border-color: var(--imi-primary);
}
.btn-outline-primary { color: var(--imi-accent-text); border-color: var(--imi-accent-border); }
.btn-outline-primary:hover, .btn-outline-primary:focus,
.btn-outline-primary:not(:disabled):not(.disabled):active,
.btn-outline-primary:not(:disabled):not(.disabled).active,
.show > .btn-outline-primary.dropdown-toggle {
    color: #fff;
    background-color: var(--imi-primary-hover);
    border-color: var(--imi-primary-hover);
}
.btn-outline-primary:disabled, .btn-outline-primary.disabled { color: var(--imi-accent-text); background: transparent; }
.btn-primary:focus, .btn-outline-primary:focus,
.btn-primary:not(:disabled):not(.disabled):active:focus,
.btn-outline-primary:not(:disabled):not(.disabled):active:focus,
.page-link:focus { box-shadow: 0 0 0 .2rem var(--imi-focus-ring); }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--imi-accent-border);
    outline-offset: 3px;
}
.form-control:focus, .custom-select:focus, .custom-file-input:focus ~ .custom-file-label {
    border-color: var(--imi-accent-border);
    box-shadow: 0 0 0 .2rem var(--imi-focus-ring);
}
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--imi-primary); }
.custom-control-input:checked ~ .custom-control-label::before,
.custom-control-input:active ~ .custom-control-label::before {
    background-color: var(--imi-primary-hover);
    border-color: var(--imi-accent-border);
}
.custom-control-input:focus ~ .custom-control-label::before { box-shadow: 0 0 0 .2rem var(--imi-focus-ring); }
.custom-control-input:focus:not(:checked) ~ .custom-control-label::before { border-color: var(--imi-accent-border); }
.custom-range::-webkit-slider-thumb { background-color: var(--imi-primary); }
.custom-range::-moz-range-thumb { background-color: var(--imi-primary); }
.progress-bar { background-color: var(--imi-primary); color: var(--imi-on-primary); }
.alert-primary, .list-group-item-primary, .table-primary, .table-primary > th, .table-primary > td {
    color: var(--imi-accent-text);
    background-color: var(--imi-accent-soft);
    border-color: var(--imi-accent-border);
}
.alert-primary .alert-link { color: var(--imi-accent-hover); }
.table-hover .table-primary:hover, .table-hover .table-primary:hover > td,
.table-hover .table-primary:hover > th, .list-group-item-primary.list-group-item-action:hover {
    background-color: var(--imi-accent-soft); color: var(--imi-accent-hover);
}
.sidebar-dark .nav-item .nav-link, .sidebar-dark .nav-item .nav-link i,
.sidebar-dark .sidebar-heading { color: rgba(236, 253, 245, .82); }
.sidebar-dark .nav-item.active .nav-link, .sidebar-dark .nav-item.active .nav-link i,
.sidebar-dark .nav-item .nav-link:hover, .sidebar-dark .sidebar-brand { color: #fff; }
.sidebar .nav-item .collapse .collapse-inner .collapse-item.active { color: var(--imi-accent-text) !important; background: var(--imi-accent-soft); }
.topbar .dropdown-list .dropdown-header { background: var(--imi-primary-active); border-color: var(--imi-primary-active); color: #fff; }

/* Plugin controls share the same focus, selection and surface colors. */
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable,
.select2-container--bootstrap4 .select2-results__option--highlighted {
    background-color: var(--imi-primary-hover); color: #fff;
}
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection,
.select2-container--bootstrap4.select2-container--focus .select2-selection {
    border-color: var(--imi-accent-border); box-shadow: 0 0 0 .2rem var(--imi-focus-ring);
}
.swal2-popup .swal2-styled.swal2-confirm, .swal-button--confirm {
    background-color: var(--imi-primary-hover) !important; color: #fff;
}
.swal2-popup .swal2-styled.swal2-confirm:focus, .swal-button--confirm:focus { box-shadow: 0 0 0 .2rem var(--imi-focus-ring); }

/* Dark surfaces: layer the page, cards and inset controls without pure black. */
html[data-theme="dark"] :is(.bg-gray-100, .bg-gray-200, .bg-gray-300, .bg-gray-400,
.breadcrumb, .toast, .toast-header, .popover, .popover-header, .swal2-popup, .swal-modal,
.dataTables_processing, .dt-processing, .note-editor, .note-toolbar, .note-editable,
.select2-container--bootstrap4 .select2-selection, .select2-container--bootstrap4 .select2-dropdown) {
    background-color: var(--imi-surface) !important; color: var(--imi-text); border-color: var(--imi-border);
}
html[data-theme="dark"] :is(.popover-body, .swal2-title, .swal2-html-container,
.swal-title, .swal-text, .form-control-plaintext, .list-group-item-action) { color: var(--imi-text); }
html[data-theme="dark"] :is(.btn-light, .badge-light, .btn-secondary, .badge-secondary,
.custom-file-label::after, .select2-selection__choice) {
    color: var(--imi-text-strong) !important; background-color: var(--imi-surface-muted) !important; border-color: #61736b !important;
}
html[data-theme="dark"] :is(.btn-light, .btn-secondary):is(:hover, :focus, :active) {
    background-color: #43554d !important; border-color: var(--imi-accent-border) !important;
}
html[data-theme="dark"] :is(.btn-outline-secondary, .btn-outline-dark, .btn-outline-light) {
    color: var(--imi-text); border-color: #8c9e95;
}
html[data-theme="dark"] :is(.btn-outline-secondary, .btn-outline-dark, .btn-outline-light):is(:hover, :focus, :active) {
    color: var(--imi-text-strong); background-color: var(--imi-surface-muted); border-color: var(--imi-accent-border);
}
html[data-theme="dark"] .dropdown-item.active,
html[data-theme="dark"] .dropdown-item:active { color: var(--imi-on-primary) !important; background-color: var(--imi-primary) !important; }
html[data-theme="dark"] .page-item.active .page-link {
    color: var(--imi-on-primary); background: var(--imi-primary); border-color: var(--imi-primary);
}
html[data-theme="dark"] .page-item.disabled .page-link { color: var(--imi-text-muted); }
html[data-theme="dark"] .nav-tabs { border-color: var(--imi-border); }
html[data-theme="dark"] .nav-tabs .nav-link { color: var(--imi-text-muted); }
html[data-theme="dark"] .nav-tabs .nav-link:is(:hover, :focus) { border-color: var(--imi-border); color: var(--imi-accent-text); }
html[data-theme="dark"] .nav-tabs .nav-link.active {
    background: var(--imi-surface); border-color: var(--imi-border) var(--imi-border) var(--imi-surface); color: var(--imi-accent-text);
}
html[data-theme="dark"] :is(.form-control, .custom-select, input, select, textarea):disabled,
html[data-theme="dark"] .form-control[readonly] {
    background: var(--imi-surface-muted) !important; color: var(--imi-text-muted) !important; opacity: 1;
}
html[data-theme="dark"] .custom-control-label::before { background-color: var(--imi-input-bg); border-color: #8c9e95; }
html[data-theme="dark"] .custom-control-input:checked ~ .custom-control-label::before { background: var(--imi-primary-hover); border-color: var(--imi-accent-border); }
html[data-theme="dark"] .custom-control-input:disabled:checked ~ .custom-control-label::before { background: var(--imi-surface-muted); }
html[data-theme="dark"] .custom-control-input:disabled ~ .custom-control-label { color: var(--imi-text-muted); }
html[data-theme="dark"] .custom-range::-webkit-slider-runnable-track { background: var(--imi-surface-muted); }
html[data-theme="dark"] .custom-range::-moz-range-track { background: var(--imi-surface-muted); }
html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-theme="dark"] .select2-container--default .select2-results__option--selected {
    background: var(--imi-accent-soft); color: var(--imi-accent-text);
}
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--imi-primary-hover); color: #fff; }
html[data-theme="dark"] :is(.select2-selection__placeholder, .select2-selection__choice__remove, .select2-results__option[aria-disabled="true"]) { color: var(--imi-text-muted) !important; }
html[data-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection { background: var(--imi-surface-muted); }
html[data-theme="dark"] .select2-selection__arrow b { border-top-color: var(--imi-text-muted) !important; }
html[data-theme="dark"] :is(.table-dark, .thead-dark th) { background: var(--imi-surface-muted); color: var(--imi-text-strong); }
html[data-theme="dark"] .dataTables_wrapper .dataTables_processing { background-image: none; }
html[data-theme="dark"] .table-active, html[data-theme="dark"] .table-active > :is(td, th) { background: var(--imi-accent-soft); }
html[data-theme="dark"] :is(.error, .error::before, .error::after) { background: var(--imi-bg); color: var(--imi-text-strong); }
html[data-theme="dark"] .scroll-to-top { color: #fff; }
html[data-theme="dark"] .scroll-to-top:hover { background: var(--imi-primary-hover); }
html[data-theme="dark"] .support-ticket-guide { border-left-color: var(--imi-accent-border) !important; }
html[data-theme="dark"] .support-ticket-guide .card-header { background: var(--imi-primary-active) !important; border-color: var(--imi-accent-border); }
html[data-theme="dark"] .support-ticket-guide .badge-primary { background: var(--imi-primary-hover); }

/* Semantic feedback remains distinct from the primary action. */
html[data-theme="dark"] { --imi-danger: #fca5a5; --imi-warning: #fde68a; --imi-info: #67e8f9; --imi-success: #86efac; }
html[data-theme="dark"] .text-danger, html[data-theme="dark"] .invalid-feedback { color: var(--imi-danger) !important; }
html[data-theme="dark"] .text-warning { color: var(--imi-warning) !important; }
html[data-theme="dark"] .text-info { color: var(--imi-info) !important; }
html[data-theme="dark"] .text-success, html[data-theme="dark"] .valid-feedback { color: var(--imi-success) !important; }
html[data-theme="dark"] :is(.alert-danger, .list-group-item-danger, .table-danger, .table-danger > td, .table-danger > th) { background: #452326; border-color: #b45359; color: var(--imi-danger); }
html[data-theme="dark"] :is(.alert-warning, .list-group-item-warning, .table-warning, .table-warning > td, .table-warning > th) { background: #3e321b; border-color: #947128; color: var(--imi-warning); }
html[data-theme="dark"] :is(.alert-info, .list-group-item-info, .table-info, .table-info > td, .table-info > th) { background: #123842; border-color: #287b8d; color: var(--imi-info); }
html[data-theme="dark"] :is(.alert-success, .list-group-item-success, .table-success, .table-success > td, .table-success > th) { background: #173b2b; border-color: #37875c; color: var(--imi-success); }
html[data-theme="dark"] :is(.alert-secondary, .alert-light, .alert-dark, .list-group-item-light, .list-group-item-dark) { background: var(--imi-surface-muted); border-color: var(--imi-border); color: var(--imi-text); }
html[data-theme="dark"] .alert .alert-link { color: inherit; text-decoration: underline; }
html[data-theme="dark"] .alert .close { color: inherit; opacity: 1; }
html[data-theme="dark"] :is(.btn-danger, .badge-danger) { color: #fff; background-color: #b91c1c; border-color: #b91c1c; }
html[data-theme="dark"] .btn-danger:is(:hover, :focus, :active) { background-color: #991b1b; border-color: #f87171; }
html[data-theme="dark"] :is(.btn-success, .badge-success) { color: #fff; background-color: #166534; border-color: #37875c; }
html[data-theme="dark"] .btn-success:is(:hover, :focus, :active) { background-color: #14532d; border-color: #86efac; }
html[data-theme="dark"] :is(.btn-info, .badge-info) { color: #fff; background-color: #155e75; border-color: #287b8d; }
html[data-theme="dark"] .btn-info:is(:hover, :focus, :active) { background-color: #164e63; border-color: #67e8f9; }
html[data-theme="dark"] :is(.btn-warning, .badge-warning) { color: #271c05; background-color: #f6c23e; border-color: #f6c23e; }
html[data-theme="dark"] .btn-outline-danger { color: var(--imi-danger); border-color: #f87171; }
html[data-theme="dark"] .btn-outline-success { color: var(--imi-success); border-color: #86efac; }
html[data-theme="dark"] .btn-outline-info { color: var(--imi-info); border-color: #67e8f9; }
html[data-theme="dark"] .btn-outline-warning { color: var(--imi-warning); border-color: #fde68a; }
html[data-theme="dark"] :is(.btn-outline-danger, .btn-outline-success, .btn-outline-info, .btn-outline-warning):is(:hover, :focus, :active) { color: #001a12; }
html[data-theme="dark"] .form-control.is-invalid,
html[data-theme="dark"] .was-validated .form-control:invalid { border-color: #f87171 !important; }
html[data-theme="dark"] .form-control.is-valid,
html[data-theme="dark"] .was-validated .form-control:valid { border-color: #86efac !important; }
html[data-theme="dark"] .form-control.is-invalid:focus,
html[data-theme="dark"] .was-validated .form-control:invalid:focus { box-shadow: 0 0 0 .2rem rgba(248, 113, 113, .3); }
html[data-theme="dark"] .form-control.is-valid:focus,
html[data-theme="dark"] .was-validated .form-control:valid:focus { box-shadow: 0 0 0 .2rem rgba(134, 239, 172, .3); }

/* Explicit filled header labels must use the same accessible foreground. */
.bg-primary.text-white, .bg-primary .text-white,
.badge-primary.text-white, .btn-primary.text-white { color: var(--imi-on-primary) !important; }
.btn-primary.text-white:is(:hover, :focus, :active) { color: #fff !important; }
html[data-theme="dark"] .bg-primary.card-header,
html[data-theme="dark"] .bg-primary.modal-header { background-color: var(--imi-primary-active) !important; color: #fff !important; }
html[data-theme="dark"] .bg-primary:is(.card-header, .modal-header) .text-white { color: #fff !important; }
html[data-theme="dark"] .additional-negative { background-color: #452326 !important; border-color: #f87171 !important; }
html[data-theme="dark"] .additional-positive { background-color: #173b2b !important; border-color: #86efac !important; }

/* Readable semantic actions in light mode as well as dark mode. */
html:not([data-theme="dark"]) :is(.btn-success, .badge-success) { background-color: #166534; border-color: #166534; color: #fff; }
html:not([data-theme="dark"]) .btn-success:is(:hover, :focus, :active) { background-color: #14532d; border-color: #14532d; }
html:not([data-theme="dark"]) :is(.btn-info, .badge-info) { background-color: #155e75; border-color: #155e75; color: #fff; }
html:not([data-theme="dark"]) .btn-info:is(:hover, :focus, :active) { background-color: #164e63; border-color: #164e63; }
html:not([data-theme="dark"]) :is(.btn-danger, .badge-danger) { background-color: #b91c1c; border-color: #b91c1c; color: #fff; }
html:not([data-theme="dark"]) .btn-danger:is(:hover, :focus, :active) { background-color: #991b1b; border-color: #991b1b; }
html:not([data-theme="dark"]) :is(.btn-secondary, .badge-secondary) { background-color: #526158; border-color: #526158; color: #fff; }
html:not([data-theme="dark"]) .btn-secondary:is(:hover, :focus, :active) { background-color: #3d4e44; border-color: #3d4e44; }
.btn-warning, .badge-warning, .btn-warning:is(:hover, :focus, :active) { color: #271c05; }
.text-muted { color: var(--imi-text-muted) !important; }
.form-control::placeholder { color: var(--imi-text-muted); }
html[data-theme="dark"] .table-hover :is(.table-success, .table-info, .table-warning, .table-danger):hover,
html[data-theme="dark"] .table-hover :is(.table-success, .table-info, .table-warning, .table-danger):hover > :is(td, th) {
    background-color: var(--imi-surface-muted); color: var(--imi-text-strong);
}
html[data-theme="dark"] .table .btn-link.text-success,
html[data-theme="dark"] .table .btn-link.text-warning,
html[data-theme="dark"] .table .btn-link.text-info { background-color: var(--imi-surface-soft); }

.form-control, .custom-select, .custom-file-label,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple { border-color: var(--imi-input-border); }
html[data-theme="dark"] .select2-container--default .select2-selection { border-color: var(--imi-input-border); }
.form-control:focus, .custom-select:focus { border-color: var(--imi-accent-border); }

html[data-theme="dark"] .list-group-item.active,
html[data-theme="dark"] .bg-primary {
    background-color: var(--imi-primary) !important;
    border-color: var(--imi-primary);
    color: var(--imi-on-primary);
}
html[data-theme="dark"] .bg-success { background-color: #173b2b !important; color: var(--imi-success); }
html[data-theme="dark"] .bg-info { background-color: #123842 !important; color: var(--imi-info); }
html[data-theme="dark"] .bg-warning { background-color: #3e321b !important; color: var(--imi-warning); }
html[data-theme="dark"] .bg-danger { background-color: #452326 !important; color: var(--imi-danger); }
html[data-theme="dark"] .custom-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3E%3Cpath fill='%23b1bdb7' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .bs-popover-top > .arrow::after { border-top-color: var(--imi-surface); }
html[data-theme="dark"] .bs-popover-bottom > .arrow::after { border-bottom-color: var(--imi-surface); }
html[data-theme="dark"] .bs-popover-left > .arrow::after { border-left-color: var(--imi-surface); }
html[data-theme="dark"] .bs-popover-right > .arrow::after { border-right-color: var(--imi-surface); }

html:not([data-theme="dark"]) .text-success { color: #166534 !important; }
html:not([data-theme="dark"]) .text-info { color: #155e75 !important; }
html:not([data-theme="dark"]) .text-warning { color: #886109 !important; }
html:not([data-theme="dark"]) .text-danger { color: #b91c1c !important; }
html:not([data-theme="dark"]) .text-secondary { color: #526158 !important; }
