/* DMT Finance Control — Platform V4 global visual layer
   Loaded last in authenticated ui-v3 pages.
   Goal: flat graphite/blue workspace without legacy violet gradients/glows.
*/

body.ui-v3 {
  --v4-bg-main: #08111b;
  --v4-bg-side: #0a141e;
  --v4-surface-1: #111b26;
  --v4-surface-2: #15212d;
  --v4-surface-3: #182633;
  --v4-surface-soft: #0f1923;
  --v4-text: #e7edf5;
  --v4-text-strong: #f3f7fb;
  --v4-muted: #94a4b6;
  --v4-border: rgba(148, 163, 184, 0.14);
  --v4-border-strong: rgba(123, 158, 190, 0.26);
  --v4-primary: #4e84ad;
  --v4-primary-hover: #5b91b8;
  --v4-primary-soft: rgba(78, 132, 173, 0.18);
  --v4-primary-border: rgba(111, 167, 210, 0.28);
  --v4-success: #3f8f73;
  --v4-warning: #b98942;
  --v4-danger: #a65353;
  --v4-header: rgba(9, 18, 28, 0.96);
  --v4-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  --v4-shadow-strong: 0 16px 36px rgba(0, 0, 0, 0.24);

  /* Replace legacy v3/style tokens so old components inherit V4 automatically. */
  --v3-bg-main: var(--v4-bg-main);
  --v3-bg-side: var(--v4-bg-side);
  --v3-bg-card: var(--v4-surface-1);
  --v3-bg-card-soft: var(--v4-surface-2);
  --v3-bg-card-strong: var(--v4-surface-3);
  --v3-text-main: var(--v4-text);
  --v3-text-muted: var(--v4-muted);
  --v3-border: var(--v4-border-strong);
  --v3-border-soft: var(--v4-border);
  --v3-accent: var(--v4-primary);
  --v3-accent-2: var(--v4-primary-hover);
  --bg-color: var(--v4-bg-main);
  --card-bg: var(--v4-surface-1);
  --card-bg-strong: var(--v4-surface-2);
  --text-color: var(--v4-text);
  --muted-text: var(--v4-muted);
  --border-color: var(--v4-border);
  --accent-color: var(--v4-primary);
  --accent-gradient: var(--v4-primary);

  background: var(--v4-bg-main) !important;
  color: var(--v4-text);
}

:root:not([data-theme="dark"]) body.ui-v3 {
  --v4-bg-main: #f1f3f6;
  --v4-bg-side: #ffffff;
  --v4-surface-1: #ffffff;
  --v4-surface-2: #f7f8fa;
  --v4-surface-3: #eceff3;
  --v4-surface-soft: #fafbfc;
  --v4-text: #273142;
  --v4-text-strong: #111827;
  --v4-muted: #5f6b7c;
  --v4-border: #d4dae3;
  --v4-border-strong: #bac4d0;
  --v4-primary: #6558d9;
  --v4-primary-hover: #5548c8;
  --v4-primary-soft: rgba(101, 88, 217, 0.10);
  --v4-primary-border: rgba(101, 88, 217, 0.30);
  --v4-success: #287a58;
  --v4-warning: #94611e;
  --v4-danger: #a13f4b;
  --v4-header: rgba(255, 255, 255, 0.98);
  --v4-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 7px 18px rgba(16, 24, 40, 0.045);
  --v4-shadow-strong: 0 10px 28px rgba(16, 24, 40, 0.10);

  --bg-color: var(--v4-bg-main);
  --card-bg: var(--v4-surface-1);
  --card-bg-strong: var(--v4-surface-2);
  --text-color: var(--v4-text);
  --muted-text: var(--v4-muted);
  --border-color: var(--v4-border);
  --accent-color: var(--v4-primary);
  --accent-gradient: var(--v4-primary);

  background: var(--v4-bg-main) !important;
  color: var(--v4-text);
}

/* ---------- Base workspace ---------- */

body.ui-v3 .app-main,
body.ui-v3 .app-content {
  background: transparent !important;
}

body.ui-v3 .app-content::before {
  content: none !important;
  display: none !important;
  background: none !important;
}

body.ui-v3 h1,
body.ui-v3 h2,
body.ui-v3 h3,
body.ui-v3 h4,
body.ui-v3 h5,
body.ui-v3 h6 {
  color: var(--v4-text-strong);
}

body.ui-v3 .text-muted,
body.ui-v3 .form-text {
  color: var(--v4-muted) !important;
}

/* ---------- Main surfaces ---------- */

