:root {
    --crm-bg: #f4f7fb;
    --crm-surface: #ffffff;
    --crm-surface-soft: #f8fafc;
    --crm-surface-raised: #ffffff;
    --crm-text: #172033;
    --crm-text-muted: #667085;
    --crm-border: #e5eaf2;
    --crm-primary: #0b8fa7;
    --crm-primary-strong: #08758a;
    --crm-accent: #19b36a;
    --crm-header-bg: rgba(255, 255, 255, 0.92);
    --crm-shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.06);
    --crm-shadow: 0 12px 32px rgba(15, 23, 42, 0.09);
    --crm-shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.13);
    --crm-radius-sm: 10px;
    --crm-radius: 16px;
    --crm-radius-lg: 22px;
}

html[data-theme="dark"] {
    --crm-bg: #0a0f1c;
    --crm-surface: #121a2a;
    --crm-surface-soft: #172033;
    --crm-surface-raised: #1a2437;
    --crm-text: #edf3fc;
    --crm-text-muted: #aebbd0;
    --crm-border: #29354a;
    --crm-primary: #31bdd0;
    --crm-primary-strong: #55cedd;
    --crm-accent: #39d98a;
    --crm-header-bg: rgba(14, 21, 35, 0.94);
    --crm-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.22);
    --crm-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
    --crm-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.36);
    --bs-body-color: var(--crm-text);
    --bs-body-bg: var(--crm-bg);
    --bs-emphasis-color: var(--crm-text);
    --bs-secondary-color: var(--crm-text-muted);
    --bs-tertiary-color: var(--crm-text-muted);
    --bs-heading-color: var(--crm-text);
    --bs-border-color: var(--crm-border);
    --bs-secondary-bg: var(--crm-surface-soft);
    --bs-tertiary-bg: var(--crm-surface);
    --bs-link-color: #70d9e5;
    --bs-link-hover-color: #a5f3fc;
    --bs-table-color: var(--crm-text);
    --bs-table-bg: var(--crm-surface);
    --bs-table-border-color: var(--crm-border);
    --bs-form-control-color: var(--crm-text);
    --bs-form-control-bg: var(--crm-surface-soft);
}

html,
body,
.wrapper,
.main-panel,
.main-panel > .container {
    background: var(--crm-bg);
}

body,
button,
input,
select,
textarea {
    color: var(--crm-text);
}

body,
.main-panel,
.main-header,
.navbar,
.sidebar,
.card,
.modal-content,
.dropdown-menu,
input,
select,
textarea {
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

::selection {
    color: #ffffff;
    background: #0b8fa7;
}

/* Header actions */
.main-header .navbar-header {
    min-height: 70px;
    border-color: var(--crm-border) !important;
    background: var(--crm-header-bg) !important;
    box-shadow: 0 1px 0 var(--crm-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.main-header .logo-header,
.main-header-logo .logo-header {
    background: var(--crm-surface) !important;
}

.topbar-nav {
    gap: 6px;
}

.crm-header-action {
    display: inline-flex;
    align-items: center;
}

.crm-icon-button,
.navbar .crm-icon-button.nav-link {
    position: relative;
    display: inline-flex !important;
    width: 42px;
    height: 42px;
    min-width: 42px;
    align-items: center;
    justify-content: center;
    margin: 0;
    border: 1px solid var(--crm-border) !important;
    border-radius: 13px !important;
    padding: 0 !important;
    color: #344054 !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.crm-icon-button:hover,
.crm-icon-button:focus-visible,
.crm-icon-button[aria-expanded="true"] {
    border-color: rgba(11, 143, 167, 0.35) !important;
    color: var(--crm-primary) !important;
    background: color-mix(in srgb, var(--crm-primary) 8%, var(--crm-surface)) !important;
    outline: none;
    transform: translateY(-1px);
}

.crm-icon-button .notification {
    top: -5px !important;
    right: -5px !important;
    display: inline-flex;
    min-width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--crm-surface);
    border-radius: 999px;
    padding: 0 4px;
    color: #ffffff;
    background: #ef5061;
    box-shadow: 0 3px 8px rgba(239, 80, 97, 0.35);
    font-size: 0.58rem;
    font-weight: 800;
}

.topbar-user .profile-pic {
    min-height: 46px;
    border-radius: 14px;
    padding: 4px 7px !important;
}

.topbar-user .avatar-sm {
    width: 42px;
    height: 42px;
    border: 2px solid var(--crm-surface);
    border-radius: 13px;
    background: #ffffff;
    box-shadow: 0 0 0 1px var(--crm-border), var(--crm-shadow-sm);
}

.topbar-user .avatar-img,
[data-profile-avatar],
.mobile-sidebar-avatar,
.navbar-brand {
    opacity: 1 !important;
    filter: none !important;
}

.crm-notification-menu {
    width: min(390px, calc(100vw - 20px)) !important;
    min-width: min(390px, calc(100vw - 20px)) !important;
    margin-top: 12px !important;
    overflow: hidden;
    border: 1px solid var(--crm-border) !important;
    border-radius: 18px !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

.crm-notification-title {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    border-bottom: 1px solid var(--crm-border);
    padding: 14px 18px !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    font-size: 0.93rem !important;
    font-weight: 800 !important;
}

.crm-notification-title small {
    border-radius: 999px;
    padding: 4px 9px;
    color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 10%, var(--crm-surface));
    font-size: 0.66rem;
    font-weight: 800;
}

.crm-notification-menu .notif-scroll {
    max-height: 360px;
}

.crm-notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--crm-border);
    padding: 13px 16px;
    color: var(--crm-text);
    background: var(--crm-surface);
}

.crm-notification-item:last-child {
    border-bottom: 0;
}

.crm-notification-item:hover {
    background: var(--crm-surface-soft);
}

.crm-notification-item .notif-icon {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 12%, var(--crm-surface));
}

.crm-notification-item .notif-content {
    min-width: 0;
    padding-top: 1px;
}

.crm-notification-item .block {
    display: block;
    color: var(--crm-text);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.45;
}

.crm-notification-item .time {
    display: block;
    margin-top: 4px;
    color: var(--crm-text-muted);
    font-size: 0.66rem;
    font-weight: 600;
}

.crm-notification-empty {
    display: flex;
    min-height: 190px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 28px 20px;
    color: var(--crm-text-muted);
    text-align: center;
}

.crm-notification-empty > span {
    display: inline-flex;
    width: 54px;
    height: 54px;
    align-items: center;
    justify-content: center;
    margin-bottom: 13px;
    border-radius: 16px;
    color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 10%, var(--crm-surface));
    font-size: 1.25rem;
}

.crm-notification-empty strong {
    color: var(--crm-text);
    font-size: 0.84rem;
}

.crm-notification-empty small {
    margin-top: 5px;
    font-size: 0.72rem;
}

.marquee-bar {
    color: var(--crm-text);
    background: var(--crm-surface-soft) !important;
}

/* Shared professional page shell */
.main-panel > .container > .page-inner {
    padding-top: 22px;
}

.crm-page-hero {
    margin-bottom: 22px !important;
    padding: 6px 2px 14px !important;
}

.crm-page-hero-icon {
    width: 44px !important;
    height: 44px !important;
    flex-basis: 44px !important;
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 14px !important;
    box-shadow: 0 7px 16px rgba(245, 158, 11, 0.12);
}

.crm-page-hero-text h3 {
    color: var(--crm-text) !important;
    font-size: clamp(1.35rem, 2vw, 1.75rem) !important;
    letter-spacing: -0.025em;
}

.crm-page-hero-text h6 {
    color: var(--crm-text-muted) !important;
}

/* Dashboard visual hierarchy */
.crm-dashboard-page .page-inner {
    max-width: 1560px;
    margin: 0 auto;
}

.crm-dashboard-page .campus-analytics {
    margin-top: 4px;
}

.crm-dashboard-page .campus-stat-grid {
    gap: 18px;
    margin-bottom: 22px;
}

.crm-dashboard-page .campus-stat-card {
    position: relative;
    min-height: 134px;
    overflow: hidden;
    gap: 14px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    padding: 20px;
    color: var(--crm-text);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-page .campus-stat-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: var(--card-accent);
    opacity: 0.85;
}

.crm-dashboard-page .campus-stat-card:hover,
.crm-dashboard-page .campus-stat-card:focus {
    border-color: color-mix(in srgb, var(--card-accent) 34%, var(--crm-border));
    color: var(--crm-text);
    transform: translateY(-4px);
    box-shadow: var(--crm-shadow);
}

.crm-dashboard-page .campus-stat-icon {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    border-radius: 15px;
    background: color-mix(in srgb, var(--card-accent) 13%, var(--crm-surface));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--card-accent) 16%, transparent);
}

.crm-dashboard-page .campus-stat-label,
.crm-dashboard-page .campus-panel-subtitle,
.crm-dashboard-page .campus-activity-text,
.crm-dashboard-page .campus-activity-time,
.crm-dashboard-page .campus-fee-legend small,
.crm-dashboard-page .revenue-card__label,
.crm-dashboard-page .revenue-card__badge,
.crm-dashboard-page .campus-revenue-note {
    color: var(--crm-text-muted) !important;
}

