/* ==========================================================================
   Dark Mode
   Every rule is scoped to html[data-theme="dark"]; light mode is untouched.
   The attribute is set before first paint in layouts/includes/html-head and
   toggled by assets/js/theme-mode.js.
   ========================================================================== */

html[data-theme="dark"] {
    --dm-bg: #151521;
    --dm-surface: #1e1e2d;
    --dm-surface-2: #252536;
    --dm-surface-3: #2d2d42;
    --dm-input: #1b1b29;
    --dm-border: #2f3044;
    --dm-border-strong: #3f4056;
    --dm-text: #cdcdde;
    --dm-text-strong: #f1f1f7;
    --dm-text-muted: #8f90a6;
    --dm-link: #7fa3d6;
    --dm-link-hover: #a4c0e6;
    --dm-focus: #5b8fd6;
    color-scheme: dark;
}

/* Theme toggle (both themes) -------------------------------------------- */
.theme-toggle {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    outline: none !important;
}
.theme-toggle .theme-toggle__icon--light { display: none !important; }
html[data-theme="dark"] .theme-toggle .theme-toggle__icon--light { display: inline-block !important; }
html[data-theme="dark"] .theme-toggle .theme-toggle__icon--dark { display: none !important; }

/* Desktop: pill button, vertically centred in the header */
.kt-header__topbar-item--theme { margin-right: 12px !important; }
.kt-header__topbar-item--theme .theme-toggle {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid #c9d3e6;
    border-radius: 18px;
    background-color: #eef2f8;
    color: #21477b;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.kt-header__topbar-item--theme .theme-toggle i { font-size: 15px; }
.kt-header__topbar-item--theme .theme-toggle:hover {
    background-color: #21477b;
    border-color: #21477b;
    color: #fff;
}

/* Mobile: square icon button */
.kt-header-mobile__theme-toggle {
    width: 38px;
    height: 38px;
    margin-right: 6px;
    border: 1px solid #c9d3e6;
    border-radius: 50%;
    background-color: #eef2f8;
    color: #21477b;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kt-header-mobile__theme-toggle i { font-size: 16px; }
.kt-header-mobile__theme-toggle:hover { background-color: #21477b; border-color: #21477b; color: #fff; }

html[data-theme="dark"] .kt-header__topbar-item--theme .theme-toggle,
html[data-theme="dark"] .kt-header-mobile__theme-toggle {
    background-color: rgba(255, 184, 34, 0.12);
    border-color: rgba(255, 184, 34, 0.45);
    color: #ffb822;
}
html[data-theme="dark"] .kt-header__topbar-item--theme .theme-toggle:hover,
html[data-theme="dark"] .kt-header-mobile__theme-toggle:hover {
    background-color: #ffb822;
    border-color: #ffb822;
    color: #1e1e2d;
}

/* Auth pages: floating toggle, top right */
.auth-theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid #c9d3e6;
    border-radius: 18px;
    background-color: #eef2f8;
    color: #21477b;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.auth-theme-toggle i { font-size: 15px; }
.auth-theme-toggle svg { width: 15px; height: 15px; flex-shrink: 0; }
.auth-theme-toggle:hover { background-color: #21477b; border-color: #21477b; color: #fff; }
html[data-theme="dark"] .auth-theme-toggle {
    background-color: rgba(255, 184, 34, 0.12);
    border-color: rgba(255, 184, 34, 0.45);
    color: #ffb822;
}
html[data-theme="dark"] .auth-theme-toggle:hover { background-color: #ffb822; border-color: #ffb822; color: #1e1e2d; }

/* Auth pages (login.css, kt-login--v3) */
html[data-theme="dark"] body:has(#kt_login) { background-color: var(--dm-bg) !important; }
html[data-theme="dark"] #kt_login,
html[data-theme="dark"] #kt_login > .kt-grid__item {
    background-color: var(--dm-bg);
    background-image: radial-gradient(ellipse at top, #1f2a44 0%, var(--dm-bg) 60%) !important;
}
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-login__head .kt-login__title { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-login__head .kt-login__desc,
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .kt-login__extra,
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .kt-login__extra .kt-login__link,
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-login__account .kt-login__account-msg { color: var(--dm-text-muted); }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .kt-login__extra .kt-login__link:hover,
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-login__account .kt-login__account-link:hover { color: var(--dm-link-hover); }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-login__account .kt-login__account-link { color: var(--dm-text); }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .form-control {
    background: var(--dm-surface-2);
    border: 1px solid var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .form-control:focus { border-color: var(--dm-focus); }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .form-control::placeholder { color: #7d7e96; }
html[data-theme="dark"] .kt-login.kt-login--v3 .kt-login__wrapper .kt-login__container .kt-form .form-control:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--dm-surface-2) inset;
    -webkit-text-fill-color: var(--dm-text-strong);
}
html[data-theme="dark"] .sr-install-app { background: var(--dm-surface); border-color: var(--dm-border-strong); color: var(--dm-link); }
html[data-theme="dark"] .sr-install-app:hover { color: var(--dm-link-hover); border-color: var(--dm-focus); }

/* Base ------------------------------------------------------------------ */
html[data-theme="dark"] body,
html[data-theme="dark"] .kt-grid--root,
html[data-theme="dark"] .kt-wrapper,
html[data-theme="dark"] .kt-content,
html[data-theme="dark"] #kt_content {
    background-color: var(--dm-bg);
    color: var(--dm-text);
}
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"] .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"] .lead,
html[data-theme="dark"] label,
html[data-theme="dark"] .col-form-label,
html[data-theme="dark"] .form-control-label {
    color: var(--dm-text-strong);
}
html[data-theme="dark"] a:not(.btn) { color: var(--dm-link); }
html[data-theme="dark"] a:not(.btn):hover { color: var(--dm-link-hover); }
html[data-theme="dark"] hr { border-top-color: var(--dm-border); }
html[data-theme="dark"] .kt-page-loader { background: var(--dm-bg); }

/* Text and background utilities */
html[data-theme="dark"] .text-dark,
html[data-theme="dark"] .text-body,
html[data-theme="dark"] .text-black,
html[data-theme="dark"] .kt-font-dark { color: var(--dm-text-strong) !important; }
html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] .form-text { color: var(--dm-text-muted) !important; }
html[data-theme="dark"] .bg-white { background-color: var(--dm-surface) !important; }
html[data-theme="dark"] .bg-light { background-color: var(--dm-surface-2) !important; }
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-left,
html[data-theme="dark"] .border-right { border-color: var(--dm-border) !important; }

/* Header, subheader, footer --------------------------------------------- */
html[data-theme="dark"] .kt-header {
    background-color: var(--dm-surface);
    border-bottom-color: var(--dm-border);
    box-shadow: none;
}
html[data-theme="dark"] .kt-header .kt-header__topbar .kt-header__topbar-item.kt-header__topbar-item--user .kt-header__topbar-user .kt-header__topbar-welcome { color: var(--dm-text-muted); }
html[data-theme="dark"] .kt-header .kt-header__topbar .kt-header__topbar-item.kt-header__topbar-item--user .kt-header__topbar-user .kt-header__topbar-username { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-header .kt-header__topbar .kt-header__topbar-item:hover .kt-header__topbar-wrapper .kt-header__topbar-user,
html[data-theme="dark"] .kt-header .kt-header__topbar .kt-header__topbar-item.show .kt-header__topbar-wrapper .kt-header__topbar-user { background-color: var(--dm-surface-2); }

html[data-theme="dark"] .kt-subheader,
html[data-theme="dark"] .kt-footer {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
}
html[data-theme="dark"] .kt-subheader .kt-subheader__title,
html[data-theme="dark"] .kt-footer .kt-footer__copyright { color: var(--dm-text); }
html[data-theme="dark"] .kt-subheader .kt-subheader__desc,
html[data-theme="dark"] .kt-subheader .kt-subheader__breadcrumbs .kt-subheader__breadcrumbs-link { color: var(--dm-text-muted); }

/* Mobile header and sidebar (mobile-responsive.css forces white) */
html[data-theme="dark"] .kt-header-mobile {
    background: var(--dm-surface);
    border-bottom-color: var(--dm-border);
}
html[data-theme="dark"] .kt-header-mobile__toggler span { background-color: var(--dm-text); }
html[data-theme="dark"] .kt-header-mobile__toggler:hover,
html[data-theme="dark"] .kt-header-mobile__toggler:focus,
html[data-theme="dark"] .kt-header-mobile__topbar-user:hover { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .kt-header-mobile__topbar-username { color: var(--dm-text-strong); }
@media (max-width: 1024px) {
    html[data-theme="dark"] .kt-aside {
        background: #12121c !important;
        border-right-color: var(--dm-border) !important;
    }
    html[data-theme="dark"] .kt-menu__link:hover { background-color: var(--dm-surface-2); }
}

/* Sidebar: keep the dark skin, just separate it from the page */
html[data-theme="dark"] .kt-aside,
html[data-theme="dark"] .kt-aside__brand { background-color: #12121c; }
html[data-theme="dark"] .kt-aside-menu { background-color: #12121c; }
html[data-theme="dark"] .kt-aside__agent-info { border-bottom-color: var(--dm-border); }

/* Portlets, cards, widgets ---------------------------------------------- */
html[data-theme="dark"] .kt-portlet,
html[data-theme="dark"] .card,
html[data-theme="dark"] .kt-section__content--solid,
html[data-theme="dark"] .kt-widget,
html[data-theme="dark"] .kt-iconbox,
html[data-theme="dark"] .jumbotron {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
    box-shadow: none;
}
html[data-theme="dark"] .kt-portlet .kt-portlet__head,
html[data-theme="dark"] .kt-portlet .kt-portlet__foot,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer {
    background-color: transparent;
    border-color: var(--dm-border);
}
html[data-theme="dark"] .kt-portlet .kt-portlet__head .kt-portlet__head-label .kt-portlet__head-title,
html[data-theme="dark"] .card-title,
html[data-theme="dark"] .kt-section__title,
html[data-theme="dark"] .kt-widget__title,
html[data-theme="dark"] .kt-widget__username,
html[data-theme="dark"] .kt-widget__value,
html[data-theme="dark"] .kt-widget-12__value { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-portlet .kt-portlet__head .kt-portlet__head-label .kt-portlet__head-title small,
html[data-theme="dark"] .kt-section__desc,
html[data-theme="dark"] .kt-widget__desc,
html[data-theme="dark"] .kt-widget__label,
html[data-theme="dark"] .kt-widget__subtitle { color: var(--dm-text-muted); }
html[data-theme="dark"] .kt-portlet.kt-portlet--solid-light { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .kt-timeline-v2__item-text,
html[data-theme="dark"] .kt-timeline-v2__item-time { color: var(--dm-text); }
html[data-theme="dark"] .kt-widget-12__item { border-bottom-color: var(--dm-border); }
html[data-theme="dark"] .kt-widget-12__desc { color: var(--dm-text-muted); }

/* Forms ----------------------------------------------------------------- */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .custom-select,
html[data-theme="dark"] .custom-file-label,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="url"] {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .custom-select:focus {
    background-color: var(--dm-input);
    border-color: var(--dm-focus);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .form-control::placeholder { color: #6c6d85; }
/* Some views force light read-only fields with !important (agent-profile, portal-profile) */
html[data-theme="dark"] .readonly-field,
html[data-theme="dark"] .readonly-field:focus {
    background-color: var(--dm-surface-2) !important;
    color: var(--dm-text) !important;
    border-color: var(--dm-border) !important;
}
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] .user-type-readonly,
html[data-theme="dark"] .sr-field-control .form-control[readonly] {
    background-color: var(--dm-surface-2);
    color: var(--dm-text);
    border-color: var(--dm-border);
}
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .toggle-pw {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}
html[data-theme="dark"] .kt-checkbox > span,
html[data-theme="dark"] .kt-radio > span {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
}
html[data-theme="dark"] .kt-checkbox,
html[data-theme="dark"] .kt-radio,
html[data-theme="dark"] .custom-control-label { color: var(--dm-text); }
html[data-theme="dark"] .custom-control-label::before {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
}
html[data-theme="dark"] .kt-switch input:empty ~ span:before { background-color: var(--dm-surface-3); }

/* Buttons --------------------------------------------------------------- */
html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-default,
html[data-theme="dark"] .btn-outline-secondary,
html[data-theme="dark"] .btn-outline-light {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}
html[data-theme="dark"] .btn-light:hover,
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-default:hover,
html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-light:hover {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .btn-outline-info,
html[data-theme="dark"] .btn-outline-primary { color: var(--dm-link); border-color: var(--dm-focus); }
html[data-theme="dark"] .btn-outline-info:hover,
html[data-theme="dark"] .btn-outline-primary:hover { color: #fff; }
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn-success,
html[data-theme="dark"] .btn-brand,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn-warning,
html[data-theme="dark"] .btn-info { color: #fff; }
/* btn-label-metal is used as the default status/priority badge in the task,
   dashboard and meeting views but isn't defined by the theme, so it falls back
   to the dark default .btn text colour. */
html[data-theme="dark"] .btn.btn-label-metal {
    background-color: rgba(211, 218, 230, 0.12);
    color: #c4c8d8;
    border: 0;
}
html[data-theme="dark"] a.btn.btn-label-metal:hover,
html[data-theme="dark"] button.btn.btn-label-metal:hover {
    background-color: rgba(211, 218, 230, 0.22);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .btn-clean { color: var(--dm-text-muted); }
html[data-theme="dark"] .btn-clean:hover { background-color: var(--dm-surface-2); color: var(--dm-link); }
html[data-theme="dark"] .close { color: var(--dm-text); text-shadow: none; }

/* Tables ---------------------------------------------------------------- */
html[data-theme="dark"] .table,
html[data-theme="dark"] table.dataTable { color: var(--dm-text); background-color: transparent; }
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td,
html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .table-bordered,
html[data-theme="dark"] .table-bordered th,
html[data-theme="dark"] .table-bordered td,
html[data-theme="dark"] table.dataTable thead th,
html[data-theme="dark"] table.dataTable tbody td { border-color: var(--dm-border); }
html[data-theme="dark"] .table th,
html[data-theme="dark"] .table thead th { color: var(--dm-text-strong); }
html[data-theme="dark"] .thead-light th,
html[data-theme="dark"] .table .thead-light th,
html[data-theme="dark"] .table-light,
html[data-theme="dark"] .table-light > td,
html[data-theme="dark"] .table-light > th {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) { background-color: rgba(255, 255, 255, 0.025); }
html[data-theme="dark"] .table-hover tbody tr:hover,
html[data-theme="dark"] table.dataTable.table-hover tbody tr:hover { background-color: var(--dm-surface-2); color: var(--dm-text-strong); }
html[data-theme="dark"] table.dataTable tbody tr,
html[data-theme="dark"] table.dataTable tbody tr.odd,
html[data-theme="dark"] table.dataTable tbody tr.even { background-color: transparent; }
html[data-theme="dark"] .table-active,
html[data-theme="dark"] .table-active > td,
html[data-theme="dark"] .table-active > th { background-color: var(--dm-surface-3); }

/* DataTables (style.bundle sets th/td to #595d6e) */
html[data-theme="dark"] .dataTables_wrapper .dataTable th,
html[data-theme="dark"] .dataTables_wrapper .dataTable td,
html[data-theme="dark"] .kt-widget11 .table tbody > tr > td,
html[data-theme="dark"] .kt-widget11 .table tbody > tr .kt-widget11__title { color: var(--dm-text); }
html[data-theme="dark"] .dataTables_wrapper .dataTable thead th { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-widget11 .table thead > tr > td,
html[data-theme="dark"] .kt-widget11 .table tbody > tr .kt-widget11__title > span { color: var(--dm-text-muted); }
html[data-theme="dark"] .dataTables_wrapper .dataTable tbody tr:hover td { color: var(--dm-text-strong); }
html[data-theme="dark"] .dataTables_wrapper .dataTable .selected th,
html[data-theme="dark"] .dataTables_wrapper .dataTable .selected td { background-color: var(--dm-surface-3); color: var(--dm-text-strong); }
html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_length,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter { color: var(--dm-text-muted); }
html[data-theme="dark"] .dataTables_wrapper .dataTables_processing {
    background: var(--dm-surface-2);
    color: var(--dm-text);
    border-color: var(--dm-border);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .pagination .page-item .page-link { color: var(--dm-text) !important; }
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .pagination .page-item:hover > .page-link { background: var(--dm-surface-3) !important; border-color: var(--dm-border) !important; }
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .pagination .page-item.active > .page-link,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current { background: #21477b !important; color: #fff !important; }
html[data-theme="dark"] .dataTables_wrapper .dataTable th.sorting_asc,
html[data-theme="dark"] .dataTables_wrapper .dataTable th.sorting_desc { color: var(--dm-link); }

/* Pagination */
html[data-theme="dark"] .page-link {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .page-link:hover { background-color: var(--dm-surface-3); color: var(--dm-text-strong); }
html[data-theme="dark"] .page-item.disabled .page-link { background-color: var(--dm-surface); color: #5d5e75; border-color: var(--dm-border); }
html[data-theme="dark"] .page-item.active .page-link { background-color: #21477b; border-color: #21477b; color: #fff; }

/* Modals, dropdowns, popovers ------------------------------------------- */
html[data-theme="dark"] .modal-content {
    background-color: var(--dm-surface);
    color: var(--dm-text);
    border-color: var(--dm-border);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer { border-color: var(--dm-border); }
html[data-theme="dark"] .modal-title { color: var(--dm-text-strong); }
html[data-theme="dark"] .modal-backdrop.show { opacity: 0.7; }

html[data-theme="dark"] .dropdown-menu {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
}
html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] .dropdown-menu > li > a { color: var(--dm-text); }
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .dropdown-menu > li > a:hover { background-color: var(--dm-surface-3); color: var(--dm-text-strong); }
html[data-theme="dark"] .dropdown-divider { border-top-color: var(--dm-border); }
html[data-theme="dark"] .dropdown-header { color: var(--dm-text-muted); }

html[data-theme="dark"] .kt-notification .kt-notification__item { border-bottom-color: var(--dm-border); }
html[data-theme="dark"] .kt-notification .kt-notification__item:hover { background-color: var(--dm-surface-3); }
html[data-theme="dark"] .kt-notification .kt-notification__item .kt-notification__item-details .kt-notification__item-title { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-notification .kt-notification__item .kt-notification__item-details .kt-notification__item-time { color: var(--dm-text-muted); }

html[data-theme="dark"] .kt-nav .kt-nav__item > .kt-nav__link .kt-nav__link-text { color: var(--dm-text); }
html[data-theme="dark"] .kt-nav .kt-nav__item > .kt-nav__link:hover,
html[data-theme="dark"] .kt-nav .kt-nav__item.kt-nav__item--active > .kt-nav__link { background-color: var(--dm-surface-3); }

html[data-theme="dark"] .popover {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
}
html[data-theme="dark"] .popover-header { background-color: var(--dm-surface-3); border-color: var(--dm-border); color: var(--dm-text-strong); }
html[data-theme="dark"] .popover-body { color: var(--dm-text); }
html[data-theme="dark"] .bs-popover-top .arrow::after,
html[data-theme="dark"] .bs-popover-auto[x-placement^="top"] .arrow::after { border-top-color: var(--dm-surface-2); }
html[data-theme="dark"] .bs-popover-bottom .arrow::after,
html[data-theme="dark"] .bs-popover-auto[x-placement^="bottom"] .arrow::after { border-bottom-color: var(--dm-surface-2); }

/* Navs, tabs, list groups, alerts, badges ------------------------------- */
html[data-theme="dark"] .nav-tabs { border-bottom-color: var(--dm-border); }
html[data-theme="dark"] .nav-tabs .nav-link,
html[data-theme="dark"] .nav-pills .nav-link,
html[data-theme="dark"] .tab-link { color: var(--dm-text-muted); }
html[data-theme="dark"] .nav-tabs .nav-link:hover { border-color: var(--dm-border) var(--dm-border) transparent; color: var(--dm-text-strong); }
html[data-theme="dark"] .nav-tabs .nav-link.active,
html[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    background-color: var(--dm-surface);
    border-color: var(--dm-border) var(--dm-border) var(--dm-surface);
    color: var(--dm-link);
}
html[data-theme="dark"] .nav-tabs.nav-tabs-line .nav-link.active,
html[data-theme="dark"] .nav-tabs.nav-tabs-line .nav-link:hover { background-color: transparent; border-color: transparent; }
html[data-theme="dark"] .nav-tabs.nav-tabs-line .nav-link.active { border-bottom-color: var(--dm-focus); }

html[data-theme="dark"] .list-group-item {
    background-color: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .list-group-item-action:hover,
html[data-theme="dark"] .list-group-item-action:focus { background-color: var(--dm-surface-2); color: var(--dm-text-strong); }

html[data-theme="dark"] .alert-light,
html[data-theme="dark"] .alert-secondary {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .alert-primary { background-color: rgba(88, 103, 221, 0.15); border-color: rgba(88, 103, 221, 0.35); color: #b7bff2; }
html[data-theme="dark"] .alert-info { background-color: rgba(23, 162, 184, 0.15); border-color: rgba(23, 162, 184, 0.35); color: #8fd9e5; }
html[data-theme="dark"] .alert-success { background-color: rgba(40, 167, 69, 0.15); border-color: rgba(40, 167, 69, 0.35); color: #94dba7; }
html[data-theme="dark"] .alert-warning { background-color: rgba(255, 193, 7, 0.15); border-color: rgba(255, 193, 7, 0.35); color: #ffd975; }
html[data-theme="dark"] .alert-danger { background-color: rgba(220, 53, 69, 0.15); border-color: rgba(220, 53, 69, 0.35); color: #f19aa3; }
html[data-theme="dark"] .alert .alert-link { color: inherit; }

/* Template solid alerts (.alert.alert-*) colour the text/icon/close parts
   directly (#111 on warning), which is unreadable on the dark tints above. */
html[data-theme="dark"] .alert.alert-warning .alert-text,
html[data-theme="dark"] .alert.alert-warning .alert-icon i,
html[data-theme="dark"] .alert.alert-warning .alert-close i { color: #ffd975; }
html[data-theme="dark"] .alert.alert-warning .alert-link { color: #ffe7a3; text-decoration: underline; }
html[data-theme="dark"] .alert.alert-warning .alert-text hr { border-top-color: rgba(255, 217, 117, 0.4); }
html[data-theme="dark"] .alert.alert-primary .alert-text,
html[data-theme="dark"] .alert.alert-primary .alert-icon i,
html[data-theme="dark"] .alert.alert-primary .alert-close i { color: #b7bff2; }
html[data-theme="dark"] .alert.alert-info .alert-text,
html[data-theme="dark"] .alert.alert-info .alert-icon i,
html[data-theme="dark"] .alert.alert-info .alert-close i { color: #8fd9e5; }
html[data-theme="dark"] .alert.alert-success .alert-text,
html[data-theme="dark"] .alert.alert-success .alert-icon i,
html[data-theme="dark"] .alert.alert-success .alert-close i { color: #94dba7; }
html[data-theme="dark"] .alert.alert-danger .alert-text,
html[data-theme="dark"] .alert.alert-danger .alert-icon i,
html[data-theme="dark"] .alert.alert-danger .alert-close i { color: #f19aa3; }
html[data-theme="dark"] .alert.alert-light .alert-text,
html[data-theme="dark"] .alert.alert-light .alert-icon i,
html[data-theme="dark"] .alert.alert-light .alert-close i { color: var(--dm-text); }

html[data-theme="dark"] .badge-light,
html[data-theme="dark"] .badge-secondary,
html[data-theme="dark"] .kt-badge--light {
    background-color: var(--dm-surface-3);
    color: var(--dm-text);
}

html[data-theme="dark"] .progress { background-color: var(--dm-surface-3); }
html[data-theme="dark"] .tooltip-inner { background-color: #000; }

/* Select2 --------------------------------------------------------------- */
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
}
html[data-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple,
html[data-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--dm-focus); }
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__rendered,
html[data-theme="dark"] .ie-editor .select2-container--default .select2-selection--single .select2-selection__rendered,
html[data-theme="dark"] .sr-field-control .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--dm-text-strong); }
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder { color: #6c6d85; }
html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--single,
html[data-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--multiple { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .select2-dropdown {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field,
html[data-theme="dark"] .select2-container--default .select2-search--inline .select2-search__field {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] { background-color: var(--dm-surface-3); color: var(--dm-text-strong); }
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background-color: #21477b; color: #fff; }

/* SweetAlert2 ----------------------------------------------------------- */
html[data-theme="dark"] .swal2-popup { background-color: var(--dm-surface); }
html[data-theme="dark"] .swal2-popup .swal2-title { color: var(--dm-text-strong); }
html[data-theme="dark"] .swal2-popup .swal2-content,
html[data-theme="dark"] .swal2-popup .swal2-html-container { color: var(--dm-text); }
html[data-theme="dark"] .swal2-popup .swal2-input,
html[data-theme="dark"] .swal2-popup .swal2-textarea,
html[data-theme="dark"] .swal2-popup .swal2-select {
    background-color: var(--dm-input);
    border-color: var(--dm-border-strong);
    color: var(--dm-text-strong);
}
html[data-theme="dark"] .swal2-icon.swal2-success [class^="swal2-success-circular-line"],
html[data-theme="dark"] .swal2-icon.swal2-success .swal2-success-fix { background-color: var(--dm-surface) !important; }

/* Date pickers ---------------------------------------------------------- */
html[data-theme="dark"] .datepicker,
html[data-theme="dark"] .datepicker.dropdown-menu,
html[data-theme="dark"] .daterangepicker,
html[data-theme="dark"] .daterangepicker .calendar-table,
html[data-theme="dark"] .flatpickr-calendar,
html[data-theme="dark"] .bootstrap-timepicker-widget.dropdown-menu {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .datepicker table tr td,
html[data-theme="dark"] .datepicker table tr th,
html[data-theme="dark"] .daterangepicker td,
html[data-theme="dark"] .daterangepicker th { color: var(--dm-text); }
html[data-theme="dark"] .datepicker table tr td.old,
html[data-theme="dark"] .datepicker table tr td.new,
html[data-theme="dark"] .daterangepicker td.off { color: #5d5e75; background-color: transparent; }
html[data-theme="dark"] .datepicker table tr td.day:hover,
html[data-theme="dark"] .datepicker table tr th.prev:hover,
html[data-theme="dark"] .datepicker table tr th.next:hover,
html[data-theme="dark"] .datepicker table tr th.datepicker-switch:hover,
html[data-theme="dark"] .datepicker table tr td span:hover,
html[data-theme="dark"] .daterangepicker td.available:hover,
html[data-theme="dark"] .daterangepicker th.available:hover { background-color: var(--dm-surface-3); color: var(--dm-text-strong); }
html[data-theme="dark"] .daterangepicker td.in-range { background-color: rgba(91, 143, 214, 0.2); color: var(--dm-text-strong); }
html[data-theme="dark"] .daterangepicker .drp-buttons,
html[data-theme="dark"] .daterangepicker .ranges li:hover { border-color: var(--dm-border); background-color: var(--dm-surface-3); }
html[data-theme="dark"] .daterangepicker:after { border-bottom-color: var(--dm-surface-2); }

/* FullCalendar ---------------------------------------------------------- */
html[data-theme="dark"] .fc-unthemed th,
html[data-theme="dark"] .fc-unthemed td,
html[data-theme="dark"] .fc-unthemed thead,
html[data-theme="dark"] .fc-unthemed tbody,
html[data-theme="dark"] .fc-unthemed .fc-divider,
html[data-theme="dark"] .fc-unthemed .fc-row,
html[data-theme="dark"] .fc-unthemed .fc-content,
html[data-theme="dark"] .fc-unthemed .fc-popover,
html[data-theme="dark"] .fc-unthemed .fc-list-view,
html[data-theme="dark"] .fc-unthemed .fc-list-heading td { border-color: var(--dm-border); }
html[data-theme="dark"] .fc-unthemed .fc-day-header,
html[data-theme="dark"] .fc-unthemed .fc-day-number,
html[data-theme="dark"] .fc-unthemed .fc-toolbar h2 { color: var(--dm-text); }
html[data-theme="dark"] .fc-unthemed .fc-today { background-color: rgba(91, 143, 214, 0.12); }
html[data-theme="dark"] .fc-unthemed .fc-popover,
html[data-theme="dark"] .fc-unthemed .fc-list-heading td,
html[data-theme="dark"] .fc-unthemed .fc-divider { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .fc-unthemed .fc-list-item:hover td { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .fc-unthemed .fc-event,
html[data-theme="dark"] .fc-unthemed .fc-event-dot { background-color: var(--dm-surface-3); }
html[data-theme="dark"] .fc-unthemed .fc-event .fc-title,
html[data-theme="dark"] .fc-unthemed .fc-event .fc-time { color: var(--dm-text-strong); }

/* KTDialog "Loading ..." toast */
html[data-theme="dark"] .kt-dialog {
    background-color: var(--dm-surface-2);
    color: var(--dm-text);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Overlays and scrollbars ----------------------------------------------- */
html[data-theme="dark"] .loadingoverlay { background-color: rgba(21, 21, 33, 0.8) !important; }
html[data-theme="dark"] .ps > .ps__rail-y > .ps__thumb-y,
html[data-theme="dark"] .ps > .ps__rail-x > .ps__thumb-x { background: var(--dm-border-strong); }

/* Page-level surfaces (classes defined in individual views) ------------- */
html[data-theme="dark"] .contact-card,
html[data-theme="dark"] .contact-card-ntp,
html[data-theme="dark"] .timeline-card,
html[data-theme="dark"] .kanban-card,
html[data-theme="dark"] .cfg-modal,
html[data-theme="dark"] .ptype-box,
html[data-theme="dark"] .stage-ribbon-container,
html[data-theme="dark"] .ud-file-btn,
html[data-theme="dark"] .profile-assign-btn--set {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .kanban-column,
html[data-theme="dark"] .stage-controls,
html[data-theme="dark"] .contact-header,
html[data-theme="dark"] .method-details,
html[data-theme="dark"] .sr-work-body,
html[data-theme="dark"] .table-controls,
html[data-theme="dark"] .perm-selected-bar,
html[data-theme="dark"] .perm-preview,
html[data-theme="dark"] .perm-preview-sm,
html[data-theme="dark"] .project-address,
html[data-theme="dark"] .document-status-badges,
html[data-theme="dark"] .document-badge,
html[data-theme="dark"] .ie-long .ie-display,
html[data-theme="dark"] .appt-disposition-col,
html[data-theme="dark"] .sr-checklist-table th,
html[data-theme="dark"] .ptype-group-row td,
html[data-theme="dark"] .perm-code,
html[data-theme="dark"] .profile-pick-card__check,
html[data-theme="dark"] .profile-pick-card__count,
html[data-theme="dark"] .psummary-type,
html[data-theme="dark"] .psummary-badge--users,
html[data-theme="dark"] .group-chip,
html[data-theme="dark"] .hint-chip,
html[data-theme="dark"] .role-badge,
html[data-theme="dark"] .count-badge--none,
html[data-theme="dark"] .type-badge--regular,
html[data-theme="dark"] .user-you-badge,
html[data-theme="dark"] .user-type-readonly--regular,
html[data-theme="dark"] .profile-assign-btn--empty,
html[data-theme="dark"] .step-number,
html[data-theme="dark"] .disabled-action,
html[data-theme="dark"] .ie-cancel span,
html[data-theme="dark"] .tier-input,
html[data-theme="dark"] .cfg-field input,
html[data-theme="dark"] .dataTables_filter input {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] .collapsible-header:hover,
html[data-theme="dark"] .permission-table tbody tr:hover,
html[data-theme="dark"] .psummary-table tbody tr:hover,
html[data-theme="dark"] .user-table tbody tr:hover,
html[data-theme="dark"] .ptype-row:hover,
html[data-theme="dark"] .profile-pick-card:hover,
html[data-theme="dark"] .method-card:hover,
html[data-theme="dark"] .psummary-action-btn--edit:hover,
html[data-theme="dark"] .profile-assign-btn--empty:hover,
html[data-theme="dark"] .disabled-action:hover,
html[data-theme="dark"] .ie-cancel:hover span {
    background: var(--dm-surface-3);
}
html[data-theme="dark"] .profile-pick-card.active {
    background: rgba(91, 143, 214, 0.18);
    border-color: var(--dm-focus);
}
html[data-theme="dark"] .timeline-dot.pending,
html[data-theme="dark"] .mobile-stage-dot.pending,
html[data-theme="dark"] .notice-dot.pending { background: var(--dm-surface-3); border-color: var(--dm-border-strong); }
html[data-theme="dark"] .kanban-cards::-webkit-scrollbar-track,
html[data-theme="dark"] .kanban-scroll-container::-webkit-scrollbar-track,
html[data-theme="dark"] .timeline-container::-webkit-scrollbar-track { background: var(--dm-surface-2); }

/* Page-level text that is hardcoded dark */
html[data-theme="dark"] .contact-item label,
html[data-theme="dark"] .contact-item span,
html[data-theme="dark"] .document-badge-name,
html[data-theme="dark"] .edit-label,
html[data-theme="dark"] .ie-display,
html[data-theme="dark"] .ie-label,
html[data-theme="dark"] .ie-status-secondary .ie-display,
html[data-theme="dark"] .kanban-card-title,
html[data-theme="dark"] .profile-pick-card__name,
html[data-theme="dark"] .project-address h6,
html[data-theme="dark"] .psummary-profile-name,
html[data-theme="dark"] .ptype-name,
html[data-theme="dark"] .sr-field-label,
html[data-theme="dark"] .sr-new-label,
html[data-theme="dark"] .sr-project-option-name,
html[data-theme="dark"] .sr-work-state,
html[data-theme="dark"] .sr-work-stat-value,
html[data-theme="dark"] .stage-ribbon-header h5,
html[data-theme="dark"] .summary-row__val,
html[data-theme="dark"] .timeline-label .stage-name,
html[data-theme="dark"] .ud-doc-label,
html[data-theme="dark"] .ud-file-name,
html[data-theme="dark"] .ud-poi-label,
html[data-theme="dark"] .user-name,
html[data-theme="dark"] .user-type-card span {
    color: var(--dm-text-strong);
}

/* Custom tables in views draw light (#ebedf2-ish) row borders and header fills */
html[data-theme="dark"] #kt_content table th,
html[data-theme="dark"] #kt_content table td { border-color: var(--dm-border) !important; }
html[data-theme="dark"] #kt_content table thead th { background-color: var(--dm-surface-2); }
html[data-theme="dark"] .user-table th,
html[data-theme="dark"] .permission-table th,
html[data-theme="dark"] .ptype-table thead th,
html[data-theme="dark"] .upload-doc-table thead th,
html[data-theme="dark"] .sr-checklist-table th { color: var(--dm-text-muted); }

/* Project details: Upload Document tab (page styles are #upload-document scoped) */
html[data-theme="dark"] #upload-document .contact-card,
html[data-theme="dark"] #upload-document .contact-body,
html[data-theme="dark"] #upload-document .table,
html[data-theme="dark"] #upload-document .table td {
    background: var(--dm-surface);
    border-color: var(--dm-border);
    color: var(--dm-text);
}
html[data-theme="dark"] #upload-document .contact-card { box-shadow: none; }
html[data-theme="dark"] #upload-document .contact-header {
    background: var(--dm-surface-2);
    border-bottom-color: var(--dm-border);
}
html[data-theme="dark"] #upload-document .contact-header h6 { color: var(--dm-text-strong); }
html[data-theme="dark"] #upload-document .table thead th { background: var(--dm-surface-2); color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .mf-doc-header td {
    background: var(--dm-surface-2);
    border-top-color: var(--dm-border);
}
html[data-theme="dark"] #upload-document .mf-head-label { color: var(--dm-text-strong); }
html[data-theme="dark"] #upload-document .mf-file-count { background: var(--dm-surface-3); color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .ud-doc-icon { color: var(--dm-link); }
html[data-theme="dark"] #upload-document .ud-member-avatar { background: #2f5a96; }
html[data-theme="dark"] #upload-document .ud-progress-pill { background: rgba(255, 184, 34, 0.12); border-color: rgba(255, 184, 34, 0.35); color: #ffc94d; }
html[data-theme="dark"] #upload-document .ud-progress-pill.is-complete { background: rgba(40, 167, 69, 0.15); border-color: rgba(40, 167, 69, 0.4); color: #7fd99a; }
html[data-theme="dark"] #upload-document .ud-type-badge.ud-type-required { background: rgba(220, 53, 69, 0.15); border-color: rgba(220, 53, 69, 0.4); color: #f19aa3; }
html[data-theme="dark"] #upload-document .ud-type-badge.ud-type-optional { background: var(--dm-surface-3); border-color: var(--dm-border-strong); color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .ud-status { color: #ffc94d; }
html[data-theme="dark"] #upload-document .doc-row.is-uploaded .ud-status { color: #7fd99a; }
html[data-theme="dark"] #upload-document .doc-row.is-uploaded td { background: var(--dm-surface); }
html[data-theme="dark"] #upload-document .doc-row.is-editing td,
html[data-theme="dark"] #upload-document .doc-row.has-pending-file td,
html[data-theme="dark"] #upload-document tr.mf-upload-row.has-pending-file td { background: rgba(255, 184, 34, 0.08); }
html[data-theme="dark"] #upload-document .ud-file-btn {
    background: var(--dm-input);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}
html[data-theme="dark"] #upload-document .ud-file-btn:hover,
html[data-theme="dark"] #upload-document .ud-file-btn.has-file { border-color: var(--dm-focus); background: rgba(91, 143, 214, 0.12); }
html[data-theme="dark"] #upload-document .ud-file-caret { color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .ud-chip-btn.mf-upload-btn,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-upload-btn { background: rgba(40, 167, 69, 0.18); color: #7fd99a; }
html[data-theme="dark"] #upload-document .ud-chip-btn.mf-upload-btn:hover:not(:disabled),
html[data-theme="dark"] #upload-document .ud-chip-btn.row-upload-btn:hover:not(:disabled) { background: rgba(40, 167, 69, 0.3); color: #a6e8b9; }
html[data-theme="dark"] #upload-document .ud-chip-btn.mf-upload-btn:disabled,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-upload-btn:disabled { background: var(--dm-surface-3); color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .ud-chip-btn.mf-remove-btn,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-cancel-btn,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-opt-remove-btn { background: var(--dm-surface-3); color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .ud-chip-btn.mf-remove-btn:hover,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-cancel-btn:hover,
html[data-theme="dark"] #upload-document .ud-chip-btn.row-opt-remove-btn:hover { background: rgba(220, 53, 69, 0.2); color: #f19aa3; }
html[data-theme="dark"] #upload-document .doc-view-btn,
html[data-theme="dark"] #upload-document .row-edit-btn,
html[data-theme="dark"] #upload-document .row-delete-btn,
html[data-theme="dark"] #upload-document .mf-delete-btn { color: var(--dm-text-muted); }
html[data-theme="dark"] #upload-document .doc-view-btn:hover,
html[data-theme="dark"] #upload-document .row-edit-btn:hover { color: var(--dm-text-strong); }
html[data-theme="dark"] #upload-document .mf-add-btn,
html[data-theme="dark"] #upload-document .ud-icon-btn.ud-download { color: var(--dm-link); }
html[data-theme="dark"] #upload-document .mf-add-btn:hover,
html[data-theme="dark"] #upload-document .ud-icon-btn.ud-download:hover { color: var(--dm-link-hover); }

/* Users list (users/index) */
html[data-theme="dark"] .user-email { color: var(--dm-text-muted); }
html[data-theme="dark"] .user-you-badge { background: rgba(88, 103, 221, 0.2); color: #9aa5f0; }
html[data-theme="dark"] .ust__track { background: #44455c; }
html[data-theme="dark"] .ust-fixed { background: #44455c; }
html[data-theme="dark"] .ust-fixed--active { background: #34bfa3; }
html[data-theme="dark"] .profile-assign-btn--set { background: rgba(88, 103, 221, 0.18); border-color: rgba(124, 137, 235, 0.5); color: #c3c9f7; }
html[data-theme="dark"] .profile-assign-btn--set:hover { background: #5867dd; color: #fff; }
html[data-theme="dark"] .profile-assign-btn--empty { background: transparent; border-color: var(--dm-border-strong); color: var(--dm-text-muted); }
html[data-theme="dark"] .profile-assign-btn--empty:hover { background: rgba(88, 103, 221, 0.18); border-color: #7c89eb; color: #c3c9f7; }
html[data-theme="dark"] .count-badge--info { background: rgba(54, 163, 247, 0.18); color: #7cc4fa; }
html[data-theme="dark"] .count-badge--none { background: var(--dm-surface-2); color: var(--dm-text-muted); }
html[data-theme="dark"] .type-badge--admin { background: rgba(245, 124, 0, 0.18); color: #ffb74d; }
html[data-theme="dark"] .type-badge--regular { background: var(--dm-surface-2); color: var(--dm-text); }
html[data-theme="dark"] .type-badge--operation { background: rgba(54, 163, 247, 0.18); color: #7cc4fa; }

/* Pages that restyle DataTables pagination with !important white buttons */
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    background: var(--dm-surface) !important;
    border-color: var(--dm-border-strong) !important;
    color: #9aa5f0 !important;
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--dm-surface-3) !important;
    border-color: var(--dm-border-strong) !important;
    color: #c3c9f7 !important;
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #5867dd !important;
    border-color: #5867dd !important;
    color: #fff !important;
}
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background: var(--dm-surface) !important;
    color: #5d5e75 !important;
}

/* Profiles list (profiles/index) */
html[data-theme="dark"] .psummary-table th {
    background: var(--dm-surface-2);
    color: var(--dm-text-muted);
}
html[data-theme="dark"] .psummary-desc-text { color: var(--dm-text); }
html[data-theme="dark"] .psummary-lock { color: var(--dm-text-muted); }
html[data-theme="dark"] .psummary-type--crm_agent { background: rgba(255, 152, 0, 0.15); color: #ffb74d; }
html[data-theme="dark"] .psummary-type--operation { background: rgba(26, 127, 209, 0.18); color: #6cb6f2; }
html[data-theme="dark"] .psummary-badge--users { background: rgba(88, 103, 221, 0.18); color: #9aa5f0; }
html[data-theme="dark"] .psummary-badge--perms { background: rgba(29, 201, 183, 0.15); color: #4fe0cf; }
html[data-theme="dark"] .psummary-action-btn--edit { color: #8f9bf0; }
html[data-theme="dark"] .psummary-action-btn--del { color: var(--dm-text-muted); }
html[data-theme="dark"] .psummary-action-btn--del:hover { background: rgba(253, 57, 149, 0.15); color: #fd5fa9; }
html[data-theme="dark"] .psummary-action-btn--locked,
html[data-theme="dark"] .psummary-action-btn--locked:hover { background: transparent; color: #5d5e75; }

/* KTDatatable (the theme's own datatable, used on the dashboard) -------- */
html[data-theme="dark"] .kt-datatable > .kt-datatable__table { background-color: transparent; }
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__head .kt-datatable__row,
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__body .kt-datatable__row,
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__foot .kt-datatable__row { border-bottom-color: var(--dm-border); }
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__head .kt-datatable__row > .kt-datatable__cell > span,
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__foot .kt-datatable__row > .kt-datatable__cell > span { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-datatable.kt-datatable--default > .kt-datatable__table > .kt-datatable__body .kt-datatable__row > .kt-datatable__cell > span { color: var(--dm-text); }
html[data-theme="dark"] .kt-datatable.kt-datatable--default > .kt-datatable__table > .kt-datatable__head .kt-datatable__row > .kt-datatable__cell.kt-datatable__cell--sorted > span { color: #9aa5f0; }
html[data-theme="dark"] .kt-datatable.kt-datatable--default > .kt-datatable__table > .kt-datatable__body .kt-datatable__row.kt-datatable__row--active > .kt-datatable__cell,
html[data-theme="dark"] .kt-datatable.kt-datatable--default > .kt-datatable__table > .kt-datatable__body .kt-datatable__row:hover > .kt-datatable__cell { background: var(--dm-surface-2); }
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__head > .kt-datatable__lock,
html[data-theme="dark"] .kt-datatable > .kt-datatable__table > .kt-datatable__body > .kt-datatable__lock { box-shadow: none; }
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link { color: #9aa5f0; }
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--first,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--prev,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--next,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--last,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--disabled,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-pager-input,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-info .kt-datatable__pager-size .btn.dropdown-toggle {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: #9aa5f0;
}
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link:hover,
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-nav > li > .kt-datatable__pager-link.kt-datatable__pager-link--active { background: #5d78ff; color: #fff; }
html[data-theme="dark"] .kt-datatable > .kt-datatable__pager > .kt-datatable__pager-info .kt-datatable__pager-detail { color: var(--dm-text-muted); }
html[data-theme="dark"] .kt-datatable .ps > .ps__rail-y > .ps__thumb-y,
html[data-theme="dark"] .kt-datatable .ps > .ps__rail-x > .ps__thumb-x { background: var(--dm-border-strong); }

/* Dashboard widgets (dashboard/index + _pipeline_stages) ---------------- */
html[data-theme="dark"] .kt-widget17 .kt-widget17__stats .kt-widget17__items .kt-widget17__item {
    background-color: var(--dm-surface-2);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .kt-widget17 .kt-widget17__stats .kt-widget17__items .kt-widget17__item .kt-widget17__subtitle { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-widget17 .kt-widget17__stats .kt-widget17__items .kt-widget17__item .kt-widget17__desc { color: var(--dm-text-muted); }

html[data-theme="dark"] .kt-widget4 .kt-widget4__item,
html[data-theme="dark"] .kt-widget5 .kt-widget5__item { border-bottom-color: var(--dm-border) !important; }
html[data-theme="dark"] .kt-widget4 .kt-widget4__item .kt-widget4__info .kt-widget4__username,
html[data-theme="dark"] .kt-widget4 .kt-widget4__item .kt-widget4__info .kt-widget4__title,
html[data-theme="dark"] .kt-widget4 .kt-widget4__item .kt-widget4__title,
html[data-theme="dark"] .kt-widget5 .kt-widget5__item .kt-widget5__content .kt-widget5__title,
html[data-theme="dark"] .kt-widget5 .kt-widget5__item .kt-widget5__content .kt-widget5__stats .kt-widget5__number { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-widget4 .kt-widget4__item .kt-widget4__info .kt-widget4__text,
html[data-theme="dark"] .kt-widget4 .kt-widget4__item .kt-widget4__icon > i,
html[data-theme="dark"] .kt-widget5 .kt-widget5__item .kt-widget5__content .kt-widget5__desc { color: var(--dm-text-muted); }

html[data-theme="dark"] .kt-timeline-v2:before { background-color: var(--dm-border-strong); }
html[data-theme="dark"] .kt-timeline-v2 .kt-timeline-v2__items .kt-timeline-v2__item .kt-timeline-v2__item-cricle { border-color: var(--dm-surface); }
html[data-theme="dark"] .kt-timeline-v2 .kt-timeline-v2__items .kt-timeline-v2__item .kt-timeline-v2__item-time { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-timeline-v2 .kt-timeline-v2__items .kt-timeline-v2__item .kt-timeline-v2__item-text,
html[data-theme="dark"] .kt-timeline-v2 .kt-timeline-v2__items .kt-timeline-v2__item .kt-timeline-v2__item-text.kt-timeline-v2__item-text--bold { color: var(--dm-text); }

html[data-theme="dark"] .kt-user-card-v2 .kt-user-card-v2__details .kt-user-card-v2__name { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-user-card-v2 .kt-user-card-v2__details a.kt-user-card-v2__name:hover { color: var(--dm-link-hover); }
html[data-theme="dark"] .kt-user-card-v2 .kt-user-card-v2__details .kt-user-card-v2__desc,
html[data-theme="dark"] .kt-user-card-v2 .kt-user-card-v2__details .kt-user-card-v2__email { color: var(--dm-text-muted); }

html[data-theme="dark"] .kt-nav .kt-nav__head,
html[data-theme="dark"] .kt-nav .kt-nav__foot { color: var(--dm-text-strong); }
html[data-theme="dark"] .kt-nav .kt-nav__head > i,
html[data-theme="dark"] .kt-nav .kt-nav__foot > i,
html[data-theme="dark"] .kt-nav .kt-nav__item > .kt-nav__link .kt-nav__link-icon { color: var(--dm-text-muted); }
html[data-theme="dark"] .kt-nav .kt-nav__separator { border-bottom-color: var(--dm-border); }

/* Inline styles on the dashboard: "Please wait" overlays, dividers, progress tracks */
html[data-theme="dark"] #kt_content [style*="rgba(255,255,255,0.75)"],
html[data-theme="dark"] #kt_content [style*="rgba(255, 255, 255, 0.75)"] { background: rgba(21, 21, 33, 0.8) !important; }
html[data-theme="dark"] #kt_content [style*="border-bottom: 1px dashed #ebedf2"],
html[data-theme="dark"] #kt_content [style*="border-bottom: 1px solid #ebedf2"] { border-bottom-color: var(--dm-border) !important; }
html[data-theme="dark"] #kt_content [style*="background:#ebedf2"] { background: var(--dm-surface-3) !important; }
html[data-theme="dark"] #kt_content [style*="color:#74788d"] { color: var(--dm-text-muted) !important; }

/* Service / Inspection detail (operation-team/show + partials/page-styles) */
html[data-theme="dark"] .sr-header,
html[data-theme="dark"] .sr-checklist-body { border-color: var(--dm-border); }
html[data-theme="dark"] .sr-section-title { color: var(--dm-link); border-bottom-color: #3b5f91; }
html[data-theme="dark"] .sr-checklist-heading,
html[data-theme="dark"] .ie-title .ie-display,
html[data-theme="dark"] .sr-work-timer { color: var(--dm-link); }
html[data-theme="dark"] .sr-checklist-hint,
html[data-theme="dark"] .sr-work-hint,
html[data-theme="dark"] .sr-work-stat-label,
html[data-theme="dark"] .sr-project-option-address { color: var(--dm-text-muted); }
html[data-theme="dark"] .sr-work-stat--total .sr-work-stat-value { color: #34d399; }

/* Inline-edit fields */
html[data-theme="dark"] .ie-field { border-bottom-color: var(--dm-border); }
html[data-theme="dark"] .ie-label { color: var(--dm-text-muted); }
html[data-theme="dark"] .ie-empty { color: #6c6d85; }
html[data-theme="dark"] .ie-pencil { color: var(--dm-link); }
html[data-theme="dark"] .ie-editable .ie-display:hover,
html[data-theme="dark"] .ie-editable .ie-display:focus { background: var(--dm-surface-2); border-color: var(--dm-border-strong); }
html[data-theme="dark"] .ie-long .ie-display { background: var(--dm-input); border-color: var(--dm-border); }
html[data-theme="dark"] .ie-cancel span { background: var(--dm-surface-2); color: var(--dm-text); border-color: var(--dm-text-muted); }
html[data-theme="dark"] .ie-cancel:hover span { background: var(--dm-surface-3); }
html[data-theme="dark"] .ie-field.ie-saved .ie-display { background: rgba(10, 187, 135, 0.15); border-color: rgba(10, 187, 135, 0.45); }
html[data-theme="dark"] .ie-field.ie-preview .ie-display { background: rgba(255, 184, 34, 0.12); border-color: rgba(255, 184, 34, 0.5); }
html[data-theme="dark"] .ie-editor .select2-container--default .select2-selection--single,
html[data-theme="dark"] .ie-editor .select2-container--default .select2-selection--multiple { border-color: var(--dm-border-strong); }
html[data-theme="dark"] .ie-editor .select2-container--default .select2-selection--single .select2-selection__placeholder { color: #6c6d85; }
@media (hover: none) {
    html[data-theme="dark"] .ie-editable .ie-display { border-color: var(--dm-border-strong); }
}

/* Header status pill: keep the colour coding, as tints */
html[data-theme="dark"] .ie-status-secondary .ie-display { background: var(--dm-surface-3); border-color: var(--dm-border-strong); color: var(--dm-text-strong); }
html[data-theme="dark"] .ie-status-warning .ie-display { background: rgba(255, 184, 34, 0.15); border-color: rgba(255, 184, 34, 0.5); color: #ffd16b; }
html[data-theme="dark"] .ie-status-success .ie-display { background: rgba(10, 187, 135, 0.15); border-color: rgba(10, 187, 135, 0.5); color: #4ade9f; }
html[data-theme="dark"] .ie-status-danger .ie-display { background: rgba(253, 57, 122, 0.15); border-color: rgba(253, 57, 122, 0.5); color: #ff8fb1; }
html[data-theme="dark"] .ie-status-dark .ie-display { background: var(--dm-surface-3); border-color: #6c6d85; color: var(--dm-text-strong); }
html[data-theme="dark"] .ie-status.ie-editable .ie-display:hover { filter: brightness(1.15); }

/* Work time card */
html[data-theme="dark"] .sr-work { --sr-work-accent: #7b7d95; --sr-work-tint: rgba(162, 165, 185, 0.15); }
html[data-theme="dark"] .sr-work.sr-work--running { --sr-work-accent: #ffb822; --sr-work-tint: rgba(255, 184, 34, 0.15); }
html[data-theme="dark"] .sr-work.sr-work--done { --sr-work-accent: #0abb87; --sr-work-tint: rgba(10, 187, 135, 0.15); }
html[data-theme="dark"] .sr-work-body { background: var(--dm-surface-2); border-color: var(--dm-border); border-left-color: var(--sr-work-accent); }
html[data-theme="dark"] .sr-work-state { background: var(--sr-work-tint); }

/* Checklist */
html[data-theme="dark"] .sr-checklist-table { border-left-color: var(--dm-border); border-right-color: var(--dm-border); }
html[data-theme="dark"] .sr-cl-category td { background: #22304a; color: #a4c0e6; }
html[data-theme="dark"] .sr-checklist-table tr.sr-cl-saved td { background: rgba(10, 187, 135, 0.15); }
html[data-theme="dark"] .sr-checklist-table tr.sr-cl-failed td { background: rgba(253, 57, 122, 0.15); }

/* Photos & Files */
html[data-theme="dark"] .sr-attach-list,
html[data-theme="dark"] .sr-attach-item + .sr-attach-item,
html[data-theme="dark"] .sr-attach-row + .sr-attach-row { border-color: var(--dm-border); }
html[data-theme="dark"] .sr-attach-thumb { background: var(--dm-surface-2); color: var(--dm-link); }
html[data-theme="dark"] .sr-attach-name { color: var(--dm-link); }
html[data-theme="dark"] .sr-attach-empty,
html[data-theme="dark"] .sr-attach-meta,
html[data-theme="dark"] .sr-attach-hint,
html[data-theme="dark"] .sr-attach-progress-text { color: var(--dm-text-muted); }
html[data-theme="dark"] .sr-attach-download,
html[data-theme="dark"] .sr-attach-remove { color: var(--dm-text); }
html[data-theme="dark"] .sr-attach-download:hover,
html[data-theme="dark"] .sr-attach-remove:hover { background: var(--dm-surface-3); color: var(--dm-link); }
html[data-theme="dark"] #sr-attach-modal .input-group-text { background: var(--dm-surface-3); border-color: var(--dm-border-strong); color: var(--dm-text-muted); }
html[data-theme="dark"] #sr-attach-modal .progress { background: var(--dm-surface-3); }

/* Permission selector (profiles/partials/perm-selector-css) ------------ */
html[data-theme="dark"] .perm-selected-bar { background: rgba(88, 103, 221, 0.18); }
html[data-theme="dark"] .perm-selected-bar__num,
html[data-theme="dark"] .text-brand { color: #9aa5f0 !important; }

html[data-theme="dark"] .ptype-chip span { background: var(--dm-surface-2); border-color: var(--dm-border-strong); color: var(--dm-text); }
html[data-theme="dark"] .ptype-chip input:checked + span { background: rgba(88, 103, 221, 0.2); border-color: #7c89eb; color: #c3c9f7; }
html[data-theme="dark"] .ptype-chip input:checked + span i { color: #c3c9f7; }

html[data-theme="dark"] .perm-group { border-color: var(--dm-border); background: var(--dm-surface); }
html[data-theme="dark"] .perm-group__head { background: var(--dm-surface-2); }
html[data-theme="dark"] .perm-group__head:hover { background: var(--dm-surface-3); }
html[data-theme="dark"] .perm-group__body { border-top-color: var(--dm-border); }
html[data-theme="dark"] .perm-group__name { color: var(--dm-text-strong); }
html[data-theme="dark"] .perm-group__icon { color: #9aa5f0; }
html[data-theme="dark"] .perm-group__chevron { color: var(--dm-text-muted); }
html[data-theme="dark"] .perm-group__select-label { color: #8b95d6; border-right-color: var(--dm-border-strong); }
html[data-theme="dark"] .perm-group__head:hover .perm-group__select-label { color: #c3c9f7; }
html[data-theme="dark"] .perm-group__counter { background: var(--dm-surface); color: var(--dm-text-muted); }
html[data-theme="dark"] .perm-group__counter-sel { color: #9aa5f0; }
html[data-theme="dark"] .perm-group__toggle-check-box { background: var(--dm-input); border-color: #5c66a8; }
html[data-theme="dark"] .perm-group__toggle-check input:checked ~ .perm-group__toggle-check-box,
html[data-theme="dark"] .perm-group__toggle-check input:indeterminate ~ .perm-group__toggle-check-box { background: #5867dd; border-color: #5867dd; }

html[data-theme="dark"] .perm-tile { border-color: var(--dm-border-strong); background: var(--dm-input); }
html[data-theme="dark"] .perm-tile:hover { border-color: #7c89eb; background: var(--dm-surface-2); }
html[data-theme="dark"] .perm-tile__name { color: var(--dm-text); }
html[data-theme="dark"] .perm-tile__check { background: var(--dm-input); border-color: #5c66a8; }
html[data-theme="dark"] .perm-tile__info { color: #5c66a8; }
html[data-theme="dark"] .perm-tile:hover .perm-tile__info { color: #9aa5f0; }
html[data-theme="dark"] .perm-tile--checked {
    background: rgba(88, 103, 221, 0.2) !important;
    border-color: #7c89eb !important;
}
html[data-theme="dark"] .perm-tile--checked .perm-tile__name { color: #e3e6fc; font-weight: 600; }
html[data-theme="dark"] .perm-tile--checked .perm-tile__check { background: #5867dd; border-color: #5867dd; color: #fff; }
html[data-theme="dark"] .perm-tile--checked .perm-tile__info { color: #9aa5f0; }

/* Admin zone keeps its red accent */
html[data-theme="dark"] .perm-zone-divider__badge { background: rgba(192, 57, 43, 0.18); border-color: rgba(241, 167, 174, 0.4); color: #f19aa3; }
html[data-theme="dark"] .perm-group--admin-zone { border-color: rgba(241, 167, 174, 0.35); }
html[data-theme="dark"] .perm-group--admin-zone .perm-group__head { background: rgba(192, 57, 43, 0.12); }
html[data-theme="dark"] .perm-group--admin-zone .perm-group__head:hover { background: rgba(192, 57, 43, 0.2); }
html[data-theme="dark"] .perm-group--admin-zone .perm-group__icon,
html[data-theme="dark"] .perm-group--admin-zone .perm-group__name,
html[data-theme="dark"] .perm-group--admin-zone .perm-group__counter-sel { color: #f19aa3; }
html[data-theme="dark"] .perm-group--admin-zone .perm-group__select-label { color: #c97b84; }
html[data-theme="dark"] .perm-tile--readonly:hover { background: var(--dm-input); }
html[data-theme="dark"] .perm-tile--readonly.perm-tile--checked { background: rgba(192, 57, 43, 0.18) !important; border-color: rgba(241, 167, 174, 0.45) !important; }
html[data-theme="dark"] .perm-tile--readonly.perm-tile--checked .perm-tile__check { background: #c0392b; border-color: #c0392b; }

html[data-theme="dark"] .btn-outline-brand { color: #9aa5f0; border-color: #7c89eb; }
html[data-theme="dark"] .btn-outline-brand:hover { background: #5867dd; color: #fff; }

/* Commission and SFA calculators: remap their local palette */
html[data-theme="dark"] .cc-wrap,
html[data-theme="dark"] .sfa-wrap {
    --cc-brand: #6f9be0;
    --cc-brand-lt: #8fb2e8;
    --cc-brand-dim: #23304a;
    --cc-bg: var(--dm-bg);
    --cc-white: var(--dm-surface);
    --cc-bd: var(--dm-border);
    --cc-bd2: var(--dm-border-strong);
    --cc-tx: var(--dm-text-strong);
    --cc-mu: var(--dm-text-muted);
    --cc-di: #6c6d85;
    --cc-gr-d: rgba(5, 150, 105, 0.18);
    --cc-gr-b: #34d399;
    --cc-rd-d: rgba(220, 38, 38, 0.18);
    --cc-go-d: rgba(217, 119, 6, 0.18);
    --cc-pu: #a78bfa;
    --cc-pu-d: rgba(124, 58, 237, 0.2);
    --cc-tl-d: rgba(8, 145, 178, 0.2);
}
html[data-theme="dark"] .cc-wrap .ni,
html[data-theme="dark"] .cc-wrap .sysinfo,
html[data-theme="dark"] .cc-wrap select,
html[data-theme="dark"] .cc-wrap .ct th,
html[data-theme="dark"] .sfa-wrap .ni,
html[data-theme="dark"] .sfa-wrap .sysinfo { background-color: var(--dm-input); }
html[data-theme="dark"] .cc-wrap .ni:focus,
html[data-theme="dark"] .sfa-wrap .ni:focus { background-color: var(--dm-input); }
/* Hardcoded light row fills: the selected row hid the light value text */
html[data-theme="dark"] .cc-wrap .ct tr.sel-row td { background: rgba(111, 155, 224, 0.14); }
html[data-theme="dark"] .cc-wrap .ct-row-inner:hover { background: var(--dm-surface-2); }
html[data-theme="dark"] #calcBtn { background: #2f5a96 !important; box-shadow: none !important; }
html[data-theme="dark"] .tier-badge.needs-approval { background: rgba(217, 119, 6, 0.18); color: #fbbf24; }
html[data-theme="dark"] .cfg-field input:focus,
html[data-theme="dark"] .tier-input:focus { background: var(--dm-input); }
html[data-theme="dark"] .tier-input { color: var(--dm-text-strong); }
html[data-theme="dark"] .cfg-modal-ft { background: var(--dm-surface-2); border-top-color: var(--dm-border); }

/* Inline styles: catch the most common hardcoded light backgrounds ------ */
html[data-theme="dark"] #kt_content [style*="background: #fff;"],
html[data-theme="dark"] #kt_content [style*="background:#fff;"],
html[data-theme="dark"] #kt_content [style*="background-color: #fff;"],
html[data-theme="dark"] #kt_content [style*="background-color:#fff;"],
html[data-theme="dark"] #kt_content [style*="background: #ffffff"],
html[data-theme="dark"] #kt_content [style*="background:#ffffff"],
html[data-theme="dark"] #kt_content [style*="background-color: #ffffff"],
html[data-theme="dark"] #kt_content [style*="background-color:#ffffff"],
html[data-theme="dark"] #kt_content [style*="background: white"],
html[data-theme="dark"] #kt_content [style*="background-color: white"] {
    background: var(--dm-surface) !important;
}
html[data-theme="dark"] #kt_content [style*="background: #f8f9fa"],
html[data-theme="dark"] #kt_content [style*="background:#f8f9fa"],
html[data-theme="dark"] #kt_content [style*="background-color: #f8f9fa"],
html[data-theme="dark"] #kt_content [style*="background-color:#f8f9fa"],
html[data-theme="dark"] #kt_content [style*="background: #f5f6fa"],
html[data-theme="dark"] #kt_content [style*="background-color: #f5f6fa"],
html[data-theme="dark"] #kt_content [style*="background: #f7f8fa"],
html[data-theme="dark"] #kt_content [style*="background-color: #f7f8fa"],
html[data-theme="dark"] #kt_content [style*="background: #f4f5f8"],
html[data-theme="dark"] #kt_content [style*="background-color: #f4f5f8"],
html[data-theme="dark"] #kt_content [style*="background: #f1f1f1"],
html[data-theme="dark"] #kt_content [style*="background-color: #f1f1f1"],
html[data-theme="dark"] #kt_content [style*="background: #eef0fe"],
html[data-theme="dark"] #kt_content [style*="background-color: #eef0fe"] {
    background: var(--dm-surface-2) !important;
}
html[data-theme="dark"] #kt_content [style*="color: #333"],
html[data-theme="dark"] #kt_content [style*="color:#333"],
html[data-theme="dark"] #kt_content [style*="color: #464e5f"],
html[data-theme="dark"] #kt_content [style*="color:#464e5f"],
html[data-theme="dark"] #kt_content [style*="color: #3f4254"],
html[data-theme="dark"] #kt_content [style*="color: #212529"],
html[data-theme="dark"] #kt_content [style*="color: #495057"],
html[data-theme="dark"] #kt_content [style*="color: #000"],
html[data-theme="dark"] #kt_content [style*="color:#000"] {
    color: var(--dm-text-strong) !important;
}
