/*
 * Dark mode.
 *
 * Turned on by <html data-bs-theme="dark" class="dark"> (see the theme
 * script in index.html). Bootstrap 5.3 and DataTables 2 switch most of their
 * own colours from those two hooks; this file covers what Kaiadmin and the
 * app's custom stylesheets hard-code as light colours.
 */

html[data-bs-theme="dark"] {
  --tupad-dark-bg: #0f1623;
  --tupad-dark-surface: #182131;
  --tupad-dark-surface-2: #1f2a3d;
  --tupad-dark-surface-3: #26334a;
  --tupad-dark-border: #2e3b52;
  --tupad-dark-text: #e2e8f0;
  --tupad-dark-text-strong: #f8fafc;
  --tupad-dark-muted: #94a3b8;
  --tupad-dark-link: #7cb4ff;

  --bs-body-bg: var(--tupad-dark-bg);
  --bs-body-color: var(--tupad-dark-text);
  --bs-secondary-bg: var(--tupad-dark-surface-2);
  --bs-tertiary-bg: var(--tupad-dark-surface-2);
  --bs-border-color: var(--tupad-dark-border);
  --bs-emphasis-color: var(--tupad-dark-text-strong);
  --bs-secondary-color: var(--tupad-dark-muted);
  --bs-link-color: var(--tupad-dark-link);
  --bs-link-color-rgb: 124, 180, 255;
  --bs-heading-color: var(--tupad-dark-text-strong);

  --dt-html-background: var(--tupad-dark-surface);
  color-scheme: dark;
}