body.ui-v3 .panel,
body.ui-v3 .card,
body.ui-v3 .dashboard-card,
body.ui-v3 .summary-card,
body.ui-v3 .usage-card,
body.ui-v3 .ai-metric,
body.ui-v3 .import-kpi-card,
body.ui-v3 .report-kpi-card {
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow) !important;
  transform: none !important;
}

body.ui-v3 .panel:hover,
body.ui-v3 .card:hover,
body.ui-v3 .dashboard-card:hover,
body.ui-v3 .summary-card:hover,
body.ui-v3 .usage-card:hover,
body.ui-v3 .ai-metric:hover,
body.ui-v3 .import-kpi-card:hover,
body.ui-v3 .report-kpi-card:hover {
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow) !important;
  transform: none !important;
}

body.ui-v3 .panel::before,
body.ui-v3 .panel::after,
body.ui-v3 .summary-card::before,
body.ui-v3 .summary-card::after,
body.ui-v3 .usage-card::before,
body.ui-v3 .usage-card::after,
body.ui-v3 .ai-metric::before,
body.ui-v3 .ai-metric::after,
body.ui-v3 .import-kpi-card::before,
body.ui-v3 .import-kpi-card::after {
  content: none !important;
  display: none !important;
  background: none !important;
}

/* ---------- Sidebar / navigation ---------- */

body.ui-v3 .sidebar {
  background: var(--v4-bg-side) !important;
  border-right-color: var(--v4-border) !important;
  box-shadow: none !important;
}

body.ui-v3 .sidebar .logo {
  color: var(--v4-text-strong) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-soft) !important;
  box-shadow: none !important;
}

body.ui-v3 .sidebar .logo i {
  color: #b9d4e8 !important;
  background: var(--v4-primary-soft) !important;
}

body.ui-v3 .sidebar-rail-toggle {
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-soft) !important;
  color: var(--v4-text) !important;
  box-shadow: none !important;
}

body.ui-v3 .sidebar-rail-toggle:hover {
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-2) !important;
}

body.ui-v3 .sidebar-nav a {
  color: var(--v4-muted) !important;
  border-color: transparent !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.ui-v3 .sidebar-nav a i {
  color: #b8c8d6 !important;
  background: rgba(148, 163, 184, 0.06) !important;
}

body.ui-v3 .sidebar-nav a:hover {
  color: var(--v4-text-strong) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-2) !important;
  transform: none !important;
}

body.ui-v3 .sidebar-nav a.active,
body.ui-v3 .sidebar-nav a[aria-current="page"] {
  color: #dfeef9 !important;
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-primary-soft) !important;
  box-shadow: none !important;
  transform: none !important;
}

body.ui-v3 .sidebar-nav a.active i,
body.ui-v3 .sidebar-nav a[aria-current="page"] i {
  color: #d9edf9 !important;
  background: rgba(78, 132, 173, 0.22) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a.active,
:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a[aria-current="page"] {
  color: #2e5e80 !important;
}

/* ---------- Header ---------- */

body.ui-v3 .app-header {
  color: var(--v4-text);
  border-bottom-color: var(--v4-border) !important;
  background: var(--v4-header) !important;
  box-shadow: none !important;
  backdrop-filter: blur(12px);
}

body.ui-v3 .header-left h1 {
  color: var(--v4-text-strong) !important;
}

body.ui-v3 .nav-compact .dropdown > button,
body.ui-v3 .nav-compact [data-currency-select],
body.ui-v3 .nav-compact #header-container .btn,
body.ui-v3 .nav-compact #header-container .form-select,
body.ui-v3 .nav-compact .btn-theme {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-soft) !important;
  box-shadow: none !important;
}

body.ui-v3 .nav-compact .dropdown > button:hover,
body.ui-v3 .nav-compact [data-currency-select]:hover,
body.ui-v3 .nav-compact #header-container .btn:hover,
body.ui-v3 .nav-compact #header-container .form-select:hover,
body.ui-v3 .nav-compact .btn-theme:hover {
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-2) !important;
  transform: none !important;
}

/* ---------- Forms ---------- */

body.ui-v3 .form-control,
body.ui-v3 .form-select,
body.ui-v3 .input-group-text,
body.ui-v3 textarea,
body.ui-v3 input[type="text"],
body.ui-v3 input[type="number"],
body.ui-v3 input[type="date"],
body.ui-v3 input[type="datetime-local"],
body.ui-v3 input[type="email"],
body.ui-v3 input[type="search"] {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background-color: var(--v4-surface-soft) !important;
  box-shadow: none !important;
}

