/* ============================================
   DENTAGEST - APP-WIDE UI HARMONIZATION
   Design-only polish for all modules
   ============================================ */

:root,
body.light-theme {
    --app-bg: #f4f7fb;
    --page-container-bg: #f4f7fb;
    --sidebar-bg: #0f172a;
    --topbar-bg: rgba(255, 255, 255, 0.94);
    --card-bg: #ffffff;
    --surface-0: #ffffff;
    --surface-1: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef3f8;
    --surface-4: #e4ebf4;
    --surface-secondary: #f7f9fc;
    --glass-bg: #ffffff;
    --glass-bg-strong: #ffffff;
    --glass-border: #dfe7f1;
    --glass-border-strong: #c8d5e4;
    --border-default: #dfe7f1;
    --border-muted: #edf2f7;
    --border-subtle: #f5f8fb;
    --text-primary: #132238;
    --text-secondary: #607086;
    --text-tertiary: #8b99aa;
    --text-muted: #aeb9c7;
    --brand-blue: #2563eb;
    --brand-blue-light: #3b82f6;
    --brand-blue-dark: #1d4ed8;
    --brand-blue-subtle: #eaf2ff;
    --brand-cyan: #0ea5a4;
    --brand-mint: #13b981;
    --brand-indigo: #4f46e5;
    --brand-violet: #7c3aed;
    --brand-gold: #d49b33;
    --brand-gold-dark: #b7791f;
    --success: #059669;
    --success-bg: #eafaf3;
    --warning: #c97706;
    --warning-bg: #fff7e6;
    --danger: #dc2626;
    --danger-bg: #fff1f2;
    --info: #2563eb;
    --info-bg: #eaf2ff;
    --input-bg: #ffffff;
    --input-border: #d6e0ec;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 24px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.10);
    --shadow-xl: 0 24px 64px rgba(15, 23, 42, 0.14);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 14px;
    --radius-card: 12px;
    --radius-btn: 9px;
    --radius-input: 9px;
    --header-height: 64px;
}

html {
    background: var(--app-bg);
}

body.light-theme,
body.light-theme .app-container,
body.light-theme .main-content {
    background:
        linear-gradient(180deg, rgba(234, 242, 255, 0.72) 0%, rgba(244, 247, 251, 0) 260px),
        var(--app-bg);
    color: var(--text-primary);
}

body.light-theme .main-content {
    min-width: 0;
}

body.light-theme .page-container {
    padding: 24px;
    background: transparent;
}

body.light-theme .page-header,
body.light-theme .patients-list-header,
body.light-theme .admin-section-header,
body.light-theme .settings-header,
body.light-theme .supplies-header,
body.light-theme .payments-filters,
body.light-theme .stats-filters,
body.light-theme .profile-header-bar {
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

body.light-theme .page-title h1,
body.light-theme .page-title,
body.light-theme .page-header-title,
body.light-theme .admin-section h2,
body.light-theme .settings-title,
body.light-theme .section-title {
    color: var(--text-primary);
    letter-spacing: 0;
    line-height: 1.15;
}

body.light-theme .page-subtitle,
body.light-theme .admin-subtitle,
body.light-theme .section-subtitle,
body.light-theme .text-secondary {
    color: var(--text-secondary);
}

/* Sidebar and topbar */
body.light-theme .sidebar {
    background: linear-gradient(180deg, #101827 0%, #0b1220 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 18px 0 44px rgba(15, 23, 42, 0.12);
}

body.light-theme .sidebar::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 220px;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(14, 165, 164, 0.08) 55%, transparent 100%),
        radial-gradient(circle at 18% 12%, rgba(96, 165, 250, 0.2), transparent 34%);
    pointer-events: none;
}

body.light-theme .sidebar-header,
body.light-theme .sidebar-footer {
    border-color: rgba(255, 255, 255, 0.08);
}

body.light-theme .sidebar-header {
    display: block;
    min-height: auto;
    padding: 12px;
    position: relative;
    z-index: 1;
}

body.light-theme .logo {
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.032));
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 12px 22px rgba(0, 0, 0, 0.13);
    gap: 10px;
    min-height: 72px;
    min-width: 0;
    padding: 10px 48px 10px 10px;
    width: 100%;
}

