/* Local, opt-in overrides for the bundled Tabler / Bootstrap 4 interface. */
.maselli-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: .5rem;
  min-width: 44px;
  min-height: 44px;
  padding: .5rem .75rem;
  margin-right: .5rem;
  border: 1px solid #d5dae2;
  border-radius: .5rem;
  background: #fff;
  color: #374151;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
.maselli-theme-toggle:hover { background: #eef2f7; }
.maselli-theme-toggle:focus-visible { outline: 3px solid #579bf4; outline-offset: 3px; }
.maselli-theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.maselli-theme-toggle .maselli-theme-sun { display: none; }
.maselli-theme-floating { position: fixed; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 1030; margin: 0; }

html[data-maselli-theme="dark"] {
  color-scheme: dark;
  --maselli-bg: #111827;
  --maselli-surface: #1b2535;
  --maselli-raised: #253247;
  --maselli-border: #3b4960;
  --maselli-text: #e5eaf2;
  --maselli-muted: #a6b3c7;
  --maselli-link: #9bbfff;
  background: var(--maselli-bg);
}
html[data-maselli-theme="light"] { color-scheme: light; }
html[data-maselli-theme="dark"] body,
html[data-maselli-theme="dark"] .page { background: var(--maselli-bg); color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(.header, .footer, .card, .modal-content, .dropdown-menu, .list-group-item, .popover) {
  background-color: var(--maselli-surface);
  border-color: var(--maselli-border);
  color: var(--maselli-text);
}
html[data-maselli-theme="dark"] :is(.card-header, .card-footer, .modal-header, .modal-footer, .dropdown-divider, .popover-header, .table td, .table th, .table thead th, .nav-tabs) { border-color: var(--maselli-border); }
html[data-maselli-theme="dark"] :is(.card-footer, .popover-header) { background-color: var(--maselli-surface); }
html[data-maselli-theme="dark"] :is(.card-title, .page-title, .form-label, .col-form-label, .modal-title, .navbar-brand, .table, .dropdown-item, .popover-body) { color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(.text-default, .text-dark, a.text-dark) { color: var(--maselli-text) !important; }
html[data-maselli-theme="dark"] :is(.text-muted, .text-secondary, .card-subtitle, .form-text, .small, .dropdown-icon, .table thead th) { color: var(--maselli-muted) !important; }
html[data-maselli-theme="dark"] a:not(.btn):not(.badge):not(.nav-link):not(.dropdown-item):not(.navbar-brand):not(.text-white) { color: var(--maselli-link); }
html[data-maselli-theme="dark"] a:not(.btn):not(.badge):hover { color: #c6dbff; }
html[data-maselli-theme="dark"] :is(.nav-link, .navbar-light .navbar-nav .nav-link) { color: var(--maselli-muted); }
html[data-maselli-theme="dark"] :is(.nav-link:hover, .nav-link.active, .nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link) { color: #b6d0ff; background-color: transparent; border-color: var(--maselli-border); }
html[data-maselli-theme="dark"] .nav-tabs .nav-link.active { border-bottom-color: #9bbfff; }
html[data-maselli-theme="dark"] :is(.dropdown-item:hover, .dropdown-item:focus, .dropdown-item.active, .dropdown-item:active, .list-group-item-action:hover, .list-group-item-action:focus) { color: #fff; background-color: var(--maselli-raised); }
html[data-maselli-theme="dark"] .dropdown-menu-arrow::after { border-bottom-color: var(--maselli-surface); }
html[data-maselli-theme="dark"] .dropdown-menu-arrow::before { border-bottom-color: var(--maselli-border); }
html[data-maselli-theme="dark"] :is(.form-control, .custom-select, .input-group-text, .selectize-input, .selectize-input.full, .selectize-control.single .selectize-input.input-active, .selectize-dropdown) {
  background-color: var(--maselli-bg);
  color: var(--maselli-text);
  border-color: var(--maselli-border);
}
html[data-maselli-theme="dark"] :is(.form-control::placeholder, .selectize-input input::placeholder) { color: #99a7bd; opacity: 1; }
html[data-maselli-theme="dark"] :is(.form-control:focus, .custom-select:focus, .selectize-input.focus) { border-color: #86aff0; box-shadow: 0 0 0 .2rem rgb(134 175 240 / 20%); }
html[data-maselli-theme="dark"] :is(.form-control:disabled, .form-control[readonly], .custom-select:disabled) { background-color: #263143; color: var(--maselli-muted); }
html[data-maselli-theme="dark"] :is(.selectize-input input, .selectize-dropdown .option) { color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(.selectize-dropdown .active, .selectize-input > .item, .selectize-control.multi .selectize-input > div) { background: #344865; color: #e9f0ff; }
html[data-maselli-theme="dark"] .selectize-control.multi .selectize-input > div.active { background: #436089; color: #fff; }
html[data-maselli-theme="dark"] .selectize-control.plugin-remove_button [data-value] .remove { color: inherit; border-left-color: #64748b; }
html[data-maselli-theme="dark"] .selectize-dropdown .create { color: var(--maselli-muted); }
html[data-maselli-theme="dark"] :is(.btn-secondary, .btn-default, .btn-white, .btn-outline-secondary) { background-color: var(--maselli-raised); border-color: #52627a; color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(.btn-secondary, .btn-default, .btn-white, .btn-outline-secondary):hover { background-color: #34465f; border-color: #71849f; color: #fff; }
html[data-maselli-theme="dark"] :is(.btn-link, .btn-options) { color: var(--maselli-link); }
html[data-maselli-theme="dark"] .close { color: var(--maselli-text); text-shadow: none; opacity: .85; }
html[data-maselli-theme="dark"] .close:hover { opacity: 1; }
html[data-maselli-theme="dark"] .table-striped tbody tr:nth-of-type(odd) { background-color: rgb(255 255 255 / 3%); }
html[data-maselli-theme="dark"] .table-hover tbody tr:hover { background-color: var(--maselli-raised); color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(.table .thead-light th, .table-active, .table-active > td, .table-active > th) { background-color: var(--maselli-raised); color: var(--maselli-text); }
html[data-maselli-theme="dark"] .page-link { background-color: var(--maselli-surface); border-color: var(--maselli-border); color: var(--maselli-link); }
html[data-maselli-theme="dark"] .page-link:hover { background-color: var(--maselli-raised); }
html[data-maselli-theme="dark"] .page-item.active .page-link { background-color: #41659b; border-color: #6086bf; color: #fff; }
html[data-maselli-theme="dark"] .page-item.disabled .page-link { background-color: var(--maselli-bg); border-color: var(--maselli-border); color: var(--maselli-muted); }
html[data-maselli-theme="dark"] :is(.bg-white, .bg-light) { background-color: var(--maselli-surface) !important; }
html[data-maselli-theme="dark"] :is(.border, .border-top, .border-right, .border-bottom, .border-left) { border-color: var(--maselli-border) !important; }
html[data-maselli-theme="dark"] :is(hr, .custom-file-label) { border-color: var(--maselli-border); }
html[data-maselli-theme="dark"] :is(.custom-file-label, .custom-file-label::after, .custom-switch-indicator, .custom-control-label::before) { background-color: #3b4960; color: var(--maselli-text); }
html[data-maselli-theme="dark"] .custom-switch-input:checked ~ .custom-switch-indicator { background-color: #467fcf; }
html[data-maselli-theme="dark"] .custom-control-input:checked ~ .custom-control-label::before { background-color: #467fcf; }
html[data-maselli-theme="dark"] :is(.text-success, .text-green, .text-teal) { color: #85d9ad !important; }
html[data-maselli-theme="dark"] :is(.text-danger, .text-red, .invalid-feedback) { color: #ff9aab !important; }
html[data-maselli-theme="dark"] :is(.text-warning, .text-yellow, .text-orange) { color: #f6cb77 !important; }
html[data-maselli-theme="dark"] :is(.text-info, .text-blue, .text-azure) { color: #91c8ff !important; }
html[data-maselli-theme="dark"] .alert { border-color: var(--maselli-border); }
html[data-maselli-theme="dark"] .alert-danger { background-color: #482633; color: #ffbec9; }
html[data-maselli-theme="dark"] .alert-warning { background-color: #403522; color: #f8dca3; }
html[data-maselli-theme="dark"] :is(.alert-info, .alert-primary) { background-color: #203b54; color: #b8dcff; }
html[data-maselli-theme="dark"] .alert-success { background-color: #1d3d35; color: #a0eac8; }
html[data-maselli-theme="dark"] .alert-secondary { background-color: var(--maselli-raised); color: var(--maselli-text); }
html[data-maselli-theme="dark"] :is(pre, code, .highlight) { background-color: #111b2b; color: #c7d8f4; border-color: var(--maselli-border); }
html[data-maselli-theme="dark"] .navbar-toggler-icon { filter: invert(1); }
html[data-maselli-theme="dark"] img[src$="logo-text-vertical-grey.png"] { filter: brightness(1.35); }
html[data-maselli-theme="dark"] .loader { border-color: #52627a; border-left-color: #aac9ff; }
html[data-maselli-theme="dark"] .maselli-theme-toggle { background: var(--maselli-raised); color: #e3edff; border-color: #52627a; }
html[data-maselli-theme="dark"] .maselli-theme-toggle:hover { background: #34465f; }
html[data-maselli-theme="dark"] .maselli-theme-sun { display: block; }
html[data-maselli-theme="dark"] .maselli-theme-moon { display: none; }

@media (max-width: 767px) {
  #header .maselli-theme-label { display: none; }
  #header .maselli-theme-toggle { padding: .5rem; margin-right: 0; }
  #header .navbar-brand { white-space: normal; line-height: 1.25; }
  #login .page-single { padding-top: 4.5rem; }
}

html[data-maselli-theme="dark"] .btn-teal { background-color: #147d75; border-color: #147d75; color: #fff; }
html[data-maselli-theme="dark"] .btn-teal:hover { background-color: #10665f; border-color: #10665f; }
html[data-maselli-theme="dark"] :is(.tag:not([class*="tag-"]), .badge-default) { background-color: #34445b; color: #e2eaf6; }
html[data-maselli-theme="dark"] :is(.form-control.is-invalid, .was-validated .form-control:invalid) { border-color: #ff9aab; }
html[data-maselli-theme="dark"] :is(.form-control.is-valid, .was-validated .form-control:valid) { border-color: #85d9ad; }