body.ui-v3 .form-control::placeholder,
body.ui-v3 textarea::placeholder,
body.ui-v3 input::placeholder {
  color: var(--v4-muted) !important;
  opacity: 0.75;
}

body.ui-v3 .form-control:focus,
body.ui-v3 .form-select:focus,
body.ui-v3 textarea:focus,
body.ui-v3 input:focus {
  border-color: rgba(111, 167, 210, 0.58) !important;
  box-shadow: 0 0 0 0.18rem rgba(70, 126, 169, 0.12) !important;
  outline: none !important;
}

body.ui-v3 .form-control:disabled,
body.ui-v3 .form-select:disabled,
body.ui-v3 input:disabled,
body.ui-v3 textarea:disabled {
  color: var(--v4-muted) !important;
  background: var(--v4-surface-2) !important;
  opacity: 0.68;
}

body.ui-v3 .form-select option {
  color: var(--v4-text);
  background: var(--v4-surface-1);
}

body.ui-v3 .form-check-input {
  border-color: var(--v4-border-strong) !important;
  background-color: var(--v4-surface-soft);
  box-shadow: none !important;
}

body.ui-v3 .form-check-input:checked {
  border-color: var(--v4-primary) !important;
  background-color: var(--v4-primary) !important;
}

body.ui-v3 .form-check-input:focus {
  border-color: var(--v4-primary) !important;
  box-shadow: 0 0 0 0.18rem rgba(70, 126, 169, 0.12) !important;
}

/* ---------- Buttons ---------- */

body.ui-v3 .btn {
  box-shadow: none !important;
}

body.ui-v3 .btn-primary {
  color: #f7fbff !important;
  border-color: #5d92b9 !important;
  background: var(--v4-primary) !important;
}

body.ui-v3 .btn-primary:hover,
body.ui-v3 .btn-primary:focus,
body.ui-v3 .btn-primary:active {
  color: #ffffff !important;
  border-color: #6aa0c5 !important;
  background: var(--v4-primary-hover) !important;
  box-shadow: 0 0 0 0.18rem rgba(88, 145, 185, 0.15) !important;
}

body.ui-v3 .btn-outline-primary {
  color: #84b7dc !important;
  border-color: #527fa2 !important;
  background: transparent !important;
}

body.ui-v3 .btn-outline-primary:hover,
body.ui-v3 .btn-outline-primary:focus {
  color: #f4f9fd !important;
  border-color: #5c8fb4 !important;
  background: #416f91 !important;
}

body.ui-v3 .btn-secondary,
body.ui-v3 .btn-outline-secondary {
  color: var(--v4-text) !important;
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-2) !important;
}

body.ui-v3 .btn-secondary:hover,
body.ui-v3 .btn-outline-secondary:hover {
  color: var(--v4-text-strong) !important;
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-3) !important;
}

body.ui-v3 .btn-success {
  color: #f7fffb !important;
  border-color: #4b9d80 !important;
  background: var(--v4-success) !important;
}

body.ui-v3 .btn-warning {
  color: #fffaf0 !important;
  border-color: #c39148 !important;
  background: var(--v4-warning) !important;
}

body.ui-v3 .btn-danger {
  color: #fff7f7 !important;
  border-color: #b85e5e !important;
  background: var(--v4-danger) !important;
}

/* ---------- Dropdowns / popovers ---------- */

body.ui-v3 .dropdown-menu,
body.ui-v3 .popover-glass,
body.ui-v3 .app-header .dropdown-menu,
body.ui-v3 #header-container .dropdown-menu {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow-strong) !important;
  backdrop-filter: blur(14px);
}

body.ui-v3 .dropdown-menu .dropdown-item,
body.ui-v3 .popover-item,
body.ui-v3 .app-header .dropdown-menu .dropdown-item,
body.ui-v3 #header-container .dropdown-menu .dropdown-item {
  color: var(--v4-text) !important;
  background: transparent !important;
}

body.ui-v3 .dropdown-menu .dropdown-item:hover,
body.ui-v3 .dropdown-menu .dropdown-item:focus,
body.ui-v3 .popover-item:hover {
  color: var(--v4-text-strong) !important;
  background: var(--v4-surface-2) !important;
}

body.ui-v3 .dropdown-menu .dropdown-item.active,
body.ui-v3 .dropdown-menu .dropdown-item:active,
body.ui-v3 .popover-item.active {
  color: #eef8ff !important;
  background: var(--v4-primary) !important;
}

body.ui-v3 .account-popover-chip {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-2) !important;
}

/* ---------- Tables ---------- */