body.light-theme .logo-icon {
    align-self: center;
    border-radius: 12px;
    height: 42px;
    padding: 6px;
    width: 42px;
}

body.light-theme .logo-icon svg {
    filter: drop-shadow(0 8px 14px rgba(14, 165, 164, 0.22));
}

body.light-theme .logo-text {
    gap: 3px;
    min-width: 0;
}

body.light-theme .logo-title,
body.light-theme .app-name,
body.light-theme .user-name {
    color: #f8fafc;
}

body.light-theme .logo-title,
body.light-theme .app-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.16;
    max-width: 124px;
    overflow-wrap: normal;
    text-wrap: wrap;
    word-break: normal;
}

body.light-theme .logo-subtitle,
body.light-theme .app-subtitle,
body.light-theme .user-role {
    color: #94a3b8;
}

body.light-theme .logo-subtitle,
body.light-theme .app-subtitle {
    color: #b9c6d8;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.11em;
    line-height: 1.3;
}

body.light-theme .logo-icon,
body.light-theme .user-avatar {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5a4 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: white;
}

body.light-theme .sidebar-toggle {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    color: #dbe7f7;
    height: 34px;
    position: absolute;
    right: 17px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
}

body.light-theme .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

body.light-theme .nav-item {
    color: #b8c4d6;
    border: 1px solid transparent;
    border-radius: 10px;
    min-height: 42px;
}

body.light-theme .nav-item .nav-icon {
    color: #8ea0b8;
}

body.light-theme .nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.08);
}

body.light-theme .nav-item.active {
    background: linear-gradient(135deg, #2563eb 0%, #0ea5a4 100%);
    color: white;
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.28);
}

body.light-theme .nav-item.active .nav-icon,
body.light-theme .nav-item.active .nav-text {
    color: white;
}

body.light-theme .nav-item.active::before {
    display: none;
}

body.light-theme .sidebar-footer {
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) 42px;
    padding: 10px 12px;
    position: relative;
    z-index: 1;
}

body.light-theme .user-profile {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.045)),
        linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 164, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 18px rgba(0, 0, 0, 0.14);
    gap: 9px;
    min-width: 0;
    padding: 9px;
    position: relative;
}

body.light-theme .user-profile::after {
    background: #22c55e;
    border: 2px solid #101827;
    border-radius: 50%;
    bottom: 10px;
    content: '';
    height: 9px;
    left: 43px;
    position: absolute;
    width: 9px;
}

body.light-theme .user-avatar {
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(14, 165, 164, 0.2);
    height: 42px;
    width: 42px;
}

body.light-theme .user-avatar span {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0;
}

body.light-theme .sidebar-footer .user-info {
    align-items: flex-start;
    margin-right: 0;
    min-width: 0;
}