/* ------------------------------------------------------------- page shell */
html[data-bs-theme="dark"] body,
html[data-bs-theme="dark"] .wrapper,
html[data-bs-theme="dark"] .main-panel,
html[data-bs-theme="dark"] #main_content {
  background: var(--tupad-dark-bg) !important;
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .main-header,
html[data-bs-theme="dark"] .main-header .navbar-header,
html[data-bs-theme="dark"] .footer {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .main-header {
  box-shadow: 0 1px 0 var(--tupad-dark-border);
}

/* Sidebar: a soft blue that sits on the dark background, instead of the navy
   and the Kaiadmin blue logo bar (that one is !important in kaiadmin.min.css).
   Hover and active use a faint tint of the link blue. */
html[data-bs-theme="dark"] {
  --tupad-dark-sidebar: #253f66;
  --tupad-dark-sidebar-head: #213a5e;
  --tupad-dark-sidebar-line: rgba(124, 180, 255, 0.18);
  --tupad-dark-sidebar-tint: rgba(124, 180, 255, 0.14);
  --tupad-dark-sidebar-tint-strong: rgba(124, 180, 255, 0.24);
}

html[data-bs-theme="dark"] .sidebar[data-background-color="dark"] {
  background: var(--tupad-dark-sidebar) !important;
  border-right: 1px solid var(--tupad-dark-sidebar-line);
  box-shadow: none;
}

html[data-bs-theme="dark"] .logo-header[data-background-color="blue"] {
  background: var(--tupad-dark-sidebar-head) !important;
  border-bottom: 1px solid var(--tupad-dark-sidebar-line);
}

html[data-bs-theme="dark"] .sidebar .nav > .nav-item > a:hover,
html[data-bs-theme="dark"] .sidebar .nav > .nav-item > a:focus,
html[data-bs-theme="dark"] .sidebar .nav > .nav-item > a[data-toggle="collapse"][aria-expanded="true"],
html[data-bs-theme="dark"] .sidebar .nav-collapse li a:hover,
html[data-bs-theme="dark"] .sidebar .nav-collapse li a:focus {
  background: var(--tupad-dark-sidebar-tint) !important;
}

html[data-bs-theme="dark"] .sidebar .nav > .nav-item.active > a,
html[data-bs-theme="dark"] .sidebar .nav-collapse li.active > a {
  background: var(--tupad-dark-sidebar-tint-strong) !important;
}

html[data-bs-theme="dark"] .sidebar .nav.nav-secondary > .nav-item.active > a::before,
html[data-bs-theme="dark"] .sidebar .nav.nav-secondary > .nav-item > a[data-toggle="collapse"][aria-expanded="true"]::before {
  background: var(--tupad-dark-link) !important;
}

html[data-bs-theme="dark"] .navbar-header .navbar-nav .nav-link,
html[data-bs-theme="dark"] .topbar-nav .nav-link,
html[data-bs-theme="dark"] .profile-username,
html[data-bs-theme="dark"] .footer .copyright {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .page-title,
html[data-bs-theme="dark"] .page-inner h1,
html[data-bs-theme="dark"] .page-inner h2,
html[data-bs-theme="dark"] .page-inner h3,
html[data-bs-theme="dark"] .page-inner h4,
html[data-bs-theme="dark"] .page-inner h5,
html[data-bs-theme="dark"] .page-inner h6,
html[data-bs-theme="dark"] .modal h5,
html[data-bs-theme="dark"] .offcanvas h5,
html[data-bs-theme="dark"] .card-title {
  color: var(--tupad-dark-text-strong);
}

/* ---------------------------------------------------- cards and surfaces */
html[data-bs-theme="dark"] .card,
html[data-bs-theme="dark"] .card-light,
html[data-bs-theme="dark"] .modal-content,
html[data-bs-theme="dark"] .offcanvas,
html[data-bs-theme="dark"] .dropdown-menu,
html[data-bs-theme="dark"] .list-group-item,
html[data-bs-theme="dark"] .accordion-item,
html[data-bs-theme="dark"] .accordion-button,
html[data-bs-theme="dark"] .popover,
html[data-bs-theme="dark"] .toast {
  background-color: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text);
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .card-header,
html[data-bs-theme="dark"] .card-footer,
html[data-bs-theme="dark"] .modal-header,
html[data-bs-theme="dark"] .modal-footer,
html[data-bs-theme="dark"] .offcanvas-header {
  background-color: transparent;
  border-color: var(--tupad-dark-border) !important;
}

/* Light utility backgrounds used all over the pages and in rendered HTML. */
html[data-bs-theme="dark"] .bg-white,
html[data-bs-theme="dark"] .bg-body,
html[data-bs-theme="dark"] .bg-body-secondary {
  background-color: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] .bg-light,
html[data-bs-theme="dark"] .bg-body-tertiary,
html[data-bs-theme="dark"] .bg-light-subtle {
  background-color: var(--tupad-dark-surface-3) !important;
}

/* Inline light backgrounds set from JS templates (e.g. drawer city rows). */
html[data-bs-theme="dark"] [style*="background:#fff"],
html[data-bs-theme="dark"] [style*="background: #fff"],
html[data-bs-theme="dark"] [style*="background-color:#fff"],
html[data-bs-theme="dark"] [style*="background-color: #fff"],
html[data-bs-theme="dark"] [style*="background:white"],
html[data-bs-theme="dark"] [style*="background: white"],
html[data-bs-theme="dark"] [style*="background-color: white"],
html[data-bs-theme="dark"] [style*="background:#f8f9fa"],
html[data-bs-theme="dark"] [style*="background: #f8f9fa"],
html[data-bs-theme="dark"] [style*="background:#f8fafc"],
html[data-bs-theme="dark"] [style*="background: #f8fafc"] {
  background: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] [style*="background:#e9f0fb"],
html[data-bs-theme="dark"] [style*="background: #e9f0fb"],
html[data-bs-theme="dark"] .drawer-group-header {
  background: #1d3354 !important;
}

html[data-bs-theme="dark"] .drawer-group-header td,
html[data-bs-theme="dark"] .drawer-group-header .text-dark {
  color: #cfe0ff !important;
}

/* ------------------------------------------------------------------ text */
html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .text-secondary,
html[data-bs-theme="dark"] .text-body-secondary,
html[data-bs-theme="dark"] small.text-muted {
  color: var(--tupad-dark-muted) !important;
}

/* Dark text on light badges (bg-warning text-dark, bg-light text-dark)
   stays dark; elsewhere it becomes light. */
html[data-bs-theme="dark"] .text-dark:not(.badge):not(.bg-warning):not(.bg-light):not(.btn-warning),
html[data-bs-theme="dark"] .text-black:not(.badge):not(.bg-warning) {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .badge.bg-light {
  background-color: var(--tupad-dark-surface-3) !important;
  color: var(--tupad-dark-text) !important;
}

/* Kaiadmin colours labels #495057 with a more specific rule. Muted labels
   (.text-muted) keep their own colour from the rule above. */
html[data-bs-theme="dark"] label:not(.text-muted):not(.btn),
html[data-bs-theme="dark"] .form-label:not(.text-muted),
html[data-bs-theme="dark"] .form-check-label,
html[data-bs-theme="dark"] div.dt-container .dt-length label {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-form-label {
  color: var(--tupad-dark-muted) !important;
}

/* ----------------------------------------------------------------- forms */
html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text,
html[data-bs-theme="dark"] textarea,
html[data-bs-theme="dark"] select {
  background-color: var(--tupad-dark-surface-2) !important;
  color: var(--tupad-dark-text) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus {
  border-color: #3e93ff !important;
}

html[data-bs-theme="dark"] .form-control::placeholder {
  color: #64748b;
}

html[data-bs-theme="dark"] .form-control:disabled,
html[data-bs-theme="dark"] .form-control[readonly],
html[data-bs-theme="dark"] .form-select:disabled {
  background-color: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .form-check-input:not(:checked) {
  background-color: var(--tupad-dark-surface-2);
  border-color: #475569;
}

/* ------------------------------------------------------------ tables */
html[data-bs-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--tupad-dark-text);
  --bs-table-border-color: var(--tupad-dark-border);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-striped-color: var(--tupad-dark-text);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
  --bs-table-hover-color: var(--tupad-dark-text-strong);
  color: var(--tupad-dark-text);
}

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

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

html[data-bs-theme="dark"] table.dataTable > tbody > tr.selected > * {
  box-shadow: inset 0 0 0 9999px rgba(62, 147, 255, 0.28) !important;
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] div.dt-container .dt-paging .dt-paging-button,
html[data-bs-theme="dark"] div.dt-container .dt-info,
html[data-bs-theme="dark"] div.dt-container .dt-length,
html[data-bs-theme="dark"] div.dt-container .dt-search {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] div.dt-container .dt-paging .dt-paging-button.current,
html[data-bs-theme="dark"] div.dt-container .dt-paging .dt-paging-button.current:hover {
  background: var(--tupad-dark-surface-3) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] div.dt-container .dt-input,
html[data-bs-theme="dark"] div.dt-container .dt-search input {
  border-color: var(--tupad-dark-border) !important;
  background-color: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] div.dt-processing {
  background: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text);
  border-color: var(--tupad-dark-border);
}

/* ------------------------------------------------------------ tabs, nav */
html[data-bs-theme="dark"] .nav-tabs {
  border-color: var(--tupad-dark-border);
}

html[data-bs-theme="dark"] .nav-tabs .nav-link {
  color: var(--tupad-dark-muted);
}

html[data-bs-theme="dark"] .nav-tabs .nav-link.active,
html[data-bs-theme="dark"] .nav-tabs .nav-link:hover {
  color: var(--tupad-dark-link);
  background-color: transparent;
}

html[data-bs-theme="dark"] .nav-tabs:not(.nav-line) .nav-link.active {
  background-color: var(--tupad-dark-surface);
  border-color: var(--tupad-dark-border) var(--tupad-dark-border) var(--tupad-dark-surface);
}

html[data-bs-theme="dark"] .dropdown-item {
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .dropdown-item:hover,
html[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: var(--tupad-dark-surface-3);
  color: var(--tupad-dark-text-strong);
}

/* -------------------------------------------------------------- buttons */
html[data-bs-theme="dark"] .btn-light {
  background-color: var(--tupad-dark-surface-3) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .btn-light:hover {
  background-color: #2f3d57 !important;
}

html[data-bs-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-dark {
  color: var(--tupad-dark-text) !important;
  border-color: #475569 !important;
}

html[data-bs-theme="dark"] .btn-outline-secondary:hover,
html[data-bs-theme="dark"] .btn-outline-dark:hover {
  background-color: var(--tupad-dark-surface-3) !important;
}

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

/* ------------------------------------------------------------- Select2 */
html[data-bs-theme="dark"] .select2-container--default .select2-selection--single,
html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple,
html[data-bs-theme="dark"] .select2-dropdown,
html[data-bs-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-bs-theme="dark"] .select2-results__option {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background-color: #2563eb !important;
  color: #fff !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-bs-theme="dark"] .select2-container--default .select2-results__option--selected {
  background-color: var(--tupad-dark-surface-3) !important;
}

html[data-bs-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: var(--tupad-dark-surface-3) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

/* ---------------------------------------------------------- SweetAlert2 */
html[data-bs-theme="dark"] .swal2-popup {
  background: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .swal2-title,
html[data-bs-theme="dark"] .swal2-html-container,
html[data-bs-theme="dark"] .swal2-input-label {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .swal2-input,
html[data-bs-theme="dark"] .swal2-textarea,
html[data-bs-theme="dark"] .swal2-select {
  background: var(--tupad-dark-surface-2) !important;
  color: var(--tupad-dark-text) !important;
  border-color: var(--tupad-dark-border) !important;
}

/* Toasts (helpers/toast.js) are coloured by type with a white icon and
   text, so they keep their colour instead of the dark pop-up surface. */
html[data-bs-theme="dark"] .colored-toast.swal2-popup {
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
}

html[data-bs-theme="dark"] .colored-toast.swal2-icon-success {
  background: #15803d !important;
}

html[data-bs-theme="dark"] .colored-toast.swal2-icon-error {
  background: #b91c1c !important;
}

html[data-bs-theme="dark"] .colored-toast.swal2-icon-warning {
  background: #b45309 !important;
}

html[data-bs-theme="dark"] .colored-toast.swal2-icon-info {
  background: #0e7490 !important;
}

html[data-bs-theme="dark"] .colored-toast.swal2-icon-question {
  background: #475569 !important;
}

html[data-bs-theme="dark"] .colored-toast .swal2-title,
html[data-bs-theme="dark"] .colored-toast .swal2-html-container,
html[data-bs-theme="dark"] .colored-toast .swal2-close {
  color: #ffffff !important;
}

/* SweetAlert colours its icon marks (the error X, success tick) with an
   inline white background; keep them out of the inline-white rule above. */
html[data-bs-theme="dark"] .swal2-icon [style*="background-color: white"],
html[data-bs-theme="dark"] .swal2-icon [style*="background-color:white"] {
  background-color: #ffffff !important;
}

html[data-bs-theme="dark"] .colored-toast .swal2-timer-progress-bar {
  background: rgba(255, 255, 255, 0.55);
}

html[data-bs-theme="dark"] .swal2-validation-message {
  background: var(--tupad-dark-surface-2) !important;
  color: var(--tupad-dark-text) !important;
}

/* ----------------------------------------------- app-specific components */
html[data-bs-theme="dark"] .notification-panel {
  background: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text);
  border-color: var(--tupad-dark-border) !important;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.52) !important;
}

html[data-bs-theme="dark"] .notification-panel-header,
html[data-bs-theme="dark"] .notification-filters,
html[data-bs-theme="dark"] .notification-push-footer {
  background: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text);
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .notification-list {
  background: var(--tupad-dark-bg) !important;
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .notification-panel-title,
html[data-bs-theme="dark"] .notification-item-title,
html[data-bs-theme="dark"] .notification-push-title {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] .notification-panel-subtitle,
html[data-bs-theme="dark"] .notification-item-time,
html[data-bs-theme="dark"] .notification-item-body,
html[data-bs-theme="dark"] .notification-push-status,
html[data-bs-theme="dark"] .notification-empty-state {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .notification-item-ref {
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] .notification-filter {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .notification-filter:hover {
  background: var(--tupad-dark-surface-3) !important;
  border-color: #3b82f6 !important;
  color: #bfdbfe !important;
}

html[data-bs-theme="dark"] .notification-filter.active {
  background: #2563eb !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

html[data-bs-theme="dark"] .notification-item {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
  box-shadow: none !important;
}

html[data-bs-theme="dark"] .notification-mark-read-btn,
html[data-bs-theme="dark"] .notification-push-manage {
  background: rgba(59, 130, 246, 0.16) !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
  color: #bfdbfe !important;
}

html[data-bs-theme="dark"] .notification-mark-read-btn:hover,
html[data-bs-theme="dark"] .notification-push-manage:hover {
  background: #2563eb !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
}

html[data-bs-theme="dark"] .notification-mark-read-btn:disabled,
html[data-bs-theme="dark"] .notification-mark-read-btn:disabled:hover {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .tracker-section-card,
html[data-bs-theme="dark"] .tracking-state-card,
html[data-bs-theme="dark"] .tracker-stepper-shell {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .tracker-section-subtext,
html[data-bs-theme="dark"] .tracking-state-card .text-muted {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .tracking-state-title {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] .loader-wrapper {
  background: var(--tupad-dark-bg) !important;
}

html[data-bs-theme="dark"] hr {
  border-color: var(--tupad-dark-border);
  opacity: 1;
}

html[data-bs-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--tupad-dark-bg);
}

html[data-bs-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #334155;
}

/* Kaiadmin alerts: white box with a coloured left border. */
html[data-bs-theme="dark"] .alert {
  background-color: var(--tupad-dark-surface-2) !important;
  color: var(--tupad-dark-text) !important;
  border-top-color: var(--tupad-dark-border) !important;
  border-right-color: var(--tupad-dark-border) !important;
  border-bottom-color: var(--tupad-dark-border) !important;
}

/* Round icon buttons in the top bar (theme switch, notifications). */
html[data-bs-theme="dark"] .topbar-icon .nav-link,
html[data-bs-theme="dark"] .topbar-user .profile-pic {
  background-color: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

/* ------------------------------------------- Document Tracking modal
   (tracking_po_tc / tracking_ro, styles in tracking-style.css) */
html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-shell,
html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-body {
  background: var(--tupad-dark-bg) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-header {
  background: linear-gradient(135deg, var(--tupad-dark-surface) 0%, #16223a 100%) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-header-bg {
  opacity: 0.25;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-kicker {
  color: var(--tupad-dark-link) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-title,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-value,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-card-title,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-state-title {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-subtitle,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-label,
html[data-bs-theme="dark"] #document_tracking_modal .tracker-section-subtext,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-updated-by,
html[data-bs-theme="dark"] #document_tracking_modal .tracker-history-legend {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Info cards (Work Program Number / Current Office / Last Updated) and the
   box around them. */
html[data-bs-theme="dark"] #document_tracking_modal .tracker-hero-panel,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-state-card,
html[data-bs-theme="dark"] #document_tracking_modal .tracker-section-card,
html[data-bs-theme="dark"] #document_tracking_modal .card {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-card {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  box-shadow: none !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-hero-panel,
html[data-bs-theme="dark"] #document_tracking_modal .tracker-section-card {
  box-shadow: none !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-card-office .tracking-info-icon {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #4ade80 !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-card-adl .tracking-info-icon {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #7cb4ff !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-info-card-updated .tracking-info-icon {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #fbbf24 !important;
}

/* Section chips ("Progress Overview", "Tracking History"). */
html[data-bs-theme="dark"] #document_tracking_modal .tracker-section-chip {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-section-chip-history {
  background: rgba(148, 163, 184, 0.16) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-mini-badge {
  background: rgba(59, 130, 246, 0.16) !important;
  color: #93c5fd !important;
  border-color: rgba(59, 130, 246, 0.35) !important;
}

/* Progress stepper. */
html[data-bs-theme="dark"] #document_tracking_modal .tracker-stepper-shell {
  background: transparent !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-step-modern.pending .tracker-step-circle-modern {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-step-index {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-step-label-modern {
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-step-line:not(.done):not(.active) {
  background: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-step-line.active {
  background: rgba(59, 130, 246, 0.22);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.45);
}

/* History timeline cards. */
html[data-bs-theme="dark"] #document_tracking_modal .tracking-card-modern {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-item-modern.current .tracking-card-modern {
  border-color: #3b82f6 !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-item-modern.completed .tracking-card-modern {
  border-color: rgba(34, 197, 94, 0.45) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-meta-pill,
html[data-bs-theme="dark"] #document_tracking_modal .tracking-card-desc {
  background: var(--tupad-dark-surface-3) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-card-footer {
  border-top-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-item-line {
  background: #1e3a5f !important;
}

/* The dot's ring is drawn in the card's background colour. */
html[data-bs-theme="dark"] #document_tracking_modal .tracking-item-dot {
  box-shadow: 0 0 0 6px var(--tupad-dark-surface) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-item-modern.current .tracking-item-dot {
  box-shadow:
    0 0 0 6px var(--tupad-dark-surface),
    0 0 0 12px rgba(59, 130, 246, 0.25) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracking-empty-icon {
  background: var(--tupad-dark-surface-2) !important;
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] #document_tracking_modal .tracker-modal-footer {
  background: var(--tupad-dark-surface) !important;
  border-top-color: var(--tupad-dark-border) !important;
}

/* Status badges: deeper tints so the text stays readable on dark. */
html[data-bs-theme="dark"] .tracking-badge-completed,
html[data-bs-theme="dark"] .tracker-status-approved,
html[data-bs-theme="dark"] .tracker-live-status-approved {
  background: rgba(34, 197, 94, 0.18) !important;
  color: #4ade80 !important;
}

html[data-bs-theme="dark"] .tracking-badge-current,
html[data-bs-theme="dark"] .tracker-status-received,
html[data-bs-theme="dark"] .tracker-live-status-received {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] .tracking-badge-pending,
html[data-bs-theme="dark"] .tracker-status-created,
html[data-bs-theme="dark"] .tracker-status-neutral,
html[data-bs-theme="dark"] .tracker-live-status-created,
html[data-bs-theme="dark"] .tracker-live-status-neutral {
  background: rgba(148, 163, 184, 0.16) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .tracker-status-review,
html[data-bs-theme="dark"] .tracker-live-status-review {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fbbf24 !important;
}

html[data-bs-theme="dark"] .tracker-status-returned,
html[data-bs-theme="dark"] .tracker-live-status-returned {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #f87171 !important;
}

html[data-bs-theme="dark"] .tracker-status-submitted,
html[data-bs-theme="dark"] .tracker-live-status-submitted {
  background: rgba(6, 182, 212, 0.18) !important;
  color: #67e8f9 !important;
}

html[data-bs-theme="dark"] .tracker-live-status-forwarded {
  background: rgba(139, 92, 246, 0.2) !important;
  color: #c4b5fd !important;
}

/* ------------------------------------------------------------- drawers
   Every "View Details" drawer is an .offcanvas; custom.css paints its body
   #f8f9fa and some sections white. */
html[data-bs-theme="dark"] .offcanvas-body,
html[data-bs-theme="dark"] .offcanvas-header,
html[data-bs-theme="dark"] .offcanvas-body > div,
html[data-bs-theme="dark"] #wp_details_section,
html[data-bs-theme="dark"] #wp_beneficiaries_section {
  background: var(--tupad-dark-surface) !important;
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .offcanvas .border-end,
html[data-bs-theme="dark"] .offcanvas .border-bottom,
html[data-bs-theme="dark"] .offcanvas .border-top {
  border-color: var(--tupad-dark-border) !important;
}

/* Detail values (District, Wages, ...) under their muted labels. */
html[data-bs-theme="dark"] .offcanvas [id^="panel_"],
html[data-bs-theme="dark"] .offcanvas h6,
html[data-bs-theme="dark"] #wp_details_section .fw-semibold,
html[data-bs-theme="dark"] #wp_details_drawer .details-panel .fw-semibold {
  color: var(--tupad-dark-text-strong) !important;
}

/* Drawer item tables (every page names its own *_drawer_items_dt). */
html[data-bs-theme="dark"] #drawer_items_dt thead,
html[data-bs-theme="dark"] [id$="_drawer_items_dt"] thead,
html[data-bs-theme="dark"] #drawer_beneficiaries_dt th {
  background-color: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] #drawer_items_dt tbody tr,
html[data-bs-theme="dark"] [id$="_drawer_items_dt"] tbody tr {
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] #drawer_items_dt tbody tr:hover,
html[data-bs-theme="dark"] [id$="_drawer_items_dt"] tbody tr:hover,
html[data-bs-theme="dark"] #drawer_beneficiaries_dt tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

html[data-bs-theme="dark"] #wp_details_drawer #drawer_items_dt tbody tr.drawer-selected {
  background-color: #1d3354 !important;
  border-left-color: #3b82f6 !important;
}

/* ---------------------------------------------------- list table rows */
html[data-bs-theme="dark"] .table.custom-hover.table-striped tbody tr:nth-of-type(odd),
html[data-bs-theme="dark"] .table.custom-hover.table-striped tbody tr:nth-of-type(odd) > * {
  background-color: rgba(255, 255, 255, 0.03) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .table-hover tbody tr:hover,
html[data-bs-theme="dark"] .table-hover tbody tr:hover td {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

html[data-bs-theme="dark"] .table.custom-hover thead th {
  border-bottom-color: var(--tupad-dark-border) !important;
}

/* ------------------------------------------ other light panels (custom.css) */
html[data-bs-theme="dark"] .province-card,
html[data-bs-theme="dark"] .tracking-list,
html[data-bs-theme="dark"] .access-card .access-sub {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .quarter-budget-item,
html[data-bs-theme="dark"] .budget-box,
html[data-bs-theme="dark"] .tracking-item .tracking-content,
html[data-bs-theme="dark"] .access-card .access-parent-header,
html[data-bs-theme="dark"] .access-card .access-sub .access-sub-item,
html[data-bs-theme="dark"] .notification-panel-header,
html[data-bs-theme="dark"] .notification-item-icon,
html[data-bs-theme="dark"] .notification-item-chip {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
  color: var(--tupad-dark-text);
}

html[data-bs-theme="dark"] .access-card .access-sub .access-sub-item:hover,
html[data-bs-theme="dark"] .notification-item:hover {
  background: var(--tupad-dark-surface-3) !important;
  border-color: #3b82f6 !important;
}

html[data-bs-theme="dark"] .access-card .access-sub .access-sub-item:has(.form-check-input:checked),
html[data-bs-theme="dark"] .notification-item.is-unread {
  background: #1d3354 !important;
  border-color: rgba(59, 130, 246, 0.55) !important;
}

html[data-bs-theme="dark"] .notification-item.is-unread:hover {
  background: #23406a !important;
}

html[data-bs-theme="dark"] .notification-badge--action {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fbbf24 !important;
}

html[data-bs-theme="dark"] .notification-badge--done,
html[data-bs-theme="dark"] .notification-badge--read {
  background: rgba(148, 163, 184, 0.16) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .notification-badge--info {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] .tracking-bg-success {
  background-color: rgba(34, 197, 94, 0.18) !important;
}

html[data-bs-theme="dark"] .tracking-bg-fail {
  background-color: rgba(239, 68, 68, 0.18) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-search-group .input-group-text,
html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table thead th,
html[data-bs-theme="dark"] .monitoring-tupad-page div.dt-scroll-head table.dataTable thead th:first-child,
html[data-bs-theme="dark"] .monitoring-tupad-page table.monitoring-table thead th:first-child {
  background: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page table.monitoring-table tbody td:first-child {
  background: var(--tupad-dark-surface) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table tbody tr:hover td,
html[data-bs-theme="dark"] .monitoring-tupad-page div.dt-scroll-body table.dataTable tbody tr:hover td:first-child,
html[data-bs-theme="dark"] .monitoring-tupad-page table.monitoring-table tbody tr:hover td:first-child {
  background: var(--tupad-dark-surface-3) !important;
}

/* TUPAD Monitoring page: palette in --mon-* variables, plus a few fixed
   colours in custom.css. */
html[data-bs-theme="dark"] .monitoring-tupad-page {
  --mon-surface: var(--tupad-dark-surface);
  --mon-ink: var(--tupad-dark-text-strong);
  --mon-muted: var(--tupad-dark-muted);
  --mon-line: var(--tupad-dark-border);
  --mon-line-soft: #243147;
  --mon-blue: #7cb4ff;
  --mon-blue-soft: rgba(59, 130, 246, 0.16);
  --mon-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-filter-card,
html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table-card {
  background: var(--tupad-dark-surface) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table thead th {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table tbody td {
  background: var(--tupad-dark-surface) !important;
  border-color: #243147 !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table td:nth-child(10),
html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table th:nth-child(10) {
  border-right-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table td:nth-child(6),
html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-table th:nth-child(6) {
  border-left-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-col-province .monitoring-money {
  color: #cbd5e1 !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-money-muted {
  color: #64748b !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-date {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page .monitoring-search-group .form-control:focus {
  border-color: #3e93ff !important;
}

html[data-bs-theme="dark"] .monitoring-tupad-page div.dt-container .dt-info {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] #review_issues_modal table thead th {
  background: var(--tupad-dark-surface-2) !important;
}

/* ------------------------------------------------------------ dashboards
   dashboard.css keeps its palette in --dsh-* variables; the cards add white
   gradients on top, overridden below. */
html[data-bs-theme="dark"] .dsh {
  --dsh-surface: var(--tupad-dark-surface);
  --dsh-canvas: var(--tupad-dark-bg);
  --dsh-ink: var(--tupad-dark-text-strong);
  --dsh-ink-2: #cbd5e1;
  --dsh-muted: var(--tupad-dark-muted);
  --dsh-line: var(--tupad-dark-border);
  --dsh-line-soft: #243147;

  --dsh-alloc: #7cb4ff;
  --dsh-alloc-soft: rgba(59, 130, 246, 0.16);
  --dsh-util: #f59e0b;
  --dsh-util-soft: rgba(245, 158, 11, 0.16);
  --dsh-disb: #4ade80;
  --dsh-disb-soft: rgba(34, 197, 94, 0.16);

  --dsh-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --dsh-shadow-hover: 0 8px 18px rgba(0, 0, 0, 0.35);
  --dsh-prov-tint: var(--tupad-dark-surface-2) !important;
  color: var(--dsh-ink);
}

html[data-bs-theme="dark"] .tupad-dashboard-page {
  background: var(--tupad-dark-bg) !important;
}

/* The DOLE background: the colour glows and the logo watermark are lifted so
   they read on the dark canvas, and the cards are slightly see-through so
   the logo shows behind them. */
html[data-bs-theme="dark"] .tupad-dashboard-page::before {
  opacity: 0.5;
}

html[data-bs-theme="dark"] .tupad-dashboard-page::after {
  opacity: 0.3;
  filter: brightness(1.35) saturate(1.15)
    drop-shadow(0 0 28px rgba(124, 180, 255, 0.35));
}

html[data-bs-theme="dark"] .dsh-card,
html[data-bs-theme="dark"] .dsh-kpi,
html[data-bs-theme="dark"] .dsh-prov,
html[data-bs-theme="dark"] .dsh-prov:hover,
html[data-bs-theme="dark"] .dsh-fya-card,
html[data-bs-theme="dark"] .dsh-fya-card--empty {
  background: linear-gradient(
    135deg,
    rgba(24, 33, 49, 0.8) 0%,
    rgba(31, 42, 61, 0.74) 100%
  ) !important;
  border-color: var(--tupad-dark-border) !important;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* Province cards set their own light --dsh-prov-tint on the card itself,
   which beats the value on .dsh, so each gets a dark tint of its colour. */
html[data-bs-theme="dark"] .dsh-prov--cavite {
  --dsh-prov-tint: rgba(249, 168, 37, 0.14);
}

html[data-bs-theme="dark"] .dsh-prov--laguna {
  --dsh-prov-tint: rgba(230, 81, 0, 0.16);
}

html[data-bs-theme="dark"] .dsh-prov--batangas {
  --dsh-prov-tint: rgba(67, 160, 71, 0.16);
}

html[data-bs-theme="dark"] .dsh-prov--rizal {
  --dsh-prov-tint: rgba(30, 136, 229, 0.16);
}

html[data-bs-theme="dark"] .dsh-prov--quezon {
  --dsh-prov-tint: rgba(173, 20, 87, 0.18);
}

html[data-bs-theme="dark"] .dsh-prov__name {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] .dsh-prov__name i {
  color: var(--tupad-dark-muted) !important;
}

html[data-bs-theme="dark"] .dsh-card:hover {
  border-color: #3a4a66 !important;
}

html[data-bs-theme="dark"] .dsh-fya-card:not(.dsh-fya-card--empty) {
  border-color: rgba(245, 158, 11, 0.45) !important;
}

html[data-bs-theme="dark"] .dsh-fya-card__icon {
  background: rgba(245, 158, 11, 0.16) !important;
}

html[data-bs-theme="dark"] .dsh h1,
html[data-bs-theme="dark"] .dsh h2,
html[data-bs-theme="dark"] .dsh h3,
html[data-bs-theme="dark"] .dsh h4,
html[data-bs-theme="dark"] .dsh h5,
html[data-bs-theme="dark"] .dsh h6 {
  color: var(--tupad-dark-text-strong);
}

/* ----------------------------------------------- inline-styled pop-ups
   Some pages build SweetAlert choices in JS with inline colours (white
   option cards, #212529 titles, #6c757d captions, pale icon circles). */
html[data-bs-theme="dark"] .fwd-card {
  background: var(--tupad-dark-surface-2) !important;
  border-color: var(--tupad-dark-border) !important;
}

html[data-bs-theme="dark"] .fwd-card:hover {
  border-color: #475569 !important;
}

html[data-bs-theme="dark"] label.fwd-card:has(input:checked) {
  background: #1d3354 !important;
  border-color: #60a5fa !important;
}

/* GSIS drawers: the municipality Forward row. Its light inline backgrounds
   are re-set by jQuery when ticked (as rgb(), which no attribute selector
   matches), so the row is styled by class: dark when not ticked, green tint
   when ticked, with readable text and badge in both. */
html[data-bs-theme="dark"] .muni-forward-label {
  background: var(--tupad-dark-surface-2) !important;
}

html[data-bs-theme="dark"] .muni-forward-label:has(.muni-forward-check:checked) {
  background: rgba(34, 197, 94, 0.2) !important;
}

html[data-bs-theme="dark"] .muni-forward-label .text-uppercase {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] .muni-forward-label .muni-fwd-badge {
  background: rgba(59, 130, 246, 0.25) !important;
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] .muni-forward-label:has(.muni-forward-check:checked) .muni-fwd-badge {
  background: #15803d !important;
  color: #ffffff !important;
}

/* Inline dark text colours. */
html[data-bs-theme="dark"] [style*="color:#212529"],
html[data-bs-theme="dark"] [style*="color: #212529"],
html[data-bs-theme="dark"] [style*="color:#333"],
html[data-bs-theme="dark"] [style*="color: #333"],
html[data-bs-theme="dark"] [style*="color:#000"],
html[data-bs-theme="dark"] [style*="color: #000"],
html[data-bs-theme="dark"] [style*="color:#1a3c6e"],
html[data-bs-theme="dark"] [style*="color: #1a3c6e"] {
  color: var(--tupad-dark-text-strong) !important;
}

html[data-bs-theme="dark"] [style*="color:#084298"],
html[data-bs-theme="dark"] [style*="color: #084298"] {
  color: #93c5fd !important;
}

html[data-bs-theme="dark"] [style*="color:#6c757d"],
html[data-bs-theme="dark"] [style*="color: #6c757d"] {
  color: var(--tupad-dark-muted) !important;
}

/* Pale icon circles: keep their hue, darken the tint. */
html[data-bs-theme="dark"] [style*="background:#e7f1ff"],
html[data-bs-theme="dark"] [style*="background: #e7f1ff"],
html[data-bs-theme="dark"] [style*="background:#cfe2ff"],
html[data-bs-theme="dark"] [style*="background: #cfe2ff"],
html[data-bs-theme="dark"] [style*="background:#f0f6ff"],
html[data-bs-theme="dark"] [style*="background: #f0f6ff"] {
  background: rgba(59, 130, 246, 0.2) !important;
}

html[data-bs-theme="dark"] [style*="background:#d1e7dd"],
html[data-bs-theme="dark"] [style*="background: #d1e7dd"] {
  background: rgba(34, 197, 94, 0.2) !important;
}

html[data-bs-theme="dark"] [style*="background:#e2d9f3"],
html[data-bs-theme="dark"] [style*="background: #e2d9f3"],
html[data-bs-theme="dark"] [style*="background:#e9d8fd"],
html[data-bs-theme="dark"] [style*="background: #e9d8fd"] {
  background: rgba(139, 92, 246, 0.2) !important;
}

html[data-bs-theme="dark"] [style*="background:#fff3cd"],
html[data-bs-theme="dark"] [style*="background: #fff3cd"] {
  background: rgba(245, 158, 11, 0.2) !important;
}

html[data-bs-theme="dark"] [style*="background:#f8d7da"],
html[data-bs-theme="dark"] [style*="background: #f8d7da"] {
  background: rgba(239, 68, 68, 0.2) !important;
}

/* --------------------------------------------------- ADL "Add ADL" accordion
   Encoding of ADL and Realignment of ADL (Budget Officer). The card-surface
   rule above flattens the bg-info header into the card around it, and the
   inputs share the body's colour. Scoped by .bo-ui so the #add_accordion on
   other roles' pages is untouched. */
html[data-bs-theme="dark"] .bo-ui #add_accordion {
  --adl-head-bg: #1d3354;
  --adl-head-bg-hover: #213b61;
  --adl-head-bg-open: #23406a;
  --adl-head-bg-open-hover: #274874;
  --adl-line: #3a4a66;
  --adl-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23cfe0ff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* Same colour as the body: custom.css indents every .collapse 15px, and
   that strip of item would otherwise show beside the form. */
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-item {
  background-color: var(--tupad-dark-surface-2) !important;
  border: 1px solid var(--adl-line) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button {
  background-color: var(--adl-head-bg) !important;
  color: var(--tupad-dark-text-strong) !important;
  filter: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:hover {
  background-color: var(--adl-head-bg-hover) !important;
}

/* The bottom line separates the open header from the form below it. */
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:not(.collapsed) {
  background-color: var(--adl-head-bg-open) !important;
  box-shadow: inset 0 -1px 0 var(--adl-line) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:not(.collapsed):hover {
  background-color: var(--adl-head-bg-open-hover) !important;
}

/* The item clips its corners, so the focus ring is drawn inside. */
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(124, 180, 255, 0.6) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:not(.collapsed):focus-visible {
  box-shadow: inset 0 0 0 2px rgba(124, 180, 255, 0.6),
    inset 0 -1px 0 var(--adl-line) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button > i {
  color: #93c5fd;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button::after,
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-button:not(.collapsed)::after {
  background-image: var(--adl-chevron);
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control,
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-select {
  background-color: var(--tupad-dark-surface) !important;
  border-color: var(--adl-line) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control:hover:not(:focus) {
  border-color: #475569 !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control:focus,
html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-select:focus {
  border-color: #3e93ff !important;
  box-shadow: 0 0 0 0.2rem rgba(62, 147, 255, 0.25) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control::placeholder {
  color: #7c8aa0;
  opacity: 1;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .input-group-text {
  background-color: var(--tupad-dark-surface-3) !important;
  border-color: var(--adl-line) !important;
  color: var(--tupad-dark-text) !important;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control::file-selector-button {
  background-color: var(--tupad-dark-surface-3);
  color: var(--tupad-dark-text);
  border-color: var(--adl-line);
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-control:hover:not(:disabled):not([readonly])::file-selector-button {
  background-color: #2f3d57;
}

html[data-bs-theme="dark"] .bo-ui #add_accordion .accordion-body .form-text strong {
  color: var(--tupad-dark-text);
}

/* ---------------------------------------------------------- theme toggle */
#theme_toggle {
  cursor: pointer;
}

#theme_toggle .theme-icon-light {
  display: none;
}

html[data-bs-theme="dark"] #theme_toggle .theme-icon-dark {
  display: none;
}

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