body.ui-v3 .table {
  --bs-table-bg: transparent !important;
  --bs-table-color: var(--v4-text) !important;
  --bs-table-border-color: var(--v4-border) !important;
  --bs-table-striped-bg: var(--v4-surface-2) !important;
  --bs-table-striped-color: var(--v4-text) !important;
  --bs-table-hover-bg: var(--v4-surface-3) !important;
  --bs-table-hover-color: var(--v4-text-strong) !important;
  color: var(--v4-text) !important;
  background: transparent !important;
}

body.ui-v3 .table > :not(caption) > * > * {
  color: var(--v4-text);
  border-color: var(--v4-border) !important;
  background-image: none !important;
  box-shadow: none !important;
}

body.ui-v3 .table thead th {
  color: #b8c7d4 !important;
  background: var(--v4-surface-soft) !important;
  border-bottom-color: var(--v4-border-strong) !important;
}

body.ui-v3 .table tbody tr > * {
  background: var(--v4-surface-1) !important;
}

body.ui-v3 .table tbody tr:hover > * {
  background: var(--v4-surface-2) !important;
}

body.ui-v3 .table-responsive {
  border-color: var(--v4-border) !important;
}

/* ---------- Modals / overlays ---------- */

body.ui-v3 .modal-content,
body.ui-v3 .offcanvas {
  color: var(--v4-text) !important;
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow-strong) !important;
}

body.ui-v3 .modal-header,
body.ui-v3 .modal-footer,
body.ui-v3 .offcanvas-header {
  border-color: var(--v4-border) !important;
}

body.ui-v3 .modal-body .form-control,
body.ui-v3 .modal-body .form-select {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-soft) !important;
}

body.ui-v3 .modal-body .form-control:focus,
body.ui-v3 .modal-body .form-select:focus {
  border-color: rgba(111, 167, 210, 0.58) !important;
  box-shadow: 0 0 0 0.18rem rgba(70, 126, 169, 0.12) !important;
}

:root[data-theme="dark"] body.ui-v3 .btn-close {
  filter: invert(1) grayscale(1) brightness(1.8);
  opacity: 0.7;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-close {
  filter: none;
}

/* ---------- Generic states ---------- */

body.ui-v3 .badge.bg-primary,
body.ui-v3 .text-bg-primary,
body.ui-v3 .progress-bar {
  background-color: var(--v4-primary) !important;
}

body.ui-v3 .nav-pills .nav-link.active,
body.ui-v3 .list-group-item.active {
  color: #f5fbff !important;
  border-color: var(--v4-primary) !important;
  background: var(--v4-primary) !important;
}

body.ui-v3 .alert {
  border-color: var(--v4-border) !important;
  box-shadow: none !important;
}

/* ---------- Reports: remove legacy violet decoration ---------- */

body.ui-v3 .report-command-deck {
  border-color: var(--v4-border) !important;
}

body.ui-v3 .report-command-field .form-select:focus,
body.ui-v3 .report-command-field .form-control:focus {
  border-color: rgba(111, 167, 210, 0.58) !important;
  box-shadow: 0 0 0 0.18rem rgba(70, 126, 169, 0.12) !important;
}

body.ui-v3 #report-export-report {
  color: #f7fbff !important;
  border-color: #5d92b9 !important;
  background: var(--v4-primary) !important;
}

body.ui-v3 .report-kpi-card::after {
  background: var(--v4-primary) !important;
}

body.ui-v3 .report-kpi-card--income::after {
  background: #3f8f73 !important;
}

body.ui-v3 .report-kpi-card--expense::after {
  background: #a65353 !important;
}

body.ui-v3 .report-kpi-card--avg::after {
  background: #b98942 !important;
}

body.ui-v3 .report-kpi-card--net h3 {
  color: #9fc4df !important;
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
}

body.ui-v3 .report-focus-card {
  border-color: var(--v4-border) !important;
  box-shadow: var(--v4-shadow) !important;
}

body.ui-v3 .report-focus-frame,
body.ui-v3 .report-chart-wrap,
body.ui-v3 .report-category-cards-wrap,
body.ui-v3 .report-category-card,
body.ui-v3 .report-category-detail,
body.ui-v3 .report-gap-card {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-2) !important;
  box-shadow: none !important;
}

body.ui-v3 .report-chart-wrap::after {
  content: none !important;
  display: none !important;
}

body.ui-v3 .report-category-card:hover,
body.ui-v3 .report-category-card.is-active {
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-surface-3) !important;
  box-shadow: none !important;
  transform: none !important;
}