.crm-dashboard-page .campus-stat-value,
.crm-dashboard-page .campus-panel-title,
.crm-dashboard-page .campus-activity-title,
.crm-dashboard-page .revenue-card__value,
.crm-dashboard-page .revenue-card__amount,
.crm-dashboard-page .latest-admissions-title {
    color: var(--crm-text) !important;
}

.crm-dashboard-page .campus-stat-value {
    font-size: clamp(1.16rem, 1.4vw, 1.4rem);
    letter-spacing: -0.02em;
}

.crm-dashboard-page .campus-main-grid,
.crm-dashboard-page .campus-lower-grid {
    gap: 18px;
    margin-bottom: 18px;
}

.crm-dashboard-page .campus-panel {
    overflow: hidden;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-page .campus-panel-head {
    min-height: 66px;
    border-bottom: 1px solid var(--crm-border);
    padding: 16px 20px;
}

.crm-dashboard-page .campus-panel-title {
    font-size: 0.96rem;
    letter-spacing: -0.012em;
}

.crm-dashboard-page .campus-panel-link,
.crm-dashboard-page .campus-range-pill,
.crm-dashboard-page .campus-range-select {
    border-color: color-mix(in srgb, var(--crm-primary) 20%, var(--crm-border));
    border-radius: 9px;
    color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 8%, var(--crm-surface));
}

.crm-dashboard-page .revenue-grid {
    gap: 14px;
    padding: 18px 20px 20px;
}

