:root {
  --theme-page: #f5f6f8;
  --theme-topbar: #ffffff;
  --theme-surface: #ffffff;
  --theme-surface-raised: #ffffff;
  --theme-surface-soft: #f8fafc;
  --theme-surface-hover: #f3f7fb;
  --theme-border: #e1e6ee;
  --theme-border-strong: #cfd7e3;
  --theme-text: #212529;
  --theme-text-soft: #495057;
  --theme-text-muted: #818ea3;
  --theme-accent: #3d7edb;
  --theme-accent-soft: #eaf2ff;
  --theme-chart-grid: rgba(90, 97, 105, 0.12);
  --theme-tooltip: #172335;
  --theme-shadow: rgba(15, 23, 42, 0.12);
}

html[data-theme="dark"] {
  --theme-page: #0d1723;
  --theme-topbar: #172335;
  --theme-sidebar: #162233;
  --theme-surface: #192638;
  --theme-surface-raised: #1e2d41;
  --theme-surface-soft: #142133;
  --theme-surface-hover: #22344a;
  --theme-border: #2a3b51;
  --theme-border-strong: #3a506b;
  --theme-text: #edf3fa;
  --theme-text-soft: #c2cede;
  --theme-text-muted: #91a2b8;
  --theme-accent: #65a7f3;
  --theme-accent-soft: #203a59;
  --theme-chart-grid: rgba(145, 162, 184, 0.2);
  --theme-tooltip: #101b29;
  --theme-shadow: rgba(2, 8, 18, 0.38);
}

/* Top-bar theme switch */
.topbar-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 3.75rem;
  padding: 0 0.75rem;
  border-left: 1px solid var(--theme-border);
}

.main-navbar.sticky-top .nav {
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: center;
}

.main-navbar.sticky-top .navbar > .w-100 {
  min-width: 0;
}