body.ui-v3 .report-category-detail__name {
  color: #b8d5e9 !important;
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-primary-soft) !important;
}

/* ---------- Import wizard ---------- */

body.ui-v3[data-page="import"] .import-stepper,
body.ui-v3[data-page="import"] .import-step,
body.ui-v3[data-page="import"] .import-preview-card,
body.ui-v3[data-page="import"] .import-confirm-card,
body.ui-v3[data-page="import"] .import-result-card,
body.ui-v3[data-page="import"] .source-option-card {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: none !important;
}

body.ui-v3[data-page="import"] .import-stepper__progress,
body.ui-v3[data-page="import"] .import-step-index {
  color: #b9d8ed !important;
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-primary-soft) !important;
}

body.ui-v3[data-page="import"] .import-step.is-active {
  border-color: var(--v4-primary-border) !important;
  box-shadow: 0 0 0 1px rgba(78, 132, 173, 0.08) !important;
}

body.ui-v3[data-page="import"] .source-option-card:hover,
body.ui-v3[data-page="import"] .source-option-card.is-selected {
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-primary-soft) !important;
  transform: none !important;
}

body.ui-v3[data-page="import"] #mapping-section [data-map-block] {
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-2) !important;
}

/* ---------- Admin support ---------- */

body.ui-v3[data-page="admin-support"] .admin-support-counter,
body.ui-v3[data-page="admin-support"] .admin-support-panel,
body.ui-v3[data-page="admin-support"] .admin-ticket-card,
body.ui-v3[data-page="admin-support"] .admin-support-card,
body.ui-v3[data-page="admin-support"] .admin-thread-bubble,
body.ui-v3[data-page="admin-support"] .support-attachment-card {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: none !important;
}

body.ui-v3[data-page="admin-support"] .admin-ticket-card:hover,
body.ui-v3[data-page="admin-support"] .admin-ticket-card.is-active {
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-surface-2) !important;
  box-shadow: none !important;
  transform: none !important;
}

body.ui-v3[data-page="admin-support"] .admin-thread-message--admin .admin-thread-bubble {
  border-color: var(--v4-primary-border) !important;
  background: #162638 !important;
}

body.ui-v3[data-page="admin-support"] .support-attachment-card:hover {
  border-color: var(--v4-primary-border) !important;
  box-shadow: none !important;
}

body.ui-v3[data-page="admin-support"] .support-attachment-icon {
  color: #8fc0e1 !important;
  background: var(--v4-primary-soft) !important;
}

/* ---------- Upgrade / Ideas & Support page ---------- */

body.ui-v3[data-page="upgrade"] .support-stat,
body.ui-v3[data-page="upgrade"] .upgrade-topic-card,
body.ui-v3[data-page="upgrade"] .upgrade-request-card,
body.ui-v3[data-page="upgrade"] .support-drawer {
  color: var(--v4-text) !important;
  border-color: var(--v4-border) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow) !important;
}

body.ui-v3[data-page="upgrade"] .support-launcher {
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-surface-2) !important;
  box-shadow: var(--v4-shadow-strong) !important;
}

body.ui-v3[data-page="upgrade"] .support-launcher::before {
  border-color: var(--v4-primary-border) !important;
}

body.ui-v3[data-page="upgrade"] .support-launcher.is-open,
body.ui-v3[data-page="upgrade"] .support-launcher.has-unread {
  box-shadow: 0 0 0 4px rgba(78, 132, 173, 0.12), var(--v4-shadow-strong) !important;
}

body.ui-v3[data-page="upgrade"] .support-thread-item:hover,
body.ui-v3[data-page="upgrade"] .support-thread-item.is-active {
  border-color: var(--v4-primary-border) !important;
  background: var(--v4-primary-soft) !important;
}

/* ---------- Data-source custom modal surfaces ---------- */

body.ui-v3 .data-source-modal__content,
body.ui-v3 .import-rows-modal__dialog {
  color: var(--v4-text) !important;
  border-color: var(--v4-border-strong) !important;
  background: var(--v4-surface-1) !important;
  box-shadow: var(--v4-shadow-strong) !important;
}

/* ---------- Scrollbars ---------- */

body.ui-v3,
body.ui-v3 .sidebar,
body.ui-v3 .table-responsive,
body.ui-v3 [class*="scroll"] {
  scrollbar-color: rgba(123, 158, 190, 0.34) transparent;
}

body.ui-v3 ::-webkit-scrollbar-thumb {
  background-color: rgba(123, 158, 190, 0.34);
  border-radius: 999px;
}