.crm-dashboard-page .revenue-card {
    border-color: var(--crm-border);
    border-radius: 14px;
    color: var(--crm-text);
    background: var(--crm-surface-soft);
    box-shadow: none;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.crm-dashboard-page .revenue-card:hover,
.crm-dashboard-page .revenue-card:focus {
    border-color: color-mix(in srgb, var(--card-accent) 35%, var(--crm-border));
    color: var(--crm-text);
    transform: translateY(-2px);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-page .revenue-card__icon {
    border-color: var(--crm-border);
    background: var(--crm-surface);
}

.crm-dashboard-page .campus-activity {
    border-color: var(--crm-border);
}

.crm-dashboard-page .campus-activity:hover {
    background: var(--crm-surface-soft);
}

.crm-dashboard-page .campus-donut-center {
    background: var(--crm-surface);
}

.crm-dashboard-page .campus-donut-center span,
.crm-dashboard-page .campus-fee-legend,
.crm-dashboard-page .campus-chart-legend {
    color: var(--crm-text-muted);
}

.crm-dashboard-page .campus-donut-center strong,
.crm-dashboard-page .campus-fee-legend-item {
    color: var(--crm-text);
}

.crm-dashboard-page .dashboard-branch-search-form {
    border-color: var(--crm-border);
    border-radius: 14px;
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-page .dashboard-branch-picker-trigger,
.crm-dashboard-page .dashboard-branch-search-button,
.crm-dashboard-page .dashboard-branch-option,
.crm-dashboard-page .dashboard-branch-options {
    border-color: var(--crm-border);
    color: var(--crm-text-muted);
    background: var(--crm-surface);
}

.crm-dashboard-page .dashboard-branch-option:hover,
.crm-dashboard-page .dashboard-branch-option:focus,
.crm-dashboard-page .dashboard-branch-option[aria-selected="true"] {
    color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 9%, var(--crm-surface));
}

.crm-dashboard-page .latest-admissions-table-wrap {
    border-color: var(--crm-border);
    border-radius: var(--crm-radius);
    background: var(--crm-surface);
    box-shadow: var(--crm-shadow-sm);
}

.crm-dashboard-page .latest-admissions-table tbody td {
    border-color: var(--crm-border);
    color: var(--crm-text);
    background: var(--crm-surface);
}

.crm-dashboard-page .latest-admissions-table tbody tr:hover td {
    background: var(--crm-surface-soft);
}

.crm-dashboard-page .latest-admissions-table a {
    color: var(--crm-text);
}

/* Dark theme: layout, navigation and reusable Bootstrap surfaces */
html[data-theme="dark"] body {
    color: var(--crm-text);
}

html[data-theme="dark"] .main-header .navbar-header,
html[data-theme="dark"] .main-header-logo,
html[data-theme="dark"] .main-header-logo .logo-header,
html[data-theme="dark"] .footer {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-header-bg) !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2,
html[data-theme="dark"] .sidebar.sidebar-style-2[data-background-color="light"],
html[data-theme="dark"] .sidebar.sidebar-style-2 .sidebar-logo,
html[data-theme="dark"] .sidebar.sidebar-style-2 .logo-header[data-background-color="light"],
html[data-theme="dark"] .sidebar.sidebar-style-2 .sidebar-wrapper {
    border-color: var(--crm-border) !important;
    background: #0f1726 !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a p,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a i,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a .sub-item,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a i,
html[data-theme="dark"] .sidebar.sidebar-style-2 .caret,
html[data-theme="dark"] .mobile-sidebar-user strong {
    color: #c9d5e8 !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a:hover,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item.active > a,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a:focus {
    background: linear-gradient(135deg, #19b36a 0%, #0b8fa7 100%) !important;
    box-shadow: 0 10px 24px rgba(11, 143, 167, 0.2) !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a:hover p,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item > a:hover i,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item.active > a p,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav > .nav-item.active > a i {
    color: #ffffff !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a:hover,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li.active > a {
    background: rgba(49, 189, 208, 0.12) !important;
}

html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a:hover .sub-item,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li.active > a .sub-item,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li > a:hover i,
html[data-theme="dark"] .sidebar.sidebar-style-2 .nav-collapse > li.active > a i {
    color: #6ed7e5 !important;
}

html[data-theme="dark"] .crm-icon-button,
html[data-theme="dark"] .navbar .crm-icon-button.nav-link {
    color: #d6e1f0 !important;
}

html[data-theme="dark"] .profile-popup.dropdown-user,
html[data-theme="dark"] .profile-popup .dropdown-user-scroll,
html[data-theme="dark"] .profile-popup__item,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .card,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .accordion-item,
html[data-theme="dark"] .accordion-button,
html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .toast {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] .profile-popup.dropdown-user::before {
    border-color: var(--crm-border);
    background: var(--crm-surface);
}

html[data-theme="dark"] .profile-popup .u-text h4,
html[data-theme="dark"] .profile-popup__item-label,
html[data-theme="dark"] .profile-popup__item {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] .profile-popup .u-text p.text-muted,
html[data-theme="dark"] .profile-popup__arrow,
html[data-theme="dark"] .mobile-sidebar-user span {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] .profile-popup__item:hover,
html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus,
html[data-theme="dark"] .list-group-item-action:hover {
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] .card-title,
html[data-theme="dark"] .modal-title,
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"] label,
html[data-theme="dark"] .form-label,
html[data-theme="dark"] .table,
html[data-theme="dark"] .dropdown-item,
html[data-theme="dark"] p {
    color: var(--crm-text);
}

html[data-theme="dark"] .text-muted,
html[data-theme="dark"] .text-secondary,
html[data-theme="dark"] small,
html[data-theme="dark"] .help-block,
html[data-theme="dark"] .form-text {
    color: var(--crm-text-muted) !important;
}

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

html[data-theme="dark"] :is(
    .text-black,
    .text-black-50,
    .text-body,
    .text-body-emphasis,
    .text-body-secondary,
    .text-secondary-emphasis,
    .link-dark
) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(.text-muted, .text-secondary, .text-black-50, .text-body-secondary) {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
    background-color: var(--crm-surface) !important;
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-end,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,
html[data-theme="dark"] hr,
html[data-theme="dark"] .dropdown-divider,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer {
    border-color: var(--crm-border) !important;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .input-group-text,
html[data-theme="dark"] .select2-container--bootstrap .select2-selection,
html[data-theme="dark"] .select2-dropdown,
html[data-theme="dark"] .select2-search__field {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background-color: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #7f8da5 !important;
    opacity: 1;
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--crm-text);
    box-shadow: 0 0 0 1000px var(--crm-surface-soft) inset;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
    border-color: var(--crm-primary) !important;
    box-shadow: 0 0 0 3px rgba(49, 189, 208, 0.15) !important;
}

html[data-theme="dark"] select option {
    color: var(--crm-text);
    background: var(--crm-surface);
}

html[data-theme="dark"] .table > :not(caption) > * > *,
html[data-theme="dark"] table tbody td,
html[data-theme="dark"] table tbody th {
    border-color: var(--crm-border);
    color: var(--crm-text);
    background-color: var(--crm-surface);
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    color: var(--crm-text);
    background-color: var(--crm-surface-soft);
}

html[data-theme="dark"] .table-hover > tbody > tr:hover > *,
html[data-theme="dark"] table tbody tr:hover td {
    color: var(--crm-text);
    background-color: #1a263b;
}

html[data-theme="dark"] .pagination .page-link {
    border-color: var(--crm-border);
    color: var(--crm-text-muted);
    background: var(--crm-surface);
}

html[data-theme="dark"] .pagination .page-item.active .page-link {
    border-color: var(--crm-primary);
    color: #ffffff;
    background: var(--crm-primary);
}

html[data-theme="dark"] .btn-light,
html[data-theme="dark"] .btn-outline-secondary {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] .alert-info {
    border-color: rgba(49, 189, 208, 0.28);
    color: #a7ebf2;
    background: rgba(49, 189, 208, 0.1);
}

html[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(180%);
}

html[data-theme="dark"] img {
    visibility: visible;
}

html[data-theme="dark"] .navbar-brand,
html[data-theme="dark"] [data-profile-avatar],
html[data-theme="dark"] .mobile-sidebar-avatar,
html[data-theme="dark"] .student-profile-image,
html[data-theme="dark"] .avatar-img {
    background: #ffffff !important;
}

/* Complete application compatibility layer
   Individual modules pre-date the shared theme and expose their own design tokens.
   Remapping those tokens keeps every authenticated screen visually consistent. */
html[data-theme="dark"] :is(
    [class*="-page"],
    [class*="-ledger"],
    .sd-wrap,
    .payment-journey,
    .balance-dashboard,
    .wallet-shell,
    .bscc-page
) {
    --cp-border: var(--crm-border);
    --cp-text: var(--crm-text);
    --cp-muted: var(--crm-text-muted);
    --permission-border: var(--crm-border);
    --permission-text: var(--crm-text);
    --permission-muted: var(--crm-text-muted);
    --permission-surface: var(--crm-surface);
    --page-border: var(--crm-border);
    --page-text: var(--crm-text);
    --page-muted: var(--crm-text-muted);
    --page-surface: var(--crm-surface);
    --course-border: var(--crm-border);
    --course-text: var(--crm-text);
    --course-muted: var(--crm-text-muted);
    --course-surface: var(--crm-surface);
    --uni-border: var(--crm-border);
    --uni-text: var(--crm-text);
    --uni-muted: var(--crm-text-muted);
    --uni-surface: var(--crm-surface);
    --ledger-border: var(--crm-border);
    --ledger-line: var(--crm-border);
    --ledger-text: var(--crm-text);
    --ledger-ink: var(--crm-text);
    --ledger-muted: var(--crm-text-muted);
    --ledger-soft: var(--crm-surface-soft);
    --expense-border: var(--crm-border);
    --expense-text: var(--crm-text);
    --expense-muted: var(--crm-text-muted);
    --enquiry-border: var(--crm-border);
    --enquiry-text: var(--crm-text);
    --enquiry-muted: var(--crm-text-muted);
    --associate-border: var(--crm-border);
    --associate-line: var(--crm-border);
    --associate-text: var(--crm-text);
    --associate-ink: var(--crm-text);
    --associate-muted: var(--crm-text-muted);
    --university-border: var(--crm-border);
    --university-text: var(--crm-text);
    --university-muted: var(--crm-text-muted);
    --admission-border: var(--crm-border);
    --admission-text: var(--crm-text);
    --admission-muted: var(--crm-text-muted);
    --uan-border: var(--crm-border);
    --uan-text: var(--crm-text);
    --uan-muted: var(--crm-text-muted);
    --report-line: var(--crm-border);
    --report-ink: var(--crm-text);
    --report-muted: var(--crm-text-muted);
    --ins-line: var(--crm-border);
    --ins-text: var(--crm-text);
    --ins-muted: var(--crm-text-muted);
    --sd-navy: var(--crm-text);
    --sd-muted: var(--crm-text-muted);
    --sd-line: var(--crm-border);
    --sd-bg: var(--crm-bg);
    --journey-ink: var(--crm-text);
    --journey-muted: var(--crm-text-muted);
    --journey-line: var(--crm-border);
    --journey-soft: var(--crm-surface-soft);
    --record-payment-card-bg: var(--crm-surface-soft);
    --record-payment-border: var(--crm-border);
    --record-payment-text: var(--crm-text);
    --record-payment-muted: var(--crm-text-muted);
    --primary-soft: rgba(49, 189, 208, 0.12);
    --border: var(--crm-border);
    --surface: var(--crm-surface);
    --ink: var(--crm-text);
    --bg: var(--crm-bg);
    --soft: var(--crm-surface-soft);
    --line: var(--crm-border);
    --text: var(--crm-text);
    --muted: var(--crm-text-muted);
    color: var(--crm-text);
}

html[data-theme="dark"] :is(
    .change-password-hero,
    .change-password-card,
    .permission-hero,
    .permission-card,
    .academic-session-hero,
    .academic-session-card,
    .session-hero,
    .session-card,
    .course-hero,
    .course-card,
    .course-selection-form-card,
    .university-hero,
    .university-card,
    .associate-hero,
    .associate-card,
    .enquiry-hero,
    .enquiry-card,
    .expense-hero,
    .expense-card,
    .ledger-hero,
    .ledger-card,
    .ledger-edit-hero,
    .ledger-edit-card,
    .admission-hero,
    .admission-card,
    .insentive-hero,
    .insentive-card,
    .fee-name-hero,
    .fee-name-card,
    .user-create-hero,
    .user-create-card,
    .assign-role-hero,
    .assign-role-card,
    .reference-hero,
    .reference-card,
    .uan-hero,
    .uan-card,
    .bank-hero,
    .bank-card,
    .account-history-card,
    .add-fee-details-card,
    .admission-address-card,
    .student-receipts-shell,
    .student-receipt-card,
    .sd-card,
    .sd-learn,
    .paid-dashboard-block,
    .paid-history-card,
    .paid-summary-card,
    .wallet-rejection-item,
    .bscc-hero,
    .bscc-card,
    .bscc-stat,
    .bscc-record,
    .bscc-student-item,
    .fee-report-card,
    .fee-stat-card,
    .fee-panel,
    .fee-report-panel,
    .balance-card,
    .balance-earnings-card,
    .balance-target-card,
    .balance-chart-card,
    .earnings-stat-card,
    .earnings-target-card,
    .earnings-chart-card,
    .reports-card,
    .dashboard-chart-panel,
    .dashboard-modern-card,
    .quick-action,
    .legend-strip,
    .transfer-panel,
    .uan-panel,
    .user-list-card,
    .payment-journey-flow,
    .payment-journey-event,
    .payment-journey-tabs,
    .record-payment-page .student-payment-summary-panel
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm) !important;
}

html[data-theme="dark"] :is(
    .academic-session-filter-panel,
    .course-filter-panel,
    .expense-filter-panel,
    .ledger-filter-panel,
    .permission-filter-panel,
    .university-filter-panel,
    .uan-filter-panel,
    .uan-filter-topbar,
    .reference-list-toolbar,
    .enquiries-ledger .ledger-filter-panel,
    .reports-ledger .report-filter-panel,
    .students-ledger .admission-board,
    .fee-student-allocations,
    .bscc-approved-panel,
    .wallet-rejection-meta div,
    .add-fee-summary__item,
    .payment-journey-summary__item,
    .associate-advance-stat,
    .balance-card__icon,
    .balance-earnings-card__icon,
    .earnings-stat-card__icon,
    .chart-range-toggle,
    .revenue-card__badge,
    .revenue-card__icon
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .academic-session-section-head,
    .permission-section-head,
    .course-section-head,
    .course-selection-section-head,
    .university-section-head,
    .associate-section-head,
    .change-password-section-head,
    .enquiry-section-head,
    .expense-section-head,
    .ledger-section-head,
    .admission-section-head,
    .insentive-section-head,
    .uan-section-head,
    .bank-section-head,
    .bscc-card-head,
    .student-receipts-head
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: #151f31 !important;
}

html[data-theme="dark"] :is(
    .academic-session-table-shell,
    .permission-table-shell,
    .course-table-shell,
    .course-selection-table-shell,
    .university-table-shell,
    .expense-table-shell,
    .ledger-table-shell,
    .assign-role-table-shell,
    .user-list-table-shell,
    .enquiries-ledger .ledger-table-shell,
    .students-ledger .ledger-table-shell,
    .management-ledger .ledger-table-shell,
    .associate-ledger .ledger-table-shell,
    .latest-admissions-table-wrap,
    .table-responsive
) {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] :is(
    .enquiries-ledger .ledger-panel,
    .students-ledger .ledger-panel,
    .management-ledger .ledger-panel,
    .associate-ledger .ledger-panel,
    .reports-ledger .ledger-panel,
    .expense-ledger-page .ledger-panel
) {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-sm) !important;
}

html[data-theme="dark"] :is(
    .enquiries-ledger .enquiry-summary-card,
    .students-ledger .admission-summary-card,
    .management-ledger .summary-card,
    .associate-ledger .summary-card,
    .reports-ledger .report-summary-card,
    .ledger-summary-card,
    .uan-summary-card
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: linear-gradient(145deg, #182337, #121a2a) !important;
    box-shadow: var(--crm-shadow-sm) !important;
}

html[data-theme="dark"] :is(
    .academic-session-search-input,
    .academic-session-control,
    .academic-session-per-page,
    .course-search-input,
    .course-control,
    .course-per-page,
    .course-selection-search-input,
    .course-selection-control,
    .course-selection-per-page,
    .permission-search-input,
    .permission-control,
    .permission-per-page,
    .university-search-input,
    .university-control,
    .university-per-page,
    .expense-search-input,
    .expense-control,
    .expense-per-page,
    .ledger-search-input,
    .ledger-control,
    .fee-control,
    .transaction-control,
    .uan-pagination-select,
    .user-list-search-input,
    .assign-role-search-input,
    .reports-ledger .report-control,
    .reports-ledger .report-page-size select,
    .enquiries-ledger .ledger-search-input,
    .enquiries-ledger .ledger-control,
    .students-ledger .ledger-search-input,
    .students-ledger .ledger-control,
    .management-ledger .ledger-search-input,
    .associate-ledger .ledger-search-input,
    .reference-list-filter .form-select
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .academic-session-btn-light,
    .course-btn-light,
    .course-selection-btn-light,
    .permission-btn-light,
    .university-btn-light,
    .expense-btn-light,
    .ledger-btn-light,
    .enquiries-ledger .ledger-btn-light,
    .students-ledger .ledger-btn-light,
    .reports-ledger .report-btn-light,
    .account-history-back,
    .receipt-view-btn,
    .fee-quick-btn,
    .fee-quick-action
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .academic-session-btn-light,
    .course-btn-light,
    .course-selection-btn-light,
    .permission-btn-light,
    .university-btn-light,
    .expense-btn-light,
    .ledger-btn-light,
    .enquiries-ledger .ledger-btn-light,
    .students-ledger .ledger-btn-light,
    .reports-ledger .report-btn-light
):hover {
    border-color: var(--crm-primary) !important;
    color: #b8f3fa !important;
    background: rgba(49, 189, 208, 0.12) !important;
}

html[data-theme="dark"] :is(
    .academic-session-pager .pager-icon,
    .academic-session-pager .pager-page,
    .course-pager .pager-icon,
    .course-pager .pager-page,
    .course-selection-pager .pager-icon,
    .course-selection-pager .pager-page,
    .permission-pager .pager-icon,
    .permission-pager .pager-page,
    .university-pager .pager-icon,
    .university-pager .pager-page,
    .expense-pager .pager-icon,
    .expense-pager .pager-page,
    .ledger-pager .pager-icon,
    .ledger-pager .pager-page,
    .fee-pager .pager-icon,
    .fee-pager .pager-page,
    .uan-pagination-btn,
    .uan-pagination-page,
    .reports-ledger .report-pagination a,
    .reports-ledger .report-pagination span,
    .enquiries-ledger .pager-icon,
    .enquiries-ledger .pager-page,
    .enquiries-ledger .ledger-per-page,
    .students-ledger .pager-icon,
    .students-ledger .pager-page,
    .students-ledger .ledger-per-page
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text-muted) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] :is(
    .academic-session-pager .pager-page.active,
    .course-pager .pager-page.active,
    .course-selection-pager .pager-page.active,
    .permission-pager .pager-page.active,
    .university-pager .pager-page.active,
    .expense-pager .pager-page.active,
    .ledger-pager .pager-page.active,
    .fee-pager .pager-page.active,
    .uan-pagination-page.is-active
) {
    border-color: var(--crm-primary) !important;
    color: #ffffff !important;
    background: var(--crm-primary) !important;
}

html[data-theme="dark"] :is(
    .admission-dropdown-menu,
    .enquiry-select-menu,
    .fee-name-picker__menu,
    .fee-year-options,
    .dashboard-branch-options
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] :is(
    .admission-dropdown-toggle,
    .enquiry-select-toggle,
    .fee-year-trigger,
    .fee-range-select,
    .fee-name-picker__add
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .admission-dropdown-option,
    .enquiry-select-option,
    .fee-year-option,
    .fee-name-picker__option
):hover,
html[data-theme="dark"] :is(
    .admission-dropdown-option,
    .enquiry-select-option,
    .fee-year-option,
    .fee-name-picker__option
)[aria-selected="true"] {
    color: #b8f3fa !important;
    background: rgba(49, 189, 208, 0.12) !important;
}

html[data-theme="dark"] :is(
    .academic-session-row-actions .academic-session-icon-btn,
    .course-row-actions .course-icon-btn,
    .course-selection-row-actions .course-selection-icon-btn,
    .permission-row-actions .permission-icon-btn,
    .university-row-actions .university-icon-btn,
    .expense-row-actions .expense-icon-btn,
    .enquiries-ledger .enquiry-action-btn,
    .management-ledger .action-btn,
    .associate-ledger .action-btn,
    .user-list-action-btn,
    .bank-action-btn
) {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .latest-admissions-table,
    .erp-table
) {
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .latest-admissions-table,
    .erp-table
) tbody td {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .latest-admissions-table,
    .erp-table
) tbody tr:hover td {
    color: var(--crm-text) !important;
    background: #1a263b !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .erp-table
) thead th {
    border-color: #34425a !important;
    color: #edf3fc !important;
    background: #1b293f !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .erp-table
) tbody tr:nth-child(even) td {
    background: #141e30 !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .erp-table
) tbody tr:nth-child(even):hover td {
    background: #1a263b !important;
}

html[data-theme="dark"] :is(
    .academic-session-table,
    .permission-table,
    .course-table,
    .course-selection-table,
    .university-table,
    .expense-table,
    .ledger-table,
    .assign-role-table,
    .user-list-table,
    .fee-table,
    .fee-report-table,
    .uan-table,
    .account-history-table,
    .latest-admissions-table,
    .erp-table
) :is(a, strong) {
    color: #79dbe7;
}

/* DataTables, Select2 and common third-party widgets */
html[data-theme="dark"] .dataTables_wrapper {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] .dataTables_wrapper :is(.dataTables_length, .dataTables_filter, .dataTables_info) {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] .dataTables_wrapper :is(input, select) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] table.dataTable,
html[data-theme="dark"] table.dataTable.no-footer,
html[data-theme="dark"] table.dataTable thead :is(th, td),
html[data-theme="dark"] table.dataTable tbody :is(th, td) {
    border-color: var(--crm-border) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    border-color: transparent !important;
    color: var(--crm-text-muted) !important;
    background: transparent !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    border-color: var(--crm-primary) !important;
    color: #ffffff !important;
    background: var(--crm-primary) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_processing {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow) !important;
}

html[data-theme="dark"] :is(
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple,
    .select2-container--bootstrap-5 .select2-selection,
    .select2-container--bootstrap4 .select2-selection,
    .select2-dropdown,
    .select2-search--dropdown .select2-search__field
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(
    .select2-container--default .select2-selection--single .select2-selection__rendered,
    .select2-container--default .select2-selection--multiple .select2-selection__choice,
    .select2-results__option
) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] .select2-results__option--highlighted,
html[data-theme="dark"] .select2-results__option[aria-selected="true"] {
    color: #ffffff !important;
    background: var(--crm-primary) !important;
}

html[data-theme="dark"] :is(.datepicker, .datepicker-dropdown, .flatpickr-calendar, .ui-datepicker) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] :is(.datepicker table tr td, .datepicker table tr th, .flatpickr-day, .flatpickr-weekday) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(.datepicker table tr td:hover, .flatpickr-day:hover) {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] input:is([type="date"], [type="datetime-local"], [type="time"])::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
    opacity: 0.85;
}

html[data-theme="dark"] :is(.swal2-popup, .sweet-alert) {
    border: 1px solid var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-raised) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] :is(.swal2-title, .swal2-html-container, .sweet-alert h2, .sweet-alert p) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(.popover, .tooltip-inner) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: #202c42 !important;
}