.theme-toggle {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  width: 4.25rem;
  height: 2.15rem;
  padding: 0.12rem;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  background: #edf1f6;
  color: #7b8798;
  cursor: pointer;
  outline: none;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-toggle:hover {
  border-color: #b8c5d4;
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(61, 126, 219, 0.2);
}

.theme-toggle__icon {
  position: relative;
  z-index: 2;
  font-size: 1.02rem;
  line-height: 1;
  transition: color 160ms ease;
}

.theme-toggle__icon--light {
  color: #52657d;
}

.theme-toggle__icon--dark {
  color: #8c9caf;
}

.theme-toggle__thumb {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: calc(25% - 0.825rem);
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0.16rem 0.45rem rgba(31, 45, 61, 0.2);
  transform: translateY(-50%);
  transition: left 180ms cubic-bezier(0.2, 0.8, 0.2, 1), background-color 160ms ease;
}

html[data-theme="dark"] .theme-toggle {
  border-color: #344a65;
  background: #101b29;
}

html[data-theme="dark"] .theme-toggle:hover {
  border-color: #4d6f96;
}

html[data-theme="dark"] .theme-toggle__thumb {
  left: calc(75% - 0.825rem);
  background: #eef4fb;
  box-shadow: 0 0 0 0.2rem rgba(68, 130, 201, 0.48), 0 0.18rem 0.5rem rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .theme-toggle__icon--light {
  color: #71849b;
}

html[data-theme="dark"] .theme-toggle__icon--dark {
  color: #16263b;
}

/* Shared dark surfaces and typography */
html[data-theme="dark"] body,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .main-content-container {
  background: var(--theme-page);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] body,
html[data-theme="dark"] p,
html[data-theme="dark"] label,
html[data-theme="dark"] td,
html[data-theme="dark"] dd {
  color: var(--theme-text-soft);
}

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

html[data-theme="dark"] a {
  color: var(--theme-accent);
}

html[data-theme="dark"] a:hover {
  color: #91c2fb;
}

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

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

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(--theme-border) !important;
}

html[data-theme="dark"] code {
  color: #95bff2;
  background: #101b29;
}

html[data-theme="dark"] ::selection {
  background: rgba(101, 167, 243, 0.3);
  color: #ffffff;
}

html[data-theme="dark"] * {
  scrollbar-color: #415976 #111c2a;
}

/* Navigation */
html[data-theme="dark"] .main-sidebar,
html[data-theme="dark"] .main-sidebar .nav-wrapper,
html[data-theme="dark"] .main-sidebar .main-navbar,
html[data-theme="dark"] .main-sidebar .main-navbar .navbar {
  background: var(--theme-sidebar) !important;
  border-color: var(--theme-border) !important;
}

html[data-theme="dark"] .main-sidebar {
  box-shadow: 0.2rem 0 1.2rem rgba(2, 8, 18, 0.22);
}

html[data-theme="dark"] .icon-sidebar-nav .main-sidebar__nav-title {
  color: #8fa2ba;
  border: 0 !important;
  box-shadow: inset 0 -1px 0 rgba(145, 162, 184, 0.12);
}

html[data-theme="dark"] .main-sidebar .main-navbar .navbar {
  border-bottom-color: rgba(145, 162, 184, 0.12) !important;
}

html[data-theme="dark"] .main-sidebar .nav-wrapper .nav,
html[data-theme="dark"] .main-sidebar .nav-wrapper .nav-item,
html[data-theme="dark"] .main-sidebar .nav-wrapper .nav-link {
  border: 0 !important;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item {
  background: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link {
  color: #aebdd0;
  border-color: transparent;
  transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link i {
  color: #91a4bc;
  transition: color 140ms ease;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item:hover {
  background: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link:hover {
  background: #1e3046;
  color: #f0f5fb;
  box-shadow: inset 0.2rem 0 0 #3d7edb;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link:hover i {
  color: #d8e7f8;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link.active {
  background: #233a55;
  color: #7db9ff;
  box-shadow: inset 0.2rem 0 0 #65a7f3;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link.active i {
  color: #7db9ff;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link.disabled {
  color: #66798f;
  opacity: 0.72;
}

html[data-theme="dark"] .main-sidebar .nav .nav-item .nav-link.disabled i {
  color: #66798f;
}

html[data-theme="dark"] .main-navbar.sticky-top,
html[data-theme="dark"] .main-navbar.sticky-top .navbar {
  background: var(--theme-topbar) !important;
  border-color: var(--theme-border) !important;
  box-shadow: 0 0.15rem 0.8rem rgba(2, 8, 18, 0.2);
}

html[data-theme="dark"] .topbar-brand {
  color: var(--theme-text);
}

html[data-theme="dark"] .topbar-brand:hover,
html[data-theme="dark"] .topbar-brand:focus {
  color: #91c2fb;
}

html[data-theme="dark"] .toggle-sidebar {
  border-color: var(--theme-border) !important;
  color: var(--theme-text-soft) !important;
}

/* Bootstrap and Shards components */
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-small,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .card-footer {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
  box-shadow: 0 0.25rem 0.9rem var(--theme-shadow);
}

html[data-theme="dark"] .card-header {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
  color: var(--theme-text);
}

html[data-theme="dark"] .stats-small__label {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .stats-small__value {
  color: var(--theme-text);
}

html[data-theme="dark"] .table {
  color: var(--theme-text-soft);
  background: transparent;
}

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

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

html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd),
html[data-theme="dark"] .table-hover tbody tr:hover {
  background: rgba(101, 167, 243, 0.07);
  color: var(--theme-text);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="month"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"] {
  background-color: var(--theme-surface-soft);
  border-color: var(--theme-border-strong);
  color: var(--theme-text);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .custom-select:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] input:focus {
  background-color: #18283b;
  border-color: var(--theme-accent);
  color: var(--theme-text);
  box-shadow: 0 0 0 0.2rem rgba(101, 167, 243, 0.16);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #718399;
  opacity: 1;
}

html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] select:disabled,
html[data-theme="dark"] input:disabled {
  background: #111d2c;
  color: #667990;
  opacity: 1;
}

html[data-theme="dark"] .input-group-text {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border-strong);
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .custom-control-label::before {
  background: #101c2a;
  border-color: #536985;
}

html[data-theme="dark"] .custom-control-input:checked ~ .custom-control-label::before {
  background: var(--theme-accent);
  border-color: var(--theme-accent);
}

html[data-theme="dark"] .btn-white,
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-secondary {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border-strong);
  color: var(--theme-text-soft);
  box-shadow: none;
}

html[data-theme="dark"] .btn-white:hover,
html[data-theme="dark"] .btn-white:focus,
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-light:focus,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:focus {
  background: var(--theme-surface-hover);
  border-color: #577394;
  color: var(--theme-text);
}

html[data-theme="dark"] .btn-link {
  color: var(--theme-accent);
}

html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .popover,
html[data-theme="dark"] .list-group-item {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
  box-shadow: 0 0.75rem 1.8rem var(--theme-shadow);
}

html[data-theme="dark"] .dropdown-divider {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .popover-header,
html[data-theme="dark"] .popover-body {
  color: var(--theme-text-soft);
}

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

html[data-theme="dark"] .popover-header {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .bs-popover-top .arrow::after {
  border-top-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .bs-popover-bottom .arrow::after {
  border-bottom-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .bs-popover-left .arrow::after {
  border-left-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .bs-popover-right .arrow::after {
  border-right-color: var(--theme-surface-raised);
}

html[data-theme="dark"] .modal-content {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
  box-shadow: 0 1rem 3rem rgba(2, 8, 18, 0.55);
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .modal-body {
  background: var(--theme-surface);
}

html[data-theme="dark"] .close {
  color: var(--theme-text);
  text-shadow: none;
}

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

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

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

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

html[data-theme="dark"] .page-link:hover,
html[data-theme="dark"] .page-item.active .page-link {
  background: var(--theme-accent-soft);
  border-color: #41658c;
  color: #b9d9ff;
}

html[data-theme="dark"] .page-item.disabled .page-link {
  background: #111d2b;
  border-color: var(--theme-border);
  color: #5f7186;
}

html[data-theme="dark"] .alert {
  border-color: var(--theme-border-strong);
}

html[data-theme="dark"] .alert-info {
  background: #15354a;
  color: #a9dcf5;
}

html[data-theme="dark"] .alert-success {
  background: #16392f;
  color: #a9e7cf;
}

html[data-theme="dark"] .alert-warning {
  background: #443719;
  color: #f1d58a;
}

html[data-theme="dark"] .alert-danger {
  background: #42232d;
  color: #f2b4c0;
}

/* Search menus and date pickers */
html[data-theme="dark"] .controlling-datepicker-group {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border-strong);
}

html[data-theme="dark"] .controlling-datepicker-group .input-group-text {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .controlling-search-dropdown__bulk-actions,
html[data-theme="dark"] .controlling-search-dropdown__footer {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .controlling-search-dropdown__bulk-actions .btn {
  background: var(--theme-surface-soft);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .controlling-search-dropdown__bulk-actions .btn:hover,
html[data-theme="dark"] .controlling-search-dropdown__bulk-actions .btn:focus,
html[data-theme="dark"] .controlling-search-dropdown__checkbox:hover,
html[data-theme="dark"] .controlling-search-dropdown__options .custom-control:hover {
  background: var(--theme-surface-hover);
  color: var(--theme-text);
  box-shadow: none;
}

html[data-theme="dark"] .controlling-search-dropdown__option.is-selected {
  background: var(--theme-accent-soft);
  color: #a9d0ff;
}

html[data-theme="dark"] .controlling-search-dropdown__checkbox.is-selected .custom-control-label {
  color: #a9d0ff;
}

html[data-theme="dark"] .datepicker.dropdown-menu {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .datepicker table tr td.day:hover,
html[data-theme="dark"] .datepicker table tr td.focused,
html[data-theme="dark"] .datepicker .datepicker-switch:hover,
html[data-theme="dark"] .datepicker .prev:hover,
html[data-theme="dark"] .datepicker .next:hover,
html[data-theme="dark"] .datepicker tfoot tr th:hover,
html[data-theme="dark"] .datepicker .datepicker-months span.month:hover,
html[data-theme="dark"] .datepicker .datepicker-months span.month.focused {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .datepicker table tr td.old,
html[data-theme="dark"] .datepicker table tr td.new,
html[data-theme="dark"] .datepicker table tr td.disabled {
  color: #5e7188;
}

html[data-theme="dark"] .datepicker table tr td.today {
  background: #284360;
  color: #a9d0ff;
}

/* Transactions, invoices, and unit pills */
html[data-theme="dark"] .transaction-date-main,
html[data-theme="dark"] .invoice-state-pill,
html[data-theme="dark"] .transaction-unit-summary,
html[data-theme="dark"] .recon-candidate-pill,
html[data-theme="dark"] .recon-pill,
html[data-theme="dark"] .recon-priority-rank {
  background: #26364a;
  border-color: #3b4f69;
  color: #c7d3e2;
}

html[data-theme="dark"] .transaction-date-main:hover,
html[data-theme="dark"] .invoice-state-pill:hover,
html[data-theme="dark"] .transaction-unit-summary:hover {
  background: #30445d;
  border-color: #4b6585;
  color: var(--theme-text);
}

html[data-theme="dark"] .transaction-reporting-editor,
html[data-theme="dark"] .transaction-category-dropdown,
html[data-theme="dark"] .transaction-reporting-editor .form-control {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .transaction-reporting-editor__title,
html[data-theme="dark"] .transaction-provenance-hover__header strong,
html[data-theme="dark"] .revenue-linked-bookings-hover__header strong {
  color: var(--theme-text);
}

html[data-theme="dark"] .transaction-reporting-editor__subtitle,
html[data-theme="dark"] .transaction-provenance-hover__row dt,
html[data-theme="dark"] .transaction-provenance-hover__empty,
html[data-theme="dark"] .revenue-linked-bookings-hover__summary,
html[data-theme="dark"] .revenue-linked-bookings-hover__empty,
html[data-theme="dark"] .revenue-linked-bookings-hover__meta,
html[data-theme="dark"] .revenue-linked-bookings-hover__id {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .transaction-provenance-hover__row dd,
html[data-theme="dark"] .revenue-linked-bookings-hover__guest,
html[data-theme="dark"] .revenue-linked-bookings-hover__num {
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .revenue-linked-bookings-hover__table thead th {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border);
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .revenue-linked-bookings-hover__table tbody td,
html[data-theme="dark"] .transactions-pagination,
html[data-theme="dark"] .invoices-pagination {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .transaction-unit-stack__badge,
html[data-theme="dark"] .transaction-unit-summary.is-multi {
  background: #203c5a;
  border-color: #3b648d;
  color: #acd2ff;
}

html[data-theme="dark"] .transaction-unit-stack:hover .transaction-unit-stack__badge,
html[data-theme="dark"] .transaction-unit-stack:focus-within .transaction-unit-stack__badge,
html[data-theme="dark"] .transaction-unit-stack:focus .transaction-unit-stack__badge {
  background: #274968;
  border-color: #4b739d;
  color: #c2ddff;
}

html[data-theme="dark"] .transaction-unit-flyout__badge {
  background: var(--unit-flyout-background, #203c5a);
  border-color: var(--unit-flyout-border-color, #3b648d);
  color: var(--unit-flyout-color, #acd2ff);
}

html[data-theme="dark"] .transaction-unit-summary__label,
html[data-theme="dark"] .transaction-unit-stack__label,
html[data-theme="dark"] .transaction-unit-flyout__label {
  color: inherit;
}

html[data-theme="dark"] .invoice-preview-popover iframe,
html[data-theme="dark"] .invoice-preview-popover img,
html[data-theme="dark"] .invoice-preview-thumb,
html[data-theme="dark"] .recon-preview-pane {
  background: #101b29;
}

/* Import and job interfaces */
html[data-theme="dark"] .dropzone {
  background: var(--theme-surface-soft);
  border-color: #48617e;
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .dropzone:hover,
html[data-theme="dark"] .dropzone:focus,
html[data-theme="dark"] .dropzone.is-dragover {
  background: #1b3048;
  border-color: var(--theme-accent);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .dropzone__title,
html[data-theme="dark"] .stripe-import__title {
  color: var(--theme-text);
}

html[data-theme="dark"] .import-overlay__panel,
html[data-theme="dark"] .import-overlay__body {
  background: var(--theme-page);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .import-overlay__header {
  background: linear-gradient(180deg, #1b2a3e 0%, #162335 100%);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .preview-stats,
html[data-theme="dark"] .docs-stats {
  background: var(--theme-border);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .preview-stat,
html[data-theme="dark"] .preview-projection__cell,
html[data-theme="dark"] .preview-table-wrapper,
html[data-theme="dark"] .run-stat,
html[data-theme="dark"] .run-card,
html[data-theme="dark"] .run-summary__cell,
html[data-theme="dark"] .docs-preview,
html[data-theme="dark"] .docs-stat,
html[data-theme="dark"] .doc-row,
html[data-theme="dark"] .review-intro,
html[data-theme="dark"] .review-card {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .run-card--chart,
html[data-theme="dark"] .run-summary {
  background: radial-gradient(circle at top, rgba(101, 167, 243, 0.09), transparent 48%), var(--theme-surface);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .doc-row:hover {
  border-color: #455f7d;
}

html[data-theme="dark"] .doc-row.is-previewed {
  border-color: #6c96c7;
  box-shadow: 0 0 0 1px rgba(108, 150, 199, 0.42) inset;
}

html[data-theme="dark"] .doc-row--analyzing {
  background: linear-gradient(100deg, rgba(112, 91, 189, 0.08), transparent 42%), var(--theme-surface);
  border-color: #687cad;
  box-shadow: 0 0 0 1px rgba(104, 124, 173, 0.32) inset, 0 0.35rem 1.2rem rgba(3, 9, 20, 0.28);
}

html[data-theme="dark"] .doc-scan {
  background: #0d1826;
  box-shadow: inset 0 0 0 1px rgba(145, 162, 184, 0.12);
}

html[data-theme="dark"] .doc-scan__beam {
  background: linear-gradient(90deg, transparent, #9f8cff, #65a7f3, transparent);
}

html[data-theme="dark"] .doc-decode {
  color: #c2b4ff;
}

html[data-theme="dark"] .doc-decode b {
  color: #e1dcff;
}

html[data-theme="dark"] .doc-decode__dots i {
  background: #ad98ff;
}

html[data-theme="dark"] .doc-decode b.is-tick {
  animation-name: decode-pop-dark;
}

@keyframes decode-pop-dark {
  from { opacity: 0.55; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

html[data-theme="dark"] .preview-table thead th,
html[data-theme="dark"] .docs-preview__header,
html[data-theme="dark"] .docs-preview__body {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .preview-stat__value,
html[data-theme="dark"] .preview-projection__value,
html[data-theme="dark"] .run-stat__value,
html[data-theme="dark"] .run-chart-center__value,
html[data-theme="dark"] .run-breakdown__value,
html[data-theme="dark"] .run-summary__title,
html[data-theme="dark"] .run-summary__cell-value,
html[data-theme="dark"] .docs-stat__value,
html[data-theme="dark"] .doc-row__name,
html[data-theme="dark"] .review-doc-name {
  color: var(--theme-text);
}

html[data-theme="dark"] .preview-stat__label,
html[data-theme="dark"] .preview-projection__label,
html[data-theme="dark"] .run-stat__label,
html[data-theme="dark"] .run-card__title,
html[data-theme="dark"] .run-chart-center__label,
html[data-theme="dark"] .run-legend,
html[data-theme="dark"] .run-breakdown__pct,
html[data-theme="dark"] .run-summary__subtitle,
html[data-theme="dark"] .run-summary__cell-label,
html[data-theme="dark"] .docs-stat__label,
html[data-theme="dark"] .docs-status__file,
html[data-theme="dark"] .doc-row__meta,
html[data-theme="dark"] .review-legend,
html[data-theme="dark"] .review-field__label,
html[data-theme="dark"] .review-doc-meta {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .run-breakdown__label,
html[data-theme="dark"] .docs-preview__title,
html[data-theme="dark"] .review-intro {
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .run-breakdown__bar,
html[data-theme="dark"] .import-mini__progress-bar,
html[data-theme="dark"] .recon-run-overlay__bar {
  background: #0e1927;
}

html[data-theme="dark"] .review-input {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border-strong);
  color: var(--theme-text);
}

html[data-theme="dark"] .review-card--failed,
html[data-theme="dark"] .review-row--result-failed {
  background: #35212b;
}

html[data-theme="dark"] .review-row--result-inserted {
  background: #183429;
}

html[data-theme="dark"] .review-row--result-duplicate {
  background: #3b321c;
}

html[data-theme="dark"] .import-mini {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border);
  box-shadow: 0 1rem 2.5rem rgba(2, 8, 18, 0.48);
}

html[data-theme="dark"] .import-mini__body:hover,
html[data-theme="dark"] .import-mini__body:focus-visible {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .import-mini__title,
html[data-theme="dark"] .import-mini__stats b {
  color: var(--theme-text);
}

html[data-theme="dark"] .import-mini__file,
html[data-theme="dark"] .import-mini__progress-text,
html[data-theme="dark"] .import-mini__dismiss {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .import-mini__phase,
html[data-theme="dark"] .import-mini__stats,
html[data-theme="dark"] .import-mini__elapsed {
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .import-mini__elapsed {
  background: #101c2a;
}

/* Revenue and co-hosting */
html[data-theme="dark"] .revenue-hero,
html[data-theme="dark"] .revenue-kpi,
html[data-theme="dark"] .revenue-panel,
html[data-theme="dark"] .revenue-overlay__panel,
html[data-theme="dark"] .revenue-booking-overlay__filters,
html[data-theme="dark"] .revenue-booking-link-item,
html[data-theme="dark"] .revenue-overlay-metric {
  background: var(--theme-surface);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .revenue-tabs,
html[data-theme="dark"] .revenue-listing-badge,
html[data-theme="dark"] .revenue-booking-overlay__section-row td.revenue-booking-overlay__section {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .revenue-tab {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .revenue-tab.is-active {
  background: var(--theme-surface-hover);
  color: var(--theme-text);
}

html[data-theme="dark"] .revenue-kpi strong,
html[data-theme="dark"] .revenue-listing-badge strong,
html[data-theme="dark"] .revenue-booking-summary-main strong,
html[data-theme="dark"] .revenue-booking-summary-fact strong,
html[data-theme="dark"] .revenue-overlay-metric strong,
html[data-theme="dark"] .payout-run-result__row strong {
  color: var(--theme-text);
}

html[data-theme="dark"] .revenue-hero__badge,
html[data-theme="dark"] .revenue-table thead th,
html[data-theme="dark"] .revenue-booking-overlay__table thead th {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .revenue-row:hover {
  background: rgba(101, 167, 243, 0.07);
}

html[data-theme="dark"] .revenue-booking-overlay__summary {
  background: linear-gradient(180deg, #1c2b3e 0%, #172436 100%);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .revenue-booking-summary-financial,
html[data-theme="dark"] .revenue-booking-overlay__table,
html[data-theme="dark"] .revenue-booking-overlay__table-header,
html[data-theme="dark"] .revenue-overlay-section,
html[data-theme="dark"] .payout-run-result__row {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .revenue-booking-link-panel {
  background: #172b42;
  border-color: #2f5276;
}

html[data-theme="dark"] .revenue-booking-conflict {
  background: #3a301d;
  border-color: #6e5930;
}

html[data-theme="dark"] .revenue-booking-conflict__table {
  background: #282719;
}

html[data-theme="dark"] .revenue-booking-conflict__table th,
html[data-theme="dark"] .revenue-booking-conflict__table td {
  border-color: #5a4a2b;
}

/* Reconciliation administration and editor */
html[data-theme="dark"] .recon-admin-card,
html[data-theme="dark"] .recon-admin-kpi,
html[data-theme="dark"] .recon-run-step,
html[data-theme="dark"] .recon-crud-table,
html[data-theme="dark"] .recon-rule-section,
html[data-theme="dark"] .recon-run-preview__table-wrap,
html[data-theme="dark"] .recon-run-overlay__progress,
html[data-theme="dark"] .recon-live-decision,
html[data-theme="dark"] .recon-activity-item,
html[data-theme="dark"] .recon-simulation-metric,
html[data-theme="dark"] .recon-simulation-result__table-wrap {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .recon-admin-card .card-header,
html[data-theme="dark"] .recon-crud-table thead,
html[data-theme="dark"] .recon-run-preview__table-title,
html[data-theme="dark"] .recon-simulation-state,
html[data-theme="dark"] .recon-simulation-result__summary,
html[data-theme="dark"] .recon-simulation-result__table-title {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-admin-kpi__value,
html[data-theme="dark"] .recon-run-step__title,
html[data-theme="dark"] .recon-rule-section__label,
html[data-theme="dark"] .recon-match-preview-cell__primary,
html[data-theme="dark"] .recon-match-preview-cell__amount,
html[data-theme="dark"] .recon-run-overlay__phase,
html[data-theme="dark"] .recon-live-decision__title,
html[data-theme="dark"] .recon-live-decision__cell b,
html[data-theme="dark"] .recon-activity-feed__title,
html[data-theme="dark"] .recon-activity-item__text,
html[data-theme="dark"] .recon-simulation-state__title,
html[data-theme="dark"] .recon-simulation-metric__value {
  color: var(--theme-text);
}

html[data-theme="dark"] .recon-admin-kpi__label,
html[data-theme="dark"] .recon-admin-kpi__detail,
html[data-theme="dark"] .recon-run-step__desc,
html[data-theme="dark"] .recon-match-preview-cell__secondary,
html[data-theme="dark"] .recon-run-overlay__current,
html[data-theme="dark"] .recon-live-decision__meta,
html[data-theme="dark"] .recon-live-decision__label,
html[data-theme="dark"] .recon-live-decision__cell span,
html[data-theme="dark"] .recon-activity-item__time,
html[data-theme="dark"] .recon-simulation-state__text,
html[data-theme="dark"] .recon-simulation-metric__label {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .recon-crud-table th,
html[data-theme="dark"] .recon-crud-table td,
html[data-theme="dark"] .recon-sub-table th,
html[data-theme="dark"] .recon-sub-table td {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-crud-table tbody tr:hover {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .recon-priority-handle,
html[data-theme="dark"] .recon-run-checkbox-option,
html[data-theme="dark"] .recon-run-direction-options,
html[data-theme="dark"] .recon-run-direction-option input:checked + span {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .recon-live-decision--check,
html[data-theme="dark"] .recon-live-decision--check.is-checked,
html[data-theme="dark"] .recon-live-decision--match-summary {
  background: linear-gradient(90deg, rgba(101, 167, 243, 0.08), rgba(75, 199, 148, 0.05)), var(--theme-surface);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-live-decision__cell {
  background: var(--theme-surface-soft);
}

html[data-theme="dark"] .recon-panel,
html[data-theme="dark"] .recon-suggest-panel {
  background: var(--theme-surface);
  border: 1px solid var(--theme-border);
}

html[data-theme="dark"] .recon-column {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-col-header,
html[data-theme="dark"] .recon-suggest-header {
  background: linear-gradient(180deg, #1d3048 0%, #18283c 100%);
  border-color: #314d6d;
}

html[data-theme="dark"] .recon-col-header h6,
html[data-theme="dark"] .recon-suggest-header h6,
html[data-theme="dark"] .recon-col-section-title {
  color: #afd2fa;
}

html[data-theme="dark"] .recon-col-filters,
html[data-theme="dark"] .recon-totals,
html[data-theme="dark"] .recon-col-section-title,
html[data-theme="dark"] .recon-link-row {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-filter-checkbox-chip,
html[data-theme="dark"] .recon-selected-card,
html[data-theme="dark"] .recon-footer,
html[data-theme="dark"] .recon-field-with-action button,
html[data-theme="dark"] .recon-close,
html[data-theme="dark"] .recon-suggest-close {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border-strong);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .recon-filter-checkbox-chip:hover,
html[data-theme="dark"] .recon-filter-checkbox-chip.is-active,
html[data-theme="dark"] .recon-candidate-row:hover,
html[data-theme="dark"] .recon-suggest-row:hover {
  background: var(--theme-accent-soft);
  border-color: #4c729a;
  color: #b9d9ff;
}

html[data-theme="dark"] .recon-candidate-row,
html[data-theme="dark"] .recon-col-pager,
html[data-theme="dark"] .recon-selected-card,
html[data-theme="dark"] .recon-selected-total,
html[data-theme="dark"] .recon-totals,
html[data-theme="dark"] .recon-footer,
html[data-theme="dark"] .recon-suggest-sub,
html[data-theme="dark"] .recon-suggest-row {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-candidate-row.is-added,
html[data-theme="dark"] .recon-selected-card.is-inv.is-previewed {
  background: #18382f;
}

html[data-theme="dark"] .recon-candidate-unlink {
  background: #44252d;
  border-color: #75424e;
  color: #ffb8c4;
}

html[data-theme="dark"] .recon-candidate-unlink:hover {
  background: #59303a;
  border-color: #955362;
  color: #ffd5dc;
}

html[data-theme="dark"] .recon-candidate-unlink:focus-visible {
  outline: 2px solid rgba(255, 140, 159, 0.42);
  outline-offset: 1px;
}

html[data-theme="dark"] .recon-candidate-title,
html[data-theme="dark"] .recon-selected-title,
html[data-theme="dark"] .recon-totals .recon-total-value {
  color: var(--theme-text);
}

html[data-theme="dark"] .recon-candidate-sub,
html[data-theme="dark"] .recon-selected-sub,
html[data-theme="dark"] .recon-selected-total,
html[data-theme="dark"] .recon-selected-amount-row label,
html[data-theme="dark"] .recon-selected-status-row label,
html[data-theme="dark"] .recon-selected-status-help,
html[data-theme="dark"] .recon-link-row .recon-link-meta,
html[data-theme="dark"] .recon-total-label,
html[data-theme="dark"] .recon-suggest-sub {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .recon-suggest-backdrop {
  background: rgba(3, 9, 18, 0.72);
}

html[data-theme="dark"] .recon-suggest-panel {
  box-shadow: 0 1.25rem 3.5rem rgba(2, 8, 18, 0.58);
}

html[data-theme="dark"] .recon-suggest-footer {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .recon-suggest-selectall {
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .recon-suggest-panel input[type="checkbox"] {
  accent-color: #65a7f3;
}

html[data-theme="dark"] .recon-suggest-row-title {
  color: var(--theme-text);
}

html[data-theme="dark"] .recon-suggest-row-sub {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .recon-suggest-row-pill {
  background: #463a1d;
  color: #f4d683;
}

html[data-theme="dark"] .recon-suggest-panel .recon-amount-expense {
  color: #ff6682;
}

html[data-theme="dark"] .recon-suggest-panel .recon-amount-income {
  color: #66d6a7;
}

html[data-theme="dark"] .recon-suggest-close:hover {
  background: var(--theme-surface-hover);
  border-color: #58728f;
  color: var(--theme-text);
}

/* Transaction unit editor */
html[data-theme="dark"] .transaction-unit-modal__panel,
html[data-theme="dark"] .transaction-unit-modal__surface,
html[data-theme="dark"] .transaction-unit-modal__picker-menu,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-card,
html[data-theme="dark"] .transaction-unit-modal__unit-rule-condition {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .transaction-unit-modal__header {
  background: linear-gradient(180deg, rgba(29, 48, 72, 0.98) 0%, rgba(24, 39, 58, 0.96) 100%);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .transaction-unit-modal__hero,
html[data-theme="dark"] .transaction-unit-modal__selected-card,
html[data-theme="dark"] .transaction-unit-modal__allocation-row,
html[data-theme="dark"] .transaction-unit-modal__summary-card,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-count-row,
html[data-theme="dark"] .transaction-unit-modal__cleaning-progress {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .transaction-unit-modal__amount,
html[data-theme="dark"] .transaction-unit-modal__segmented-button.is-active,
html[data-theme="dark"] .transaction-unit-modal__picker-trigger,
html[data-theme="dark"] .transaction-unit-modal__ghost-button,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-actions {
  background: var(--theme-surface-raised);
  border-color: var(--theme-border-strong);
  color: var(--theme-text-soft);
  box-shadow: none;
}

html[data-theme="dark"] .transaction-unit-modal__segmented {
  background: #111d2c;
}

html[data-theme="dark"] .transaction-unit-modal__picker-actions {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .transaction-unit-modal__title,
html[data-theme="dark"] .transaction-unit-modal__partner,
html[data-theme="dark"] .transaction-unit-modal__amount-value,
html[data-theme="dark"] .transaction-unit-modal__section-title,
html[data-theme="dark"] .transaction-unit-modal__selected-value,
html[data-theme="dark"] .transaction-unit-modal__summary-value,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-title,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-count-row span {
  color: var(--theme-text);
}

html[data-theme="dark"] .transaction-unit-modal__subtitle,
html[data-theme="dark"] .transaction-unit-modal__details,
html[data-theme="dark"] .transaction-unit-modal__amount-label,
html[data-theme="dark"] .transaction-unit-modal__section-copy,
html[data-theme="dark"] .transaction-unit-modal__selected-label,
html[data-theme="dark"] .transaction-unit-modal__picker-icon,
html[data-theme="dark"] .transaction-unit-modal__picker-count,
html[data-theme="dark"] .transaction-unit-modal__team-allocation-label,
html[data-theme="dark"] .transaction-unit-modal__summary-label,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-copy,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-dates label,
html[data-theme="dark"] .transaction-unit-modal__past-jobs-note,
html[data-theme="dark"] .transaction-unit-modal__cleaning-upload label,
html[data-theme="dark"] .transaction-unit-modal__cleaning-dropzone-copy {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .transaction-unit-modal__close {
  background: #26384d;
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .transaction-unit-modal__cleaning-dropzone {
  background: #172b42;
  border-color: #466487;
  color: #b9d9ff !important;
}

html[data-theme="dark"] .transaction-unit-modal__share,
html[data-theme="dark"] .transaction-unit-modal__validation {
  background: #223248;
  color: var(--theme-text-soft);
}

/* Keep semantic colors vivid without bright light-theme fills. */
html[data-theme="dark"] .invoice-state-pill.is-reconciled,
html[data-theme="dark"] .revenue-state--ok,
html[data-theme="dark"] .revenue-transaction-match--matched,
html[data-theme="dark"] .recon-pill.is-active,
html[data-theme="dark"] .recon-candidate-pill.is-settled,
html[data-theme="dark"] .docs-status--ready,
html[data-theme="dark"] .review-confidence--high {
  background: #184033;
  border-color: #2f735d;
  color: #9be4c5;
}

html[data-theme="dark"] .invoice-state-pill.is-partially_reconciled,
html[data-theme="dark"] .revenue-state--warning,
html[data-theme="dark"] .revenue-transaction-match--partial,
html[data-theme="dark"] .recon-candidate-pill.is-partial,
html[data-theme="dark"] .recon-weight-sum,
html[data-theme="dark"] .review-confidence--mid {
  background: #463a1d;
  border-color: #7d6933;
  color: #f0d383;
}

html[data-theme="dark"] .invoice-state-pill.is-missing_invoice,
html[data-theme="dark"] .invoice-state-pill.is-unlinked,
html[data-theme="dark"] .revenue-state--danger,
html[data-theme="dark"] .review-confidence--low {
  background: #46252e;
  border-color: #7b3f4d;
  color: #f1acb9;
}

html[data-theme="dark"] .transaction-reporting-badge,
html[data-theme="dark"] .revenue-pill,
html[data-theme="dark"] .revenue-pill--booking,
html[data-theme="dark"] .docs-status--active,
html[data-theme="dark"] .review-chip--manual,
html[data-theme="dark"] .recon-match-badge.is-auto {
  background: #1d3b5a;
  border-color: #356691;
  color: #9fcaff;
}

html[data-theme="dark"] .transaction-provenance-badge.is-ai,
html[data-theme="dark"] .transaction-unit-summary.is-ai,
html[data-theme="dark"] .transaction-unit-stack.is-ai .transaction-unit-stack__badge,
html[data-theme="dark"] .revenue-pill--stripe,
html[data-theme="dark"] .review-chip--verified {
  background: #392d53;
  border-color: #665083;
  color: #d3bafb;
}

html[data-theme="dark"] .transaction-provenance-badge.is-manual,
html[data-theme="dark"] .transaction-unit-summary.is-manual,
html[data-theme="dark"] .transaction-unit-stack.is-manual .transaction-unit-stack__badge,
html[data-theme="dark"] .recon-match-badge.is-manual {
  background: #49341f;
  border-color: #765733;
  color: #efc18f;
}

html[data-theme="dark"] .transaction-provenance-badge.is-template,
html[data-theme="dark"] .transaction-unit-summary.is-template,
html[data-theme="dark"] .transaction-unit-stack.is-template .transaction-unit-stack__badge,
html[data-theme="dark"] .revenue-pill--direct {
  background: #183d36;
  border-color: #326c60;
  color: #9cddd0;
}

html[data-theme="dark"] .transaction-provenance-badge.is-payout,
html[data-theme="dark"] .transaction-unit-summary.is-payout,
html[data-theme="dark"] .transaction-unit-stack.is-payout .transaction-unit-stack__badge {
  background: #153d50;
  border-color: #2f708c;
  color: #9edbef;
}

html[data-theme="dark"] .transaction-provenance-badge.is-rule,
html[data-theme="dark"] .transaction-provenance-badge.is-auto,
html[data-theme="dark"] .transaction-unit-summary.is-rule,
html[data-theme="dark"] .transaction-unit-summary.is-auto,
html[data-theme="dark"] .transaction-unit-stack.is-rule .transaction-unit-stack__badge,
html[data-theme="dark"] .transaction-unit-stack.is-auto .transaction-unit-stack__badge {
  background: #1d3b5a;
  border-color: #356691;
  color: #9fcaff;
}

html[data-theme="dark"] .transaction-provenance-badge.is-mixed,
html[data-theme="dark"] .transaction-unit-summary.is-mixed,
html[data-theme="dark"] .transaction-unit-stack.is-mixed .transaction-unit-stack__badge {
  background: #463126;
  border-color: #754e3a;
  color: #f0bda0;
}

html[data-theme="dark"] .transaction-provenance-badge.is-unknown,
html[data-theme="dark"] .transaction-provenance-badge.is-none,
html[data-theme="dark"] .transaction-unit-summary.is-unknown,
html[data-theme="dark"] .transaction-unit-summary.is-none,
html[data-theme="dark"] .transaction-unit-stack.is-unknown .transaction-unit-stack__badge,
html[data-theme="dark"] .transaction-unit-stack.is-none .transaction-unit-stack__badge {
  background: #26364a;
  border-color: #3b4f69;
  color: #c7d3e2;
}

/* Dashboard labels and miscellaneous custom panels */
html[data-theme="dark"] .start-filter-help,
html[data-theme="dark"] .start-filter-label,
html[data-theme="dark"] .start-filter-menu-empty,
html[data-theme="dark"] .transactions-filter-menu-empty,
html[data-theme="dark"] .exports-history__meta,
html[data-theme="dark"] .empty-state {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .transactions-filter-trigger,
html[data-theme="dark"] .transactions-filter-date,
html[data-theme="dark"] .transactions-filter-select {
  background-color: var(--theme-surface-soft);
  border-color: var(--theme-border-strong);
  color: var(--theme-text-soft);
}

html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .exports-history__item {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

/* Standalone authentication, admin, and PDF viewer pages */
html[data-theme="dark"] .auth-form .card,
html[data-theme="dark"] .login-container,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .files-grid,
html[data-theme="dark"] .file-info {
  background: var(--theme-surface);
  border-color: var(--theme-border);
  color: var(--theme-text);
  box-shadow: 0 0.5rem 1.5rem var(--theme-shadow);
}

html[data-theme="dark"] .custom-dropdown .btn,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] input[type="password"] {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border-strong);
  color: var(--theme-text);
}

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

html[data-theme="dark"] .login-title,
html[data-theme="dark"] .file-name,
html[data-theme="dark"] .files-header {
  color: var(--theme-text);
}

html[data-theme="dark"] .legal-links,
html[data-theme="dark"] .signup-link,
html[data-theme="dark"] .login-container label,
html[data-theme="dark"] .log-dir,
html[data-theme="dark"] .selection-tools,
html[data-theme="dark"] .file-details,
html[data-theme="dark"] .file-size,
html[data-theme="dark"] .no-files,
html[data-theme="dark"] .page-ellipsis {
  color: var(--theme-text-muted);
}

html[data-theme="dark"] .header {
  background: linear-gradient(135deg, #172335 0%, #203a59 100%);
  box-shadow: 0 0.25rem 0.8rem var(--theme-shadow);
}

html[data-theme="dark"] .login-btn,
html[data-theme="dark"] .toolbar-btn {
  background: linear-gradient(135deg, #3d7edb 0%, #285d9b 100%);
  color: #ffffff;
}

html[data-theme="dark"] .file-icon,
html[data-theme="dark"] .selection-tools button {
  color: var(--theme-accent);
}

html[data-theme="dark"] .files-header,
html[data-theme="dark"] .pagination {
  background: var(--theme-surface-soft);
  border-color: var(--theme-border);
}

html[data-theme="dark"] .file-item {
  border-color: var(--theme-border);
}

html[data-theme="dark"] .file-item:hover {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .toolbar-btn.secondary,
html[data-theme="dark"] .view-link {
  background: var(--theme-accent-soft);
  border-color: var(--theme-border-strong);
  color: var(--theme-accent);
}

html[data-theme="dark"] .toolbar-btn.secondary:hover,
html[data-theme="dark"] .view-link:hover {
  background: var(--theme-surface-hover);
}

html[data-theme="dark"] .flash-error,
html[data-theme="dark"] .flash-message.error {
  background: #4a232d;
  border-color: #754052;
  color: #ffb6c5;
}

html[data-theme="dark"] .flash-success,
html[data-theme="dark"] .flash-message.success {
  background: #193d33;
  border-color: #326b5c;
  color: #9ce0ca;
}

html[data-theme="dark"] .flash-info,
html[data-theme="dark"] .flash-message.info {
  background: #1d3b5a;
  border-color: #356691;
  color: #a9d1ff;
}

html[data-theme="dark"] .canvas-wrap,
html[data-theme="dark"] body.compact .canvas-wrap,
html[data-theme="dark"] body.thumbnail .canvas-wrap,
html[data-theme="dark"] body.all-pages .canvas-wrap,
html[data-theme="dark"] body.preview .canvas-wrap {
  background: var(--theme-surface-soft);
}

html[data-theme="dark"] #pageInfo {
  color: var(--theme-text-soft);
}

@media (max-width: 767.98px) {
  .main-navbar.sticky-top .navbar {
    min-height: 4rem;
    padding-right: max(0.65rem, env(safe-area-inset-right)) !important;
    padding-left: max(0.65rem, env(safe-area-inset-left)) !important;
  }

  .main-navbar.sticky-top .navbar > .w-100 {
    display: none;
  }

  .main-navbar.sticky-top .nav {
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
  }

  .topbar-account {
    order: 1;
  }

  .topbar-theme {
    order: 2;
    height: 4rem;
    padding: 0;
    border-left: 0;
  }

  .topbar-menu-toggle {
    order: 3;
  }

  .topbar-account .topbar-brand,
  .topbar-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    padding: 0 !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 0.8rem !important;
    background: var(--theme-surface-soft);
    color: var(--theme-text-soft);
  }

  .topbar-account .topbar-brand:hover,
  .topbar-account .topbar-brand:focus,
  .topbar-menu-toggle:hover,
  .topbar-menu-toggle:focus {
    background: var(--theme-surface-hover);
    border-color: var(--theme-border-strong) !important;
    color: var(--theme-text);
    box-shadow: none;
  }

  .topbar-account .topbar-brand span,
  .topbar-account .topbar-brand::after {
    display: none !important;
  }

  .topbar-account .dropdown-menu {
    right: auto;
    left: 0;
    margin-top: 0.35rem;
  }

  .topbar-brand__logo {
    width: 2rem;
    height: 2rem;
  }

  .topbar-menu-toggle .material-icons {
    font-size: 1.45rem;
    line-height: 1;
  }

  .theme-toggle {
    width: 4.15rem;
    height: 2.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle__thumb,
  .theme-toggle__icon {
    transition: none;
  }
}