body.ui-v3 ::-webkit-scrollbar-thumb:hover {
  background-color: rgba(123, 158, 190, 0.5);
}

body.ui-v3 ::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Mobile ---------- */

@media (max-width: 992px) {
  body.ui-v3 .mobile-nav {
    color: var(--v4-text) !important;
    border-right-color: var(--v4-border) !important;
    background: var(--v4-bg-side) !important;
    box-shadow: var(--v4-shadow-strong) !important;
  }

  body.ui-v3 .app-header {
    background: var(--v4-header) !important;
  }
}

/* V4.7.5 control-event emphasis */
.calendar-control-shortcut {
  border-style: dashed;
  font-weight: 600;
}

.calendar-day__switcher--alert {
  background: #f59e0b;
  border-color: #f59e0b;
}

.calendar-day__main-badge--alert {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #b45309;
  font-weight: 800;
}

:root[data-theme="dark"] .calendar-day__main-badge--alert,
body.theme-dark .calendar-day__main-badge--alert {
  color: #fbbf24;
}


/* DMT unified controls v4.2 */
body.ui-v3 .btn-primary {
  background: var(--accent-gradient) !important;
  border-color: transparent !important;
  box-shadow: 0 8px 22px rgba(109,93,252,.20);
}

body.ui-v3 .btn-primary:hover,
body.ui-v3 .btn-primary:focus,
body.ui-v3 .btn-primary:active {
  background: var(--accent-gradient) !important;
  border-color: transparent !important;
  transform: none !important;
  filter: brightness(1.035);
}

body.ui-v3 .btn-outline-primary,
body.ui-v3 .form-check-input:checked {
  border-color: var(--ui-primary) !important;
}

body.ui-v3 .btn-outline-primary {
  color: var(--ui-primary);
  background: var(--ui-primary-soft);
}

body.ui-v3 .btn-outline-primary:hover,
body.ui-v3 .btn-outline-primary:focus {
  color: var(--ui-primary);
  background: color-mix(in srgb, var(--ui-primary) 14%, transparent);
}

body.ui-v3 .form-check-input:checked {
  background-color: var(--ui-primary);
}

body.ui-v3 .btn:focus-visible,
body.ui-v3 .btn-theme:focus-visible,
body.ui-v3 .form-control:focus,
body.ui-v3 .form-select:focus {
  box-shadow: 0 0 0 .2rem var(--ui-focus) !important;
}

body.ui-v3 .account-kind-switch .btn-check:checked + .btn,
body.ui-v3 .quick-period .btn.active,
body.ui-v3 .settings-tab-button.is-active {
  border-color: var(--ui-primary) !important;
  color: var(--ui-primary) !important;
  background: var(--ui-primary-soft) !important;
}


/* ---------- Light theme contrast pass ---------- */