/* Professional text hierarchy without flattening semantic status colors. */
html[data-theme="dark"] :is(
    .summary-value,
    .enquiry-summary-value,
    .admission-summary-value,
    .report-summary-value,
    .uan-summary-value,
    .expense-value,
    .enquiry-value,
    .fee-stat-value,
    .fee-report-value,
    .paid-money,
    .paid-summary-card strong,
    .payment-journey-summary__value,
    .payment-journey-event__title,
    .balance-card__amount,
    .balance-earnings-card__value,
    .balance-gauge__value,
    .balance-target-mini strong,
    .earnings-gauge__value,
    .earnings-stat-card__value,
    .earnings-target-mini strong,
    .associate-advance-stat strong,
    .fee-table .text-strong,
    .student-phone,
    .student-father-name
) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(
    .summary-label,
    .enquiry-summary-label,
    .admission-summary-label,
    .report-summary-label,
    .campus-panel-subtitle,
    .fee-stat-label,
    .fee-report-label,
    .payment-journey-summary__label,
    .paid-history-meta,
    .bscc-meta,
    .sd-muted
) {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] :is(.nav-tabs, .nav-pills, .payment-fee-tab) {
    border-color: var(--crm-border) !important;
}

html[data-theme="dark"] :is(.nav-tabs .nav-link, .nav-pills .nav-link, .payment-fee-tab) {
    color: var(--crm-text-muted);
}

html[data-theme="dark"] :is(.nav-tabs .nav-link.active, .nav-pills .nav-link.active, .payment-fee-tab.active) {
    border-color: var(--crm-border) var(--crm-border) var(--crm-surface) !important;
    color: #ffffff !important;
    background: var(--crm-primary) !important;
}

html[data-theme="dark"] :is(.progress, .bscc-progress) {
    background: #26344a !important;
}

html[data-theme="dark"] :is(code, pre) {
    border-color: var(--crm-border);
    color: #a5f3fc;
    background: #0b1220;
}