body.light-theme .sidebar-footer .user-name {
    display: -webkit-box;
    font-size: 12.5px;
    font-weight: 750;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    width: 100%;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

body.light-theme .sidebar-footer .user-role {
    color: #b7c5d8;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.35;
}

body.light-theme .btn-logout {
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    color: #dbe7f7;
    display: flex;
    font-size: 15px;
    height: 62px;
    justify-content: center;
    position: relative;
    transition: all 160ms ease;
    width: 42px;
}

body.light-theme .btn-logout::before {
    content: '';
}

body.light-theme .btn-logout:hover {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(252, 165, 165, 0.32);
    color: #fecdd3;
    transform: translateY(-1px);
}

body.light-theme .sidebar.collapsed .sidebar-header {
    align-items: center;
    min-height: auto;
    padding: 14px 10px;
}

body.light-theme .sidebar.collapsed .logo {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding: 0;
}

body.light-theme .sidebar.collapsed .logo-icon {
    height: 42px;
    width: 42px;
}

body.light-theme .sidebar.collapsed .sidebar-footer {
    padding: 10px;
}

body.light-theme .sidebar.collapsed .user-profile {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    justify-content: center;
    padding: 0;
}

body.light-theme .sidebar.collapsed .user-profile::after {
    display: none;
}

body.light-theme .sidebar.collapsed .user-avatar {
    border-radius: 12px;
    height: 42px;
    width: 42px;
}

body.light-theme .sidebar.collapsed .btn-logout {
    height: 38px;
    width: 42px;
}

body.light-theme .sidebar.collapsed .btn-logout::before {
    content: '';
}

body.light-theme .sidebar.collapsed .btn-logout {
    font-size: 16px;
}

body.light-theme .header {
    height: var(--header-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid rgba(223, 231, 241, 0.9);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

body.light-theme .search-box {
    max-width: 520px;
}

body.light-theme .search-input,
body.light-theme .patients-search-input {
    height: 40px;
    background: #f8fbff;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-input);
    color: var(--text-primary);
    box-shadow: var(--shadow-inset);
}

body.light-theme .search-input:focus,
body.light-theme .patients-search-input:focus {
    background: #ffffff;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body.light-theme .header-date,
body.light-theme .notification-btn,
body.light-theme .mobile-menu-btn,
body.light-theme .back-admin-btn {
    background: #ffffff;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

body.light-theme .notification-btn:hover,
body.light-theme .mobile-menu-btn:hover,
body.light-theme .back-admin-btn:hover {
    background: var(--brand-blue-subtle);
    border-color: #bdd2f6;
    color: var(--brand-blue);
}

body.light-theme .quick-add-btn,
body.light-theme .btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #0f8fbe 100%);
    border: 1px solid rgba(37, 99, 235, 0.18);
    color: #ffffff;
    border-radius: var(--radius-btn);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.22);
}

body.light-theme .quick-add-btn:hover,
body.light-theme .btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #0b7da8 100%);
    box-shadow: 0 16px 32px rgba(37, 99, 235, 0.28);
    transform: translateY(-1px);
}

/* Shared components */
body.light-theme .card,
body.light-theme .stat-card,
body.light-theme .dashboard-card,
body.light-theme .admin-stat-card,
body.light-theme .admin-section,
body.light-theme .clinic-card,
body.light-theme .patient-card,
body.light-theme .invoice-card,
body.light-theme .supply-card,
body.light-theme .supplier-card,
body.light-theme .settings-card,
body.light-theme .settings-section,
body.light-theme .finance-card,
body.light-theme .chart-card,
body.light-theme .profile-patient-banner,
body.light-theme .profile-tabs-bar,
body.light-theme .profile-content-card,
body.light-theme .orthodontic-card,
body.light-theme .ortho-stat-card,
body.light-theme .appointment-card,
body.light-theme .appointment-list-card,
body.light-theme .calendar-container,
body.light-theme .table-container,
body.light-theme .modal-content,
body.light-theme .quick-add-option {
    background: var(--card-bg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}

body.light-theme .card:hover,
body.light-theme .patient-card:hover,
body.light-theme .invoice-card:hover,
body.light-theme .supply-card:hover,
body.light-theme .supplier-card:hover,
body.light-theme .clinic-card:hover,
body.light-theme .quick-add-option:hover,
body.light-theme .orthodontic-card:hover,
body.light-theme .appointment-card:hover {
    border-color: #cbd9ea;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

body.light-theme .stat-card,
body.light-theme .admin-stat-card,
body.light-theme .ortho-stat-card {
    min-height: 118px;
    padding: 18px;
}

body.light-theme .dashboard-grid > .stat-card,
body.light-theme .dashboard-grid > .stat-card:nth-child(1),
body.light-theme .dashboard-grid > .stat-card:nth-child(2),
body.light-theme .dashboard-grid > .stat-card:nth-child(3),
body.light-theme .dashboard-grid > .stat-card:nth-child(4) {
    background: var(--card-bg);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

body.light-theme .dashboard-grid > .stat-card:hover {
    border-color: #cbd9ea;
    box-shadow: var(--shadow-md);
}

body.light-theme .dashboard-grid > .stat-card .stat-value,
body.light-theme .dashboard-grid > .stat-card .stat-label,
body.light-theme .dashboard-grid > .stat-card .carousel-slide .stat-value,
body.light-theme .dashboard-grid > .stat-card .carousel-slide .stat-label,
body.light-theme .dashboard-grid > .stat-card .carousel-label {
    color: var(--text-primary);
    opacity: 1;
}

body.light-theme .dashboard-grid > .stat-card .stat-label,
body.light-theme .dashboard-grid > .stat-card .carousel-label {
    color: var(--text-secondary);
}

body.light-theme .dashboard-grid > .stat-card .stat-icon,
body.light-theme .dashboard-grid > .stat-card .stat-icon.blue,
body.light-theme .dashboard-grid > .stat-card .stat-icon.gold,
body.light-theme .dashboard-grid > .stat-card .stat-icon.green,
body.light-theme .dashboard-grid > .stat-card .stat-icon.red {
    background: #eff6ff;
    color: var(--brand-blue);
}

body.light-theme .dashboard-grid > .stat-card:nth-child(2) .stat-icon,
body.light-theme .dashboard-grid > .stat-card:nth-child(2) .stat-icon svg {
    background: #fff7ed;
    color: var(--warning);
}

body.light-theme .dashboard-grid > .stat-card:nth-child(3) .stat-icon,
body.light-theme .dashboard-grid > .stat-card:nth-child(3) .stat-icon svg {
    background: #ecfdf5;
    color: var(--success);
}

body.light-theme .dashboard-grid > .stat-card:nth-child(4) .stat-icon,
body.light-theme .dashboard-grid > .stat-card:nth-child(4) .stat-icon svg {
    background: #fff1f2;
    color: var(--danger);
}

body.light-theme .dashboard-grid > .stat-card .stat-icon svg {
    color: currentColor;
}

body.light-theme .dashboard-grid > .stat-card .carousel-dot {
    background: #cbd9ea;
}

body.light-theme .dashboard-grid > .stat-card .carousel-dot.active {
    background: var(--brand-blue);
}

body.light-theme .stat-card::before,
body.light-theme .stat-card::after,
body.light-theme .admin-stat-card::before,
body.light-theme .card::before {
    display: none;
}

body.light-theme .stat-icon,
body.light-theme .admin-stat-icon,
body.light-theme .ortho-stat-icon,
body.light-theme .metric-icon,
body.light-theme .popup-icon {
    border-radius: 12px;
    box-shadow: none;
}

body.light-theme .stat-icon.blue,
body.light-theme .admin-stat-icon.blue,
body.light-theme .ortho-stat-icon.blue {
    background: #eaf2ff;
    color: #2563eb;
}

body.light-theme .stat-icon.green,
body.light-theme .admin-stat-icon.green,
body.light-theme .ortho-stat-icon.green {
    background: #eafaf3;
    color: #059669;
}

body.light-theme .stat-icon.gold,
body.light-theme .admin-stat-icon.gold,
body.light-theme .ortho-stat-icon.gold {
    background: #fff7e6;
    color: #b7791f;
}

body.light-theme .stat-icon.red,
body.light-theme .admin-stat-icon.red,
body.light-theme .ortho-stat-icon.red {
    background: #fff1f2;
    color: #dc2626;
}

body.light-theme .stat-value,
body.light-theme .admin-stat-value,
body.light-theme .metric-value,
body.light-theme .balance-value {
    color: var(--text-primary);
    letter-spacing: 0;
}

body.light-theme .stat-label,
body.light-theme .admin-stat-label,
body.light-theme .metric-label {
    color: var(--text-secondary);
}

body.light-theme .card-header,
body.light-theme .card-footer,
body.light-theme .modal-header,
body.light-theme .modal-footer,
body.light-theme .invoice-card-header,
body.light-theme .clinic-card-header {
    border-color: var(--border-muted);
}

body.light-theme .invoice-card-header,
body.light-theme .table th,
body.light-theme .appointments-table th {
    background: #f8fbff;
}

/* Forms, filters, segmented controls */
body.light-theme .form-input,
body.light-theme .form-select,
body.light-theme .form-textarea,
body.light-theme input[type="text"],
body.light-theme input[type="email"],
body.light-theme input[type="number"],
body.light-theme input[type="date"],
body.light-theme input[type="time"],
body.light-theme input[type="tel"],
body.light-theme input[type="password"],
body.light-theme select,
body.light-theme textarea {
    background: #ffffff;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-input);
    color: var(--text-primary);
    box-shadow: var(--shadow-inset);
}

body.light-theme .form-input:focus,
body.light-theme .form-select:focus,
body.light-theme .form-textarea:focus,
body.light-theme input:focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
    border-color: rgba(37, 99, 235, 0.58);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
    outline: none;
}

body.light-theme .btn {
    border-radius: var(--radius-btn);
    font-weight: 650;
    letter-spacing: 0;
}

body.light-theme .btn-secondary,
body.light-theme .btn-ghost,
body.light-theme .filter-btn,
body.light-theme .tab,
body.light-theme .patient-tab,
body.light-theme .profile-tab,
body.light-theme .calendar-view-btn,
body.light-theme .view-btn {
    background: #ffffff;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    border-radius: var(--radius-btn);
}

body.light-theme .btn-secondary:hover:not(:disabled),
body.light-theme .btn-ghost:hover:not(:disabled),
body.light-theme .filter-btn:hover,
body.light-theme .tab:hover,
body.light-theme .patient-tab:hover,
body.light-theme .profile-tab:hover,
body.light-theme .calendar-view-btn:hover,
body.light-theme .view-btn:hover {
    background: #f8fbff;
    border-color: #cbd9ea;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

body.light-theme .filter-buttons,
body.light-theme .tabs,
body.light-theme .patient-tabs,
body.light-theme .profile-tabs-bar,
body.light-theme .calendar-view-switcher,
body.light-theme .view-toggle {
    background: #edf3fb;
    border: 1px solid #dce6f2;
    border-radius: 12px;
    padding: 4px;
    box-shadow: none;
}

body.light-theme .filter-btn::before {
    display: none;
}

body.light-theme .filter-btn.active,
body.light-theme .tab.active,
body.light-theme .patient-tab.active,
body.light-theme .profile-tab.active,
body.light-theme .calendar-view-btn.active,
body.light-theme .view-btn.active {
    background: #ffffff;
    color: var(--brand-blue);
    border-color: #bfd3f5;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.10);
}

body.light-theme .patient-tab {
    border-bottom: 1px solid var(--border-default);
}

body.light-theme .patient-tab.active {
    border-bottom-color: #bfd3f5;
}

/* Tables */
body.light-theme .table-container {
    overflow: hidden;
}

body.light-theme .table,
body.light-theme table {
    border-collapse: separate;
    border-spacing: 0;
}

body.light-theme .table th,
body.light-theme table th {
    color: #526176;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    border-bottom: 1px solid var(--border-default);
}

body.light-theme .table td,
body.light-theme table td {
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-muted);
}

body.light-theme .table tbody tr:hover,
body.light-theme table tbody tr:hover {
    background: #f8fbff;
}

/* Module-specific harmonization */
body.light-theme .admin-dashboard {
    background: transparent;
}

body.light-theme .admin-header {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

body.light-theme .admin-title {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--text-primary);
}

body.light-theme .admin-logo svg circle {
    stroke: #2563eb;
}

body.light-theme .clinic-logo,
body.light-theme .patient-avatar-large,
body.light-theme .profile-avatar,
body.light-theme .admin-logo {
    background: linear-gradient(135deg, #eaf2ff 0%, #e8fbf8 100%);
    color: #2563eb;
}

body.light-theme .patient-card.selected {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body.light-theme .history-item,
body.light-theme .balance-item,
body.light-theme .patient-info-card,
body.light-theme .document-card,
body.light-theme .treatment-card,
body.light-theme .payment-item,
body.light-theme .quote-card,
body.light-theme .setting-item,
body.light-theme .expense-item,
body.light-theme .charge-item {
    background: #f8fbff;
    border: 1px solid var(--border-muted);
    border-radius: 10px;
}

body.light-theme .payment-method,
body.light-theme .invoice-status,
body.light-theme .badge,
body.light-theme .status-badge,
body.light-theme .doctor-badge,
body.light-theme .gender-badge {
    border-radius: 999px;
    font-weight: 650;
}

body.light-theme .invoice-total,
body.light-theme .history-amount {
    color: var(--brand-blue);
}

body.light-theme .settings-sidebar,
body.light-theme .settings-nav,
body.light-theme .supplies-filters,
body.light-theme .payments-filters,
body.light-theme .calendar-controls,
body.light-theme .ortho-filters {
    background: #ffffff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}

body.light-theme .settings-layout,
body.light-theme .finances-page,
body.light-theme .patients-layout,
body.light-theme .supplies-page,
body.light-theme .orthodontics-page,
body.light-theme .statistics-page {
    color: var(--text-primary);
}

body.light-theme .settings-content,
body.light-theme .finance-content {
    min-width: 0;
}

body.light-theme .settings-nav {
    padding: 8px;
}

body.light-theme .settings-nav-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 650;
    min-height: 40px;
}

body.light-theme .settings-nav-item:hover {
    background: #f8fbff;
    border-color: var(--border-muted);
    color: var(--text-primary);
}

body.light-theme .settings-nav-item.active {
    background: var(--brand-blue-subtle);
    border-color: #bfd3f5;
    color: var(--brand-blue);
}

body.light-theme .settings-section-header,
body.light-theme .section-header,
body.light-theme .finance-section h3,
body.light-theme .treatment-category,
body.light-theme .treatments-list,
body.light-theme .schedule-day {
    border-color: var(--border-muted);
}

body.light-theme .treatment-item,
body.light-theme .schedule-day,
body.light-theme .theme-option,
body.light-theme .google-card,
body.light-theme .whatsapp-card {
    background: #f8fbff;
    border: 1px solid var(--border-muted);
    border-radius: 10px;
}

body.light-theme .treatment-item:hover,
body.light-theme .theme-option:hover {
    background: #ffffff;
    border-color: #cbd9ea;
    box-shadow: var(--shadow-sm);
}

body.light-theme .treatment-price,
body.light-theme .finance-stat-value,
body.light-theme .transaction-amount.income,
body.light-theme .text-success {
    color: var(--success);
}

body.light-theme .text-danger,
body.light-theme .transaction-amount.expense {
    color: var(--danger);
}

body.light-theme .finance-stats-grid,
body.light-theme .payments-stats,
body.light-theme .stats-grid,
body.light-theme .admin-stats,
body.light-theme .dashboard-stats,
body.light-theme .supplies-stats,
body.light-theme .ortho-stats {
    gap: 16px;
}

body.light-theme .finance-stat-card,
body.light-theme .stat-card-premium,
body.light-theme .summary-card,
body.light-theme .metric-card,
body.light-theme .analytics-card,
body.light-theme .ranking-card,
body.light-theme .activity-card {
    background: #ffffff !important;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

body.light-theme .finance-stat-card:hover,
body.light-theme .stat-card-premium:hover,
body.light-theme .summary-card:hover,
body.light-theme .metric-card:hover,
body.light-theme .analytics-card:hover,
body.light-theme .ranking-card:hover,
body.light-theme .activity-card:hover {
    border-color: #cbd9ea;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

body.light-theme .finance-stat-icon,
body.light-theme .transaction-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--brand-blue-subtle);
    color: var(--brand-blue);
}

body.light-theme .finance-stat-card.income .finance-stat-icon,
body.light-theme .transaction-item.income .transaction-icon {
    background: var(--success-bg);
    color: var(--success);
}

body.light-theme .finance-stat-card.expenses .finance-stat-icon,
body.light-theme .transaction-item.expense .transaction-icon {
    background: var(--danger-bg);
    color: var(--danger);
}

body.light-theme .finance-stat-card.balance .finance-stat-icon {
    background: var(--info-bg);
    color: var(--info);
}

body.light-theme .finance-tabs {
    background: #edf3fb;
    border: 1px solid #dce6f2;
    border-radius: 12px;
    padding: 4px;
    box-shadow: none;
}

body.light-theme .finance-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text-secondary);
    font-weight: 650;
}

body.light-theme .finance-tab:hover {
    background: #f8fbff;
    color: var(--text-primary);
}

body.light-theme .finance-tab.active {
    background: #ffffff;
    border-color: #bfd3f5;
    color: var(--brand-blue);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.10);
}

body.light-theme .finance-section,
body.light-theme .transactions-list,
body.light-theme .monthly-chart {
    background: #ffffff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}

body.light-theme .transaction-item {
    background: #f8fbff;
    border: 1px solid var(--border-muted);
    border-radius: 10px;
}

body.light-theme .month-bar {
    background: #edf3fb;
    border-radius: 10px;
}

body.light-theme .month-bar-income {
    background: linear-gradient(180deg, #13b981 0%, #059669 100%);
}

body.light-theme .month-bar-expense {
    background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
}

body.light-theme .supply-card,
body.light-theme .supplier-card {
    overflow: hidden;
}

body.light-theme .supply-card::before,
body.light-theme .supplier-card::before,
body.light-theme .clinic-card::before,
body.light-theme .patient-card::before {
    display: none;
}

body.light-theme .supply-category,
body.light-theme .supplier-type,
body.light-theme .stock-status,
body.light-theme .priority-badge,
body.light-theme .appointment-status {
    border-radius: 999px;
    font-weight: 650;
}

body.light-theme .stock-bar,
body.light-theme .progress {
    background: #edf3fb;
    border-radius: 999px;
    overflow: hidden;
}

body.light-theme .stock-fill,
body.light-theme .progress-bar {
    background: linear-gradient(90deg, #2563eb 0%, #0ea5a4 100%);
}

body.light-theme .appointment-event,
body.light-theme .calendar-event,
body.light-theme .timeline-item,
body.light-theme .ortho-session-item {
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

body.light-theme .calendar-day,
body.light-theme .time-slot,
body.light-theme .appointment-slot {
    background: #ffffff;
    border-color: var(--border-muted);
}

body.light-theme .calendar-day:hover,
body.light-theme .time-slot:hover,
body.light-theme .appointment-slot:hover {
    background: #f8fbff;
}

body.light-theme .patient-profile-page {
    max-width: 1500px;
}

body.light-theme .profile-avatar-img,
body.light-theme .profile-avatar {
    border: 3px solid #dbeafe;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.14);
}

body.light-theme .profile-patient-meta,
body.light-theme .patient-info-row,
body.light-theme .invoice-detail-label,
body.light-theme .treatment-duration,
body.light-theme .transaction-date {
    color: var(--text-secondary);
}

body.light-theme .statistics-page {
    --stat-glass-bg: #ffffff;
    --stat-glass-border: #dfe7f1;
    --stat-glass-highlight: #f8fbff;
    --stat-gradient-primary: linear-gradient(135deg, #2563eb 0%, #0ea5a4 100%);
    --stat-gradient-success: linear-gradient(135deg, #059669 0%, #13b981 100%);
    --stat-gradient-warning: linear-gradient(135deg, #c97706 0%, #f59e0b 100%);
    --stat-gradient-danger: linear-gradient(135deg, #dc2626 0%, #f87171 100%);
    --stat-gradient-info: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
    --stat-gradient-gold: linear-gradient(135deg, #d49b33 0%, #f5c56b 100%);
}

body.light-theme .statistics-page .page-title h1,
body.light-theme .stat-card-premium,
body.light-theme .chart-card,
body.light-theme .ranking-card,
body.light-theme .activity-card {
    background: var(--card-bg);
    color: var(--text-primary);
    -webkit-text-fill-color: currentColor;
    border-color: var(--border-default);
    box-shadow: var(--shadow-sm);
}

body.light-theme .statistics-page .page-title h1 {
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
}

body.light-theme .odontogram-hd {
    background: #ffffff;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
}

body.light-theme .chart-separator {
    background: linear-gradient(to right, transparent 2%, rgba(37, 99, 235, 0.18) 15%, rgba(14, 165, 164, 0.42) 50%, rgba(37, 99, 235, 0.18) 85%, transparent 98%);
    box-shadow: none;
}

/* Auth screen */
body.light-theme #loginScreen {
    align-items: center;
    background:
        linear-gradient(120deg, rgba(11, 18, 32, 0.98) 0%, rgba(16, 24, 39, 0.98) 42%, rgba(244, 247, 251, 0.94) 42%, rgba(248, 251, 255, 0.98) 100%);
    justify-content: flex-end;
    padding: 32px clamp(24px, 10vw, 136px) 32px 24px;
}

body.light-theme #loginScreen::before {
    display: none;
}

body.light-theme #loginScreen::after {
    display: none;
}

body.light-theme .login-container {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(203, 217, 234, 0.9);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
    color: var(--text-primary);
    max-width: 448px;
    padding: 36px;
    position: relative;
    text-align: center;
    z-index: 1;
}

body.light-theme .login-container::before {
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-teal), var(--brand-gold));
    height: 5px;
    left: 0;
    right: 0;
    top: 0;
}

body.light-theme .login-logo {
    animation: none;
    filter: drop-shadow(0 14px 24px rgba(37, 99, 235, 0.22));
    margin-bottom: 18px;
}

body.light-theme .login-title {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-teal) 58%, var(--brand-gold) 115%);
    -webkit-background-clip: text;
    background-clip: text;
    font-size: 28px;
    letter-spacing: 0;
}

body.light-theme .login-subtitle,
body.light-theme .login-footer,
body.light-theme .login-divider {
    color: var(--text-secondary);
}

body.light-theme .login-form .form-label {
    color: #334155;
    font-weight: 650;
}

body.light-theme .login-form .form-input {
    background: #ffffff;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    min-height: 46px;
    box-shadow: var(--shadow-inset);
}

body.light-theme .login-form .form-input::placeholder {
    color: #94a3b8;
}

body.light-theme .login-form .form-input:focus {
    background: #ffffff;
    border-color: rgba(37, 99, 235, 0.58);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

body.light-theme .login-divider::before,
body.light-theme .login-divider::after {
    background: #dbe5f1;
}

body.light-theme .btn-google {
    background: #ffffff;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    min-height: 46px;
    box-shadow: var(--shadow-sm);
}

body.light-theme .btn-google:hover {
    background: #f8fbff;
    border-color: #bfd3f5;
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.14);
}

body.light-theme .login-error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #b91c1c;
}

/* Modals and overlays */
body.light-theme .modal-overlay {
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(8px);
}

body.light-theme .modal-content {
    box-shadow: var(--shadow-xl);
}

body.light-theme .modal-close {
    background: #f8fbff;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

body.light-theme .modal-close:hover {
    color: var(--danger);
    border-color: #fecdd3;
    background: #fff1f2;
}

/* Empty states */
body.light-theme .empty-state,
body.light-theme .admin-empty-state,
body.light-theme .no-data,
body.light-theme .empty-message {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px dashed #cbd9ea;
    border-radius: var(--radius-card);
    color: var(--text-secondary);
}

/* Keep dense tools usable on small screens */
@media (max-width: 900px) {
    body.light-theme #loginScreen {
        background: linear-gradient(180deg, #0b1220 0%, #101827 38%, #f4f7fb 38%, #f8fbff 100%);
        justify-content: center;
        padding: 20px;
    }

    body.light-theme .page-container {
        padding: 16px;
    }

    body.light-theme .header {
        height: auto;
        min-height: var(--header-height);
    }

    body.light-theme .patients-list-header,
    body.light-theme .payments-filters,
    body.light-theme .stats-filters,
    body.light-theme .admin-section-header,
    body.light-theme .profile-header-bar {
        align-items: stretch;
        flex-direction: column;
    }

    body.light-theme .patients-search,
    body.light-theme .search-box {
        max-width: none;
        width: 100%;
    }

    body.light-theme .filter-buttons,
    body.light-theme .tabs,
    body.light-theme .patient-tabs,
    body.light-theme .profile-tabs-bar {
        overflow-x: auto;
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    body.light-theme #loginScreen {
        align-items: flex-start;
        overflow-y: auto;
        padding: 14px;
    }

    body.light-theme .login-container {
        background: #ffffff;
        border-radius: 16px;
        margin: 0 auto;
        padding: 24px 22px;
        width: min(100%, 356px);
    }

    body.light-theme .login-logo {
        height: 64px;
        margin-bottom: 12px;
        width: 64px;
    }

    body.light-theme .login-title {
        font-size: 24px;
    }

    body.light-theme .login-subtitle {
        margin-bottom: 18px;
    }

    body.light-theme .login-form .form-group {
        margin-bottom: 12px;
    }

    body.light-theme .login-divider {
        margin: 16px 0;
    }

    body.light-theme .login-footer {
        margin-top: 18px;
    }

    body.light-theme .page-container {
        padding: 12px;
    }

    body.light-theme .card,
    body.light-theme .stat-card,
    body.light-theme .admin-section,
    body.light-theme .patient-card,
    body.light-theme .invoice-card,
    body.light-theme .modal-content {
        border-radius: 10px;
    }

    body.light-theme .btn,
    body.light-theme .quick-add-btn {
        min-height: 40px;
    }
}
