/* Shared dark interface palette for admin and tenant screens. */
html.dark-style,
html[data-tenant-theme="dark"] {
  color-scheme: dark;
  --bs-body-bg: #111827;
  --bs-body-color: #e5e7eb;
  --bs-secondary-color: #aeb9ca;
  --bs-tertiary-bg: #202d3d;
  --bs-border-color: #344255;
  --bs-emphasis-color: #f3f6fb;
  --sisforty-theme-page: #111827;
  --sisforty-theme-surface: #182230;
  --sisforty-theme-surface-alt: #202d3d;
  --sisforty-theme-hover: #24364d;
  --sisforty-theme-text: #e5e7eb;
  --sisforty-theme-text-soft: #dce6f5;
  --sisforty-theme-heading: #f3f6fb;
  --sisforty-theme-muted: #aeb9ca;
  --sisforty-theme-placeholder: #7f8da1;
  --sisforty-theme-border: #344255;
  --sisforty-theme-border-strong: #40516a;
  --sisforty-theme-accent: #a9c9ff;
  background: var(--sisforty-theme-page);
}

html.dark-style body,
html[data-tenant-theme="dark"] body {
  color: var(--sisforty-theme-text);
  background: var(--sisforty-theme-page);
}

html.dark-style body :is(h1,h2,h3,h4,h5,h6,.text-heading,.text-dark,.page-title),
html[data-tenant-theme="dark"] body :is(h1,h2,h3,h4,h5,h6,.text-heading,.text-dark,.page-title) {
  color: var(--sisforty-theme-heading) !important;
}
html.dark-style body .text-dark,
html[data-tenant-theme="dark"] body .text-dark { color: var(--sisforty-theme-text-soft) !important; }

html.dark-style body :is(p,label,small,.text-muted,.text-body,.form-label),
html[data-tenant-theme="dark"] body :is(p,label,small,.text-muted,.text-body,.form-label) {
  color: var(--sisforty-theme-muted);
}

html.dark-style body :is(.layout-navbar,.layout-menu,.menu-vertical,.menu-horizontal,.content-footer,.footer),
html[data-tenant-theme="dark"] body :is(.layout-navbar,.layout-menu,.menu-vertical,.menu-horizontal,.content-footer,.footer) {
  color: var(--sisforty-theme-text);
  background-color: var(--sisforty-theme-surface) !important;
  border-color: var(--sisforty-theme-border) !important;
}

html.dark-style body :is(.card,.card-header,.card-footer,.accordion-item,.list-group-item,.offcanvas,.popover,.toast),
html[data-tenant-theme="dark"] body :is(.card,.card-header,.card-footer,.accordion-item,.list-group-item,.offcanvas,.popover,.toast) {
  color: var(--sisforty-theme-text);
  background-color: var(--sisforty-theme-surface) !important;
  border-color: var(--sisforty-theme-border) !important;
}

html.dark-style body :is(.modal-content,.modal-header,.modal-footer,.dropdown-menu,.select2-dropdown,.select2-container--default .select2-selection--single,.select2-container--default .select2-selection--multiple,.datepicker,.flatpickr-calendar,.flatpickr-months,.flatpickr-weekdays,.bootstrap-select .dropdown-menu),
html[data-tenant-theme="dark"] body :is(.modal-content,.modal-header,.modal-footer,.dropdown-menu,.select2-dropdown,.select2-container--default .select2-selection--single,.select2-container--default .select2-selection--multiple,.datepicker,.flatpickr-calendar,.flatpickr-months,.flatpickr-weekdays,.bootstrap-select .dropdown-menu) {
  color: var(--sisforty-theme-text);
  background-color: var(--sisforty-theme-surface) !important;
  border-color: var(--sisforty-theme-border-strong) !important;
}

html.dark-style body :is(.form-control,.form-select,textarea,.input-group-text,.select2-search__field,.bootstrap-select .dropdown-toggle),
html[data-tenant-theme="dark"] body :is(.form-control,.form-select,textarea,.input-group-text,.select2-search__field,.bootstrap-select .dropdown-toggle) {
  color: var(--sisforty-theme-text) !important;
  background-color: var(--sisforty-theme-surface-alt) !important;
  border-color: var(--sisforty-theme-border-strong) !important;
}

html.dark-style body :is(.form-control,.form-select,textarea)::placeholder,
html[data-tenant-theme="dark"] body :is(.form-control,.form-select,textarea)::placeholder { color: var(--sisforty-theme-placeholder) !important; }
html.dark-style body select option,
html[data-tenant-theme="dark"] body select option { color: var(--sisforty-theme-text); background: var(--sisforty-theme-surface); }