html[data-theme="dark"] :is(.preview iframe, .preview object, .document-preview iframe, .document-preview object) {
    border: 1px solid var(--crm-border);
    background: #ffffff !important;
}

html[data-theme="dark"] :is(.student-image-frame, .profile-upload-box, .photo) {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(.student-image-frame, .profile-upload-box, .photo) img {
    opacity: 1 !important;
    filter: none !important;
}

html[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0d1422;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
    border: 2px solid #0d1422;
    border-radius: 999px;
    background: #34445d;
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #455a78;
}

/* Wallet and bank-account modules */
html[data-theme="dark"] .wallet-page {
    --wallet-ink: var(--crm-text);
    --wallet-muted: var(--crm-text-muted);
    --wallet-line: var(--crm-border);
    color: var(--crm-text);
}

html[data-theme="dark"] :is(.wallet-panel, .wallet-modal .modal-content) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow) !important;
}

html[data-theme="dark"] :is(.wallet-panel__head, .wallet-filters, .wallet-modal .modal-footer) {
    border-color: var(--crm-border) !important;
}

html[data-theme="dark"] .wallet-stat {
    border-color: color-mix(in srgb, var(--tone, var(--crm-primary)) 35%, var(--crm-border)) !important;
    background: color-mix(in srgb, var(--tone, var(--crm-primary)) 10%, var(--crm-surface)) !important;
}

html[data-theme="dark"] .wallet-stat strong {
    color: color-mix(in srgb, var(--tone, var(--crm-primary)) 72%, #ffffff) !important;
}

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

html[data-theme="dark"] :is(.wallet-control, .wallet-upload) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] .wallet-field label,
html[data-theme="dark"] .wallet-table td {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] .wallet-table td {
    border-color: var(--crm-border) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] .wallet-table tbody tr:nth-child(even) td {
    background: #141e30 !important;
}

html[data-theme="dark"] .wallet-table tbody tr:hover td {
    background: #1a263b !important;
}

html[data-theme="dark"] .wallet-btn--outline {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] .wallet-btn--danger {
    border-color: rgba(248, 113, 113, 0.35) !important;
    color: #fca5a5 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

html[data-theme="dark"] .wallet-upload {
    border-color: rgba(49, 189, 208, 0.42) !important;
}

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

html[data-theme="dark"] .bank-form-page {
    --bank-border: var(--crm-border);
    --bank-text: var(--crm-text);
    --bank-muted: var(--crm-text-muted);
}

html[data-theme="dark"] .account-history {
    --history-ink: var(--crm-text);
    --history-muted: var(--crm-text-muted);
    --history-border: var(--crm-border);
}

html[data-theme="dark"] :is(.balance-entry-upload, .associate-student-list) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

/* Authentication and safe error screens inherit the saved site preference. */
html[data-theme="dark"] body:has(.login-scene),
html[data-theme="dark"] body:has(.forgot-card),
html[data-theme="dark"] body:has(.reset-card),
html[data-theme="dark"] body:has(.success-card),
html[data-theme="dark"] body:has(.otp-card) {
    --bg: var(--crm-bg);
    --card: var(--crm-surface);
    --text: var(--crm-text);
    --muted: var(--crm-text-muted);
    --login-text: var(--crm-text);
    --login-muted: var(--crm-text-muted);
    --login-panel: rgba(18, 26, 42, 0.94);
    --login-border: rgba(148, 163, 184, 0.24);
    color: var(--crm-text);
    background: radial-gradient(circle at top left, rgba(11, 143, 167, 0.14), transparent 34%), var(--crm-bg) !important;
}

html[data-theme="dark"] body:has(.login-scene)::before,
html[data-theme="dark"] body:has(.login-scene)::after {
    opacity: 0.18;
}

html[data-theme="dark"] :is(.login-scene__card, .forgot-card, .reset-card, .success-card, .otp-card) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] :is(.login-title, .page-title, .login-field__label, .login-options, .requirements strong) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] :is(.login-subtitle, .helper, .login-footer, .strength-text) {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] :is(.login-field, .login-input, .forgot-card .form-control, .reset-card .form-control, .otp-card .form-control) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(.login-field__icon, .login-password-toggle, .password-toggle) {
    color: #79dbe7 !important;
}

html[data-theme="dark"] :is(.requirements, .otp-meta) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text-muted) !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] :is(.brand-mark, .login-brand img) {
    border-radius: 10px;
    background: #ffffff;
    filter: none !important;
}

html[data-theme="dark"] body > main,
html[data-theme="dark"] body > .card:not(.login-card) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] .social-enquiry-page {
    color: var(--crm-text) !important;
    background: var(--crm-bg) !important;
}

html[data-theme="dark"] .social-enquiry-shell {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
    box-shadow: var(--crm-shadow-lg) !important;
}

html[data-theme="dark"] .social-enquiry-shell :is(.brand-title, .form-label) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] .social-enquiry-shell .brand-subtitle {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] .social-enquiry-shell img {
    border-radius: 10px;
    background: #ffffff;
    filter: none !important;
}

html[data-theme="dark"] .misc-wrapper :is(h1, h4, p) {
    color: var(--crm-text) !important;
}