:root:not([data-theme="dark"]) body.ui-v3 .sidebar {
  border-right-color: #c7d0dc !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-group-title {
  color: #667085 !important;
  font-weight: 750 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a {
  color: #526079 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a i {
  color: #66758b !important;
  background: #eef2f7 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a:hover {
  color: #172033 !important;
  background: #edf1f7 !important;
  border-color: #c3cedb !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a.active,
:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a[aria-current="page"] {
  color: #3f31c8 !important;
  background: rgba(103, 87, 232, 0.13) !important;
  border-color: rgba(103, 87, 232, 0.34) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a.active i,
:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a[aria-current="page"] i {
  color: #4d3ed0 !important;
  background: rgba(103, 87, 232, 0.14) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .panel,
:root:not([data-theme="dark"]) body.ui-v3 .card,
:root:not([data-theme="dark"]) body.ui-v3 .dashboard-card,
:root:not([data-theme="dark"]) body.ui-v3 .summary-card,
:root:not([data-theme="dark"]) body.ui-v3 .usage-card,
:root:not([data-theme="dark"]) body.ui-v3 .ai-metric,
:root:not([data-theme="dark"]) body.ui-v3 .import-kpi-card,
:root:not([data-theme="dark"]) body.ui-v3 .report-kpi-card {
  border-color: #c8d2de !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.075) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .text-muted,
:root:not([data-theme="dark"]) body.ui-v3 .form-text,
:root:not([data-theme="dark"]) body.ui-v3 small.text-muted {
  color: #596a80 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control,
:root:not([data-theme="dark"]) body.ui-v3 .form-select,
:root:not([data-theme="dark"]) body.ui-v3 textarea {
  color: #172033 !important;
  background: #ffffff !important;
  border-color: #b9c5d3 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control::placeholder,
:root:not([data-theme="dark"]) body.ui-v3 textarea::placeholder {
  color: #8492a6 !important;
  opacity: 1 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control:focus,
:root:not([data-theme="dark"]) body.ui-v3 .form-select:focus,
:root:not([data-theme="dark"]) body.ui-v3 textarea:focus {
  border-color: #7667ea !important;
  box-shadow: 0 0 0 3px rgba(103, 87, 232, 0.14) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .table {
  --bs-table-border-color: #c8d2de !important;
  --bs-table-hover-bg: #eef2f7 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .table thead th {
  color: #344054 !important;
  background: #e8eef5 !important;
  border-bottom-color: #b8c4d2 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .table tbody td {
  color: #1d2939 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-secondary {
  color: #344054 !important;
  background: #ffffff !important;
  border-color: #b8c4d2 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-secondary:hover {
  color: #172033 !important;
  background: #edf1f6 !important;
  border-color: #98a8bb !important;
  transform: none !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-primary {
  color: #5747d8 !important;
  background: #ffffff !important;
  border-color: #7c6df0 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-primary:hover:not(:disabled) {
  color: #ffffff !important;
  background: #6757e8 !important;
  border-color: #6757e8 !important;
  transform: none !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-primary:disabled,
:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-secondary:disabled {
  color: #7b8798 !important;
  background: #f4f6f9 !important;
  border-color: #c5ced9 !important;
  opacity: 0.78 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .app-header {
  border-bottom-color: #c6d0dc !important;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03) !important;
}


/* ---------- Light theme polish v4.2.2 ---------- */

:root:not([data-theme="dark"]) body.ui-v3 {
  --ui-primary: #6558d9;
  --ui-primary-soft: rgba(101, 88, 217, .10);
  --ui-focus: rgba(101, 88, 217, .16);
}

/* Workspace */
:root:not([data-theme="dark"]) body.ui-v3,
:root:not([data-theme="dark"]) body.ui-v3 .app-main {
  background: #f1f3f6 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .app-content {
  background: transparent !important;
}

/* Header */
:root:not([data-theme="dark"]) body.ui-v3 .app-header {
  background: rgba(255, 255, 255, .98) !important;
  border-bottom: 1px solid #d4dae3 !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .025) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .header-left h1 {
  color: #111827 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .header-left p,
:root:not([data-theme="dark"]) body.ui-v3 .header-left .text-muted {
  color: #667085 !important;
}

/* Sidebar */
:root:not([data-theme="dark"]) body.ui-v3 .sidebar {
  background: #ffffff !important;
  border-right: 1px solid #d4dae3 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar .logo {
  background: #ffffff !important;
  border-color: #d4dae3 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-group-title {
  color: #697386 !important;
  font-weight: 750 !important;
  letter-spacing: .035em;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a {
  color: #526077 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a i {
  color: #667085 !important;
  background: #f1f3f6 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a:hover {
  color: #1f2937 !important;
  background: #f3f4f6 !important;
  border-color: #d4dae3 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a.active,
:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a[aria-current="page"] {
  color: #493dc2 !important;
  background: #f0edff !important;
  border-color: #d7d1ff !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a.active i,
:root:not([data-theme="dark"]) body.ui-v3 .sidebar-nav a[aria-current="page"] i {
  color: #5144cb !important;
  background: #e6e1ff !important;
}

/* Cards / panels */
:root:not([data-theme="dark"]) body.ui-v3 .panel,
:root:not([data-theme="dark"]) body.ui-v3 .card,
:root:not([data-theme="dark"]) body.ui-v3 .dashboard-card,
:root:not([data-theme="dark"]) body.ui-v3 .summary-card,
:root:not([data-theme="dark"]) body.ui-v3 .usage-card,
:root:not([data-theme="dark"]) body.ui-v3 .ai-metric,
:root:not([data-theme="dark"]) body.ui-v3 .import-kpi-card,
:root:not([data-theme="dark"]) body.ui-v3 .report-kpi-card {
  background: #ffffff !important;
  border-color: #d4dae3 !important;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, .035),
    0 6px 18px rgba(16, 24, 40, .035) !important;
}

/* Typography */
:root:not([data-theme="dark"]) body.ui-v3 h1,
:root:not([data-theme="dark"]) body.ui-v3 h2,
:root:not([data-theme="dark"]) body.ui-v3 h3,
:root:not([data-theme="dark"]) body.ui-v3 h4,
:root:not([data-theme="dark"]) body.ui-v3 h5,
:root:not([data-theme="dark"]) body.ui-v3 h6 {
  color: #111827 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .text-muted,
:root:not([data-theme="dark"]) body.ui-v3 .form-text,
:root:not([data-theme="dark"]) body.ui-v3 small.text-muted {
  color: #667085 !important;
}

/* THIS is what was especially washed out */
:root:not([data-theme="dark"]) body.ui-v3 .form-label,
:root:not([data-theme="dark"]) body.ui-v3 .col-form-label,
:root:not([data-theme="dark"]) body.ui-v3 label:not(.form-check-label) {
  color: #475467 !important;
  font-weight: 650 !important;
}

/* Inputs */
:root:not([data-theme="dark"]) body.ui-v3 .form-control,
:root:not([data-theme="dark"]) body.ui-v3 .form-select,
:root:not([data-theme="dark"]) body.ui-v3 textarea,
:root:not([data-theme="dark"]) body.ui-v3 input[type="text"],
:root:not([data-theme="dark"]) body.ui-v3 input[type="number"],
:root:not([data-theme="dark"]) body.ui-v3 input[type="email"],
:root:not([data-theme="dark"]) body.ui-v3 input[type="search"] {
  color: #1f2937 !important;
  background: #ffffff !important;
  border-color: #c6ced9 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control:hover,
:root:not([data-theme="dark"]) body.ui-v3 .form-select:hover,
:root:not([data-theme="dark"]) body.ui-v3 textarea:hover {
  border-color: #aeb9c7 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control:focus,
:root:not([data-theme="dark"]) body.ui-v3 .form-select:focus,
:root:not([data-theme="dark"]) body.ui-v3 textarea:focus,
:root:not([data-theme="dark"]) body.ui-v3 input:focus {
  border-color: #7165de !important;
  box-shadow: 0 0 0 3px rgba(101, 88, 217, .12) !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .form-control::placeholder,
:root:not([data-theme="dark"]) body.ui-v3 textarea::placeholder,
:root:not([data-theme="dark"]) body.ui-v3 input::placeholder {
  color: #98a2b3 !important;
  opacity: 1 !important;
}

/* Header controls */
:root:not([data-theme="dark"]) body.ui-v3 .nav-compact .dropdown > button,
:root:not([data-theme="dark"]) body.ui-v3 .nav-compact [data-currency-select],
:root:not([data-theme="dark"]) body.ui-v3 .nav-compact #header-container .btn,
:root:not([data-theme="dark"]) body.ui-v3 .nav-compact #header-container .form-select,
:root:not([data-theme="dark"]) body.ui-v3 .nav-compact .btn-theme {
  color: #344054 !important;
  background: #ffffff !important;
  border-color: #d0d5dd !important;
}

/* Primary buttons - solid, no glow */
:root:not([data-theme="dark"]) body.ui-v3 .btn-primary {
  color: #ffffff !important;
  background: #6558d9 !important;
  border-color: #6558d9 !important;
  box-shadow: none !important;
  filter: none !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-primary:hover,
:root:not([data-theme="dark"]) body.ui-v3 .btn-primary:focus,
:root:not([data-theme="dark"]) body.ui-v3 .btn-primary:active {
  color: #ffffff !important;
  background: #5548c8 !important;
  border-color: #5548c8 !important;
  box-shadow: none !important;
  filter: none !important;
  transform: none !important;
}

/* Secondary buttons */
:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-secondary {
  color: #344054 !important;
  background: #ffffff !important;
  border-color: #c7ced8 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .btn-outline-secondary:hover {
  color: #1f2937 !important;
  background: #f4f5f7 !important;
  border-color: #aeb8c5 !important;
}

/* Tabs */
:root:not([data-theme="dark"]) body.ui-v3 .nav-tabs {
  border-bottom-color: #d4dae3 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .nav-tabs .nav-link {
  color: #566174 !important;
  background: transparent !important;
  border-color: transparent !important;
  font-weight: 600;
}

:root:not([data-theme="dark"]) body.ui-v3 .nav-tabs .nav-link:hover {
  color: #4035b3 !important;
  background: #f4f2ff !important;
  border-color: transparent !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .nav-tabs .nav-link.active {
  color: #342a9f !important;
  background: #ffffff !important;
  border-color: #d4dae3 #d4dae3 #ffffff !important;
}

/* Tables */
:root:not([data-theme="dark"]) body.ui-v3 .table thead th {
  color: #475467 !important;
  background: #edf1f5 !important;
  border-bottom-color: #c3ccd7 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .table tbody td {
  color: #273142 !important;
}

:root:not([data-theme="dark"]) body.ui-v3 .table tbody tr:hover > * {
  background: #f7f8fa !important;
}