html.dark-style body :is(.dropdown-item,.select2-results__option,.list-group-item-action),
html[data-tenant-theme="dark"] body :is(.dropdown-item,.select2-results__option,.list-group-item-action) { color: var(--sisforty-theme-text-soft); }
html.dark-style body :is(.dropdown-item:hover,.dropdown-item:focus,.list-group-item-action:hover,.select2-results__option--highlighted),
html[data-tenant-theme="dark"] body :is(.dropdown-item:hover,.dropdown-item:focus,.list-group-item-action:hover,.select2-results__option--highlighted) { color: #fff; background: var(--sisforty-theme-hover) !important; }

html.dark-style body :is(.table,.table > :not(caption) > * > *,table.dataTable),
html[data-tenant-theme="dark"] body :is(.table,.table > :not(caption) > * > *,table.dataTable) {
  --bs-table-color: var(--sisforty-theme-text-soft);
  --bs-table-bg: var(--sisforty-theme-surface);
  --bs-table-border-color: var(--sisforty-theme-border);
  --bs-table-striped-bg: var(--sisforty-theme-surface-alt);
  --bs-table-striped-color: var(--sisforty-theme-text-soft);
  --bs-table-hover-bg: var(--sisforty-theme-hover);
  --bs-table-hover-color: #fff;
  color: var(--sisforty-theme-text-soft);
  border-color: var(--sisforty-theme-border);
}
html.dark-style body :is(.table thead th,table.dataTable thead th),
html[data-tenant-theme="dark"] body :is(.table thead th,table.dataTable thead th) { color: var(--sisforty-theme-heading); background: var(--sisforty-theme-surface-alt); border-color: var(--sisforty-theme-border-strong) !important; }
html.dark-style body :is(.dataTables_wrapper,.dataTables_info,.dataTables_length,.dataTables_filter,.pagination .page-link),
html[data-tenant-theme="dark"] body :is(.dataTables_wrapper,.dataTables_info,.dataTables_length,.dataTables_filter,.pagination .page-link) { color: var(--sisforty-theme-muted); }
html.dark-style body .pagination .page-link,
html[data-tenant-theme="dark"] body .pagination .page-link { background: var(--sisforty-theme-surface-alt); border-color: var(--sisforty-theme-border); }
html.dark-style body .pagination .active .page-link,
html[data-tenant-theme="dark"] body .pagination .active .page-link { color: #fff; background: var(--sisforty-primary); border-color: var(--sisforty-primary); }

html.dark-style body :is(.btn-light,.btn-outline-secondary,.btn-secondary),
html[data-tenant-theme="dark"] body :is(.btn-light,.btn-outline-secondary,.btn-secondary) { color: var(--sisforty-theme-text-soft); background: var(--sisforty-theme-surface-alt); border-color: var(--sisforty-theme-border-strong); }
html.dark-style body :is(.btn-light,.btn-outline-secondary,.btn-secondary):hover,
html[data-tenant-theme="dark"] body :is(.btn-light,.btn-outline-secondary,.btn-secondary):hover { color: #fff; background: var(--sisforty-theme-hover); }

/* Keep every Bootstrap button variant legible against dark surfaces. */
html.dark-style body .btn-primary,
html[data-tenant-theme="dark"] body .btn-primary {
  color: #fff !important;
  background-color: #1766a5 !important;
  border-color: #3b7fb8 !important;
}
html.dark-style body .btn-primary:hover,
html.dark-style body .btn-primary:focus,
html.dark-style body .btn-primary:active,
html[data-tenant-theme="dark"] body .btn-primary:hover,
html[data-tenant-theme="dark"] body .btn-primary:focus,
html[data-tenant-theme="dark"] body .btn-primary:active {
  color: #fff !important;
  background-color: #287bbd !important;
  border-color: #5b9bd0 !important;
}

html.dark-style body .btn-success,
html[data-tenant-theme="dark"] body .btn-success { color: #a7f3d0 !important; background: #153d32 !important; border-color: #22634f !important; }
html.dark-style body .btn-success:hover,
html[data-tenant-theme="dark"] body .btn-success:hover { color: #d1fae5 !important; background: #1c5142 !important; border-color: #328067 !important; }
html.dark-style body .btn-info,
html[data-tenant-theme="dark"] body .btn-info { color: #a5f3fc !important; background: #123f4a !important; border-color: #1f6574 !important; }
html.dark-style body .btn-info:hover,
html[data-tenant-theme="dark"] body .btn-info:hover { color: #cffafe !important; background: #185464 !important; border-color: #2c8295 !important; }
html.dark-style body .btn-warning,
html[data-tenant-theme="dark"] body .btn-warning { color: #facc75 !important; background: #4b3b1e !important; border-color: #765c2e !important; }
html.dark-style body .btn-warning:hover,
html[data-tenant-theme="dark"] body .btn-warning:hover { color: #fde68a !important; background: #604b25 !important; border-color: #9a7938 !important; }
html.dark-style body .btn-danger,
html[data-tenant-theme="dark"] body .btn-danger { color: #fecaca !important; background: #48242c !important; border-color: #773944 !important; }
html.dark-style body .btn-danger:hover,
html[data-tenant-theme="dark"] body .btn-danger:hover { color: #fee2e2 !important; background: #5c2b35 !important; border-color: #9a4a58 !important; }

html.dark-style body :is(.btn-light,.btn-secondary,.btn-dark,.btn-outline-light,.btn-outline-secondary,.btn-outline-dark),
html[data-tenant-theme="dark"] body :is(.btn-light,.btn-secondary,.btn-dark,.btn-outline-light,.btn-outline-secondary,.btn-outline-dark) {
  color: var(--sisforty-theme-text-soft) !important;
  background: var(--sisforty-theme-surface-alt) !important;
  border-color: var(--sisforty-theme-border-strong) !important;
}
html.dark-style body :is(.btn-light,.btn-secondary,.btn-dark,.btn-outline-light,.btn-outline-secondary,.btn-outline-dark):hover,
html[data-tenant-theme="dark"] body :is(.btn-light,.btn-secondary,.btn-dark,.btn-outline-light,.btn-outline-secondary,.btn-outline-dark):hover {
  color: #fff !important;
  background: var(--sisforty-theme-hover) !important;
  border-color: #71809d !important;
}

html.dark-style body .btn-outline-primary,
html[data-tenant-theme="dark"] body .btn-outline-primary { color: var(--sisforty-theme-accent) !important; background: transparent !important; border-color: #5278ac !important; }
html.dark-style body .btn-outline-primary:hover,
html.dark-style body .btn-outline-primary:focus,
html.dark-style body .btn-outline-primary:active,
html[data-tenant-theme="dark"] body .btn-outline-primary:hover,
html[data-tenant-theme="dark"] body .btn-outline-primary:focus,
html[data-tenant-theme="dark"] body .btn-outline-primary:active { color: #fff !important; background: #1766a5 !important; border-color: #5b9bd0 !important; }

html.dark-style body .btn-outline-success,
html[data-tenant-theme="dark"] body .btn-outline-success { color: #a7f3d0 !important; background: transparent !important; border-color: #328067 !important; }
html.dark-style body .btn-outline-info,
html[data-tenant-theme="dark"] body .btn-outline-info { color: #a5f3fc !important; background: transparent !important; border-color: #2c8295 !important; }
html.dark-style body .btn-outline-warning,
html[data-tenant-theme="dark"] body .btn-outline-warning { color: #facc75 !important; background: transparent !important; border-color: #9a7938 !important; }
html.dark-style body .btn-outline-danger,
html[data-tenant-theme="dark"] body .btn-outline-danger { color: #fecaca !important; background: transparent !important; border-color: #9a4a58 !important; }
html.dark-style body :is(.btn-outline-success,.btn-outline-info,.btn-outline-warning,.btn-outline-danger):hover,
html[data-tenant-theme="dark"] body :is(.btn-outline-success,.btn-outline-info,.btn-outline-warning,.btn-outline-danger):hover { color: #fff !important; background: var(--sisforty-theme-hover) !important; }

html.dark-style body .btn-link,
html[data-tenant-theme="dark"] body .btn-link { color: var(--sisforty-theme-accent) !important; }
html.dark-style body .btn-dot,
html[data-tenant-theme="dark"] body .btn-dot { color: var(--sisforty-theme-muted) !important; background: transparent !important; border-color: transparent !important; }
html.dark-style body .btn-dot:hover,
html.dark-style body .btn-dot:focus,
html.dark-style body .btn-dot[aria-expanded="true"],
html[data-tenant-theme="dark"] body .btn-dot:hover,
html[data-tenant-theme="dark"] body .btn-dot:focus,
html[data-tenant-theme="dark"] body .btn-dot[aria-expanded="true"] { color: var(--sisforty-theme-accent) !important; background: var(--sisforty-theme-hover) !important; border-color: var(--sisforty-theme-border-strong) !important; }
html.dark-style body .btn-label-secondary,
html[data-tenant-theme="dark"] body .btn-label-secondary { color: var(--sisforty-theme-text-soft) !important; background: var(--sisforty-theme-surface-alt) !important; border-color: var(--sisforty-theme-border-strong) !important; }
html.dark-style body .btn-label-secondary:hover,
html[data-tenant-theme="dark"] body .btn-label-secondary:hover { color: #fff !important; background: var(--sisforty-theme-hover) !important; }

html.dark-style body .dt-button,
html[data-tenant-theme="dark"] body .dt-button { color: var(--sisforty-theme-text-soft) !important; background: var(--sisforty-theme-surface-alt) !important; border-color: var(--sisforty-theme-border-strong) !important; }
html.dark-style body .dt-button:hover,
html.dark-style body .dt-button:focus,
html[data-tenant-theme="dark"] body .dt-button:hover,
html[data-tenant-theme="dark"] body .dt-button:focus { color: #fff !important; background: var(--sisforty-theme-hover) !important; border-color: var(--sisforty-theme-border-strong) !important; }
html.dark-style body .btn:focus-visible,
html[data-tenant-theme="dark"] body .btn:focus-visible { outline: 2px solid var(--sisforty-theme-accent); outline-offset: 2px; box-shadow: 0 0 0 .2rem rgba(169, 201, 255, .2) !important; }
html.dark-style body .btn:disabled,
html.dark-style body .btn.disabled,
html[data-tenant-theme="dark"] body .btn:disabled,
html[data-tenant-theme="dark"] body .btn.disabled { opacity: .55; }

html.dark-style body .modal .btn-close,
html[data-tenant-theme="dark"] body .modal .btn-close {
  filter: none !important;
  opacity: .85;
  background-color: var(--sisforty-theme-surface-alt);
  border: 1px solid var(--sisforty-theme-border-strong);
  border-radius: 50%;
}
html.dark-style body .modal .btn-close:hover,
html[data-tenant-theme="dark"] body .modal .btn-close:hover { opacity: 1; background-color: var(--sisforty-theme-hover); }

html.dark-style body :is(.bg-white,.bg-light,.bg-label-secondary),
html[data-tenant-theme="dark"] body :is(.bg-white,.bg-light,.bg-label-secondary) { color: var(--sisforty-theme-text-soft) !important; background-color: var(--sisforty-theme-surface-alt) !important; border-color: var(--sisforty-theme-border) !important; }
html.dark-style body .alert-primary,
html[data-tenant-theme="dark"] body .alert-primary { color: #c4dcff; background: #1b3554; border-color: #315b91; }
html.dark-style body .alert-success,
html[data-tenant-theme="dark"] body .alert-success { color: #a7f3d0; background: #153d32; border-color: #22634f; }
html.dark-style body .alert-warning,
html[data-tenant-theme="dark"] body .alert-warning { color: #facc75; background: #4b3b1e; border-color: #765c2e; }
html.dark-style body .alert-danger,
html[data-tenant-theme="dark"] body .alert-danger { color: #fecaca; background: #48242c; border-color: #773944; }
html.dark-style body a:not(.btn):not(.dropdown-item),
html[data-tenant-theme="dark"] body a:not(.btn):not(.dropdown-item) { color: var(--sisforty-theme-accent); }
html.dark-style body a:not(.btn):not(.dropdown-item):hover,
html[data-tenant-theme="dark"] body a:not(.btn):not(.dropdown-item):hover { color: #d5e5ff; }

html.dark-style body :is(hr,.border,.border-top,.border-bottom),
html[data-tenant-theme="dark"] body :is(hr,.border,.border-top,.border-bottom) { border-color: var(--sisforty-theme-border) !important; }
html.dark-style body ::selection,
html[data-tenant-theme="dark"] body ::selection { color: #fff; background: #315b91; }
html.dark-style body,
html[data-tenant-theme="dark"] body { scrollbar-color: #52627a var(--sisforty-theme-page); }
html.dark-style body ::-webkit-scrollbar-track,
html[data-tenant-theme="dark"] body ::-webkit-scrollbar-track { background: var(--sisforty-theme-page); }
html.dark-style body ::-webkit-scrollbar-thumb,
html[data-tenant-theme="dark"] body ::-webkit-scrollbar-thumb { background: #52627a; border-radius: 1rem; }

html.dark-style body :is(.apexcharts-text,.apexcharts-legend-text,.apexcharts-title-text,.chartjs-render-monitor),
html[data-tenant-theme="dark"] body :is(.apexcharts-text,.apexcharts-legend-text,.apexcharts-title-text,.chartjs-render-monitor) { color: var(--sisforty-theme-muted) !important; }
html.dark-style body .flatpickr-day,
html[data-tenant-theme="dark"] body .flatpickr-day { color: var(--sisforty-theme-text-soft); }
html.dark-style body .flatpickr-day:hover,
html[data-tenant-theme="dark"] body .flatpickr-day:hover { background: var(--sisforty-theme-hover); border-color: var(--sisforty-theme-hover); }
html.dark-style body :is(.ql-toolbar,.ql-container,.ql-editor,.CodeMirror),
html[data-tenant-theme="dark"] body :is(.ql-toolbar,.ql-container,.ql-editor,.CodeMirror) { color: var(--sisforty-theme-text-soft); background: var(--sisforty-theme-surface); border-color: var(--sisforty-theme-border-strong); }

@media (prefers-reduced-motion: no-preference) {
  html.dark-style body :is(.card,.dropdown-menu,.modal-content,.form-control,.form-select) { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
}