@media (max-width: 991.98px) {
    .main-header .navbar-header {
        min-height: 64px;
    }

    .topbar-nav {
        gap: 3px;
    }

    .crm-icon-button,
    .navbar .crm-icon-button.nav-link {
        width: 39px;
        height: 39px;
        min-width: 39px;
        border-radius: 12px !important;
    }

    .crm-dashboard-page .campus-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .main-panel > .container > .page-inner {
        padding-top: 16px;
    }

    .crm-page-hero {
        margin-bottom: 16px !important;
        padding-bottom: 8px !important;
    }

    .crm-page-hero-icon {
        width: 40px !important;
        height: 40px !important;
        flex-basis: 40px !important;
    }

    .topbar-user .avatar-sm {
        width: 39px;
        height: 39px;
    }

    .crm-notification-menu {
        position: fixed !important;
        top: 64px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        min-width: 0 !important;
        transform: none !important;
    }

    .crm-dashboard-page .campus-stat-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .crm-dashboard-page .campus-stat-card {
        min-height: 116px;
        padding: 17px;
    }

    .crm-dashboard-page .campus-main-grid,
    .crm-dashboard-page .campus-lower-grid {
        gap: 14px;
    }

    .crm-dashboard-page .campus-panel,
    .crm-dashboard-page .latest-admissions-table-wrap {
        border-radius: 14px;
    }

    .crm-dashboard-page .campus-panel-head {
        min-height: auto;
        padding: 14px;
    }

    .crm-dashboard-page .revenue-grid {
        padding: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* High-contrast dropdown layer.
   Kept last and intentionally specific because a few dynamic dropdown styles
   are rendered inside page-level script sections after the main stylesheet. */
html[data-theme="dark"] body .admission-dropdown-toggle {
    border-color: #34445d !important;
    color: #f3f7fd !important;
    background: #151f31 !important;
    box-shadow: none !important;
}

html[data-theme="dark"] body .admission-dropdown-toggle::after {
    border-color: #aebbd0 !important;
}

html[data-theme="dark"] body .admission-dropdown.open .admission-dropdown-toggle,
html[data-theme="dark"] body .admission-dropdown-toggle:focus-visible {
    border-color: #31bdd0 !important;
    box-shadow: 0 0 0 3px rgba(49, 189, 208, 0.16) !important;
    outline: none;
}

html[data-theme="dark"] body .admission-dropdown-menu {
    border-color: #34445d !important;
    color: #edf3fc !important;
    background: #182337 !important;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] body .admission-dropdown-search .admission-inline-add {
    border: 1px dashed #416078 !important;
    color: #edf3fc !important;
    background: #111a2b !important;
    caret-color: #67d7e5;
}

html[data-theme="dark"] body .admission-dropdown-search .admission-inline-add::placeholder {
    color: #9aa9bf !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .admission-dropdown-search .admission-inline-add:focus {
    border-color: #31bdd0 !important;
    color: #ffffff !important;
    background: #101a2a !important;
    box-shadow: 0 0 0 3px rgba(49, 189, 208, 0.15) !important;
}

html[data-theme="dark"] body .admission-dropdown-option {
    color: #dce6f5 !important;
    background: transparent !important;
    font-weight: 600;
    opacity: 1 !important;
}

html[data-theme="dark"] body .admission-dropdown-option:hover,
html[data-theme="dark"] body .admission-dropdown-option:focus-visible,
html[data-theme="dark"] body .admission-dropdown-option.is-highlighted {
    color: #ffffff !important;
    background: #24334b !important;
    outline: none;
}

html[data-theme="dark"] body .admission-dropdown-option.selected {
    color: #8ee7f1 !important;
    background: rgba(49, 189, 208, 0.14) !important;
}

html[data-theme="dark"] body .admission-dropdown-option-row + .admission-dropdown-option-row,
html[data-theme="dark"] body .admission-dropdown-option-row + .admission-dropdown-option {
    border-top-color: rgba(148, 163, 184, 0.08) !important;
}

html[data-theme="dark"] body .admission-dropdown-delete {
    color: #fb7185 !important;
    background: transparent !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .admission-dropdown-delete:hover,
html[data-theme="dark"] body .admission-dropdown-delete:focus-visible {
    color: #fecdd3 !important;
    background: rgba(244, 63, 94, 0.14) !important;
}

html[data-theme="dark"] body .admission-inline-save {
    color: #55d4e3 !important;
    background: transparent !important;
}

html[data-theme="dark"] body .admission-inline-save:hover,
html[data-theme="dark"] body .admission-inline-save:focus-visible {
    color: #b8f3fa !important;
    background: rgba(49, 189, 208, 0.12) !important;
}

html[data-theme="dark"] body :is(
    .enquiry-select-option,
    .fee-name-picker__option,
    .fee-year-option,
    .dashboard-branch-option,
    [role="listbox"] [role="option"]
) {
    color: #dce6f5 !important;
    background: transparent !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body :is(
    .enquiry-select-option,
    .fee-name-picker__option,
    .fee-year-option,
    .dashboard-branch-option,
    [role="listbox"] [role="option"]
):is(:hover, :focus-visible, .is-highlighted, .selected, [aria-selected="true"]) {
    color: #ffffff !important;
    background: #24334b !important;
    outline: none;
}

html[data-theme="dark"] body :is(
    .enquiry-select-menu,
    .fee-name-picker__menu,
    .fee-year-options,
    [role="listbox"]
) {
    border-color: #34445d !important;
    color: #edf3fc !important;
    background: #182337 !important;
}

html[data-theme="dark"] body .dropdown-menu :is(.dropdown-item, .dropdown-item-text, .dropdown-header) {
    color: #dce6f5 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .dropdown-menu .dropdown-item:is(:hover, :focus, .active) {
    color: #ffffff !important;
    background: #24334b !important;
}

html[data-theme="dark"] body :is(select, .form-select) {
    color: #edf3fc !important;
    background-color: #151f31 !important;
}

html[data-theme="dark"] body :is(select, .form-select):disabled {
    color: #8f9db2 !important;
    background-color: #111827 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body select option {
    color: #edf3fc !important;
    background: #182337 !important;
}

html[data-theme="dark"] body select option:disabled {
    color: #8290a6 !important;
}

/* High-contrast form typography and tabs across every module. */
html[data-theme="dark"] body .page-inner :is(
    label,
    legend,
    .form-label,
    .field-label,
    .control-label,
    .col-form-label,
    .input-label,
    .custom-control-label,
    .form-check-label,
    .add-fee-field .form-label,
    .wallet-field label,
    .bscc-field label,
    .bscc-group-label,
    .admission-grid label,
    .admission-section-body label,
    .course-selection-field > label
) {
    color: #d8e2f0 !important;
    font-weight: 600 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .modal :is(
    label,
    legend,
    .form-label,
    .field-label,
    .control-label,
    .col-form-label,
    .form-check-label
) {
    color: #d8e2f0 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .page-inner :is(
    .form-text,
    .help-text,
    .helper-text,
    .field-help,
    .field-hint,
    .input-hint,
    .text-muted,
    .small-muted
) {
    color: #aebbd0 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .page-inner :is(
    .required,
    .admission-required,
    .text-danger
) {
    color: #fb7185 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .page-inner :is(
    .form-control-plaintext,
    .form-check-label,
    .form-check-input + label
) {
    color: #d8e2f0 !important;
}

html[data-theme="dark"] body :is(
    .nav-tabs,
    .nav-pills,
    [role="tablist"],
    .admission-tabs,
    .assign-role-tabs,
    .bank-tabs,
    .enquiry-tabs,
    .fee-tabs,
    .ledger-tabs,
    .payment-fee-tabs,
    .report-tabs,
    .user-list-tabs
) {
    border-color: #34445d !important;
}

html[data-theme="dark"] body :is(
    .nav-tabs .nav-link,
    .nav-pills .nav-link,
    [role="tablist"] [role="tab"],
    .admission-tab,
    .assign-role-tab,
    .bank-tab,
    .enquiry-tab,
    .fee-tab,
    .ledger-tab,
    .payment-fee-tab,
    .report-tab,
    .user-list-tab
) {
    border-color: transparent !important;
    color: #b8c5d8 !important;
    background: transparent !important;
    opacity: 1 !important;
    font-weight: 700 !important;
    text-shadow: none !important;
}

html[data-theme="dark"] body :is(
    .nav-tabs .nav-link,
    .nav-pills .nav-link,
    [role="tablist"] [role="tab"],
    .admission-tab,
    .assign-role-tab,
    .bank-tab,
    .enquiry-tab,
    .fee-tab,
    .ledger-tab,
    .payment-fee-tab,
    .report-tab,
    .user-list-tab
):hover {
    border-color: rgba(49, 189, 208, 0.28) !important;
    color: #ffffff !important;
    background: rgba(49, 189, 208, 0.1) !important;
}

html[data-theme="dark"] body :is(
    .nav-tabs .nav-link.active,
    .nav-pills .nav-link.active,
    [role="tablist"] [role="tab"][aria-selected="true"],
    .admission-tab.is-active,
    .assign-role-tab.is-active,
    .bank-tab.is-active,
    .enquiry-tab.is-active,
    .fee-tab.is-active,
    .ledger-tab.is-active,
    .payment-fee-tab.is-active,
    .report-tab.is-active,
    .user-list-tab.is-active
) {
    border-color: #31bdd0 !important;
    color: #ffffff !important;
    background: #0f8297 !important;
    box-shadow: 0 7px 18px rgba(11, 143, 167, 0.24) !important;
}

html[data-theme="dark"] body :is(
    .nav-tabs .nav-link,
    .nav-pills .nav-link,
    [role="tablist"] [role="tab"],
    .admission-tab,
    .assign-role-tab,
    .bank-tab,
    .enquiry-tab,
    .fee-tab,
    .ledger-tab,
    .payment-fee-tab,
    .report-tab,
    .user-list-tab
):focus-visible {
    color: #ffffff !important;
    outline: 2px solid #67d7e5 !important;
    outline-offset: 2px;
}

html[data-theme="dark"] body .tab-content,
html[data-theme="dark"] body .tab-pane {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] body .tab-pane :is(h1, h2, h3, h4, h5, h6, p, label, th, td) {
    opacity: 1 !important;
}

/* References module: dedicated dark composition */
html[data-theme="dark"] body .reference-page {
    --ref-primary: #31bdd0;
    --ref-soft: rgba(49, 189, 208, 0.12);
    --ref-line: #304058;
    --ref-text: #edf3fc;
    --ref-muted: #aebbd0;
    color: var(--ref-text) !important;
}

html[data-theme="dark"] body .reference-page .reference-hero {
    border: 1px solid #304058 !important;
    border-left: 4px solid #31bdd0 !important;
    color: #edf3fc !important;
    background:
        radial-gradient(circle at top right, rgba(49, 189, 208, 0.1), transparent 32%),
        linear-gradient(135deg, #172337 0%, #121b2c 100%) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24) !important;
}

html[data-theme="dark"] body .reference-page .reference-hero-icon {
    border-color: rgba(167, 139, 250, 0.36) !important;
    color: #c4b5fd !important;
    background: rgba(139, 92, 246, 0.16) !important;
    box-shadow: inset 0 0 0 1px rgba(196, 181, 253, 0.08);
}

html[data-theme="dark"] body .reference-page .reference-hero h4 {
    color: #f8fbff !important;
    font-weight: 800 !important;
}

html[data-theme="dark"] body .reference-page .reference-hero p {
    color: #c1cce0 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-card {
    border: 1px solid #304058 !important;
    color: #edf3fc !important;
    background: #121b2c !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22) !important;
}

html[data-theme="dark"] body .reference-page .reference-section-head {
    border-bottom: 1px solid #304058 !important;
    color: #edf3fc !important;
    background: linear-gradient(90deg, #19253a 0%, #162033 100%) !important;
}

html[data-theme="dark"] body .reference-page .reference-section-head h4 {
    color: #f1f6fd !important;
    font-weight: 800 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-section-icon {
    color: #79dbe7 !important;
    background: rgba(49, 189, 208, 0.14) !important;
    box-shadow: inset 0 0 0 1px rgba(49, 189, 208, 0.18);
}

html[data-theme="dark"] body .reference-page #referenceList .reference-section-icon {
    color: #c4b5fd !important;
    background: rgba(139, 92, 246, 0.16) !important;
    box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.18);
}

html[data-theme="dark"] body .reference-page .reference-section-body {
    color: #edf3fc !important;
    background: #121b2c !important;
}

html[data-theme="dark"] body .reference-page .reference-grid label {
    color: #dce6f5 !important;
    font-weight: 650 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-required {
    color: #fb7185 !important;
}

html[data-theme="dark"] body .reference-page :is(.reference-note, .reference-list-note) {
    color: #aebbd0 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page :is(.form-control, .form-select) {
    border-color: #3a4b64 !important;
    color: #edf3fc !important;
    background-color: #172235 !important;
    box-shadow: none !important;
}

html[data-theme="dark"] body .reference-page :is(.form-control, .form-select):focus {
    border-color: #31bdd0 !important;
    color: #ffffff !important;
    background-color: #172235 !important;
    box-shadow: 0 0 0 3px rgba(49, 189, 208, 0.15) !important;
}

html[data-theme="dark"] body .reference-page :is(.form-control, .form-select)::placeholder {
    color: #93a2b8 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-list-toolbar {
    border: 1px solid #304058 !important;
    color: #dce6f5 !important;
    background: #172235 !important;
}

html[data-theme="dark"] body .reference-page .reference-list-filter .form-select {
    border-color: #3a4b64 !important;
    color: #edf3fc !important;
    background-color: #111a2b !important;
}

html[data-theme="dark"] body .reference-page .reference-count {
    border: 1px solid rgba(49, 189, 208, 0.25);
    color: #8ee7f1 !important;
    background: rgba(49, 189, 208, 0.13) !important;
}

html[data-theme="dark"] body .reference-page .table-responsive {
    border: 1px solid #304058 !important;
    border-radius: 10px;
    background: #121b2c !important;
}

html[data-theme="dark"] body .reference-page .reference-table {
    border-color: #304058 !important;
    color: #dce6f5 !important;
    background: #121b2c !important;
}

html[data-theme="dark"] body .reference-page .reference-table thead th {
    border-color: #3a4b64 !important;
    color: #cbd7e8 !important;
    background: #1c2940 !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-table tbody td {
    border-color: #2b3950 !important;
    color: #dce6f5 !important;
    background: #121b2c !important;
    opacity: 1 !important;
}

html[data-theme="dark"] body .reference-page .reference-table tbody tr:nth-child(even) td {
    background: #151f31 !important;
}

html[data-theme="dark"] body .reference-page .reference-table tbody tr:hover td {
    color: #ffffff !important;
    background: #1d2a40 !important;
}

html[data-theme="dark"] body .reference-page .reference-type {
    border: 1px solid rgba(49, 189, 208, 0.24);
    color: #8ee7f1 !important;
    background: rgba(49, 189, 208, 0.12) !important;
}

html[data-theme="dark"] body .reference-page .reference-empty {
    color: #aebbd0 !important;
    background: #121b2c !important;
}

html[data-theme="dark"] body .reference-page .reference-action-btn,
html[data-theme="dark"] body .reference-page .reference-table .btn.btn-light {
    border: 1px solid #3a4b64 !important;
    color: #79dbe7 !important;
    background: #172235 !important;
}

html[data-theme="dark"] body .reference-page .reference-action-btn:hover,
html[data-theme="dark"] body .reference-page .reference-table .btn.btn-light:hover {
    border-color: #31bdd0 !important;
    color: #ffffff !important;
    background: rgba(49, 189, 208, 0.16) !important;
}

html[data-theme="dark"] body .reference-page .reference-action-btn.is-danger,
html[data-theme="dark"] body .reference-page .reference-table .btn.btn-light.text-danger {
    border-color: rgba(251, 113, 133, 0.28) !important;
    color: #fb7185 !important;
    background: rgba(244, 63, 94, 0.08) !important;
}

html[data-theme="dark"] body .reference-page .reference-action-btn.is-danger:hover,
html[data-theme="dark"] body .reference-page .reference-table .btn.btn-light.text-danger:hover {
    border-color: #fb7185 !important;
    color: #ffe4e9 !important;
    background: rgba(244, 63, 94, 0.16) !important;
}

html[data-theme="dark"] body .reference-page .reference-actions {
    border-top-color: #304058 !important;
}

/* Login: polished, high-contrast composition in both saved themes. */
body:has(.login-scene) .login-theme-toggle {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 4;
    display: inline-grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(11, 143, 167, 0.2);
    border-radius: 12px;
    color: #0b7f96;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 8px 22px rgba(31, 50, 81, 0.08);
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

/* Reserve a dedicated row for the theme control so flash messages never sit under it. */
body:has(.login-scene) .login-card {
    padding-top: 50px;
}

body:has(.login-scene) .login-theme-toggle:hover,
body:has(.login-scene) .login-theme-toggle:focus-visible {
    border-color: rgba(11, 143, 167, 0.52);
    color: #075f71;
    background: #ffffff;
    outline: 3px solid rgba(11, 143, 167, 0.14);
    transform: translateY(-1px);
}

html[data-theme="dark"] body:has(.login-scene) {
    background:
        radial-gradient(circle at 12% 18%, rgba(29, 184, 207, 0.13), transparent 0 26%),
        radial-gradient(circle at 88% 82%, rgba(255, 139, 31, 0.08), transparent 0 22%),
        linear-gradient(145deg, #07101f 0%, #0a1322 48%, #0d1728 100%) !important;
}

html[data-theme="dark"] body:has(.login-scene)::before {
    opacity: 0.32;
    background: radial-gradient(circle at center, rgba(29, 184, 207, 0.18) 0 30%, rgba(29, 184, 207, 0.07) 31% 54%, transparent 55%);
}

html[data-theme="dark"] body:has(.login-scene)::after {
    opacity: 0.24;
    background: radial-gradient(circle at center, rgba(255, 139, 31, 0.13) 0 26%, rgba(255, 139, 31, 0.05) 27% 48%, transparent 49%);
}

html[data-theme="dark"] body:has(.login-scene) .login-scene__card {
    border-color: #2a3850 !important;
    background: linear-gradient(155deg, rgba(17, 27, 44, 0.98), rgba(12, 21, 36, 0.98)) !important;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-scene__card::before {
    background:
        linear-gradient(135deg, rgba(29, 184, 207, 0.065), transparent 34%),
        linear-gradient(315deg, rgba(255, 139, 31, 0.035), transparent 28%);
}

html[data-theme="dark"] body:has(.login-scene) .login-scene__card::after {
    opacity: 0.34;
    background: radial-gradient(circle at 4px 4px, rgba(103, 127, 158, 0.28) 0 2.5px, transparent 3px) 0 0 / 24px 24px;
}

html[data-theme="dark"] body:has(.login-scene) .login-theme-toggle {
    border-color: #33445e;
    color: #ffb366;
    background: rgba(24, 36, 56, 0.94);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] body:has(.login-scene) .login-theme-toggle:hover,
html[data-theme="dark"] body:has(.login-scene) .login-theme-toggle:focus-visible {
    border-color: rgba(121, 219, 231, 0.55);
    color: #ffd09f;
    background: #1b2a42;
    outline-color: rgba(49, 189, 208, 0.17);
}

html[data-theme="dark"] body:has(.login-scene) .login-alert {
    border-color: rgba(74, 222, 128, 0.3);
    color: #b8f5ce;
    background: rgba(22, 101, 52, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] body:has(.login-scene) .login-alert__icon {
    border-color: #62d990;
    color: #78e5a1;
    background: rgba(22, 101, 52, 0.2);
}

html[data-theme="dark"] body:has(.login-scene) :is(.alert-danger, .invalid-feedback) {
    color: #fecaca !important;
}

html[data-theme="dark"] body:has(.login-scene) .alert-danger {
    border-color: rgba(248, 113, 113, 0.34) !important;
    background: rgba(127, 29, 29, 0.24) !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-brand img {
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.23);
}

html[data-theme="dark"] body:has(.login-scene) .login-divider::before,
html[data-theme="dark"] body:has(.login-scene) .login-divider::after,
html[data-theme="dark"] body:has(.login-scene) .login-footer__rule::before,
html[data-theme="dark"] body:has(.login-scene) .login-footer__rule::after {
    background: linear-gradient(90deg, rgba(78, 99, 129, 0.05), rgba(78, 99, 129, 0.88));
}

html[data-theme="dark"] body:has(.login-scene) .login-title {
    color: #f4f8ff !important;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.24);
}

html[data-theme="dark"] body:has(.login-scene) .login-title span {
    color: #39c5d8 !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-subtitle {
    color: #aebbd0 !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-field {
    border-color: #314159 !important;
    background: rgba(18, 29, 47, 0.96) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16) !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-field:focus-within {
    border-color: #31bdd0 !important;
    background: #142239 !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), 0 0 0 3px rgba(49, 189, 208, 0.13) !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-field__icon {
    border: 1px solid rgba(49, 189, 208, 0.16);
    color: #79dbe7 !important;
    background: rgba(49, 189, 208, 0.09) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html[data-theme="dark"] body:has(.login-scene) .login-field__label {
    color: #cbd7e8 !important;
    font-weight: 600;
}

html[data-theme="dark"] body:has(.login-scene) .login-input {
    color: #f1f6ff !important;
    background: transparent !important;
    -webkit-text-fill-color: #f1f6ff !important;
    caret-color: #79dbe7;
}

html[data-theme="dark"] body:has(.login-scene) .login-input::placeholder {
    color: #7f90aa !important;
    opacity: 1;
}

html[data-theme="dark"] body:has(.login-scene) .login-input:-webkit-autofill,
html[data-theme="dark"] body:has(.login-scene) .login-input:-webkit-autofill:hover,
html[data-theme="dark"] body:has(.login-scene) .login-input:-webkit-autofill:focus,
html[data-theme="dark"] body:has(.login-scene) .login-input:-webkit-autofill:active {
    -webkit-text-fill-color: #f1f6ff !important;
    caret-color: #79dbe7 !important;
    -webkit-box-shadow: 0 0 0 1000px #121d2f inset !important;
    box-shadow: 0 0 0 1000px #121d2f inset !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-password-toggle {
    color: #9fb0c8 !important;
    background: transparent !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-password-toggle:hover,
html[data-theme="dark"] body:has(.login-scene) .login-password-toggle:focus-visible {
    color: #79dbe7 !important;
    background: rgba(49, 189, 208, 0.1) !important;
    outline: 2px solid rgba(49, 189, 208, 0.16);
}

html[data-theme="dark"] body:has(.login-scene) .login-options .form-check-label {
    color: #c2cee0 !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-options a {
    color: #67d4e2 !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-options a:hover,
html[data-theme="dark"] body:has(.login-scene) .login-options a:focus-visible {
    color: #9ce8f0 !important;
    text-decoration: underline;
}

html[data-theme="dark"] body:has(.login-scene) .login-options .form-check-input {
    border-color: #56cad9;
    background-color: #101b2d;
}

html[data-theme="dark"] body:has(.login-scene) .login-options .form-check-input:checked {
    border-color: #31bdd0;
    background-color: #31bdd0;
}

html[data-theme="dark"] body:has(.login-scene) .login-submit {
    background: linear-gradient(100deg, #26bdc9 0%, #087aa8 100%);
    box-shadow: 0 16px 34px rgba(4, 126, 164, 0.24);
}

html[data-theme="dark"] body:has(.login-scene) .login-submit:hover,
html[data-theme="dark"] body:has(.login-scene) .login-submit:focus-visible {
    background: linear-gradient(100deg, #35ced8 0%, #0b8dbb 100%);
    box-shadow: 0 18px 38px rgba(4, 126, 164, 0.34), 0 0 0 3px rgba(49, 189, 208, 0.14);
}

html[data-theme="dark"] body:has(.login-scene) :is(.login-footer, .login-footer p) {
    color: #aab8cc !important;
}

html[data-theme="dark"] body:has(.login-scene) .login-footer__shield {
    color: #7fdce7;
}

@media (max-width: 575.98px) {
    body:has(.login-scene) .login-theme-toggle {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    body:has(.login-scene) .login-card {
        padding-top: 46px;
    }

    body:has(.login-scene) .login-brand {
        padding-inline: 42px;
    }
}

/* Incentive fee rows and paid incentive reports use their own light palette. */
html[data-theme="dark"] body .insentive-page :is(.fee-student-allocations, .associate-student-list) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] body .insentive-page :is(.fee-student-allocations__head, .associate-student-list__head) {
    border-color: var(--crm-border) !important;
    color: #dce6f5 !important;
    background: #202c42 !important;
}

html[data-theme="dark"] body .insentive-page .fee-student-allocation,
html[data-theme="dark"] body .insentive-page .associate-student-row {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] body .insentive-page .fee-student-allocation:nth-child(odd),
html[data-theme="dark"] body .insentive-page .associate-student-row:nth-child(even) {
    background: #172033 !important;
}

html[data-theme="dark"] body .insentive-page :is(.fee-student-allocation:hover, .associate-student-row:hover, .associate-student-row.is-selected) {
    background: #202c42 !important;
}

html[data-theme="dark"] body .insentive-page :is(.fee-student-allocation strong, .associate-student-row strong) {
    color: #edf3fc !important;
}

html[data-theme="dark"] body .insentive-page :is(
    .fee-student-allocation__detail,
    .fee-student-allocation__mobile-label,
    .associate-student-row small,
    .associate-student-note,
    .associate-student-empty
) {
    color: #aebbd0 !important;
}

html[data-theme="dark"] body .insentive-page .fee-student-allocation__paid,
html[data-theme="dark"] body .insentive-page .fee-student-allocation__balance,
html[data-theme="dark"] body .insentive-page .fee-student-allocation__balance.is-cleared {
    border-color: rgba(57, 217, 138, 0.3) !important;
    color: #9aefc1 !important;
    background: rgba(25, 179, 106, 0.14) !important;
}

html[data-theme="dark"] body .insentive-page :is(.paid-accounting-note, .paid-history-filter) {
    border-color: var(--crm-border) !important;
    color: #cbd7e8 !important;
    background: var(--crm-surface-soft) !important;
}

html[data-theme="dark"] body .insentive-page :is(.paid-summary-card, .paid-dashboard-block, .paid-history-card) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] body .insentive-page .paid-summary-card__top > span:first-child {
    color: var(--crm-text-muted) !important;
}

html[data-theme="dark"] body .insentive-page .paid-summary-card strong {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] body .insentive-page .paid-summary-card__icon {
    border-radius: 9px;
    color: color-mix(in srgb, var(--summary-color, var(--crm-primary)) 58%, #ffffff) !important;
    background: color-mix(in srgb, var(--summary-color, var(--crm-primary)) 18%, var(--crm-surface-soft)) !important;
}

html[data-theme="dark"] body .insentive-page .paid-dashboard-table th {
    border-color: var(--crm-border) !important;
    color: #dce6f5 !important;
    background: #202c42 !important;
}

html[data-theme="dark"] body .insentive-page .paid-dashboard-table tbody td {
    border-color: var(--crm-border) !important;
    color: #dce6f5 !important;
    background: var(--crm-surface) !important;
}

html[data-theme="dark"] body .insentive-page .paid-dashboard-table tbody tr:nth-child(even) td {
    background: #172033 !important;
}

html[data-theme="dark"] body .insentive-page .paid-dashboard-table tbody tr:hover td {
    background: #202c42 !important;
}

html[data-theme="dark"] body .insentive-page :is(.paid-party strong, .paid-history-primary, .paid-money) {
    color: #edf3fc !important;
}

html[data-theme="dark"] body .insentive-page :is(.paid-party small, .paid-history-secondary, .paid-dashboard-block__head small, .paid-empty) {
    color: #aebbd0 !important;
}

html[data-theme="dark"] body .insentive-page .paid-money.is-positive {
    color: #86efac !important;
}

html[data-theme="dark"] body .insentive-page .paid-money.is-negative {
    color: #fda4af !important;
}

html[data-theme="dark"] body .insentive-page :is(.paid-purpose-badge, .paid-purpose-badge.is-direct, .paid-mode-badge) {
    border: 1px solid var(--crm-border) !important;
    color: #dce6f5 !important;
    background: #202c42 !important;
}

html[data-theme="dark"] body .insentive-page .paid-dashboard-block__head {
    border-color: var(--crm-border) !important;
}

/* Dropdowns keep the same clear, elevated treatment in dark mode. */
html[data-theme="dark"] body :is(
    select:not(.mobile-select-source),
    .form-select,
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple,
    .mobile-select-trigger
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background-color: var(--crm-surface-soft) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

html[data-theme="dark"] body :is(
    .mobile-select-menu,
    .select2-dropdown,
    .dropdown-menu,
    .admission-dropdown-menu,
    .fee-name-picker__menu,
    .enquiry-select-menu,
    .fee-year-options,
    .dashboard-branch-options,
    [role='listbox']
) {
    border-color: var(--crm-border) !important;
    color: var(--crm-text) !important;
    background-color: var(--crm-surface) !important;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.38) !important;
}

html[data-theme="dark"] body :is(
    .mobile-select-option,
    .select2-container--default .select2-results__option,
    .dropdown-menu .dropdown-item,
    .admission-dropdown-option,
    .fee-name-picker__choose,
    .enquiry-select-option,
    .fee-year-option,
    .dashboard-branch-option,
    [role='listbox'] [role='option']
) {
    color: var(--crm-text) !important;
}

html[data-theme="dark"] body :is(
    .mobile-select-option:hover,
    .mobile-select-option:focus-visible,
    .select2-container--default .select2-results__option--highlighted[aria-selected],
    .dropdown-menu .dropdown-item:hover,
    .dropdown-menu .dropdown-item:focus,
    .admission-dropdown-option:hover,
    .fee-name-picker__choose:hover,
    .enquiry-select-option:hover,
    .enquiry-select-option:focus-visible,
    .fee-year-option:hover,
    .dashboard-branch-option:hover,
    [role='listbox'] [role='option']:hover
) {
    color: #f5fbff !important;
    background: #1d5262 !important;
}

html[data-theme="dark"] body .mobile-select-option[aria-selected="true"] {
    color: #fff !important;
    background: linear-gradient(135deg, #138b63 0%, #087d92 100%) !important;
}

html[data-theme="dark"] body :is(
    select option:checked,
    .select2-container--default .select2-results__option[aria-selected="true"],
    .dropdown-menu .dropdown-item.active,
    .dropdown-menu .dropdown-item:active,
    .admission-dropdown-option.selected,
    .admission-dropdown-option.is-highlighted,
    .enquiry-select-option.is-selected,
    .enquiry-select-option.is-highlighted,
    .fee-year-option[aria-selected="true"],
    .dashboard-branch-option[aria-selected="true"],
    [role='listbox'] [role='option'][aria-selected='true']
) {
    color: #fff !important;
    background: linear-gradient(105deg, #138b63 0%, #087d92 100%) !important;
    font-weight: 700 !important;
}

html[data-theme="dark"] body :is(
    .mobile-select-group,
    select optgroup
) {
    color: var(--crm-text-muted) !important;
    background-color: var(--crm-surface-soft) !important;
}
