/**
 * Arab Sass — dark mode system overrides
 * Loaded LAST so token-based dark surfaces beat legacy hard-coded whites.
 * Consumes tokens from custom-colors.css ([data-theme-mode="dark"]).
 */

/* ── Base / typography ─────────────────────────────────────────── */
[data-theme-mode="dark"] {
    color-scheme: dark;
    --topnav-bg: var(--brand-dark, #07152F);
    --topnav-text: #ffffff;
}

[data-theme-mode="dark"] html,
[data-theme-mode="dark"] body {
    background-color: var(--app-background) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] h1,
[data-theme-mode="dark"] h2,
[data-theme-mode="dark"] h3,
[data-theme-mode="dark"] h4,
[data-theme-mode="dark"] h5,
[data-theme-mode="dark"] h6,
[data-theme-mode="dark"] .h1,
[data-theme-mode="dark"] .h2,
[data-theme-mode="dark"] .h3,
[data-theme-mode="dark"] .h4,
[data-theme-mode="dark"] .h5,
[data-theme-mode="dark"] .h6 {
    color: var(--text-primary);
}

[data-theme-mode="dark"] .text-muted,
[data-theme-mode="dark"] .form-text,
[data-theme-mode="dark"] small.text-muted,
[data-theme-mode="dark"] .small.text-muted {
    color: var(--text-muted) !important;
}

[data-theme-mode="dark"] .text-dark,
[data-theme-mode="dark"] .text-body,
[data-theme-mode="dark"] .text-black {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .text-secondary {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):not(.mega-nav-link):not(.mega-quick-link):not(.mega-quick-btn):not(.header-nav-link):not(.erp-sidebar-link):not(.search-result-item) {
    color: var(--text-link);
}

[data-theme-mode="dark"] a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):hover {
    color: var(--text-link-hover);
}

[data-theme-mode="dark"] .bg-white,
[data-theme-mode="dark"] .bg-light,
[data-theme-mode="dark"] .bg-body,
[data-theme-mode="dark"] .bg-body-tertiary,
[data-theme-mode="dark"] .card.bg-white,
[data-theme-mode="dark"] body.bg-light {
    background-color: var(--surface) !important;
    color: var(--text-primary);
}

[data-theme-mode="dark"] .border,
[data-theme-mode="dark"] .border-top,
[data-theme-mode="dark"] .border-bottom,
[data-theme-mode="dark"] .border-start,
[data-theme-mode="dark"] .border-end,
[data-theme-mode="dark"] .border-light {
    border-color: var(--border-subtle) !important;
}

/* ── Cards / panels ────────────────────────────────────────────── */
[data-theme-mode="dark"] .card,
[data-theme-mode="dark"] .card-body,
[data-theme-mode="dark"] .card-footer {
    background-color: var(--surface) !important;
    color: var(--text-primary);
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .card-header {
    background-color: var(--surface-muted) !important;
    color: var(--text-primary);
    border-bottom-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .card-title,
[data-theme-mode="dark"] .card-header h1,
[data-theme-mode="dark"] .card-header h2,
[data-theme-mode="dark"] .card-header h3,
[data-theme-mode="dark"] .card-header h4,
[data-theme-mode="dark"] .card-header h5,
[data-theme-mode="dark"] .card-header h6 {
    color: var(--text-primary) !important;
}

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

/* ── Header / top nav ──────────────────────────────────────────── */
[data-theme-mode="dark"] .top-header.elegant-header,
[data-theme-mode="dark"] .top-header.elegant-header.erp-app-chrome {
    background: var(--header-bg) !important;
    border-bottom-color: var(--border-subtle) !important;
    box-shadow: none !important;
}

[data-theme-mode="dark"] .header-nav-link {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .header-nav-link:hover,
[data-theme-mode="dark"] .header-nav-link.active,
[data-theme-mode="dark"] .header-nav-link.dropdown-toggle[aria-expanded="true"] {
    color: var(--brand-primary) !important;
    background: var(--hover-bg) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

[data-theme-mode="dark"] .erp-chrome-menu-btn,
[data-theme-mode="dark"] .erp-app-chrome .topnav-icon-btn,
[data-theme-mode="dark"] .erp-app-chrome .erp-lang-code {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-app-chrome .topnav-icon-btn:hover {
    background: var(--hover-bg) !important;
}

[data-theme-mode="dark"] .topnav-bar.erp-context-subbar {
    background: var(--brand-dark-deep) !important;
}

[data-theme-mode="dark"] .top-layout-page,
[data-theme-mode="dark"] .admin-main-content {
    background-color: var(--app-background) !important;
}

[data-theme-mode="dark"] .footer,
[data-theme-mode="dark"] footer.footer {
    background-color: var(--surface) !important;
    color: var(--text-muted) !important;
    border-top-color: var(--border-subtle) !important;
}

/* ── Dropdowns (all levels) ────────────────────────────────────── */
[data-theme-mode="dark"] .dropdown-menu,
[data-theme-mode="dark"] .header-nav-menu .dropdown-menu,
[data-theme-mode="dark"] .topnav-bar .dropdown-menu,
[data-theme-mode="dark"] .profile-dropdown,
[data-theme-mode="dark"] .dropdown-menu.actions-menu,
[data-theme-mode="dark"] .dropdown-menu.erp-mega-panel,
[data-theme-mode="dark"][data-page-style=modern] .dropdown-menu,
[data-page-style=modern][data-theme-mode="dark"] .dropdown-menu {
    background: var(--surface-elevated) !important;
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
    box-shadow: var(--shadow-elevated) !important;
}

[data-theme-mode="dark"] .dropdown-item,
[data-theme-mode="dark"] .dropdown-item span,
[data-theme-mode="dark"] .dropdown-header,
[data-theme-mode="dark"] .dropdown-header h6,
[data-theme-mode="dark"] .dropdown-header small {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .dropdown-item:hover,
[data-theme-mode="dark"] .dropdown-item:focus,
[data-theme-mode="dark"] .dropdown-item:focus-visible {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .dropdown-item.active,
[data-theme-mode="dark"] .dropdown-item:active {
    background-color: var(--active-bg) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .dropdown-item.disabled,
[data-theme-mode="dark"] .dropdown-item:disabled {
    color: var(--text-disabled) !important;
    background: transparent !important;
}

[data-theme-mode="dark"] .dropdown-divider {
    border-top-color: var(--divider) !important;
    opacity: 1;
}

[data-theme-mode="dark"] .profile-dropdown .dropdown-header {
    background: var(--surface-muted) !important;
}

[data-theme-mode="dark"] .profile-dropdown .dropdown-item,
[data-theme-mode="dark"] .profile-dropdown .dropdown-item i {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .profile-dropdown .dropdown-item:hover,
[data-theme-mode="dark"] .profile-dropdown .dropdown-item:hover i {
    color: var(--brand-primary) !important;
    background: var(--hover-bg) !important;
}

[data-theme-mode="dark"] .profile-dropdown .dropdown-item.text-danger,
[data-theme-mode="dark"] .profile-dropdown .dropdown-item.text-danger i,
[data-theme-mode="dark"] .dropdown-item.text-danger {
    color: #f87171 !important;
}

[data-theme-mode="dark"] .actions-menu-btn {
    background-color: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .dropdown-menu.actions-menu .dropdown-item i {
    color: var(--icon-color) !important;
}

/* ── Mega menus (HR + all modules) ─────────────────────────────── */
[data-theme-mode="dark"] .erp-mega-panel,
[data-theme-mode="dark"] .header-nav-menu .dropdown-menu.erp-mega-panel,
[data-theme-mode="dark"] .header-nav-menu .dropdown-menu.erp-mega-panel.erp-mega-panel--hr {
    background: var(--surface-elevated) !important;
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-card {
    background: var(--surface) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-card__title,
[data-theme-mode="dark"] .erp-mega-browse-card__title span,
[data-theme-mode="dark"] .erp-mega-section-title,
[data-theme-mode="dark"] .erp-mega-subsection-title,
[data-theme-mode="dark"] .erp-mega-muted,
[data-theme-mode="dark"] .erp-mega-muted.small,
[data-theme-mode="dark"] p.erp-mega-muted {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-card__title i,
[data-theme-mode="dark"] .erp-mega-panel--hr .erp-mega-browse-card__title i {
    color: var(--brand-primary) !important;
    opacity: 1 !important;
}

[data-theme-mode="dark"] .erp-mega-browse-card__divider {
    background: var(--divider) !important;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link,
[data-theme-mode="dark"] .erp-mega-panel--hr .mega-nav-link--dense,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-nav-link--dense,
[data-theme-mode="dark"] .erp-mega-panel .mega-signal-link,
[data-theme-mode="dark"] .erp-mega-panel .mega-recent-link {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link .erp-nav-item-icon,
[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link .erp-nav-item-text,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-nav-link--dense .erp-nav-item-icon,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-nav-link--dense .erp-nav-item-text {
    color: inherit !important;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link:hover,
[data-theme-mode="dark"] .erp-mega-panel--hr .mega-nav-link--dense:hover,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-nav-link--dense:hover {
    background: var(--hover-bg) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link.is-active,
[data-theme-mode="dark"] .erp-mega-panel--hr .mega-nav-link--dense.is-active,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-nav-link--dense.is-active {
    background: var(--active-bg) !important;
    color: var(--brand-primary) !important;
    font-weight: 600;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-quick-link,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-quick-btn {
    color: var(--brand-primary) !important;
    background: rgba(var(--primary-rgb), 0.1) !important;
}

[data-theme-mode="dark"] .erp-mega-panel .mega-quick-link:hover,
[data-theme-mode="dark"] .erp-mega-panel--hr a.mega-quick-btn:hover,
[data-theme-mode="dark"] .erp-mega-panel .mega-signal-link:hover,
[data-theme-mode="dark"] .erp-mega-panel .mega-recent-link:hover {
    background: var(--hover-bg) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .erp-mega-hr__rail {
    border-inline-start-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-search__input i {
    color: var(--text-muted) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-search__input .form-control {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-search__input .form-control::placeholder {
    color: var(--text-placeholder) !important;
}

[data-theme-mode="dark"] .erp-mega-browse-search__empty {
    color: var(--text-muted) !important;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
[data-theme-mode="dark"] .erp-sidebar,
[data-theme-mode="dark"] .app-sidebar {
    background: var(--sidebar-bg) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary);
}

[data-theme-mode="dark"] .erp-sidebar-group-toggle,
[data-theme-mode="dark"] .erp-sidebar-link {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .erp-sidebar-link:hover {
    background: var(--hover-bg) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .erp-sidebar-link.is-active {
    background: var(--active-bg) !important;
    color: var(--brand-primary) !important;
    border-inline-start-color: var(--brand-primary);
    box-shadow: none;
}

[data-theme-mode="dark"] .erp-mega-subsection-title {
    color: var(--text-muted) !important;
}

/* ── Forms ─────────────────────────────────────────────────────── */
[data-theme-mode="dark"] .form-label,
[data-theme-mode="dark"] label {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .form-control,
[data-theme-mode="dark"] .form-select,
[data-theme-mode="dark"] textarea.form-control,
[data-theme-mode="dark"] .form-control-sm,
[data-theme-mode="dark"] .form-select-sm {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--input-border) !important;
}

[data-theme-mode="dark"] .form-control::placeholder,
[data-theme-mode="dark"] .form-control::-webkit-input-placeholder {
    color: var(--text-placeholder) !important;
    opacity: 1;
}

[data-theme-mode="dark"] .form-control:focus,
[data-theme-mode="dark"] .form-control:focus-visible,
[data-theme-mode="dark"] .form-select:focus,
[data-theme-mode="dark"] .form-select:focus-visible,
[data-theme-mode="dark"] textarea.form-control:focus,
[data-theme-mode="dark"] textarea.form-control:focus-visible {
    border-color: var(--focus-ring-color) !important;
    box-shadow: 0 0 0 0.2rem var(--focus-ring) !important;
    outline: 2px solid var(--focus-ring-color) !important;
    outline-offset: 1px;
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .form-control:disabled,
[data-theme-mode="dark"] .form-select:disabled,
[data-theme-mode="dark"] .form-control[readonly] {
    background-color: var(--disabled-bg) !important;
    color: var(--text-disabled) !important;
    opacity: 1;
}

[data-theme-mode="dark"] .form-check-input {
    background-color: var(--input-bg);
    border-color: var(--input-border) !important;
}

[data-theme-mode="dark"] .form-check-label {
    color: var(--text-primary);
}

[data-theme-mode="dark"] .input-group-text {
    background-color: var(--surface-muted) !important;
    color: var(--text-secondary) !important;
    border-color: var(--input-border) !important;
}

[data-theme-mode="dark"] .invalid-feedback,
[data-theme-mode="dark"] .text-danger {
    color: #f87171 !important;
}

[data-theme-mode="dark"] .valid-feedback,
[data-theme-mode="dark"] .text-success {
    color: #34d399 !important;
}

/* Choices / searchable selects */
[data-theme-mode="dark"] .erp-choices .choices__inner {
    background-color: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-choices .choices__list--single .choices__item {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-choices .choices__placeholder {
    color: var(--text-placeholder) !important;
    opacity: 1;
}

[data-theme-mode="dark"] .erp-choices .choices__list--dropdown,
[data-theme-mode="dark"] .erp-choices .choices__list[aria-expanded] {
    background-color: var(--surface-elevated) !important;
    border-color: var(--brand-primary) !important;
    box-shadow: var(--shadow-elevated) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-choices[data-type*="select-one"] .choices__input,
[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__input {
    background-color: var(--surface-muted) !important;
    color: var(--text-primary) !important;
    border-block-end-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .erp-choices[data-type*="select-one"] .choices__input:focus,
[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__input:focus {
    background-color: var(--input-bg) !important;
}

[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__item,
[data-theme-mode="dark"] .erp-choices .choices__list[aria-expanded] .choices__item {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__item--selectable.is-highlighted,
[data-theme-mode="dark"] .erp-choices .choices__list[aria-expanded] .choices__item--selectable.is-highlighted,
[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__item--selectable.is-selected,
[data-theme-mode="dark"] .erp-choices .choices__list[aria-expanded] .choices__item--selectable.is-selected {
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .erp-choices .choices__list--dropdown .choices__item--selectable.is-highlighted,
[data-theme-mode="dark"] .erp-choices .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
    background-color: var(--hover-bg) !important;
}

/* ── Tables ────────────────────────────────────────────────────── */
[data-theme-mode="dark"] .table {
    --bs-table-bg: var(--surface);
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-subtle);
    --bs-table-striped-bg: var(--surface-muted);
    --bs-table-hover-bg: var(--hover-bg);
    --bs-table-hover-color: var(--text-primary);
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text-primary);
    border-bottom-color: var(--border-subtle);
}

[data-theme-mode="dark"] .table thead th,
[data-theme-mode="dark"] .table thead td,
[data-theme-mode="dark"] .table > thead {
    background-color: var(--surface-muted) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .table-hover > tbody > tr:hover > * {
    background-color: var(--hover-bg) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-sort-link,
[data-theme-mode="dark"] .erp-sort-link__icon {
    color: inherit;
}

[data-theme-mode="dark"] .table-responsive {
    scrollbar-color: var(--brand-primary) var(--surface-muted);
}

/* ── Pagination ────────────────────────────────────────────────── */
[data-theme-mode="dark"] .page-link,
[data-theme-mode="dark"] .pagination-primary .page-link {
    background-color: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-link) !important;
}

[data-theme-mode="dark"] .page-link:hover,
[data-theme-mode="dark"] .pagination-primary .page-link:hover {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: var(--text-on-primary) !important;
}

[data-theme-mode="dark"] .page-item.active .page-link,
[data-theme-mode="dark"] .pagination-primary .page-item.active .page-link {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: var(--text-on-primary) !important;
}

[data-theme-mode="dark"] .page-item.disabled .page-link {
    background-color: var(--disabled-bg) !important;
    color: var(--text-disabled) !important;
    border-color: var(--border-subtle) !important;
}

/* ── Modals / offcanvas ────────────────────────────────────────── */
[data-theme-mode="dark"] .modal-content,
[data-theme-mode="dark"] .offcanvas,
[data-theme-mode="dark"] .offcanvas-body,
[data-theme-mode="dark"] .modal-body,
[data-theme-mode="dark"] .modal-footer {
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .modal-header {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border-bottom-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .modal-title {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.75;
}

[data-theme-mode="dark"] .modal-backdrop {
    background-color: #000;
}

[data-theme-mode="dark"] .erp-actions-modal .action-card {
    background: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .erp-actions-modal .action-card:hover {
    background: var(--hover-bg) !important;
}

/* ── Alerts / toasts / badges ──────────────────────────────────── */
[data-theme-mode="dark"] .alert {
    color: var(--text-primary);
}

[data-theme-mode="dark"] .alert-primary {
    background-color: var(--success-bg) !important;
    border-color: rgba(var(--primary-rgb), 0.35) !important;
    color: var(--brand-teal-light) !important;
}

[data-theme-mode="dark"] .alert-danger,
[data-theme-mode="dark"] .alert-warning,
[data-theme-mode="dark"] .alert-success,
[data-theme-mode="dark"] .alert-info {
    border-width: 1px;
}

[data-theme-mode="dark"] .toast,
[data-theme-mode="dark"] .toast-header,
[data-theme-mode="dark"] .toast-body {
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .badge.bg-light,
[data-theme-mode="dark"] .badge.text-dark {
    background-color: var(--surface-muted) !important;
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .badge.bg-secondary {
    background-color: #6c757d !important;
    color: #fff !important;
}

/* Status tint helpers */
[data-theme-mode="dark"] .badge.bg-success,
[data-theme-mode="dark"] .badge.text-bg-success {
    background-color: var(--success-bg) !important;
    color: #6ee7b7 !important;
}

[data-theme-mode="dark"] .badge.bg-danger,
[data-theme-mode="dark"] .badge.text-bg-danger {
    background-color: var(--danger-bg) !important;
    color: #fca5a5 !important;
}

[data-theme-mode="dark"] .badge.bg-warning,
[data-theme-mode="dark"] .badge.text-bg-warning {
    background-color: var(--warning-bg) !important;
    color: #fde68a !important;
}

[data-theme-mode="dark"] .badge.bg-info,
[data-theme-mode="dark"] .badge.text-bg-info {
    background-color: var(--info-bg) !important;
    color: #93c5fd !important;
}

/* ── Global search overlay ─────────────────────────────────────── */
[data-theme-mode="dark"] .search-overlay-container,
[data-theme-mode="dark"] .search-overlay-header-integrated,
[data-theme-mode="dark"] .search-overlay-results-container,
[data-theme-mode="dark"] .search-overlay-results-container .search-results-dropdown {
    background: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .search-overlay-search-wrapper,
[data-theme-mode="dark"] .search-overlay-search-wrapper:focus-within {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
}

[data-theme-mode="dark"] .search-overlay-input {
    color: var(--text-primary) !important;
    background: transparent !important;
}

[data-theme-mode="dark"] .search-overlay-input::placeholder {
    color: var(--text-placeholder) !important;
}

[data-theme-mode="dark"] .search-overlay-icon,
[data-theme-mode="dark"] .search-overlay-close-btn {
    color: var(--icon-color) !important;
}

[data-theme-mode="dark"] .search-category-header {
    color: var(--text-muted) !important;
}

[data-theme-mode="dark"] .search-result-item {
    color: var(--text-primary) !important;
}

[data-theme-mode="dark"] .search-result-item:hover,
[data-theme-mode="dark"] .search-result-item:focus {
    background: var(--hover-bg) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .search-overlay-status {
    color: var(--text-muted) !important;
}

/* ── Nav pills / tabs / list groups / breadcrumbs ──────────────── */
[data-theme-mode="dark"] .nav-tabs {
    border-bottom-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .nav-tabs .nav-link {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .nav-tabs .nav-link:hover {
    border-color: var(--border-subtle) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .nav-tabs .nav-link.active {
    background-color: var(--surface) !important;
    border-color: var(--border-subtle) var(--border-subtle) var(--surface) !important;
    color: var(--brand-primary) !important;
}

[data-theme-mode="dark"] .nav-pills .nav-link {
    color: var(--text-secondary) !important;
}

[data-theme-mode="dark"] .list-group-item {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .breadcrumb-item,
[data-theme-mode="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted) !important;
}

[data-theme-mode="dark"] .breadcrumb-item a {
    color: var(--text-link) !important;
}

[data-theme-mode="dark"] .breadcrumb-item.active {
    color: var(--text-primary) !important;
}

/* ── Empty states / filter sidebars / misc chrome ──────────────── */
[data-theme-mode="dark"] .filter-sidebar,
[data-theme-mode="dark"] .page-with-filters .filter-sidebar {
    background: var(--surface) !important;
    border-color: var(--border-subtle) !important;
    color: var(--text-primary);
}

[data-theme-mode="dark"] .filter-sidebar-title,
[data-theme-mode="dark"] .filter-sidebar-header {
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .popover,
[data-theme-mode="dark"] .popover-body,
[data-theme-mode="dark"] .popover-header {
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .tooltip-inner {
    background-color: var(--surface-elevated) !important;
    color: var(--text-primary) !important;
}

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

[data-theme-mode="dark"] .accordion-item,
[data-theme-mode="dark"] .accordion-button,
[data-theme-mode="dark"] .accordion-body {
    background-color: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
}

[data-theme-mode="dark"] .accordion-button:not(.collapsed) {
    background-color: var(--active-bg) !important;
    color: var(--brand-primary) !important;
    box-shadow: none;
}

[data-theme-mode="dark"] .accordion-button::after {
    filter: invert(1) brightness(1.4);
}

/* Icons inherit parent color by default */
[data-theme-mode="dark"] .fe,
[data-theme-mode="dark"] [class^="fe-"],
[data-theme-mode="dark"] [class*=" fe-"] {
    color: inherit;
}

[data-theme-mode="dark"] .erp-nav-item-icon {
    color: inherit !important;
}

/* Disabled controls remain understandable */
[data-theme-mode="dark"] .btn:disabled,
[data-theme-mode="dark"] .btn.disabled {
    opacity: 0.55;
}

/* Chart / empty placeholders often use muted text */
[data-theme-mode="dark"] .empty-state,
[data-theme-mode="dark"] .erp-empty-state,
[data-theme-mode="dark"] .no-data,
[data-theme-mode="dark"] .text-center.text-muted {
    color: var(--text-muted) !important;
}

/* Legacy hard-coded slate text in mega panels */
[data-theme-mode="dark"] .erp-mega-panel .mega-nav-link,
[data-theme-mode="dark"] .erp-mega-panel .mega-signal-link {
    color: var(--text-primary) !important;
}

/* Mobile sidebar backdrop stays dimmed */
[data-theme-mode="dark"] .erp-sidebar-backdrop {
    background: rgba(0, 0, 0, 0.55);
}

/* Pagination / table sort icons */
[data-theme-mode="dark"] .erp-sort-link__icon.is-active {
    color: var(--brand-primary) !important;
}

/* Ensure white buttons on dark context bar keep contrast */
[data-theme-mode="dark"] .topnav-context-toolbar .btn-primary {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: var(--text-on-primary) !important;
}

[data-theme-mode="dark"] .topnav-context-toolbar .btn-outline-light,
[data-theme-mode="dark"] .topnav-context-toolbar .btn-light {
    color: var(--text-primary) !important;
    border-color: var(--border-subtle) !important;
    background: transparent !important;
}
