:root,
[data-theme="light"],
[data-theme="light"][data-light-palette="porcelain"] {
    --bg-primary: #F8FAFC;
    --bg-surface: #FFFFFF;
    --text-primary: #0F172A;
    --text-muted: #64748B;
    --brand-primary: #0284C7;
    --accent-cta: #0D9488;
    --border-color: #E2E8F0;

    --status-success: #10B981;
    --status-error: #EF4444;
    --status-pending: #F59E0B;
}

[data-theme="light"][data-light-palette="nordic"] {
    --bg-primary: #F0FDF4;
    --bg-surface: #FFFFFF;
    --text-primary: #064E3B;
    --text-muted: #047857;
    --brand-primary: #059669;
    --accent-cta: #0284C7;
    --border-color: #DCFCE7;

    --status-success: #10B981;
    --status-error: #EF4444;
    --status-pending: #F59E0B;
}

[data-theme="light"][data-light-palette="platinum"] {
    --bg-primary: #FAF5FF;
    --bg-surface: #FFFFFF;
    --text-primary: #3B0764;
    --text-muted: #6B21A8;
    --brand-primary: #7C3AED;
    --accent-cta: #2563EB;
    --border-color: #F3E8FF;

    --status-success: #10B981;
    --status-error: #EF4444;
    --status-pending: #F59E0B;
}

[data-theme="light"][data-light-palette="vanilla"] {
    --bg-primary: #FEFCE8;
    --bg-surface: #FFFFFF;
    --text-primary: #713F12;
    --text-muted: #854D0E;
    --brand-primary: #D97706;
    --accent-cta: #0284C7;
    --border-color: #FEF08A;

    --status-success: #10B981;
    --status-error: #EF4444;
    --status-pending: #F59E0B;
}

[data-theme="light"][data-light-palette="steel"] {
    --bg-primary: #F1F5F9;
    --bg-surface: #FFFFFF;
    --text-primary: #0F172A;
    --text-muted: #475569;
    --brand-primary: #2563EB;
    --accent-cta: #0D9488;
    --border-color: #CBD5E1;

    --status-success: #10B981;
    --status-error: #EF4444;
    --status-pending: #F59E0B;
}

[data-theme="dark"],
[data-theme="dark"][data-dark-palette="midnight"] {
    --bg-primary: #0F172A;
    --bg-surface: #1E293B;
    --text-primary: #F8FAFC;
    --text-muted: #94A3B8;
    --brand-primary: #38BDF8;
    --accent-cta: #2DD4BF;
    --border-color: #334155;

    --status-success: #34D399;
    --status-error: #F87171;
    --status-pending: #FBBF24;
}

[data-theme="dark"][data-dark-palette="obsidian"] {
    --bg-primary: #0B0F19;
    --bg-surface: #151C2C;
    --text-primary: #F8FAFC;
    --text-muted: #94A3B8;
    --brand-primary: #818CF8;
    --accent-cta: #06B6D4;
    --border-color: #222F43;

    --status-success: #34D399;
    --status-error: #F87171;
    --status-pending: #FBBF24;
}

[data-theme="dark"][data-dark-palette="emerald"] {
    --bg-primary: #061412;
    --bg-surface: #0E2421;
    --text-primary: #ECFDF5;
    --text-muted: #6EE7B7;
    --brand-primary: #34D399;
    --accent-cta: #22D3EE;
    --border-color: #1A3B37;

    --status-success: #34D399;
    --status-error: #F87171;
    --status-pending: #FBBF24;
}

[data-theme="dark"][data-dark-palette="onyx"] {
    --bg-primary: #121212;
    --bg-surface: #1E1E1E;
    --text-primary: #FEF08A;
    --text-muted: #A1A1AA;
    --brand-primary: #FACC15;
    --accent-cta: #38BDF8;
    --border-color: #2D2D2D;

    --status-success: #34D399;
    --status-error: #F87171;
    --status-pending: #FBBF24;
}

[data-theme="dark"][data-dark-palette="titanium"] {
    --bg-primary: #18181B;
    --bg-surface: #27272A;
    --text-primary: #F4F4F5;
    --text-muted: #A1A1AA;
    --brand-primary: #60A5FA;
    --accent-cta: #A7F3D0;
    --border-color: #3F3F46;

    --status-success: #34D399;
    --status-error: #F87171;
    --status-pending: #FBBF24;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: Arial, sans-serif;
}

[dir="rtl"] body {
    direction: rtl;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[dir="ltr"] body,
html:not([dir="rtl"]) body {
    direction: ltr;
}

/* Mobile Header (Hidden by default on Desktop) */
.mobile-header {
    display: none;
    background-color: var(--bg-surface);
    color: var(--brand-primary);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    width: 100%;
    z-index: 900;
    direction: ltr !important; /* Fixed button & logo layout in both Arabic and English */
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0 4px;
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 950;
}
.mobile-overlay.active {
    display: block;
}

.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    z-index: 1000;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

[dir="rtl"] .sidebar {
    border-left: 1px solid var(--border-color);
    border-right: none;
    direction: rtl;
}

[dir="ltr"] .sidebar,
html:not([dir="rtl"]) .sidebar {
    border-right: 1px solid var(--border-color);
    border-left: none;
    direction: ltr;
}

.sidebar h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.sidebar a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.sidebar a::before {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    width: 24px;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.sidebar a[data-target="dashboard-section"]::before,
.sidebar a[data-target="patients-section"]::before,
.sidebar a[data-target="schedule-section"]::before,
.sidebar a[data-target="inventory-section"]::before,
.sidebar a[data-target="financial-section"]::before,
.sidebar a[data-target="payments-section"]::before,
.sidebar a[data-target="expenses-section"]::before,
.sidebar a[data-target="settings-section"]::before {
 content: none !important;
 display: none !important;
}

.sidebar a:hover {
    background-color: rgba(56, 189, 248, 0.12);
    color: var(--brand-primary);
    transform: translateX(4px);
}

[dir="rtl"] .sidebar a:hover {
    transform: translateX(-4px);
}

.sidebar a:hover::before {
    transform: scale(1.3) rotate(8deg);
}

.sidebar a.active {
    background-color: var(--brand-primary);
    color: #FFFFFF !important;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.sidebar a.active::before {
    transform: scale(1.15);
    animation: iconPulseGleam 2.4s infinite ease-in-out;
}

.desktop-network-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    margin: 0.5rem 0.25rem 0.85rem 0.25rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #10b981;
    user-select: none;
    transition: all 0.3s ease;
    cursor: default;
}

.desktop-network-indicator .net-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
    flex-shrink: 0;
    animation: pulseNetworkDot 2.8s infinite ease-in-out;
}

.desktop-network-indicator.offline {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
}

.desktop-network-indicator.offline .net-status-dot {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
    animation: none;
}

/* ============================================================
   OFFLINE MODE VISUAL STYLING (30% Brightness Dimming & Desaturation)
   ============================================================ */
html.is-offline,
body.is-offline {
    filter: grayscale(100%) brightness(70%) !important;
    transition: filter 0.5s ease-in-out;
}

#offline-mode-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999999;
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    color: #ffffff;
    padding: 12px 20px;
    text-align: center;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Tajawal', sans-serif;
    border-bottom: 2px solid #f87171;
}

body.is-offline #offline-mode-banner {
    display: flex !important;
}

@keyframes pulseNetworkDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.85); }
}

/* Hidden strictly on Mobile viewports (< 768px) */
@media (max-width: 768px) {
    .desktop-network-indicator {
        display: none !important;
    }
}

.controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.controls button {
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-weight: bold;
}

.controls button:hover {
    background-color: var(--border-color);
}

.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    min-width: 0;
    min-height: 100vh;
}

/* Home Section Redesign */
.home-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--bg-primary); /* matches parent */
}

.home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.welcome-text h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.text-muted {
    color: var(--text-muted);
    font-size: 1rem;
}

.quick-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}
.btn-outline:hover {
    background: var(--bg-surface);
}

/* Home Grids & Cards */
.home-grid {
    display: grid;
    gap: 1rem;
}
.stats-grid { 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 0.6rem; 
}
.three-cols { grid-template-columns: repeat(3, 1fr); }
.four-cols { grid-template-columns: repeat(4, 1fr); }

.home-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.35rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    margin-bottom: 1.75rem;
}
.home-card.full-width { 
    width: 100%; 
    margin-bottom: 1.75rem;
}
.home-card.full-width:last-child {
    margin-bottom: 0.5rem;
}

.stats-grid .home-card {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    padding: 0.95rem 1.1rem;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}

.stats-grid .home-card:hover {
    transform: translateY(-4px);
    border-color: var(--brand-primary);
    box-shadow: 0 10px 24px -6px rgba(0, 0, 0, 0.12);
}

.stats-grid .home-card:active {
    transform: translateY(-1px) scale(0.98);
}

.home-card .card-header-flex {
    margin-bottom: 1.15rem;
}

.home-card .col-item {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.1rem 0.85rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.home-card .col-item:hover {
    transform: translateY(-3px);
    border-color: var(--brand-primary);
    background-color: rgba(56, 189, 248, 0.06);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.08);
}

.home-card .col-item:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.text-error {
    color: var(--status-error) !important;
}

.alert-card {
    background-color: rgba(239, 68, 68, 0.05); /* light red tint */
    border-color: rgba(239, 68, 68, 0.3);
}
[data-theme="dark"] .alert-card {
    background-color: rgba(248, 113, 113, 0.1);
}

/* Card Headers Flexbox */
.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}
.card-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
}
.header-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.header-title h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}
.nav-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
}
.nav-link:hover {
    text-decoration: underline;
}

.center-text { text-align: center; }
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.min-h-200 { min-height: 200px; }
.state-empty {
    text-align: center;
    color: var(--text-muted);
    margin-top: 1rem;
}
.icon-large {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Lists */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.list-item-left {
    display: flex;
    flex-direction: column;
}
.list-item-title { font-weight: bold; color: var(--text-primary); }
.list-item-sub { font-size: 0.85rem; color: var(--text-muted); }
.list-item-right { font-weight: bold; color: var(--text-primary); }

/* Search Bar */
.search-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

/* Timeline Schedule */
.timeline-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    padding: 1rem 0 2rem 0;
}
.timeline-hours {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 600px; /* Force scroll on small screens */
}
.timeline-events {
    position: relative;
    height: 40px;
    margin-top: 0.5rem;
    min-width: 600px;
}
.timeline-block {
    position: absolute;
    height: 100%;
    background-color: var(--brand-primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 0 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
}
.timeline-block:hover {
    filter: brightness(1.18);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 5;
}

/* =========================================================================
   Modern Clinical Calendar View & FullCalendar Pro Overhaul
   ========================================================================= */

/* Calendar Outer Container */
.calendar-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    transition: all 0.2s ease-in-out;
}

/* Custom Calendar Control Top Bar */
.calendar-unified-toolbar {
    transition: all 0.2s ease-in-out;
}

.cal-nav-btn {
    padding: 0.45rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    min-height: 38px;
    min-width: 38px;
}
.cal-nav-btn:hover {
    background: rgba(2, 132, 199, 0.12);
    color: var(--brand-primary);
}

.cal-today-pill {
    transition: all 0.15s ease;
}
.cal-today-pill:hover {
    background: rgba(2, 132, 199, 0.12) !important;
    color: var(--brand-primary) !important;
}

.cal-view-tab-btn {
    padding: 0.42rem 0.85rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.cal-view-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}
.cal-view-tab-btn.active {
    background: var(--brand-primary) !important;
    color: #ffffff !important;
    font-weight: 800;
    box-shadow: 0 2px 10px rgba(2, 132, 199, 0.35);
}

/* Status Filter Chips for Calendar */
.cal-filter-chip {
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    user-select: none;
}
.cal-filter-chip:hover {
    border-color: var(--chip-accent, var(--brand-primary));
    color: var(--text-primary);
}
.cal-filter-chip.active {
    border-color: var(--chip-accent, var(--brand-primary));
    background: rgba(2, 132, 199, 0.14);
    color: var(--text-primary);
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.cal-chip-count {
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.07);
    font-family: monospace;
    font-size: 0.72rem;
    font-weight: 800;
}
[data-theme="dark"] .cal-chip-count {
    background: rgba(255, 255, 255, 0.1);
}

/* RTL Icon Flip Helper */
[dir="rtl"] .rtl-flip {
    transform: scaleX(1);
}
[dir="ltr"] .rtl-flip {
    transform: scaleX(-1);
}

/* FullCalendar System Theme Customization */
.fc {
    --fc-page-bg-color: transparent;
    --fc-neutral-bg-color: var(--bg-primary);
    --fc-neutral-text-color: var(--text-primary);
    --fc-border-color: var(--border-color);
    --fc-button-text-color: #ffffff;
    --fc-button-bg-color: var(--brand-primary);
    --fc-button-border-color: var(--brand-primary);
    --fc-button-hover-bg-color: var(--accent-cta);
    --fc-button-hover-border-color: var(--accent-cta);
    --fc-button-active-bg-color: var(--accent-cta);
    --fc-button-active-border-color: var(--accent-cta);
    --fc-event-bg-color: transparent;
    --fc-event-border-color: transparent;
    --fc-event-text-color: var(--text-primary);
    --fc-today-bg-color: rgba(2, 132, 199, 0.06);
    --fc-highlight-color: rgba(2, 132, 199, 0.12);
    font-family: inherit;
}

[data-theme="dark"] .fc {
    --fc-today-bg-color: rgba(56, 189, 248, 0.08);
}

.fc-theme-standard td, .fc-theme-standard th {
    border-color: var(--border-color);
}

/* Column Headers */
.fc .fc-col-header-cell {
    background: var(--bg-primary);
    padding: 0.65rem 0.25rem;
    border-color: var(--border-color);
}
.fc .fc-col-header-cell-cushion {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-block;
}

/* Time Gutter & Slots */
.fc .fc-timegrid-slot {
    height: 3rem;
    border-bottom: 1px dashed rgba(100, 116, 139, 0.15) !important;
}
.fc .fc-timegrid-slot-minor {
    border-bottom: 1px dotted rgba(100, 116, 139, 0.1) !important;
}
.fc .fc-timegrid-slot-label-cushion {
    font-family: monospace;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Now Indicator */
.fc .fc-timegrid-now-indicator-line {
    border-color: #ef4444 !important;
    border-width: 2px !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    z-index: 10;
}
.fc .fc-timegrid-now-indicator-arrow {
    border-color: #ef4444 !important;
    margin-top: -5px;
}

/* Today Cell Highlight */
.fc-day-today {
    background-color: var(--fc-today-bg-color) !important;
}
.fc-day-today .fc-col-header-cell-cushion {
    color: var(--brand-primary);
    font-weight: 800;
}

/* Custom Rich Event Card Styling (Week & Day View) */
.fc-timegrid-event {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 1px 2px !important;
}

.fc-custom-event-card {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    padding: 6px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 3px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .fc-custom-event-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.fc-custom-event-card:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    z-index: 25;
}

.fc-event-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
}
.fc-event-time-badge {
    font-family: monospace;
    font-weight: 800;
    white-space: nowrap;
    font-size: 0.75rem;
}
.fc-event-status-pill {
    padding: 1px 6px;
    border-radius: 12px;
    border: 1px solid;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.fc-event-patient-name {
    font-weight: 800;
    font-size: 0.84rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}
.fc-event-phone {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
}
.fc-card-notes {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fc-event-visit-pill, .fc-card-visit-badge {
    margin-top: auto;
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    font-weight: 800;
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    display: inline-block;
}

/* Custom Month View Event Pill */
.fc-daygrid-event {
    background: transparent !important;
    border: none !important;
    margin: 2px 1px !important;
}
.fc-custom-event-month {
    width: 100%;
    border-radius: 5px;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.74rem;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    transition: transform 0.15s ease;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .fc-custom-event-month {
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.fc-custom-event-month:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
}
.fc-event-dot-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.fc-event-time-text {
    font-family: monospace;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.fc-event-patient-title {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

/* List View Overhaul */
.fc-list-table {
    border-collapse: separate;
    border-spacing: 0 4px;
}
.fc-list-day-cushion {
    background: var(--bg-primary) !important;
    color: var(--brand-primary) !important;
    font-weight: 700 !important;
    padding: 0.6rem 1rem !important;
}
.fc-list-event {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    cursor: pointer;
    transition: background 0.15s ease;
}
.fc-list-event:hover td {
    background: rgba(2, 132, 199, 0.08) !important;
}
.fc-list-event-time {
    font-family: monospace;
    font-weight: 700;
    color: var(--brand-primary);
}
.fc-list-event-title {
    font-weight: 700;
    color: var(--text-primary);
}

/* Clickable KPI Cards for Appointments Statistics Modal */
.appt-kpi-clickable-card {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}
.appt-kpi-clickable-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}
.appt-kpi-clickable-card::after {
    content: "✏️";
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.72rem;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
[dir="rtl"] .appt-kpi-clickable-card::after {
    left: auto;
    right: 8px;
}
.appt-kpi-clickable-card:hover::after {
    opacity: 1;
    transform: scale(1.15);
}

/* Responsive Mobile Rules for Calendar */
@media (max-width: 768px) {
    .calendar-container {
        padding: 0.75rem 0.5rem;
        border-radius: 12px;
    }
    .calendar-unified-toolbar {
        padding: 0.65rem 0.75rem;
    }
    .cal-nav-btn-group, .cal-view-segmented-group, .cal-status-filter-bar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }
    .cal-view-tab-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.76rem;
    }
    #calCurrentRangeLabel {
        font-size: 0.9rem;
        padding: 0.3rem 0.5rem;
    }
    #calSearchInput {
        min-width: 160px;
    }
    .fc .fc-col-header-cell {
        padding: 0.4rem 0.15rem;
    }
    .fc .fc-col-header-cell-cushion {
        font-size: 0.76rem;
    }
    .fc .fc-timegrid-slot {
        height: 2.7rem;
    }
    .fc-custom-event-card {
        padding: 4px 5px;
    }
    .fc-event-patient-name {
        font-size: 0.78rem;
    }
}

.table-container {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.btn-primary {
    background-color: var(--accent-cta);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* =========================================================
   Global Search Bar & Interactive Ctrl+K Quick Actions Menu
   ========================================================= */
.global-search-icon {
    position: absolute;
    left: 12px;
    font-size: 14px;
    opacity: 0.6;
    pointer-events: none;
    z-index: 2;
}

[dir="rtl"] .global-search-icon {
    left: auto !important;
    right: 12px !important;
}

.search-kbd-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    z-index: 5;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.search-kbd-btn:hover,
.search-kbd-btn:focus-visible {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: var(--bg-primary);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.search-kbd-btn.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    box-shadow: 0 0 0 2px var(--brand-primary);
}

[dir="rtl"] .search-kbd-btn {
    right: auto !important;
    left: 8px !important;
}

[dir="rtl"] .global-search-wrapper input.search-input {
    padding-left: 74px !important;
    padding-right: 36px !important;
}

[dir="ltr"] .global-search-wrapper input.search-input,
html:not([dir="rtl"]) .global-search-wrapper input.search-input {
    padding-left: 36px !important;
    padding-right: 74px !important;
}

/* Quick Actions Dropdown Menu */
.quick-actions-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    min-width: 320px;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 1100;
    overflow: hidden;
    animation: quickActionsFadeDown 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes quickActionsFadeDown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.quick-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.quick-actions-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.quick-actions-subtitle {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.quick-actions-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.quick-actions-close:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.quick-actions-list {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-action-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.quick-action-item:hover,
.quick-action-item:focus-visible {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.3);
    outline: none;
}

.quick-action-item:active {
    transform: scale(0.99);
}

.quick-action-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.quick-action-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.quick-action-texts {
    display: flex;
    flex-direction: column;
}

.quick-action-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.quick-action-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.quick-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 24px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 0 var(--border-color);
    border-radius: 6px;
    color: var(--brand-primary);
    flex-shrink: 0;
}

.quick-actions-footer {
    padding: 0.6rem 1rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 768px) {
    .home-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    /* Mobile-only compact greeting */
    .welcome-text h1#greetingMessage {
        font-size: 1.15rem !important;
        margin-bottom: 0.2rem !important;
        gap: 0.35rem !important;
        line-height: 1.25 !important;
    }
    #timeOfDayIcon {
        font-size: 1.15rem !important;
    }
    #greetingMessageText {
        font-size: 1.15rem !important;
        font-weight: 700 !important;
    }
    .welcome-text div {
        font-size: 0.8rem !important;
        gap: 0.4rem !important;
    }
    #currentDateDisplay,
    #currentTimeDisplay {
        font-size: 0.8rem !important;
    }

    /* Mobile search adjustment (< 768px) */
    .global-search-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Hide Ctrl+K button on mobile phones (< 640px) */
    @media (max-width: 640px) {
        .search-kbd-btn {
            display: none !important;
        }
        .global-search-wrapper input.search-input {
            padding-left: 36px !important;
            padding-right: 14px !important;
        }
        [dir="rtl"] .global-search-wrapper input.search-input {
            padding-left: 14px !important;
            padding-right: 36px !important;
        }
    }
    .quick-actions {
        width: 100%;
        justify-content: space-between;
    }
    .quick-actions button {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.6rem 0.5rem;
    }
    .three-cols, .four-cols {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Mobile Single-Line Compact Patient Name */
    .patient-info-card {
        padding: 0.75rem 1rem !important;
        gap: 0.6rem !important;
    }
    .profile-alert-compact {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
        margin-top: 0.45rem !important;
        line-height: 1.3 !important;
        border-radius: 5px !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 2px !important;
    }
    .profile-alert-compact strong, 
    .profile-alert-compact span {
        font-size: 0.75rem !important;
    }
    .patient-top-status-bar {
        display: inline-flex !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
    }
    .patient-status-chip {
        font-size: 0.72rem !important;
        padding: 2px 7px !important;
    }
    .patient-info-card .patient-avatar {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.15rem !important;
        flex-shrink: 0 !important;
    }
    #profilePatientName {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
        max-width: calc(100vw - 150px) !important;
    }
    #editPatientProfileBtn {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.78rem !important;
    }
    .list-item-title {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 0.9rem !important;
        max-width: 170px !important;
    }
    #patients-table-body td:nth-child(2) {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        font-size: 0.9rem !important;
        max-width: 135px !important;
    }

    body {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -260px; /* Hide off screen for LTR */
    }

    [dir="rtl"] .sidebar {
        left: auto;
        right: -260px; /* Hide off screen for RTL */
    }

    .sidebar.open {
        transform: translateX(260px); /* LTR Open */
    }

    [dir="rtl"] .sidebar.open {
        transform: translateX(-260px); /* RTL Open */
    }

    .sidebar h2 {
        display: none; /* Hide duplicate title in sidebar on mobile */
    }

    .content-area {
        padding: 1rem;
    }

    /* Mobile Calendar Responsive Fixes */
    .fc-header-toolbar {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.2rem;
    }
    .fc-toolbar-title {
        font-size: 1.1rem !important;
    }
    .fc-button {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
    .fc-col-header-cell-cushion {
        font-size: 0.8rem;
        padding: 4px !important;
    }
    .fc-timegrid-slot-label-cushion {
        font-size: 0.75rem;
    }
    .fc-event-main {
        font-size: 0.75rem;
        padding: 1px !important;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

[dir="ltr"] table {
    text-align: left;
}

th, td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-weight: bold;
}

td {
    color: var(--text-muted);
}

.btn-action {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 0.2rem;
}

.btn-edit { background-color: #fca311; color: white; }
.btn-delete { background-color: #d62828; color: white; }

.status-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
}
.status-pending { background-color: var(--status-pending); color: #000; }
.status-inprogress { background-color: var(--brand-primary); }
.status-completed { background-color: var(--status-success); }

/* Modal Styles */
.modal {
    display: flex;
    visibility: hidden;
    opacity: 0;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
    pointer-events: none;
}

.modal.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    padding: 2rem;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border-color);
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.92) translateY(14px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: var(--brand-primary);
    text-align: center;
}

.modal-content .input-group {
    margin-bottom: 1rem;
}

.modal-content .input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-content .input-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    gap: 1rem;
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.modal-actions .btn-primary {
    flex: 1;
}

/* Patient Profile specific styles */
.profile-tabs .tab-btn.active {
    border-bottom: 3px solid var(--brand-primary) !important;
    color: var(--brand-primary) !important;
    font-weight: 600;
}

/* Modern Multi-Surface Anatomical Odontogram Styles (Mobile Responsive) */
:root {
    --odontogram-zoom: 1;
}

.odontogram-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.odontogram-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.odontogram-btn-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
    flex-shrink: 0;
}

.odontogram-toggle-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.odontogram-toggle-btn.active {
    background: var(--bg-surface);
    color: var(--brand-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    font-weight: 700;
}

/* Odontogram Bottom Horizontal Compact Zoom Dock (منصة تكبير وتصغير أفقية صغيرة أسفل المخطط) */
.odontogram-canvas-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
    padding: 0.85rem 0.5rem 0.75rem 0.5rem;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

.odontogram-bottom-controls-dock {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-top: 0.65rem;
    user-select: none;
    z-index: 10;
    flex-wrap: wrap;
}

.odontogram-dock-divider {
    width: 1.5px;
    height: 22px;
    background: var(--border-color);
    opacity: 0.7;
}

.odontogram-bottom-zoom-dock {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2px 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 0;
    user-select: none;
    z-index: 10;
    transition: all 0.2s ease;
}

[data-theme="dark"] .odontogram-bottom-zoom-dock {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(51, 65, 85, 0.85);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.bottom-zoom-btn,
.side-zoom-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-primary);
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1;
    transition: all 0.18s ease;
    user-select: none;
}

.bottom-zoom-btn:hover,
.side-zoom-btn:hover {
    background: var(--bg-primary);
    color: var(--brand-primary);
    transform: scale(1.15);
}

.bottom-zoom-btn:active,
.side-zoom-btn:active {
    transform: scale(0.92);
}

.bottom-zoom-indicator,
.side-zoom-indicator {
    font-size: 0.68rem;
    font-family: monospace;
    font-weight: 700;
    color: var(--brand-primary);
    padding: 0 6px;
    user-select: none;
    letter-spacing: -0.3px;
    border-inline-start: 1px solid var(--border-color);
    border-inline-end: 1px solid var(--border-color);
    line-height: 1.4;
    text-align: center;
}

.bottom-zoom-reset-btn,
.side-zoom-reset-btn {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.bottom-zoom-reset-btn:hover,
.side-zoom-reset-btn:hover {
    color: var(--status-error);
}

.odontogram-arch-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    position: relative;
    padding: 0.5rem 0;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scroll-behavior: smooth;
}

.odontogram-arch-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    min-width: max-content;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.odontogram-arch-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.odontogram-arch-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: center;
    gap: clamp(0.75rem, 1.2vw, 1.5rem);
    position: relative;
    width: 100%;
    min-width: max-content;
    max-width: 1080px;
    transform: scale(var(--odontogram-zoom, 1));
    transform-origin: center center;
    transition: transform 0.15s ease;
}

.odontogram-quadrant {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    gap: clamp(3px, 0.45vw, 6px);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.odontogram-quadrant-divider {
    width: 2px;
    height: 56px;
    background: repeating-linear-gradient(to bottom, var(--brand-primary) 0, var(--brand-primary) 4px, transparent 4px, transparent 8px);
    opacity: 0.55;
    margin: 0 clamp(0.25rem, 0.5vw, 0.6rem);
    flex-shrink: 0;
}

.odontogram-arch-divider {
    width: 96%;
    max-width: 1040px;
    height: 1px;
    background: var(--border-color);
    position: relative;
    margin: 0.25rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.odontogram-arch-divider-badge {
    position: absolute;
    background: var(--bg-surface);
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Individual Tooth Unit */
.tooth-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
    padding: 3px clamp(2px, 0.35vw, 5px);
    border-radius: 8px;
    border: 1.5px solid transparent;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.tooth-unit:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.05);
}

.tooth-unit.selected {
    border-color: var(--brand-primary);
    background: rgba(56, 189, 248, 0.12);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
}

.tooth-unit.scope-selected {
    border-color: var(--brand-primary);
    background: rgba(56, 189, 248, 0.14);
    box-shadow: 0 0 0 1.5px rgba(56, 189, 248, 0.45), 0 0 10px rgba(56, 189, 248, 0.2);
    transform: translateY(-1px);
}

.tooth-unit.scope-selected .tooth-num-badge {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.35);
}

/* Arch Header Row & Batch Scope Actions */
.odontogram-arch-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1060px;
    padding: 0.2rem 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.odontogram-arch-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.odontogram-arch-batch-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.arch-batch-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    line-height: 1.25;
}

.arch-batch-select-btn:hover {
    color: var(--brand-primary);
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.08);
    transform: translateY(-1px);
}

.arch-batch-select-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

/* Mobile responsive optimizations for arch & quadrant batch tools */
@media (max-width: 768px) {
    .odontogram-arch-header-row {
        padding: 0.15rem 0.3rem;
        gap: 0.3rem;
        margin-bottom: 0.15rem;
    }

    .odontogram-arch-label {
        font-size: 0.72rem;
    }

    .odontogram-arch-batch-actions {
        gap: 0.25rem;
    }

    .arch-batch-select-btn {
        font-size: 0.67rem;
        padding: 2px 6px;
        gap: 2px;
        border-radius: 4px;
    }

    .btn-full-mouth-select {
        font-size: 0.68rem !important;
        padding: 0.18rem 0.65rem !important;
        gap: 4px !important;
    }

    .odontogram-toolbar .odontogram-btn-group button {
        padding: 3px 6px !important;
        font-size: 0.68rem !important;
    }

    .odontogram-scope-banner {
        padding: 0.45rem 0.65rem;
        gap: 0.45rem;
    }

    .odontogram-scope-banner .scope-icon {
        font-size: 1.15rem !important;
    }

    .odontogram-scope-banner strong {
        font-size: 0.82rem !important;
    }

    .odontogram-scope-banner button {
        padding: 0.25rem 0.55rem !important;
        font-size: 0.72rem !important;
    }
}

@media (max-width: 480px) {
    .odontogram-arch-header-row {
        padding: 0.1rem 0.15rem;
        gap: 0.2rem;
    }

    .odontogram-arch-label {
        font-size: 0.68rem;
    }

    .odontogram-arch-batch-actions {
        gap: 0.18rem;
    }

    .arch-batch-select-btn {
        font-size: 0.64rem;
        padding: 2px 4px;
        gap: 2px;
    }

    .btn-full-mouth-select {
        font-size: 0.64rem !important;
        padding: 0.15rem 0.5rem !important;
    }
}

.btn-full-mouth-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.24rem 0.9rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    user-select: none;
}

.btn-full-mouth-select:hover {
    color: var(--brand-primary);
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.1);
    transform: scale(1.03);
}

.btn-full-mouth-select.active {
    background: linear-gradient(135deg, #0284c7, #0d9488);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.odontogram-scope-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1060px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.12), rgba(16, 185, 129, 0.08));
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    margin: 0.4rem 0 0.6rem 0;
    gap: 0.75rem;
    flex-wrap: wrap;
    animation: fadeInSlide 0.2s ease forwards;
}

.scope-proc-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: start;
}

.scope-proc-card:hover {
    border-color: var(--brand-primary);
    background: rgba(56, 189, 248, 0.06);
    transform: translateY(-1px);
}

.tooth-num-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--text-primary);
    background: var(--bg-primary);
    padding: 1px 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    line-height: 1.2;
    text-align: center;
    min-width: 18px;
}

.tooth-unit.selected .tooth-num-badge {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

/* Multi-Surface SVG Tooth & Anatomical Geometry */
.tooth-svg {
    width: clamp(38px, 2.5vw, 48px);
    height: clamp(54px, 3.6vw, 68px);
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.08));
    transition: transform 0.15s ease, filter 0.15s ease;
    flex-shrink: 0;
    overflow: visible;
}
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.08));
    transition: transform 0.15s ease, filter 0.15s ease;
    flex-shrink: 0;
    overflow: visible;
}

@keyframes toothPopAnim {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes surfaceGlowPulse {
    0% { filter: drop-shadow(0 0 10px #38bdf8); }
    100% { filter: drop-shadow(0 1px 3px rgba(0,0,0,0.08)); }
}

.tooth-unit.tooth-pop-anim {
    animation: toothPopAnim 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tooth-unit.tooth-pop-anim .tooth-svg {
    animation: surfaceGlowPulse 0.6s ease;
}

.tooth-surface {
    fill: var(--bg-surface, #ffffff);
    stroke: var(--border-color, #cbd5e1);
    stroke-width: 1.35;
    transition: fill 0.15s ease, stroke 0.15s ease, filter 0.15s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tooth-surface:hover, .tooth-surface:active {
    stroke: var(--brand-primary);
    stroke-width: 2.2;
    filter: brightness(0.92);
}

/* Surface Conditions */
.tooth-surface.cond-normal { fill: var(--bg-surface, #ffffff); }
.tooth-surface.cond-decay { fill: #ef4444; }
.tooth-surface.cond-composite { fill: #3b82f6; }
.tooth-surface.cond-amalgam { fill: #64748b; }
.tooth-surface.cond-rct { fill: #ec4899; }
.tooth-surface.cond-crown { fill: #f59e0b; }
.tooth-surface.cond-missing { fill: #ef4444; }
.tooth-surface.cond-implant { fill: #0d9488; }
.tooth-surface.cond-veneer { fill: #06b6d4; }
.tooth-surface.cond-bridge { fill: #ea580c; }

/* Anatomical Roots Visualizer Styles */
.tooth-root-bg {
    fill: #f1f5f9;
    stroke: #94a3b8;
    stroke-width: 1.2;
    stroke-linejoin: round;
    transition: all 0.2s ease;
}

[data-theme="dark"] .tooth-root-bg {
    fill: #1e293b;
    stroke: #475569;
}

.tooth-root-canal-line {
    stroke: #cbd5e1;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 2, 2;
    fill: none;
    transition: all 0.2s ease;
}

[data-theme="dark"] .tooth-root-canal-line {
    stroke: #475569;
}

.tooth-root-canal-line.active-rct {
    stroke: #ec4899 !important;
    stroke-width: 2.5 !important;
    stroke-dasharray: none !important;
    filter: drop-shadow(0 0 3px #f43f5e);
}

.tooth-root-apex-seal {
    fill: #ec4899;
    filter: drop-shadow(0 0 2px #f43f5e);
}

.tooth-implant-screw {
    fill: #0d9488;
    stroke: #042f2e;
    stroke-width: 1.2;
}

/* Animated Standalone Implant SVG */
@keyframes animMainImplant {
    from { transform: translateY(0); }
    to { transform: translateY(40px); }
}

.implant-anim-threads {
    transform: translateY(0);
    transform-box: view-box;
    animation: animMainImplant 2.4s linear infinite;
}

.implant-crown {
    stroke: #00cfc8;
    fill: #ffffff;
    stroke-width: 22;
    stroke-linejoin: round;
    stroke-linecap: round;
}

[data-theme="dark"] .implant-crown {
    fill: #0f172a;
    stroke: #00cfc8;
}

.implant-screw-body {
    stroke: #0f172a;
    fill: none;
    stroke-width: 22;
    stroke-linejoin: round;
    stroke-linecap: round;
}

[data-theme="dark"] .implant-screw-body {
    stroke: #f1f5f9;
}

.implant-screw-thread {
    stroke: #0f172a;
    fill: none;
    stroke-width: 20;
    stroke-linejoin: round;
    stroke-linecap: round;
}

[data-theme="dark"] .implant-screw-thread {
    stroke: #cbd5e1;
}

.implant-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palette-tool-btn:hover .implant-icon-badge,
.modal-whole-btn:hover .implant-icon-badge,
.diag-item-card:hover .implant-icon-badge {
    transform: scale(1.18);
}

/* ========================================================
   ANIMATED ENDO (RCT) TOOTH ICON & NERVE FLOW
   ======================================================== */
.endo-svg-animated {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Base pulse effect for the main nerve */
.nerve-base {
    animation: pulse-glow 2s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    0% {
        filter: drop-shadow(0 0 2px rgba(255, 102, 133, 0.4));
        opacity: 0.9;
    }
    100% {
        filter: drop-shadow(0 0 10px rgba(255, 102, 133, 0.8));
        opacity: 1;
    }
}

/* Flowing dash effect to simulate nerve/blood movement */
.nerve-flow {
    stroke-dasharray: 12 12;
    animation: flow-up 1s linear infinite;
    opacity: 0.85;
}

@keyframes flow-up {
    from { stroke-dashoffset: 24; }
    to { stroke-dashoffset: 0; }
}

.rct-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palette-tool-btn:hover .rct-icon-badge,
.modal-whole-btn:hover .rct-icon-badge,
.diag-item-card:hover .rct-icon-badge {
    transform: scale(1.18);
}

/* Animated Standalone Crown SVG */
@keyframes crownSeatingFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes crownJewelGlint {
    0%, 100% {
        transform: scale(0.9) rotate(0deg);
        opacity: 0.8;
        filter: drop-shadow(0 0 2px #facc15);
    }
    50% {
        transform: scale(1.3) rotate(20deg);
        opacity: 1;
        filter: drop-shadow(0 0 8px #facc15) drop-shadow(0 0 14px #f59e0b);
    }
}

.crw-stump-root {
    fill: #f1f5f9;
    stroke: #94a3b8;
    stroke-width: 16;
    stroke-linejoin: round;
    stroke-linecap: round;
}

[data-theme="dark"] .crw-stump-root {
    fill: #1e293b;
    stroke: #475569;
}

.crw-prep-core {
    fill: #e2e8f0;
    stroke: #94a3b8;
    stroke-width: 14;
    stroke-linejoin: round;
    stroke-dasharray: 8, 8;
}

[data-theme="dark"] .crw-prep-core {
    fill: #334155;
    stroke: #64748b;
}

.crw-anim-cap {
    transform-origin: center;
    transform-box: fill-box;
    animation: crownSeatingFloat 2.6s ease-in-out infinite;
}

.crw-cap-body {
    fill: url(#crwGoldGrad);
    stroke: #0f172a;
    stroke-width: 20;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.crw-margin-collar {
    stroke: #0f172a;
    stroke-width: 14;
    stroke-linecap: round;
    fill: none;
}

.crw-cusp-ridge {
    stroke: rgba(15, 23, 42, 0.4);
    stroke-width: 12;
    stroke-linecap: round;
    fill: none;
}

.crw-shine-glint {
    fill: #ffffff;
    opacity: 0.45;
}

.crw-star-glint {
    fill: #ffffff;
    stroke: #f59e0b;
    stroke-width: 3;
    transform-origin: 250px 40px;
    animation: crownJewelGlint 2.4s ease-in-out infinite;
}

.crown-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palette-tool-btn:hover .crown-icon-badge,
.modal-whole-btn:hover .crown-icon-badge,
.diag-item-card:hover .crown-icon-badge {
    transform: scale(1.18);
}

/* ========================================================
   MODERN CLINICAL DENTAL CATEGORY BADGES & ICONS
   (Restorative, Surgery, Ortho, Hygiene, Prostho)
   ======================================================== */
.dental-cat-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
}

.dental-cat-badge-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: middle;
    margin-inline-end: 4px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quick-proc-cat-btn:hover .dental-cat-badge-wrap,
.chip:hover .dental-cat-badge-wrap {
    transform: scale(1.2) translateY(-1px);
}

/* Restorative micro-glow */
.restorative-svg:hover {
    filter: drop-shadow(0 0 4px rgba(2, 132, 199, 0.6));
}

/* Surgery precision scalpel micro-animation */
.surgery-svg:hover {
    filter: drop-shadow(0 0 4px rgba(244, 63, 94, 0.6));
    transform: rotate(-5deg) scale(1.1);
}

/* Ortho wire tension micro-animation */
.ortho-svg:hover {
    filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6));
}

/* Hygiene fresh sparkle micro-animation */
.hygiene-svg:hover {
    filter: drop-shadow(0 0 4px rgba(20, 184, 166, 0.6));
}

/* Prostho ceramic luster */
.prostho-svg:hover {
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.6));
}

/* Endo nerve pulse luster */
.endo-svg:hover {
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.7));
}

/* Standalone Category Pills Styling */
.dental-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.dental-cat-pill.cat-restorative { background: rgba(2, 132, 199, 0.12); color: #0284c7; border: 1px solid rgba(2, 132, 199, 0.25); }
.dental-cat-pill.cat-surgery { background: rgba(244, 63, 94, 0.12); color: #e11d48; border: 1px solid rgba(244, 63, 94, 0.25); }
.dental-cat-pill.cat-ortho, .dental-cat-pill.cat-orthodontics { background: rgba(139, 92, 246, 0.12); color: #7c3aed; border: 1px solid rgba(139, 92, 246, 0.25); }
.dental-cat-pill.cat-hygiene { background: rgba(13, 148, 136, 0.12); color: #0d9488; border: 1px solid rgba(13, 148, 136, 0.25); }
.dental-cat-pill.cat-prostho, .dental-cat-pill.cat-prosthodontics { background: rgba(245, 158, 11, 0.12); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.25); }
.dental-cat-pill.cat-endodontics { background: rgba(239, 68, 68, 0.12); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.25); }
.dental-cat-pill.cat-implant { background: rgba(100, 116, 139, 0.12); color: #475569; border: 1px solid rgba(100, 116, 139, 0.25); }
[data-theme="dark"] .dental-cat-pill.cat-implant { color: #94a3b8; }

/* Animated Standalone Deep Inspector SVG */
@keyframes deepScanSweep {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(130px);
    }
    100% {
        transform: translateY(0);
    }
}

@keyframes deepLensFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-4px) scale(1.03);
    }
}

@keyframes deepSparkle {
    0%, 100% {
        transform: scale(0.85) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.25) rotate(20deg);
        opacity: 1;
    }
}

.deep-inspector-group {
    transform-origin: 210px 195px;
    animation: deepLensFloat 2.6s ease-in-out infinite;
}

.deep-scan-beam-anim {
    animation: deepScanSweep 2.2s ease-in-out infinite;
}

.deep-handle {
    fill: #1e293b;
    stroke: #0f172a;
    stroke-width: 14;
    stroke-linejoin: round;
    stroke-linecap: round;
}

[data-theme="dark"] .deep-handle {
    fill: #334155;
    stroke: #e2e8f0;
}

.deep-target-bracket {
    fill: none;
    stroke: #38bdf8;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}

.deep-lens-outer {
    fill: none;
    stroke: #0f172a;
    stroke-width: 22;
}

[data-theme="dark"] .deep-lens-outer {
    stroke: #38bdf8;
}

.deep-tooth-body {
    fill: #ffffff;
    stroke: #0284c7;
    stroke-width: 12;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.deep-sparkle-glow {
    transform-origin: 100px 110px;
    animation: deepSparkle 2.4s ease-in-out infinite;
}

.deep-inspector-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-primary:hover .deep-inspector-badge,
.palette-tool-btn:hover .deep-inspector-badge {
    transform: scale(1.2);
}

/* Animated Standalone Missing / Extracted Tooth SVG */
@keyframes missingDashMarch {
    0% {
        stroke-dashoffset: 64;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes missingCrossGlow {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.4));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.85)) drop-shadow(0 0 14px rgba(244, 63, 94, 0.5));
    }
}

@keyframes missingSocketPulse {
    0%, 100% {
        opacity: 0.65;
    }
    50% {
        opacity: 1;
    }
}

.mis-bone-socket {
    fill: rgba(100, 116, 139, 0.12);
    stroke: #64748b;
    stroke-width: 14;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: missingSocketPulse 2.8s ease-in-out infinite;
}

[data-theme="dark"] .mis-bone-socket {
    fill: rgba(148, 163, 184, 0.15);
    stroke: #94a3b8;
}

.mis-ghost-tooth {
    fill: rgba(241, 245, 249, 0.45);
    stroke: #64748b;
    stroke-width: 18;
    stroke-dasharray: 20, 14;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: missingDashMarch 3s linear infinite;
}

[data-theme="dark"] .mis-ghost-tooth {
    fill: rgba(30, 41, 59, 0.45);
    stroke: #94a3b8;
}

.mis-cross-group {
    transform-origin: 250px 240px;
    animation: missingCrossGlow 2.4s ease-in-out infinite;
}

.mis-cross-stem {
    stroke: #ef4444;
    stroke-width: 26;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[data-theme="dark"] .mis-cross-stem {
    stroke: #f87171;
}

.mis-center-node {
    fill: #ffffff;
    stroke: #ef4444;
    stroke-width: 8;
}

[data-theme="dark"] .mis-center-node {
    fill: #0f172a;
    stroke: #f87171;
}

.missing-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palette-tool-btn:hover .missing-icon-badge,
.modal-whole-btn:hover .missing-icon-badge,
.btn-outline:hover .missing-icon-badge,
.diag-item-card:hover .missing-icon-badge {
    transform: scale(1.18);
}






.tooth-overlay-crown {
    stroke: #f59e0b;
    stroke-width: 2.4;
    fill: rgba(245, 158, 11, 0.25);
    stroke-dasharray: 4, 2;
}

.tooth-overlay-missing {
    stroke: #ef4444;
    stroke-width: 3.2;
    stroke-linecap: round;
    opacity: 0.9;
}

/* WHO DMFT Epidemiological Statistics Cards */
.dmft-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.dmft-stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.dmft-stat-card:hover {
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.dmft-stat-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dmft-stat-number {
    font-size: 1.45rem;
    font-weight: 800;
    font-family: 'Tajawal', monospace, sans-serif;
    line-height: 1.1;
    color: var(--text-primary);
}

.dmft-stat-badge {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 9999px;
    font-weight: 700;
    display: inline-block;
    width: fit-content;
}

.dmft-badge-very-low { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.dmft-badge-low { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }
.dmft-badge-moderate { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.dmft-badge-high { background: rgba(249, 115, 22, 0.15); color: #f97316; border: 1px solid rgba(249, 115, 22, 0.3); }
.dmft-badge-very-high { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Palette Tool Buttons (Responsive Ribbon on Mobile) */
.odontogram-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    padding: 0.6rem;
    margin: 0.4rem 0;
    background: var(--bg-primary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

/* ========================================================
   ODONTOGRAM TOOLBAR & QUICK ACTIONS COLOR HARMONIZATION
   Linking Toolbar Icons & Buttons to Tooth Surface Mark Colors
   ======================================================== */
.palette-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0.38rem 0.72rem;
    font-size: 0.79rem;
    font-weight: 700;
    border-radius: 9px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    flex-shrink: 0;
    min-height: 38px;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.palette-tool-btn:hover {
    transform: translateY(-2px);
}

/* Tooth surface simulation indicator dot & Anatomical Facet Badge */
.palette-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px; /* Matches 5-surface facet shape on tooth */
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}
.palette-tool-btn:hover .palette-color-dot {
    transform: scale(1.22);
}

/* ========================================================
   UNIFIED ANATOMICAL TOOTH CROWN & BADGES
   (إلغاء تقسيم السطح إلى أجزاء واعتماد مجسم سن كامل وموحد)
   ======================================================== */
.tooth-crown-unified {
    stroke: var(--border-color, #cbd5e1);
    stroke-width: 1.5;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill 0.18s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.18s ease, filter 0.18s ease;
}

.tooth-unit:hover .tooth-crown-unified {
    stroke: var(--brand-primary);
    stroke-width: 2.2;
    filter: brightness(0.95);
}

.tooth-fissure-line {
    stroke: rgba(100, 116, 139, 0.35);
    stroke-width: 1.3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    transition: stroke 0.2s ease, opacity 0.2s ease;
}

[data-theme="dark"] .tooth-fissure-line {
    stroke: rgba(255, 255, 255, 0.30);
}

.tooth-surface.cond-decay ~ .tooth-fissures-group .tooth-fissure-line {
    stroke: rgba(185, 28, 28, 0.7);
}
.tooth-surface.cond-composite ~ .tooth-fissures-group .tooth-fissure-line {
    stroke: rgba(29, 78, 216, 0.6);
}
.tooth-surface.cond-amalgam ~ .tooth-fissures-group .tooth-fissure-line {
    stroke: rgba(51, 65, 85, 0.7);
}

/* Unified Tooth Crown Badges for Toolbar */
.palette-tooth-badge,
.palette-facet-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palette-tool-btn:hover .palette-tooth-badge,
.palette-tool-btn:hover .palette-facet-badge {
    transform: scale(1.20);
}

.badge-tooth-decay {
    fill: #ef4444;
    stroke: #dc2626;
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.65));
}
.badge-tooth-composite {
    fill: #3b82f6;
    stroke: #2563eb;
    filter: drop-shadow(0 0 2px rgba(59, 130, 246, 0.65));
}
.badge-tooth-amalgam {
    fill: #64748b;
    stroke: #475569;
}
.badge-tooth-veneer {
    fill: #06b6d4;
    stroke: #0891b2;
    filter: drop-shadow(0 0 2px rgba(6, 182, 212, 0.65));
}
.badge-tooth-normal {
    fill: #ffffff;
    stroke: #cbd5e1;
}
[data-theme="dark"] .badge-tooth-normal {
    fill: #1e293b;
    stroke: #475569;
}

.facet-base {
    fill: #f8fafc;
    stroke: #cbd5e1;
    stroke-width: 1.2;
}

[data-theme="dark"] .facet-base {
    fill: #1e293b;
    stroke: #475569;
}

.facet-sur {
    fill: #ffffff;
    stroke: #cbd5e1;
    stroke-width: 0.9;
    transition: fill 0.15s ease, stroke 0.15s ease;
}

[data-theme="dark"] .facet-sur {
    fill: #1e293b;
    stroke: #475569;
}

/* Decay Mark */
.facet-mark-decay {
    fill: #ef4444 !important;
    stroke: #dc2626 !important;
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.65));
}

/* Composite Mark */
.facet-mark-composite {
    fill: #3b82f6 !important;
    stroke: #2563eb !important;
    filter: drop-shadow(0 0 2px rgba(59, 130, 246, 0.65));
}

/* Amalgam Mark */
.facet-mark-amalgam {
    fill: #64748b !important;
    stroke: #475569 !important;
    filter: drop-shadow(0 0 1px rgba(100, 116, 139, 0.6));
}

/* Veneer Mark */
.facet-mark-veneer {
    fill: #06b6d4 !important;
    stroke: #0891b2 !important;
    filter: drop-shadow(0 0 2px rgba(6, 182, 212, 0.65));
}

/* 1. Custom / Deep Inspect (Laser Sky Blue) */
.palette-tool-btn[data-condition="custom"] {
    border-color: rgba(14, 165, 233, 0.40);
    background: rgba(14, 165, 233, 0.08);
    color: #0284c7;
}
.palette-tool-btn[data-condition="custom"]:hover,
.palette-tool-btn[data-condition="custom"].active {
    border-color: #0284c7;
    background: rgba(14, 165, 233, 0.20);
    box-shadow: 0 0 14px rgba(14, 165, 233, 0.35);
    color: #0284c7;
}

/* 2. Decay - Red Caries (#ef4444) */
.palette-tool-btn[data-condition="decay"] {
    border-color: rgba(239, 68, 68, 0.40);
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}
.palette-tool-btn[data-condition="decay"]:hover,
.palette-tool-btn[data-condition="decay"].active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.20);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.40);
    color: #dc2626;
}

/* 3. Composite - Resin Blue (#3b82f6) */
.palette-tool-btn[data-condition="composite"] {
    border-color: rgba(59, 130, 246, 0.40);
    background: rgba(59, 130, 246, 0.08);
    color: #2563eb;
}
.palette-tool-btn[data-condition="composite"]:hover,
.palette-tool-btn[data-condition="composite"].active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.20);
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.40);
    color: #2563eb;
}

/* 4. Amalgam - Metallic Slate (#64748b) */
.palette-tool-btn[data-condition="amalgam"] {
    border-color: rgba(100, 116, 139, 0.40);
    background: rgba(100, 116, 139, 0.08);
    color: #475569;
}
.palette-tool-btn[data-condition="amalgam"]:hover,
.palette-tool-btn[data-condition="amalgam"].active {
    border-color: #64748b;
    background: rgba(100, 116, 139, 0.22);
    box-shadow: 0 0 14px rgba(100, 116, 139, 0.35);
    color: #334155;
}

/* 5. RCT / Endo - Nerve Pink & Fuchsia (#ff6685 / #ec4899) */
.palette-tool-btn[data-condition="rct"] {
    border-color: rgba(255, 102, 133, 0.45);
    background: rgba(255, 102, 133, 0.08);
    color: #e11d48;
}
.palette-tool-btn[data-condition="rct"]:hover,
.palette-tool-btn[data-condition="rct"].active {
    border-color: #ff6685;
    background: rgba(255, 102, 133, 0.20);
    box-shadow: 0 0 16px rgba(255, 102, 133, 0.45);
    color: #e11d48;
}

/* 6. Crown - Royal Amber Gold (#f59e0b) */
.palette-tool-btn[data-condition="crown"] {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
}
.palette-tool-btn[data-condition="crown"]:hover,
.palette-tool-btn[data-condition="crown"].active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.20);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.45);
    color: #d97706;
}

/* 7. Implant - Surgical Teal (#0d9488 / #10b981) */
.palette-tool-btn[data-condition="implant"] {
    border-color: rgba(13, 148, 136, 0.45);
    background: rgba(13, 148, 136, 0.08);
    color: #0d9488;
}
.palette-tool-btn[data-condition="implant"]:hover,
.palette-tool-btn[data-condition="implant"].active {
    border-color: #0d9488;
    background: rgba(13, 148, 136, 0.20);
    box-shadow: 0 0 16px rgba(13, 148, 136, 0.45);
    color: #0d9488;
}

/* 8. Missing - Surgical Red Extraction Cross (#ef4444 / #dc2626) */
.palette-tool-btn[data-condition="missing"] {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}
.palette-tool-btn[data-condition="missing"]:hover,
.palette-tool-btn[data-condition="missing"].active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.20);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.40);
    color: #dc2626;
}

/* 9. Veneer - Crystal Aqua Cyan (#06b6d4) */
.palette-tool-btn[data-condition="veneer"] {
    border-color: rgba(6, 182, 212, 0.45);
    background: rgba(6, 182, 212, 0.08);
    color: #0891b2;
}
.palette-tool-btn[data-condition="veneer"]:hover,
.palette-tool-btn[data-condition="veneer"].active {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.20);
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.40);
    color: #0891b2;
}

/* 10. Normal / Sound - Clean White (#ffffff) */
.palette-tool-btn[data-condition="normal"] {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(248, 250, 252, 0.85);
    color: #475569;
}
.palette-tool-btn[data-condition="normal"]:hover,
.palette-tool-btn[data-condition="normal"].active {
    border-color: #94a3b8;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(148, 163, 184, 0.35);
    color: #1e293b;
}

/* Dark mode palette adjustments */
[data-theme="dark"] .palette-tool-btn[data-condition="custom"] { color: #38bdf8; }
[data-theme="dark"] .palette-tool-btn[data-condition="decay"] { color: #f87171; }
[data-theme="dark"] .palette-tool-btn[data-condition="composite"] { color: #60a5fa; }
[data-theme="dark"] .palette-tool-btn[data-condition="amalgam"] { color: #94a3b8; }
[data-theme="dark"] .palette-tool-btn[data-condition="rct"] { color: #ff6685; }
[data-theme="dark"] .palette-tool-btn[data-condition="crown"] { color: #fbbf24; }
[data-theme="dark"] .palette-tool-btn[data-condition="implant"] { color: #2dd4bf; }
[data-theme="dark"] .palette-tool-btn[data-condition="missing"] { color: #f87171; }
[data-theme="dark"] .palette-tool-btn[data-condition="veneer"] { color: #22d3ee; }
[data-theme="dark"] .palette-tool-btn[data-condition="normal"] {
    background: rgba(30, 41, 59, 0.6);
    border-color: #475569;
    color: #e2e8f0;
}

/* ========================================================
   QUICK ACTIONS BAR COLOR HARMONIZATION
   Matches the exact visual trace and mark on the tooth
   ======================================================== */
.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.35rem 0.72rem;
    border-radius: 8px;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    flex-shrink: 0;
    min-height: 34px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.quick-action-btn:hover {
    transform: translateY(-2px);
}

.clear-tooth-badge,
.treatment-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.quick-action-btn:hover .clear-tooth-badge,
.quick-action-btn:hover .treatment-badge {
    transform: scale(1.16);
}

/* 1. Deep Inspector (Diagnostic Laser Sky) */
.quick-action-inspector {
    border-color: rgba(14, 165, 233, 0.45);
    background: rgba(14, 165, 233, 0.10);
    color: #0284c7;
}
.quick-action-inspector:hover {
    border-color: #0284c7;
    background: rgba(14, 165, 233, 0.22);
    box-shadow: 0 0 14px rgba(14, 165, 233, 0.35);
}

/* 2. Crown (Gold Amber - Matches Golden Overlay on Tooth) */
.quick-action-crown {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.10);
    color: #d97706;
}
.quick-action-crown:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.22);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.40);
}
.quick-action-crown.active {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.26);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.45);
    color: #b45309;
    font-weight: 800;
}

/* 3. RCT (Nerve Pink - Matches Active Root Canal Glow) */
.quick-action-rct {
    border-color: rgba(255, 102, 133, 0.45);
    background: rgba(255, 102, 133, 0.10);
    color: #e11d48;
}
.quick-action-rct:hover {
    border-color: #ff6685;
    background: rgba(255, 102, 133, 0.22);
    box-shadow: 0 0 14px rgba(255, 102, 133, 0.45);
}
.quick-action-rct.active {
    border-color: #ff6685;
    background: rgba(255, 102, 133, 0.26);
    box-shadow: 0 0 16px rgba(255, 102, 133, 0.50);
    color: #be123c;
    font-weight: 800;
}

/* 4. Missing (Surgical Red Cross - Matches Red Cross on Tooth) */
.quick-action-missing {
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}
.quick-action-missing:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.22);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.40);
    color: #dc2626;
}
.quick-action-missing.active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.26);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.45);
    color: #b91c1c;
    font-weight: 800;
}

/* 5. Implant (Surgical Teal - Matches Titanium Screw Roots) */
.quick-action-implant {
    border-color: rgba(13, 148, 136, 0.45);
    background: rgba(13, 148, 136, 0.10);
    color: #0d9488;
}
.quick-action-implant:hover {
    border-color: #0d9488;
    background: rgba(13, 148, 136, 0.22);
    box-shadow: 0 0 14px rgba(13, 148, 136, 0.40);
}
.quick-action-implant.active {
    border-color: #0d9488;
    background: rgba(13, 148, 136, 0.26);
    box-shadow: 0 0 16px rgba(13, 148, 136, 0.45);
    color: #0f766e;
    font-weight: 800;
}

/* 6. Clear Surfaces (Healthy Enamel Wipe - Neutral Sound) */
.quick-action-clear {
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(241, 245, 249, 0.85);
    color: #475569;
}
.quick-action-clear:hover {
    border-color: #94a3b8;
    background: #ffffff;
    box-shadow: 0 0 12px rgba(148, 163, 184, 0.35);
    color: #1e293b;
}

/* 7. Treatment (+ Plan - Clinical Emerald Green) */
.quick-action-treatment {
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
.quick-action-treatment:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.24);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.40);
}

[data-theme="dark"] .quick-action-inspector { color: #38bdf8; }
[data-theme="dark"] .quick-action-crown { color: #fbbf24; }
[data-theme="dark"] .quick-action-crown.active { color: #fde047; }
[data-theme="dark"] .quick-action-rct { color: #ff6685; }
[data-theme="dark"] .quick-action-rct.active { color: #fda4af; }
[data-theme="dark"] .quick-action-missing { color: #f87171; }
[data-theme="dark"] .quick-action-missing.active { color: #fca5a5; }
[data-theme="dark"] .quick-action-implant { color: #2dd4bf; }
[data-theme="dark"] .quick-action-implant.active { color: #5eead4; }
[data-theme="dark"] .quick-action-clear {
    background: rgba(30, 41, 59, 0.65);
    border-color: #475569;
    color: #e2e8f0;
}
[data-theme="dark"] .quick-action-treatment { color: #34d399; }

/* Tooth Inspector Drawer & Unified Clinical Palette */
.odontogram-inspector-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

.odontogram-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    justify-content: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-color);
}

.summary-badge-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

/* Documented Clinical Procedures Table */
.odontogram-procedures-container {
    margin-top: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.odontogram-procedures-header {
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.odontogram-proc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    text-align: start;
}

.odontogram-proc-table th, .odontogram-proc-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.odontogram-proc-table th {
    background: rgba(0,0,0,0.02);
    font-weight: 700;
    color: var(--text-muted);
}

.odontogram-proc-table tr:hover {
    background: rgba(56, 189, 248, 0.04);
}

.odontogram-proc-table tr.tooth-details-dropdown-row:hover {
    background: var(--bg-surface) !important;
}

/* Tooth Details Expandable Panel in Documented Procedures Table */
.tooth-interactive-badge {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--brand-primary);
    border: 1.5px solid rgba(37, 99, 235, 0.25);
    font-weight: 800;
    font-family: monospace;
    font-size: 0.84rem;
    transition: all 0.2s ease;
}

.tooth-interactive-badge:hover,
.tooth-interactive-badge.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
}

.tooth-interactive-badge .tooth-arrow {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.tooth-interactive-cell {
    cursor: pointer;
    transition: background 0.15s ease;
}

.tooth-interactive-cell:hover {
    background: rgba(37, 99, 235, 0.05);
}

.tooth-details-dropdown-row {
    background: var(--bg-surface) !important;
    animation: fadeInToothDetails 0.22s ease-out;
}

@keyframes fadeInToothDetails {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tooth-details-panel-card {
    margin: 0.4rem 0.5rem 0.75rem 0.5rem;
    padding: 1rem 1.15rem;
    border-radius: 12px;
    background: var(--bg-primary);
    border: 1.5px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .tooth-details-panel-card {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.tooth-details-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.tooth-details-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tooth-details-close-btn {
    border: none;
    background: rgba(100, 116, 139, 0.12);
    color: var(--text-muted);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s ease;
}

.tooth-details-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.tooth-finance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.85rem;
    background: var(--bg-surface);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.tooth-finance-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tooth-finance-item .tooth-finance-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tooth-finance-item .val {
    font-family: monospace;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary);
}

.tooth-finance-item .val-paid {
    color: #10b981;
}

.tooth-finance-item .val-remaining-due {
    color: #ef4444;
}

.tooth-finance-item .val-remaining-zero {
    color: #10b981;
}

.tooth-actions-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tooth-actions-toolbar .btn-tooth-action {
    padding: 0.42rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1.5px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: all 0.18s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tooth-actions-toolbar .btn-tooth-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.tooth-actions-toolbar .btn-tooth-invoice {
    color: #0284c7;
    border-color: rgba(2, 132, 199, 0.4);
    background: rgba(2, 132, 199, 0.08);
}
.tooth-actions-toolbar .btn-tooth-invoice:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.tooth-actions-toolbar .btn-tooth-pay {
    color: #059669;
    border-color: rgba(16, 185, 129, 0.45);
    background: rgba(16, 185, 129, 0.09);
}
.tooth-actions-toolbar .btn-tooth-pay:hover {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
}

.tooth-actions-toolbar .btn-tooth-installment {
    color: #7c3aed;
    border-color: rgba(139, 92, 246, 0.45);
    background: rgba(139, 92, 246, 0.09);
}
.tooth-actions-toolbar .btn-tooth-installment:hover {
    background: #8b5cf6;
    color: #ffffff;
    border-color: #8b5cf6;
}

.tooth-actions-toolbar .btn-tooth-edit {
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.09);
}
.tooth-actions-toolbar .btn-tooth-edit:hover {
    background: #d97706;
    color: #ffffff;
    border-color: #d97706;
}

.tooth-actions-toolbar .btn-tooth-delete {
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(239, 68, 68, 0.08);
}
.tooth-actions-toolbar .btn-tooth-delete:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* --- Mobile Specific Adaptations (<= 768px & <= 480px) --- */
@media (max-width: 768px) {
    .odontogram-section {
        padding: 0.75rem;
        border-radius: 10px;
    }

    .odontogram-toolbar {
        justify-content: flex-start;
        gap: 0.35rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
        scrollbar-width: none;
    }

    .odontogram-palette {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        justify-content: flex-start;
        padding: 0.45rem;
    }

    .odontogram-arch-row {
        gap: 0.35rem;
        flex-wrap: nowrap !important;
        min-width: max-content;
    }

    .odontogram-quadrant {
        gap: 2px;
        flex-wrap: nowrap !important;
        flex-shrink: 0;
    }

    .odontogram-quadrant-divider {
        height: 42px;
        margin: 0 0.2rem;
        flex-shrink: 0;
    }

    .tooth-svg {
        width: 26px;
        height: 34px;
        flex-shrink: 0;
    }

    .tooth-unit {
        padding: 2px 1px;
        flex-shrink: 0;
    }

    .tooth-num-badge {
        font-size: 0.68rem;
        padding: 1px 3px;
        min-width: 14px;
        flex-shrink: 0;
    }

    .odontogram-inspector-card {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
        gap: 0.65rem;
    }

    .odontogram-inspector-card > div:last-child {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px !important;
        width: 100%;
    }

    .odontogram-inspector-card > div:last-child button {
        min-height: 38px;
        justify-content: center;
        padding: 0.35rem 0.4rem !important;
        font-size: 0.76rem !important;
    }
}

@media (max-width: 480px) {
    .odontogram-arch-row {
        gap: 0.2rem;
        flex-wrap: nowrap !important;
        min-width: max-content;
    }

    .odontogram-quadrant {
        gap: 1.5px;
        flex-wrap: nowrap !important;
        flex-shrink: 0;
    }

    .tooth-svg {
        width: 20px;
        height: 28px;
        flex-shrink: 0;
    }

    .tooth-num-badge {
        font-size: 0.62rem;
        padding: 0 2px;
        flex-shrink: 0;
    }

    /* In single arch focus view on mobile, expand tooth size for tactile precision */
    .odontogram-arch-section.single-arch-focus .tooth-svg {
        width: 32px;
        height: 42px;
    }

    .odontogram-arch-section.single-arch-focus .tooth-num-badge {
        font-size: 0.75rem;
        padding: 1px 5px;
    }

    .odontogram-arch-section.single-arch-focus .odontogram-arch-row {
        gap: 0.5rem;
    }

    .odontogram-arch-section.single-arch-focus .odontogram-quadrant {
        gap: 3px;
    }
}

/* Inventory and Profile Styles */
.patient-info-card div {
    font-size: 1rem;
    color: var(--text-primary);
}

.profile-tabs {
    flex-wrap: wrap;
}

.tab-btn {
    transition: color 0.3s, border-color 0.3s;
}

.tab-btn:hover {
    color: var(--brand-primary);
}

/* =========================================================
   Patient Top Status Bar (Ultra-Compact Micro-Pills)
   ========================================================= */
.patient-top-status-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.45rem;
    padding: 0;
    border: none;
    vertical-align: middle;
}

.patient-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.25;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    transition: all 0.15s ease;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    white-space: nowrap;
}

.patient-status-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.patient-status-chip-action {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    margin-inline-start: 4px;
    border: 1px solid transparent;
}

/* Variant: Active Installments (Sky Blue) */
.patient-status-chip.chip-installments-active {
    background: rgba(2, 132, 199, 0.08);
    border-color: rgba(2, 132, 199, 0.35);
    color: #0284c7;
}
.patient-status-chip.chip-installments-active .patient-status-chip-action {
    background: #0284c7;
    color: #ffffff;
}

/* Variant: Overdue Installments (Crimson Warning) */
.patient-status-chip.chip-installments-overdue {
    background: rgba(239, 68, 68, 0.09);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}
.patient-status-chip.chip-installments-overdue .patient-status-chip-action {
    background: #ef4444;
    color: #ffffff;
}

/* Variant: In Progress (Purple / Violet) */
.patient-status-chip.chip-treatments-inprogress {
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.35);
    color: #8b5cf6;
}
.patient-status-chip.chip-treatments-inprogress .patient-status-chip-action {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

/* Variant: Pending (Amber / Warning) */
.patient-status-chip.chip-treatments-pending {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.35);
    color: #d97706;
}
.patient-status-chip.chip-treatments-pending .patient-status-chip-action {
    background: rgba(245, 158, 11, 0.2);
    color: #d97706;
}

/* Variant: Balance Due (Orange) */
.patient-status-chip.chip-balance-due {
    background: rgba(234, 88, 12, 0.08);
    border-color: rgba(234, 88, 12, 0.35);
    color: #ea580c;
}
.patient-status-chip.chip-balance-due .patient-status-chip-action {
    background: #ea580c;
    color: #ffffff;
}

/* Variant: Settled / Clean (Emerald Green) */
.patient-status-chip.chip-clean-all {
    background: rgba(16, 185, 129, 0.07);
    border-color: rgba(16, 185, 129, 0.25);
    color: #10b981;
}

/* Status live dot */
.patient-status-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.patient-status-pulse-dot.pulse-red {
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: statusPulseRed 1.8s infinite;
}
.patient-status-pulse-dot.pulse-blue {
    background: #0284c7;
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7);
    animation: statusPulseBlue 2s infinite;
}
.patient-status-pulse-dot.pulse-violet {
    background: #8b5cf6;
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    animation: statusPulseViolet 2s infinite;
}
.patient-status-pulse-dot.pulse-amber {
    background: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    animation: statusPulseAmber 2s infinite;
}

@keyframes statusPulseRed {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
@keyframes statusPulseBlue {
    0% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7); }
    70% { box-shadow: 0 0 0 5px rgba(2, 132, 199, 0); }
    100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}
@keyframes statusPulseViolet {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
    70% { box-shadow: 0 0 0 5px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}
@keyframes statusPulseAmber {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* =========================================================
   Patient Un-installment Balance Breakdown Modal
   ========================================================= */
.uninstalled-balance-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    transition: all 0.2s ease;
    border-inline-start: 4px solid #ea580c;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.uninstalled-balance-card:hover {
    border-color: rgba(234, 88, 12, 0.45);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}
.uninstalled-balance-card.completed {
    border-inline-start-color: var(--status-completed);
}
.uninstalled-balance-card.inprogress {
    border-inline-start-color: #8b5cf6;
}
.uninstalled-balance-card.pending {
    border-inline-start-color: #f59e0b;
}
.uninstalled-stat-col {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    text-align: center;
    flex: 1;
    min-width: 90px;
}
.uninstalled-item-progress-track {
    width: 100%;
    height: 6px;
    background: rgba(148, 163, 184, 0.15);
    border-radius: 999px;
    overflow: hidden;
}
.uninstalled-item-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #0284c7);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Single Molar Header Icon Badge (أيقونة الضرس الفردي الأصيلة) */
.odontogram-single-molar-icon {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.collapsible-btn:hover .odontogram-single-molar-icon {
    transform: scale(1.08) translateY(-1px);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    border-color: var(--brand-primary) !important;
}

.odontogram-container {
    background: var(--bg-surface);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Cloud Sync Live Status Badge */
.odontogram-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.65rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    user-select: none;
    transition: all 0.2s ease;
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    transition: all 0.2s ease;
}

.sync-dot.synced {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.sync-dot.syncing {
    background: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.35);
    animation: syncPulse 1s infinite alternate;
}

.sync-dot.error {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

@keyframes syncPulse {
    0% { transform: scale(0.85); opacity: 0.6; }
    100% { transform: scale(1.15); opacity: 1; }
}

/* Deep Tooth Inspector Modal Styling */
#deepToothModal {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    background-color: rgba(15, 23, 42, 0.6) !important;
}

#deepToothModal .modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.15);
}

/* Screenshot-matched Diagnostic Tooth Inspector Modal */
.tooth-modal-card {
    max-width: 480px;
    width: 95%;
    border-radius: 20px;
    overflow: hidden;
    padding: 0 !important;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    box-shadow: 0 25px 35px -5px rgba(0, 0, 0, 0.3), 0 15px 15px -5px rgba(0, 0, 0, 0.15);
}

.tooth-modal-header {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    padding: 1.15rem 1.25rem;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    direction: ltr !important;
}

.tooth-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    border: none;
    color: #ffffff;
    font-size: 1.15rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.tooth-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.tooth-modal-badge {
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 800;
    font-family: monospace;
    color: #ffffff;
}

.tooth-modal-body {
    padding: 1.25rem;
    max-height: 80vh;
    overflow-y: auto;
}



.diag-card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.1rem;
}

.diag-item-card {
    background: var(--bg-surface);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.diag-item-card:hover {
    border-color: #0284c7;
    transform: translateY(-1px);
}

.diag-item-card.active {
    border-color: #0284c7 !important;
    background: rgba(2, 132, 199, 0.08) !important;
    box-shadow: 0 0 0 1px #0284c7;
}

.diag-tag-pill {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.large-tooth-svg {
    width: 110px;
    height: 150px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
    overflow: visible;
}

.large-tooth-surface {
    fill: var(--bg-surface, #ffffff);
    stroke: var(--border-color, #cbd5e1);
    stroke-width: 1.6;
    transition: all 0.15s ease;
    cursor: pointer;
}

.large-tooth-surface:hover {
    stroke: var(--brand-primary);
    stroke-width: 2.5;
    filter: brightness(0.95);
}

.large-tooth-surface.selected-surf {
    stroke: #0284c7 !important;
    stroke-width: 3.2 !important;
    filter: drop-shadow(0 0 6px rgba(2, 132, 199, 0.6)) !important;
}

.surface-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.surface-checkbox-item:hover {
    border-color: var(--brand-primary);
}

.surface-checkbox-item.checked {
    background: rgba(56, 189, 248, 0.14);
    border-color: var(--brand-primary);
    font-weight: 700;
}

.modal-whole-btn {
    font-size: 0.82rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-whole-btn.active-crown {
    background: rgba(245, 158, 11, 0.15) !important;
    border-color: #f59e0b !important;
    color: #d97706 !important;
    font-weight: 800;
}

.modal-whole-btn.active-rct {
    background: rgba(139, 92, 246, 0.15) !important;
    border-color: #8b5cf6 !important;
    color: #7c3aed !important;
    font-weight: 800;
}

.modal-whole-btn.active-implant {
    background: rgba(0, 207, 200, 0.15) !important;
    border-color: #00cfc8 !important;
    color: #00cfc8 !important;
    font-weight: 800;
}

.modal-whole-btn.active-missing {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: #ef4444 !important;
    color: #ef4444 !important;
    font-weight: 800;
}

.diag-applied-surfs-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(2, 132, 199, 0.15);
    color: #0284c7;
    margin-inline-start: 4px;
    font-family: monospace;
}

.diag-item-card.has-applied {
    border-color: rgba(2, 132, 199, 0.6) !important;
    background: rgba(2, 132, 199, 0.04) !important;
}

.clinical-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.clinical-chip:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.clinical-chip.active {
    background: rgba(2, 132, 199, 0.15);
    border-color: #0284c7;
    color: #0284c7;
    font-weight: 700;
}



.odontogram-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    transition: all 0.2s ease;
}

.odontogram-sync-badge.syncing {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    border-color: rgba(2, 132, 199, 0.3);
}

.odontogram-sync-badge.pending {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sync-dot.synced {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

.sync-dot.syncing {
    background: #0284c7;
    animation: syncPulse 1s infinite alternate;
}

.sync-dot.pending {
    background: #f59e0b;
}

#saveOdontogramBtn.active-attention {
    animation: saveBtnGlow 1.5s infinite alternate;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

@keyframes saveBtnGlow {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.03); filter: brightness(1.15); box-shadow: 0 0 14px rgba(56, 189, 248, 0.85); }
}

@keyframes syncPulse {
    0% { opacity: 0.4; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1.2); }
}

/* Print Odontogram Media Query */
@media print {
    body.printing-odontogram * {
        visibility: hidden !important;
    }
    body.printing-odontogram #odontogramPrintReport,
    body.printing-odontogram #odontogramPrintReport * {
        visibility: visible !important;
    }
    body.printing-odontogram #odontogramPrintReport {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        background: #ffffff !important;
        color: #0f172a !important;
        padding: 1cm !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        z-index: 999999 !important;
    }
    body.printing-odontogram #odontogramPrintReport table {
        width: 100% !important;
        border-collapse: collapse !important;
    }
    body.printing-odontogram #odontogramPrintReport th,
    body.printing-odontogram #odontogramPrintReport td {
        border: 1px solid #cbd5e1 !important;
        padding: 6px 8px !important;
        color: #0f172a !important;
    }
}

/* Print Styles for Invoice & Patient Records */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .sidebar, .mobile-header, .controls, .collapsible-btn, .filter-chips, #backToPatientsBtn, button, .quick-actions {
        display: none !important;
    }
    .content-area {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .glass-card, .home-card, .table-container {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        background: #fff !important;
        color: #000 !important;
    }
    #print-invoice-container {
        position: relative;
        width: 100%;
        color: #000 !important;
        background: #fff !important;
        padding: 1rem;
    }
    #print-invoice-container table {
        border-collapse: collapse;
        width: 100%;
    }
    #print-invoice-container th, #print-invoice-container td {
        border: 1px solid #ddd;
        padding: 8px;
        color: #000;
    }
}

/* Glassmorphism & Timeline Styles */
.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
}

[data-theme="light"] .glass-card {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chip {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.chip:hover {
    border-color: var(--brand-primary);
}

.chip.active {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.patient-timeline-container {
    position: relative;
    padding-left: 2rem;
    margin-top: 1rem;
}

[dir="rtl"] .patient-timeline-container {
    padding-left: 0;
    padding-right: 2rem;
}

.patient-timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 7px; /* align with icon center */
    width: 2px;
    background: var(--border-color);
}

[dir="rtl"] .patient-timeline-container::before {
    left: auto;
    right: 7px;
}

.timeline-event {
    position: relative;
    margin-bottom: 1.5rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.timeline-event:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.timeline-icon {
    position: absolute;
    left: -2.4rem;
    top: 1rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 2px solid var(--bg-surface);
    z-index: 1;
}

[dir="rtl"] .timeline-icon {
    left: auto;
    right: -2.4rem;
}

.timeline-event.type-visit .timeline-icon { border-color: #3b82f6; background: #eff6ff; color: #3b82f6;}
.timeline-event.type-xray .timeline-icon { border-color: #f97316; background: #fff7ed; color: #f97316;}
.timeline-event.type-treatment .timeline-icon { border-color: #a855f7; background: #faf5ff; color: #a855f7;}
.timeline-event.type-payment .timeline-icon { border-color: #22c55e; background: #f0fdf4; color: #22c55e;}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.event-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.event-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.event-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    display: none;
}

.timeline-event.expanded .event-details {
    display: block;
}

.xray-thumbnail {
    max-width: 200px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.xray-thumbnail:hover {
    transform: scale(1.05);
}

/* Fix Modal scrolling for mobile devices */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* Medical Alerts Toggle Styles */
.alert-toggle input[type="checkbox"] {
    display: none;
}

.alert-chip {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    user-select: none;
}

.alert-toggle input[type="checkbox"]:checked + .alert-chip {
    background-color: rgba(239, 68, 68, 0.1); /* light red */
    border-color: var(--status-error);
    color: var(--status-error);
    font-weight: bold;
}

/* Autocomplete Dropdown Styles */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.selected {
    background-color: rgba(59, 130, 246, 0.1);
}

.autocomplete-name {
    font-weight: bold;
}

.autocomplete-details {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    margin-top: 0.2rem;
}

.timeline-event.type-prescription .timeline-icon { border-color: #ef4444; background: #fef2f2; color: #ef4444;}

/* --- Micro-Interactions & UX Polish --- */

/* Tactile Press & Hover Micro-Interactions */
button, .btn-primary, .btn-outline, .btn-secondary, .btn-action {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s, background-color 0.15s, border-color 0.15s;
}

button:active, .btn-primary:active, .btn-outline:active, .btn-secondary:active, .btn-action:active {
    transform: scale(0.96) translateY(1px) !important;
}

.home-card {
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s, border-color 0.25s;
}

.home-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.18);
    border-color: rgba(56, 189, 248, 0.4) !important;
}

/* Staggered Row Entrance Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

tbody tr {
    animation: fadeInUp 0.28s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.05s; }
tbody tr:nth-child(3) { animation-delay: 0.08s; }
tbody tr:nth-child(4) { animation-delay: 0.11s; }
tbody tr:nth-child(5) { animation-delay: 0.14s; }
tbody tr:nth-child(6) { animation-delay: 0.17s; }
tbody tr:nth-child(7) { animation-delay: 0.20s; }

/* Pulsing radar dot for active / today appointments */
@keyframes pulseRadar {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.pulse-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background-color: #22c55e;
    animation: pulseRadar 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
    margin-inline-end: 6px;
    vertical-align: middle;
}

/* Skeleton Shimmer Loading Effect */
@keyframes shimmerWave {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-shimmer {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: shimmerWave 1.6s infinite;
    border-radius: 6px;
}

/* --- Floating Toast Notification System --- */
#toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - 48px);
}

[dir="rtl"] #toast-container {
    right: auto;
    left: 24px;
}

@media (max-width: 600px) {
    #toast-container {
        top: 16px;
        left: 16px !important;
        right: 16px !important;
        width: calc(100vw - 32px);
    }
}

.toast-item {
    pointer-events: auto;
    position: relative;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.92rem;
    font-weight: 500;
    overflow: hidden;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: toastSlideIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: transform 0.2s, opacity 0.2s;
}

.toast-item.toast-hiding {
    animation: toastSlideOut 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.3);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    line-height: 1;
}

.toast-message {
    flex: 1;
    word-break: break-word;
    line-height: 1.4;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--brand-primary);
    transform-origin: left;
    animation: toastProgress linear forwards;
}

[dir="rtl"] .toast-progress {
    transform-origin: right;
}

.toast-success {
    border-left: 4px solid #22c55e;
}
[dir="rtl"] .toast-success {
    border-left: 1px solid var(--border-color);
    border-right: 4px solid #22c55e;
}
.toast-success .toast-progress {
    background: #22c55e;
}

.toast-error {
    border-left: 4px solid #ef4444;
}
[dir="rtl"] .toast-error {
    border-left: 1px solid var(--border-color);
    border-right: 4px solid #ef4444;
}
.toast-error .toast-progress {
    background: #ef4444;
}

.toast-warning {
    border-left: 4px solid #f59e0b;
}
[dir="rtl"] .toast-warning {
    border-left: 1px solid var(--border-color);
    border-right: 4px solid #f59e0b;
}
.toast-warning .toast-progress {
    background: #f59e0b;
}

.toast-info {
    border-left: 4px solid var(--brand-primary);
}
[dir="rtl"] .toast-info {
    border-left: 1px solid var(--border-color);
    border-right: 4px solid var(--brand-primary);
}
.toast-info .toast-progress {
    background: var(--brand-primary);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-12px) scale(0.92);
    }
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* --- Brand Logo Pointer & Feedback --- */
.sidebar h2, .mobile-header h2 {
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.sidebar h2:hover, .mobile-header h2:hover {
    opacity: 0.9;
    transform: scale(1.02);
}
.sidebar h2:active, .mobile-header h2:active {
    transform: scale(0.98);
}

/* --- Unified Today & Tomorrow Agenda Hub --- */
.unified-agenda-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.5rem;
}

.agenda-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
}

.agenda-filter-tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.agenda-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.agenda-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.agenda-tab-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(45, 212, 191, 0.35);
}

.agenda-tab-count {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
}

.today-count-pill {
    background: rgba(45, 212, 191, 0.2);
    color: var(--brand-primary);
}
.agenda-tab-btn.active .today-count-pill {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.tomorrow-count-pill {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}
.agenda-tab-btn.active .tomorrow-count-pill {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Dual Grid */
.agenda-dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .agenda-dual-grid {
        grid-template-columns: 1fr;
    }
}

.agenda-day-panel {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    position: relative;
    overflow: hidden;
}

.agenda-day-panel.today-panel {
    border-color: rgba(45, 212, 191, 0.35);
    background: linear-gradient(180deg, rgba(45, 212, 191, 0.03) 0%, var(--bg-primary) 100%);
}

.agenda-day-panel.tomorrow-panel {
    border-color: rgba(245, 158, 11, 0.35);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.03) 0%, var(--bg-primary) 100%);
}

.agenda-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.65rem;
}

.agenda-day-icon {
    font-size: 1.3rem;
}

.agenda-day-badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

.today-badge {
    background: rgba(45, 212, 191, 0.15);
    color: var(--brand-primary);
    border: 1px solid rgba(45, 212, 191, 0.3);
}

.tomorrow-badge {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.agenda-day-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.agenda-quick-add-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.agenda-quick-add-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    background: rgba(45, 212, 191, 0.08);
}

/* Modern Dynamic Calendar Icon Block */
.calendar-day-icon {
    width: 44px;
    height: 46px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    user-select: none;
    transition: transform 0.2s ease;
}

.calendar-day-icon:hover {
    transform: translateY(-1px);
}

.today-calendar-icon {
    border-color: rgba(45, 212, 191, 0.4);
}

.today-calendar-icon .cal-icon-month {
    background: var(--brand-primary);
    color: #ffffff;
}

.tomorrow-calendar-icon {
    border-color: rgba(245, 158, 11, 0.4);
}

.tomorrow-calendar-icon .cal-icon-month {
    background: #f59e0b;
    color: #ffffff;
}

.cal-icon-month {
    width: 100%;
    padding: 2px 0;
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.5px;
    line-height: 1.15;
}

.cal-icon-day {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

/* Agenda Appointments List & Items - Vertical on Desktop/Tablet, Horizontal on Mobile */
.agenda-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 480px;
    padding-right: 4px;
    padding-left: 2px;
    padding-bottom: 0.25rem;
}

/* Custom Sleek Scrollbar */
.agenda-items-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.agenda-items-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
}
.agenda-items-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
.agenda-items-list::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

.agenda-item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.95rem 1.15rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 0 0 auto;
    border-inline-start: 4px solid var(--brand-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.agenda-item-card.agenda-card-tomorrow {
    border-inline-start-color: #f59e0b;
}

.agenda-item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.09);
    border-color: var(--brand-primary);
}

.agenda-item-left {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex: 1;
    min-width: 0;
}

.agenda-patient-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(2, 132, 199, 0.12);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
    border: 1.5px solid rgba(2, 132, 199, 0.25);
    letter-spacing: -0.5px;
}

.agenda-card-tomorrow .agenda-patient-avatar {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.25);
}

.agenda-time-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    background: rgba(45, 212, 191, 0.1);
    color: var(--brand-primary);
    border: 1px solid rgba(45, 212, 191, 0.25);
    white-space: nowrap;
    text-align: center;
    flex-shrink: 0;
    line-height: 1.2;
}

.agenda-card-tomorrow .agenda-time-pill {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.25);
}

.agenda-time-text {
    font-weight: 800;
    font-size: 0.88rem;
}

.agenda-status-chip {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-top: 3px;
    display: inline-block;
}

.agenda-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

/* Patient Full Name - Never broken character by character */
.agenda-item-patient-name {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: normal;
    line-height: 1.35;
    display: inline-block;
    transition: color 0.15s ease;
}

.agenda-item-patient-name:hover {
    color: var(--brand-primary);
    text-decoration: underline;
}

.patient-id-badge {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    font-size: 0.76rem;
    padding: 2px 7px;
    font-weight: 800;
    border-radius: 6px;
    font-family: monospace;
    border: 1px solid rgba(2, 132, 199, 0.2);
}

.agenda-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.patient-meta-tag, .patient-doctor-tag, .patient-proc-tag {
    font-size: 0.76rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
}

.patient-doctor-tag {
    color: var(--brand-primary);
    border-color: rgba(2, 132, 199, 0.25);
    background: rgba(2, 132, 199, 0.05);
}

.patient-proc-tag {
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.05);
}

.agenda-item-phones-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.agenda-phone-entry {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    line-height: 1.3;
}

.agenda-phone-entry.agenda-phone-secondary {
    color: var(--brand-primary);
}

.agenda-phone-label {
    font-size: 0.76rem;
    opacity: 0.85;
}

.agenda-phone-num {
    font-weight: 700;
    color: var(--text-primary);
    direction: ltr;
    display: inline-block;
}

.agenda-phone-secondary .agenda-phone-num {
    color: var(--brand-primary);
}

.agenda-item-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.agenda-btn-visit {
    background: var(--brand-primary);
    color: #ffffff !important;
    border: none;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
    min-height: 34px;
}

.agenda-btn-visit:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.agenda-action-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    transition: all 0.15s ease;
    min-height: 34px;
}

.agenda-action-btn:hover {
    background: var(--bg-surface);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.agenda-action-btn:active {
    transform: scale(0.97);
}

.agenda-action-wa {
    color: #25D366 !important;
    border-color: rgba(37, 211, 102, 0.35) !important;
    background: rgba(37, 211, 102, 0.05);
}

.agenda-action-wa:hover {
    background: rgba(37, 211, 102, 0.15) !important;
    border-color: #25D366 !important;
}

.agenda-action-call {
    color: var(--brand-primary) !important;
    border-color: rgba(45, 212, 191, 0.35) !important;
    background: rgba(45, 212, 191, 0.05);
}
.agenda-action-call:hover {
    background: rgba(45, 212, 191, 0.15) !important;
    border-color: var(--brand-primary) !important;
}

.pref-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-inline-start: 4px;
    line-height: 1.2;
}

.pref-tag-both {
    background: rgba(45, 212, 191, 0.15);
    color: var(--brand-primary);
    border: 1px solid rgba(45, 212, 191, 0.3);
}

.pref-tag-call {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.pref-tag-wa {
    background: rgba(37, 211, 102, 0.15);
    color: #25D366;
    border: 1px solid rgba(37, 211, 102, 0.3);
}

.agenda-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.02);
    min-height: 120px;
    width: 100%;
}

/* --- Mobile Dedicated Styles for Appointment Cards (Responsive Vertical Layout on Mobile) --- */
@media (max-width: 640px) {
    .agenda-day-panel {
        padding: 0.85rem;
    }

    .agenda-items-list {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        overflow-x: hidden;
        overflow-y: visible;
        max-height: none;
        padding: 0;
        width: 100%;
    }

    .agenda-item-card {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex: 1 1 auto;
        padding: 0.75rem 0.85rem;
        border-radius: 12px;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0.65rem;
        box-sizing: border-box;
        overflow: hidden;
    }

    .agenda-item-left {
        width: 100%;
        display: flex;
        align-items: flex-start;
        gap: 0.55rem;
        min-width: 0;
    }

    .agenda-patient-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .agenda-time-pill {
        min-width: 58px;
        padding: 0.25rem 0.4rem;
        border-radius: 8px;
        flex-shrink: 0;
    }

    .agenda-time-text {
        font-size: 0.78rem;
        font-weight: 800;
    }

    .agenda-status-chip {
        font-size: 0.64rem;
        padding: 1px 4px;
        margin-top: 2px;
    }

    .agenda-item-info {
        flex: 1;
        min-width: 0;
    }

    .agenda-item-patient-name {
        font-size: 0.95rem;
        font-weight: 800;
        line-height: 1.3;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
    }

    .patient-id-badge {
        font-size: 0.7rem;
        padding: 1px 5px;
        flex-shrink: 0;
    }

    .agenda-item-meta {
        font-size: 0.72rem;
        gap: 4px;
        margin-top: 3px;
    }

    .patient-meta-tag, .patient-doctor-tag, .patient-proc-tag {
        font-size: 0.7rem;
        padding: 1px 5px;
        white-space: nowrap;
    }

    .agenda-item-phones-wrap {
        margin-top: 4px;
        font-size: 0.76rem;
    }

    .agenda-phone-entry {
        font-size: 0.76rem;
        gap: 4px;
        flex-wrap: wrap;
    }

    .agenda-phone-num {
        font-size: 0.76rem;
    }

    .agenda-item-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.55rem;
        margin-top: 0.15rem;
    }

    .agenda-btn-visit {
        flex: 1 1 100%;
        justify-content: center;
        font-size: 0.82rem;
        padding: 0.45rem 0.75rem;
        min-height: 36px;
        border-radius: 8px;
    }

    .agenda-action-btn {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        font-size: 0.76rem;
        padding: 0.35rem 0.4rem;
        min-height: 34px;
        border-radius: 8px;
        gap: 3px;
    }

    .agenda-action-more {
        flex: 0 0 48px;
        min-width: 48px;
        justify-content: center;
        padding: 0.35rem 0.2rem;
    }
}

/* --- Tablet & Desktop Responsive Layout (641px and above) --- */
@media (min-width: 641px) {
    .agenda-day-panel {
        padding: 1.1rem;
    }

    .agenda-item-card {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.95rem 1.15rem;
        border-radius: 14px;
        box-sizing: border-box;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-inline-start: 4px solid var(--brand-primary);
        width: 100%;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    }

    .agenda-item-card.agenda-card-tomorrow {
        border-inline-start-color: #f59e0b;
    }

    .agenda-item-left {
        width: 100%;
        display: flex;
        align-items: flex-start;
        gap: 0.85rem;
        min-width: 0;
    }

    .agenda-time-pill {
        min-width: 68px;
        padding: 0.4rem 0.55rem;
        border-radius: 10px;
        flex-shrink: 0;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .agenda-time-text {
        font-size: 0.85rem;
        font-weight: 800;
    }

    .agenda-patient-avatar {
        width: 42px;
        height: 42px;
        font-size: 0.88rem;
        flex-shrink: 0;
    }

    .agenda-item-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .agenda-item-patient-name {
        font-size: 1.02rem;
        font-weight: 800;
        color: var(--text-primary);
        line-height: 1.3;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
    }

    .patient-id-badge {
        font-size: 0.76rem;
        padding: 2px 7px;
        flex-shrink: 0;
    }

    .agenda-item-meta {
        font-size: 0.78rem;
        gap: 6px;
        margin-top: 2px;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
    }

    .patient-meta-tag, .patient-doctor-tag, .patient-proc-tag {
        font-size: 0.75rem;
        padding: 2px 8px;
        white-space: nowrap;
    }

    .agenda-item-phones-wrap {
        margin-top: 4px;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }

    .agenda-phone-entry {
        font-size: 0.8rem;
        gap: 5px;
        display: inline-flex;
        align-items: center;
    }

    .agenda-item-actions {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.65rem;
        margin-top: 0.2rem;
    }

    .agenda-btn-visit {
        flex: 1 1 auto;
        min-width: 110px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.82rem;
        font-weight: 800;
        padding: 0.45rem 0.85rem;
        min-height: 36px;
        border-radius: 8px;
        white-space: nowrap;
    }

    .agenda-action-btn {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.78rem;
        font-weight: 700;
        padding: 0.45rem 0.75rem;
        min-height: 36px;
        border-radius: 8px;
        gap: 5px;
        white-space: nowrap;
    }

    .agenda-action-more {
        flex: 0 0 40px;
        min-width: 40px;
        padding: 0.45rem 0.3rem;
    }
}

/* ==========================================================================
   ENTERPRISE SETTINGS & PRACTICE CONFIGURATION STYLES
   ========================================================================== */
.settings-header-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-nav-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    scrollbar-width: thin;
}

.settings-nav-tab {
    padding: 0.65rem 1.15rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-nav-tab:hover {
    color: var(--text-primary);
    border-color: rgba(56, 189, 248, 0.4);
    background: var(--bg-primary);
}

.settings-nav-tab.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}

.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.settings-card-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toggle-switch-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    margin-bottom: 0.75rem;
    transition: border-color 0.2s;
}

.toggle-switch-card:hover {
    border-color: rgba(56, 189, 248, 0.4);
}

.toggle-switch-info h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.toggle-switch-info p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Switch Toggle UI */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--brand-primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

html[dir="rtl"] input:checked + .slider:before {
    transform: translateX(-22px);
}

.settings-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 768px) {
    .settings-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   Payment Sources & Financial Breakdown UI
   ========================================= */
.payment-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-cash {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.badge-card {
    background: rgba(56, 189, 248, 0.15);
    color: #0284c7;
    border-color: rgba(56, 189, 248, 0.3);
}
[data-theme="dark"] .badge-card {
    color: #38bdf8;
}

.badge-instapay {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
}

.badge-vodafone {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.badge-bank {
    background: rgba(20, 184, 166, 0.15);
    color: #14b8a6;
    border-color: rgba(20, 184, 166, 0.3);
}

.badge-insurance {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.3);
}
[data-theme="dark"] .badge-insurance {
    color: #fbbf24;
}

.badge-installment {
    background: rgba(249, 115, 22, 0.15);
    color: #ea580c;
    border-color: rgba(249, 115, 22, 0.3);
}
[data-theme="dark"] .badge-installment {
    color: #fb923c;
}

.badge-other {
    background: rgba(148, 163, 184, 0.15);
    color: #64748b;
    border-color: rgba(148, 163, 184, 0.3);
}
[data-theme="dark"] .badge-other {
    color: #94a3b8;
}

/* Payment Quick Chips Selector */
.payment-chips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-top: 0.4rem;
    margin-bottom: 0.75rem;
}

.payment-source-chip-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    user-select: none;
}

.payment-source-chip-btn:hover {
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.payment-source-chip-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.25);
}

/* Income Sources Breakdown Grid */
.income-sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.income-source-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s;
}
.income-source-card:hover {
    transform: translateY(-2px);
}

.income-source-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.income-source-amount {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: monospace;
}

.income-source-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Printable Official Receipt Styling */
@media print {
    body * {
        visibility: hidden;
    }
    #printableReceiptCard, #printableReceiptCard * {
        visibility: visible;
    }
    #printableReceiptCard {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 2cm;
        background: #ffffff !important;
        color: #000000 !important;
        box-shadow: none !important;
        border: none !important;
    }
    .no-print {
        display: none !important;
    }
}

/* Smart Payment Calculator & Dynamic Quick Amount Selection */
.smart-calc-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 0.9rem;
    margin-top: 0.6rem;
    margin-bottom: 0.85rem;
    transition: all 0.2s ease;
}

.smart-calc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px dashed var(--border-color);
}

.smart-calc-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    text-align: center;
}

.smart-calc-metric-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.smart-calc-metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.smart-calc-metric-value {
    font-size: 0.95rem;
    font-weight: 700;
    font-family: monospace;
}

.quick-amount-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 0.5rem;
    margin-bottom: 0.3rem;
}

.quick-amount-chips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}

.quick-percent-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.45rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    text-align: center;
    line-height: 1.15;
}

.quick-percent-chip:hover {
    border-color: var(--brand-primary);
    background: rgba(2, 132, 199, 0.04);
    transform: translateY(-1px);
}

.quick-percent-chip.active {
    background: var(--brand-primary);
    color: #ffffff !important;
    border-color: var(--brand-primary);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.quick-percent-chip.active span {
    color: #ffffff !important;
}

.quick-percent-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

.quick-percent-val {
    font-size: 0.68rem;
    font-family: monospace;
    color: var(--text-muted);
    margin-top: 2px;
}

.quick-adders-bar {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.3rem;
}

.quick-add-btn {
    padding: 3px 8px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-add-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.quick-add-btn.special-reset {
    color: var(--status-error);
    border-color: rgba(239, 68, 68, 0.3);
}
.quick-add-btn.special-reset:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================================
   ANIMATED ICONS & MICRO-INTERACTIONS ENGINE
   ======================================================== */

/* 1. Keyframe Definitions */
@keyframes iconPulseGleam {
    0%, 100% {
        transform: scale(1.15);
        filter: drop-shadow(0 0 0 rgba(56, 189, 248, 0));
    }
    50% {
        transform: scale(1.28);
        filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.6));
    }
}

@keyframes animBounceDown {
    0%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

@keyframes animFloatUp {
    0%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(2px);
    }
}

@keyframes animRotateFull {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes animDangerWiggle {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    20% {
        transform: rotate(-14deg) scale(1.15);
    }
    40% {
        transform: rotate(12deg) scale(1.2);
    }
    60% {
        transform: rotate(-10deg) scale(1.15);
    }
    80% {
        transform: rotate(6deg) scale(1.1);
    }
}

@keyframes animHeartbeat {
    0%, 100% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.22);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.16);
    }
    70% {
        transform: scale(1);
    }
}

@keyframes animToothSparkle {
    0%, 100% {
        transform: rotate(0deg) scale(1);
        filter: drop-shadow(0 2px 4px rgba(56, 189, 248, 0.15));
    }
    30% {
        transform: rotate(-8deg) scale(1.14);
        filter: drop-shadow(0 4px 10px rgba(56, 189, 248, 0.45));
    }
    70% {
        transform: rotate(6deg) scale(1.12);
        filter: drop-shadow(0 4px 8px rgba(139, 92, 246, 0.4));
    }
}

@keyframes animPillBob {
    0%, 100% {
        transform: rotate(0deg) translateY(0);
    }
    50% {
        transform: rotate(15deg) translateY(-3px);
    }
}

@keyframes animInfoPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(37, 99, 235, 0);
    }
}

@keyframes animPhoneRing {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    15% {
        transform: rotate(-16deg) scale(1.15);
    }
    30% {
        transform: rotate(14deg) scale(1.15);
    }
    45% {
        transform: rotate(-12deg) scale(1.1);
    }
    60% {
        transform: rotate(10deg) scale(1.1);
    }
    75% {
        transform: rotate(0deg) scale(1);
    }
}

/* 2. Interactive Base for all icon containers and spans */
button span,
.btn-primary span,
.btn-outline span,
.btn-secondary span,
.btn-action span,
.home-card span,
.settings-card span {
    display: inline-block;
    transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.24s ease;
}

/* 3. Automatic contextual icon micro-interactions on button hover */

/* Download / Export Button: icon bounces down */
#exportPatientsCsvBtn:hover span:first-child,
#exportFullConfigJsonBtn:hover span:first-child,
.btn-export-patients:hover span:first-child {
    animation: animBounceDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

/* Upload / Import Button: icon floats up */
#triggerImportPatientsBtn:hover span:first-child,
#triggerImportInventoryBtn:hover span:first-child {
    animation: animFloatUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}

/* Refresh / Restore Button: icon spins */
#triggerRestoreSettingsBtn:hover span:first-child,
button[onclick*="reload"]:hover span:first-child {
    animation: animRotateFull 0.85s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Delete / Trash Button: icon shakes with danger warning */
.btn-danger:hover span,
.btn-delete:hover,
#deletePatientProfileBtn:hover span,
#executeDeletePatientConfirmBtn:hover span:first-child {
    animation: animDangerWiggle 0.5s ease-in-out infinite;
}

/* 4. KPI Stat Cards */
.home-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.home-card:hover {
    border-color: rgba(56, 189, 248, 0.25);
}

.home-card [style*="border-radius: 10px"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 5. Info Guide Badge & Buttons Breathing Glow */
.info-guide-btn,
button[onclick*="openManualDataMigrationHelpModal"] {
    position: relative;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.info-guide-btn {
    animation: animInfoPulse 3s infinite ease-in-out;
}

.info-guide-btn:hover {
    transform: scale(1.22) rotate(10deg) !important;
    animation: none;
}

/* 6. Tooth & Odontogram Icons */
.tooth-unit,
.tooth-card,
button[onclick*="odontogram"] {
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tooth-unit:hover {
    transform: translateY(-2px) scale(1.05);
}

/* 7. Action Icons on Patient Table Rows (Call, WhatsApp, Edit, Delete) */
td a[href^="tel:"] svg,
td a[href*="wa.me"] svg {
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

td a[href^="tel:"]:hover svg {
    animation: animPhoneRing 0.6s ease-in-out infinite;
}

td a[href*="wa.me"]:hover svg {
    transform: scale(1.3) rotate(8deg);
    filter: drop-shadow(0 2px 8px rgba(37, 211, 102, 0.5));
}

.btn-action.btn-edit:hover span,
.btn-action.btn-edit:hover svg {
    transform: rotate(35deg) scale(1.15);
}

/* 8. Reusable Animation Utility Classes */
.anim-icon {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.anim-spin {
    animation: animRotateFull 1.2s linear infinite;
}
.anim-spin-hover:hover {
    animation: animRotateFull 0.8s linear infinite;
}
.anim-bounce {
    animation: animBounceDown 1.5s ease-in-out infinite;
}
.anim-bounce-hover:hover {
    animation: animBounceDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.anim-float-hover:hover {
    animation: animFloatUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite;
}
.anim-pulse {
    animation: animInfoPulse 2.5s ease-in-out infinite;
}
.anim-wiggle-hover:hover {
    animation: animDangerWiggle 0.5s ease-in-out infinite;
}
.anim-heartbeat {
    animation: animHeartbeat 2.2s ease-in-out infinite;
}
.anim-tooth {
    animation: animToothSparkle 3s ease-in-out infinite;
}

/* 9. Accessibility: Respect User's Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Patient Profile Drawer: Side Drawer (Desktop) & Bottom Sheet (Mobile)
   ========================================================================== */
#patientModal.patient-drawer-modal {
    padding: 0;
    transition: opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Desktop Side Drawer (sliding in from the side) --- */
@media (min-width: 769px) {
    #patientModal.patient-drawer-modal {
        justify-content: flex-end;
        align-items: stretch;
        padding: 0 !important;
    }

    [dir="rtl"] #patientModal.patient-drawer-modal,
    html[dir="rtl"] #patientModal.patient-drawer-modal {
        justify-content: flex-start;
    }

    #patientModal.patient-drawer-modal .patient-drawer-content {
        width: 490px;
        max-width: 100%;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100% !important;
        max-height: 100dvh !important;
        border-radius: 0;
        margin: 0;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        background-color: var(--bg-surface);
        box-shadow: -10px 0 35px rgba(0, 0, 0, 0.25);
        border: none;
        border-left: 1px solid var(--border-color);
        transform: translateX(100%);
        transition: transform 0.38s cubic-bezier(0.25, 0.8, 0.25, 1);
        overflow: hidden !important;
        position: relative;
    }

    [dir="rtl"] #patientModal.patient-drawer-modal .patient-drawer-content,
    html[dir="rtl"] #patientModal.patient-drawer-modal .patient-drawer-content {
        border-left: none;
        border-right: 1px solid var(--border-color);
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.25);
        transform: translateX(-100%);
    }

    #patientModal.patient-drawer-modal.show .patient-drawer-content {
        transform: translateX(0) !important;
    }
}

/* --- Mobile Bottom Sheet (sliding up from the bottom) --- */
@media (max-width: 768px) {
    #patientModal.patient-drawer-modal {
        justify-content: center;
        align-items: flex-end;
        padding: 0 !important;
    }

    #patientModal.patient-drawer-modal .patient-drawer-content {
        width: 100%;
        max-width: 100%;
        height: 92vh !important;
        height: 92dvh !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        border-radius: 24px 24px 0 0;
        margin: 0;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        background-color: var(--bg-surface);
        box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.35);
        border: none;
        border-top: 1px solid var(--border-color);
        transform: translateY(100%);
        transition: transform 0.38s cubic-bezier(0.25, 0.8, 0.25, 1);
        overflow: hidden !important;
        position: relative;
    }

    #patientModal.patient-drawer-modal.show .patient-drawer-content {
        transform: translateY(0) !important;
    }

    #patientModal.patient-drawer-modal .drawer-header {
        padding-top: 1.85rem !important;
        position: relative;
    }

    #patientModal.patient-drawer-modal .patient-drawer-content::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 5px;
        background-color: var(--border-color);
        border-radius: 10px;
        z-index: 20;
    }
}

/* --- Drawer Layout & Inner Components --- */
#patientModal #patientForm {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
    min-height: 0 !important;
    flex: 1 1 100% !important;
    margin: 0 !important;
}

#patientModal .drawer-header {
    flex: 0 0 auto !important;
    min-height: 60px !important;
    padding: 1rem 1.5rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: var(--bg-surface) !important;
    z-index: 20 !important;
}

#patientModal .drawer-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: color 0.2s, background-color 0.2s;
}

#patientModal .drawer-close-btn:hover {
    color: var(--status-error);
    background-color: rgba(239, 68, 68, 0.1);
}

#patientModal .drawer-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.25rem 1.5rem !important;
}

#patientModal .drawer-body .input-group {
    margin-bottom: 1.15rem;
}

#patientModal .drawer-body .input-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

#patientModal .drawer-body .input-group input,
#patientModal .drawer-body .input-group select,
#patientModal .drawer-body .input-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#patientModal .drawer-body .input-group input:focus,
#patientModal .drawer-body .input-group select:focus,
#patientModal .drawer-body .input-group textarea:focus {
    border-color: var(--brand-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#patientModal .drawer-footer {
    flex: 0 0 auto !important;
    min-height: 64px !important;
    padding: 0.85rem 1.5rem !important;
    border-top: 1px solid var(--border-color) !important;
    background: var(--bg-surface) !important;
    display: flex !important;
    gap: 0.75rem !important;
    justify-content: flex-end !important;
    align-items: center !important;
    z-index: 25 !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08) !important;
}

/* =========================================
   Live Clock & Time Widget Styles
========================================= */
#currentTimeDisplay {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    cursor: default;
    user-select: none;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

#currentTimeText {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

/* ==========================================================================
   Unified Professional International Phone Input Component
   ========================================================================== */
@keyframes animRotateGlobe {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.phone-input-container {
    display: flex;
    align-items: center;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--bg-primary);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.phone-input-container:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.phone-globe-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline-start: 0.65rem;
    color: var(--brand-primary, #2dd4bf);
    width: 32px;
    height: 100%;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), 
                width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), 
                padding 0.35s ease, 
                transform 0.35s ease;
    overflow: hidden;
}

.phone-globe-icon .globe-spin-svg {
    animation: animRotateGlobe 3.5s linear infinite;
    transform-origin: center center;
    flex-shrink: 0;
}

/* When active (number is entered), globe shrinks and rotates out smoothly */
.phone-input-container.phone-active .phone-globe-icon {
    opacity: 0;
    width: 0 !important;
    padding-inline-start: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    transform: scale(0.2) rotate(180deg);
    pointer-events: none;
}

/* By default when container is NOT active (empty number), hide the country flag/trigger button */
.phone-input-container:not(.phone-active) .phone-code-trigger {
    opacity: 0;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border-inline-end: none !important;
    overflow: hidden;
    pointer-events: none;
    transform: scale(0.6);
    transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                min-width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                max-width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                padding 0.3s ease,
                transform 0.35s ease;
}

/* ==========================================================================
   Custom Searchable Country Code Picker Component & Modal
   ========================================================================== */
.phone-code-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    padding: 0.65rem 0.45rem 0.65rem 0.6rem !important;
    cursor: pointer;
    border: none !important;
    border-inline-end: 1px solid var(--border-color) !important;
    min-width: 82px;
    max-width: 95px;
    flex-shrink: 0;
    user-select: none;
    outline: none !important;
    transform: scale(1);
    opacity: 1;
    transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                min-width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                max-width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                padding 0.3s ease,
                background-color 0.2s ease,
                transform 0.35s ease;
}

.phone-code-trigger:hover,
.phone-code-trigger:focus {
    background-color: var(--bg-primary) !important;
}

.phone-code-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
}

.phone-code-chevron {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

/* Modal Overlay & Dialog */
.country-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(5px);
    z-index: 10500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 1rem;
}

.country-picker-overlay.show {
    opacity: 1;
    visibility: visible;
}

.country-picker-dialog {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.country-picker-overlay.show .country-picker-dialog {
    transform: scale(1) translateY(0);
}

.country-picker-header {
    padding: 1rem 1.15rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.country-picker-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.country-picker-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 8px;
    transition: color 0.15s, background-color 0.15s;
}

.country-picker-close-btn:hover {
    color: var(--status-error, #ef4444);
    background-color: rgba(239, 68, 68, 0.1);
}

.country-picker-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.country-picker-search-icon {
    position: absolute;
    inset-inline-start: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.country-picker-search-input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.4rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

[dir="rtl"] .country-picker-search-input,
html[dir="rtl"] .country-picker-search-input {
    padding: 0.65rem 2.4rem 0.65rem 0.85rem;
}

.country-picker-search-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.country-picker-list {
    overflow-y: auto;
    padding: 0.5rem;
    max-height: 360px;
    overscroll-behavior: contain;
}

.country-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    user-select: none;
    margin-bottom: 2px;
}

.country-picker-item:hover {
    background-color: var(--bg-primary);
}

.country-picker-item.active-selected {
    background-color: rgba(45, 212, 191, 0.12);
    font-weight: 700;
}

.country-picker-item-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.country-picker-flag {
    font-size: 1.35rem;
    line-height: 1;
}

.country-picker-name {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.country-picker-code {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--brand-primary);
    background-color: rgba(45, 212, 191, 0.15);
    padding: 3px 8px;
    border-radius: 6px;
    direction: ltr;
}

.sidebar-icon-wrap {
 display: inline-flex;
 align-items: center;
 justify-content: center;
 width: 36px;
 height: 36px;
 flex-shrink: 0;
 transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sidebar-icon-wrap svg {
 display: block;
 width: 36px;
 height: 36px;
 overflow: visible;
}

.sidebar a:hover .sidebar-icon-wrap {
 transform: scale(1.2) rotate(4deg);
}

.sidebar a.active .sidebar-icon-wrap {
 transform: scale(1.1);
}

/* ========================================================= */
/* --- CLINICAL ODONTOGRAM LAYERS & SEPARATION SYSTEM --- */
/* ========================================================= */

.tooth-unit {
    position: relative;
}

/* Indicator dot for teeth with treatment layers over baseline */
.tooth-unit.has-treatments-layer::after {
    content: '';
    position: absolute;
    top: 1px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    border: 1px solid #ffffff;
    box-shadow: 0 0 4px #10b981;
    z-index: 10;
}

/* Indicator dot for teeth with baseline findings */
.tooth-unit.has-baseline-records::before {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #eab308;
    border: 1px solid #ffffff;
    z-index: 10;
}

[data-theme="dark"] .tooth-unit.has-treatments-layer::after {
    border-color: #0f172a;
}
[data-theme="dark"] .tooth-unit.has-baseline-records::before {
    border-color: #0f172a;
}

.odontogram-layer-btn-group {
    display: inline-flex;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.odontogram-layer-btn-group .odontogram-toggle-btn {
    border: none;
    background: transparent;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.odontogram-layer-btn-group .odontogram-toggle-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Layer Badge in Deep Inspector */
.modal-layer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
}

.modal-layer-baseline {
    background: rgba(234, 179, 8, 0.15);
    color: #ca8a04;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.modal-layer-treatments {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.modal-layer-all {
    background: rgba(2, 132, 199, 0.15);
    color: #0284c7;
    border: 1px solid rgba(2, 132, 199, 0.3);
}

/* ========================================================= */
/* --- PATIENT TIMELINE: TOOTH IDENTIFICATION & DETAILS --- */
/* ========================================================= */

.timeline-tooth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(2, 132, 199, 0.1);
    color: var(--brand-primary);
    border: 1px solid rgba(2, 132, 199, 0.25);
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    font-size: 0.84rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    letter-spacing: 0.2px;
}

.timeline-tooth-badge .tooth-icon {
    font-size: 1rem;
}

.timeline-proc-details {
    background: rgba(248, 250, 252, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

[data-theme="dark"] .timeline-proc-details {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(51, 65, 85, 0.7);
}

.timeline-proc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.4rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
}

.timeline-proc-item {
    display: flex;
    flex-direction: column;
}

.timeline-proc-item .proc-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.timeline-proc-item .proc-val {
    font-weight: 700;
    color: var(--text-primary);
}

/* ========================================================= */
/* --- INVOICES: TOOTH LINKING & PRINTABLE INVOICE CARD --- */
/* ========================================================= */

.invoice-tooth-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(2, 132, 199, 0.08);
    color: #0284c7;
    border: 1px solid rgba(2, 132, 199, 0.2);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

[data-theme="dark"] .invoice-tooth-badge {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.25);
}

.printable-invoice-card {
    background: #ffffff;
    color: #0f172a;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.15rem 1.25rem;
    font-family: inherit;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.invoice-table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.78rem;
    box-sizing: border-box;
}

.invoice-items-table th {
    background: #f8fafc;
    color: #475569;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e2e8f0;
    font-weight: 700;
    font-size: 0.76rem;
    text-align: inherit;
    white-space: nowrap;
}

.invoice-items-table td {
    padding: 0.4rem 0.5rem;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    font-size: 0.78rem;
    word-break: break-word;
}

.invoice-items-table tr:nth-child(even) {
    background: #f8fafc;
}

@media print {
    body.printing-invoice * {
        visibility: hidden;
    }
    body.printing-invoice #printableInvoiceCard,
    body.printing-invoice #printableInvoiceCard * {
        visibility: visible;
    }
    body.printing-invoice #printableInvoiceCard {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 20px;
        border: none;
        box-shadow: none;
    }

    body.printing-outstanding * {
        visibility: hidden;
    }
    body.printing-outstanding #printableOutstandingReport,
    body.printing-outstanding #printableOutstandingReport * {
        visibility: visible;
    }
    body.printing-outstanding #printableOutstandingReport {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 20px;
        border: none;
        box-shadow: none;
    }
}

/* Outstanding Card & Modal Enhancements */
#ledger-outstanding-card {
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

#ledger-outstanding-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.15), 0 8px 10px -6px rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4) !important;
}

.outstanding-kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
}

.outstanding-search-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.outstanding-search-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.outstanding-progress-track {
    width: 100%;
    height: 7px;
    background: rgba(239, 68, 68, 0.15);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: 4px;
}

.outstanding-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 9999px;
    transition: width 0.3s ease;
}

.outstanding-item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.outstanding-item-card:hover {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-whatsapp-reminder {
    background: rgba(37, 211, 102, 0.12);
    color: #16a34a;
    border: 1px solid rgba(37, 211, 102, 0.3);
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-whatsapp-reminder:hover {
    background: #25d366;
    color: #ffffff;
    border-color: #25d366;
}

/* Single-line Recent Patients Styling for Desktop and Mobile */
.recent-patient-item {
    box-sizing: border-box !important;
    max-width: 100% !important;
}

.recent-patient-item:hover {
    background-color: var(--bg-surface) !important;
    border-color: var(--brand-primary) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.recent-patient-item .action-icon-btn {
    transition: transform 0.2s, background-color 0.2s, color 0.2s !important;
}

.recent-patient-item .action-icon-btn:hover {
    transform: scale(1.08);
}

.recent-patient-item .call-btn:hover {
    background-color: var(--brand-primary) !important;
    color: #ffffff !important;
}

.recent-patient-item .wa-btn:hover {
    background-color: #25d366 !important;
    color: #ffffff !important;
}

@media (max-width: 600px) {
    .recent-patient-item {
        padding: 0.6rem 0.65rem !important;
        gap: 6px !important;
    }
    .recent-patient-item .list-item-title {
        font-size: 1.05rem !important;
        max-width: none !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    .recent-patient-item .recent-phone-num {
        display: none !important;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    .recent-patient-item .list-item-title {
        font-size: 1.1rem !important;
        max-width: none !important;
        white-space: normal !important;
    }
}

/* ==========================================================================
   Main Home Quick 4 KPI Cards (Side-by-side in same row on Tablet & Desktop)
   ========================================================================== */
.main-quick-stats-grid {
    display: grid !important;
    margin-bottom: 1rem;
    width: 100%;
}

/* Tablet & Desktop (>= 768px): All 4 cards strictly side-by-side in the SAME single row */
@media (min-width: 768px) {
    .main-quick-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0.65rem !important;
    }

    .main-quick-stats-grid > .home-card {
        padding: 0.85rem 0.9rem !important;
        min-width: 0 !important; /* Critical: allows flexbox truncation without column blow-out */
        margin-bottom: 0 !important;
    }

    .main-quick-stats-grid .stat-label {
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.25;
    }

    .main-quick-stats-grid .stat-value {
        font-size: 1.6rem !important;
        margin: 0.25rem 0 0.15rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .main-quick-stats-grid .home-card > div > div:first-child > div:nth-child(3) {
        font-size: 0.72rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        opacity: 0.85;
    }

    .main-quick-stats-grid .kpi-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 1.1rem !important;
        border-radius: 10px !important;
    }

    .main-quick-stats-grid .outstanding-kpi-badge {
        font-size: 0.68rem !important;
        padding: 1px 6px !important;
        white-space: nowrap !important;
    }
}

/* Larger Tablet & Standard Desktop (>= 1024px) */
@media (min-width: 1024px) {
    .main-quick-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
    }

    .main-quick-stats-grid > .home-card {
        padding: 0.95rem 1rem !important;
    }

    .main-quick-stats-grid .stat-label {
        font-size: 0.85rem !important;
    }

    .main-quick-stats-grid .stat-value {
        font-size: 1.75rem !important;
    }

    .main-quick-stats-grid .home-card > div > div:first-child > div:nth-child(3) {
        font-size: 0.76rem !important;
    }

    .main-quick-stats-grid .kpi-icon-wrapper {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        font-size: 1.2rem !important;
    }
}

/* Wide Desktop Screens (>= 1280px) */
@media (min-width: 1280px) {
    .main-quick-stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 0.85rem !important;
    }

    .main-quick-stats-grid > .home-card {
        padding: 1rem 1.15rem !important;
    }

    .main-quick-stats-grid .stat-label {
        font-size: 0.88rem !important;
    }

    .main-quick-stats-grid .stat-value {
        font-size: 1.85rem !important;
    }

    .main-quick-stats-grid .home-card > div > div:first-child > div:nth-child(3) {
        font-size: 0.8rem !important;
    }

    .main-quick-stats-grid .kpi-icon-wrapper {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        font-size: 1.3rem !important;
    }
}

/* Mobile Devices (< 768px): 2 columns layout */
@media (max-width: 767px) {
    .main-quick-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.55rem !important;
    }

    .main-quick-stats-grid > .home-card {
        padding: 0.8rem 0.85rem !important;
        margin-bottom: 0 !important;
    }

    .main-quick-stats-grid .stat-label {
        font-size: 0.78rem !important;
    }

    .main-quick-stats-grid .stat-value {
        font-size: 1.45rem !important;
    }

    .main-quick-stats-grid .kpi-icon-wrapper {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        font-size: 1.05rem !important;
    }
}

/* Very Small Mobile Screens (< 380px) */
@media (max-width: 380px) {
    .main-quick-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.4rem !important;
    }

    .main-quick-stats-grid > .home-card {
        padding: 0.65rem 0.7rem !important;
    }

    .main-quick-stats-grid .stat-value {
        font-size: 1.3rem !important;
    }

    .main-quick-stats-grid .kpi-icon-wrapper {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        font-size: 0.9rem !important;
    }
}

/* ==========================================================================
   KPI Stat Cards (Enterprise ERP Glassmorphism & Glow Icons)
   ========================================================================== */
.stats-grid .home-card {
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.stats-grid .home-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.home-card:hover .kpi-icon-wrapper {
    transform: translateY(-2px) scale(1.06);
}

/* Card 1: Today's Appointments (Warm Amber / Golden Honey - Distinct from Patient Blue) */
.kpi-icon-appts {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.32);
    color: #d97706;
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.20), inset 0 0 8px rgba(245, 158, 11, 0.10);
}
.home-card:hover .kpi-icon-appts {
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.40), inset 0 0 10px rgba(245, 158, 11, 0.20);
}
.kpi-val-appts {
    color: #d97706 !important;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Card 2: Total Patients (Brand Primary Blue) */
.kpi-icon-patients {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.30);
    color: #2563eb;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.18), inset 0 0 8px rgba(59, 130, 246, 0.10);
}
.home-card:hover .kpi-icon-patients {
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.38), inset 0 0 10px rgba(59, 130, 246, 0.18);
}
.kpi-val-patients {
    color: #2563eb !important;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Card 3: Monthly Revenue (Emerald Green / Success) */
.kpi-icon-revenue {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.30);
    color: #10b981;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.18), inset 0 0 8px rgba(16, 185, 129, 0.10);
}
.home-card:hover .kpi-icon-revenue {
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.38), inset 0 0 10px rgba(16, 185, 129, 0.18);
}
.kpi-val-revenue {
    color: #10b981 !important;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Card 4: Low Stock Alerts (Red / Warning) */
.kpi-icon-stock {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.30);
    color: #f43f5e;
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.18), inset 0 0 8px rgba(244, 63, 94, 0.10);
}
.home-card:hover .kpi-icon-stock {
    box-shadow: 0 0 24px rgba(244, 63, 94, 0.38), inset 0 0 10px rgba(244, 63, 94, 0.18);
}
.kpi-val-stock {
    color: #f43f5e !important;
    font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* Dark mode theme adjustments for elevated vibrance */
[data-theme="dark"] .kpi-icon-appts {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.35);
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.22), inset 0 0 8px rgba(251, 191, 36, 0.12);
}
.home-card:hover .kpi-icon-appts {
    box-shadow: 0 0 24px rgba(251, 191, 36, 0.42), inset 0 0 10px rgba(251, 191, 36, 0.20);
}
[data-theme="dark"] .kpi-val-appts {
    color: #fbbf24 !important;
}

[data-theme="dark"] .kpi-icon-patients {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.35);
}
[data-theme="dark"] .kpi-val-patients {
    color: #60a5fa !important;
}

[data-theme="dark"] .kpi-icon-revenue {
    color: #34d399;
    background: rgba(52, 211, 153, 0.18);
    border-color: rgba(52, 211, 153, 0.35);
}
[data-theme="dark"] .kpi-val-revenue {
    color: #34d399 !important;
}

[data-theme="dark"] .kpi-icon-stock {
    color: #fb7185;
    background: rgba(251, 113, 133, 0.18);
    border-color: rgba(251, 113, 133, 0.35);
}
[data-theme="dark"] .kpi-val-stock {
    color: #fb7185 !important;
}

/* Authentication Screen Animation */
@keyframes loginFadeSlideUp {
    0% {
        opacity: 0;
        transform: translateY(24px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-box {
    animation: loginFadeSlideUp 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
    .login-box {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ==========================================================================
   PATIENTS DIRECTORY TABLE REDESIGN & MODERNIZATION
   ========================================================================== */

.patients-card-wrapper {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-top: 1.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .patients-card-wrapper {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.07);
}

/* Card Header Toolbar */
.patients-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.85rem;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.patients-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.patients-card-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.patients-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.2rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
    border-radius: 20px;
    background: rgba(2, 132, 199, 0.1);
    color: var(--brand-primary);
    border: 1px solid rgba(2, 132, 199, 0.22);
    font-variant-numeric: tabular-nums;
}

.patients-badge-pill.filtered {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

.patients-header-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.patients-sort-select {
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.patients-sort-select:focus {
    border-color: var(--brand-primary);
}

/* Quick Filter Segmented Buttons */
.patients-quick-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.75rem 1.4rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: thin;
}

.patients-filter-pill-btn {
    padding: 0.35rem 0.8rem;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.18s ease;
}

.patients-filter-pill-btn:hover {
    color: var(--text-primary);
    border-color: var(--brand-primary);
}

.patients-filter-pill-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
}

/* Table Container & Layout */
.patients-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.patients-modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

[dir="ltr"] .patients-modern-table {
    text-align: left;
}

/* Table Head */
.patients-modern-table thead th {
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}

.patients-modern-table thead th.sortable-th {
    cursor: pointer;
}

.patients-modern-table thead th.sortable-th:hover {
    color: var(--brand-primary);
    background: rgba(2, 132, 199, 0.04);
}

.patients-modern-table thead th.sorted-active {
    color: var(--brand-primary);
}

/* Table Body Rows */
.patients-modern-table tbody tr.patient-table-row {
    transition: background-color 0.15s ease, transform 0.15s ease;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
}

.patients-modern-table tbody tr.patient-table-row:last-child td {
    border-bottom: none;
}

.patients-modern-table tbody tr.patient-table-row:hover {
    background-color: rgba(2, 132, 199, 0.045);
}

[data-theme="dark"] .patients-modern-table tbody tr.patient-table-row:hover {
    background-color: rgba(56, 189, 248, 0.05);
}

.patients-modern-table tbody td {
    padding: 0.95rem 1.15rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.88rem;
    color: var(--text-primary);
}

/* Column 1: File ID */
.patient-id-col {
    width: 110px;
    white-space: nowrap;
}

.patient-id-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    font-family: monospace, 'Courier New', Courier, sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--brand-primary);
    letter-spacing: 0.03em;
}

/* Column 2: Patient Profile & Details */
.patient-cell-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.patient-avatar-box {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.88rem;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    user-select: none;
}

.patient-avatar-male {
    background: linear-gradient(135deg, #0284c7, #0d9488);
}

.patient-avatar-female {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

.patient-avatar-neutral {
    background: linear-gradient(135deg, #64748b, #475569);
}

.patient-meta-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.patient-name-link {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.18s;
}

.patient-table-row:hover .patient-name-link {
    color: var(--brand-primary);
}

.patient-sub-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.patient-alert-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
    white-space: nowrap;
}

/* Column 3: Contact & Communication Channels */
.patient-cell-phone {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.patient-primary-phone {
    font-family: monospace, 'Courier New', Courier, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.patient-phone-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-comm-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.18s ease;
    border: 1px solid transparent;
}

.table-comm-call {
    background: rgba(2, 132, 199, 0.1);
    color: var(--brand-primary);
    border-color: rgba(2, 132, 199, 0.2);
}

.table-comm-call:hover {
    background: var(--brand-primary);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(2, 132, 199, 0.3);
}

.table-comm-wa {
    background: rgba(37, 211, 102, 0.12);
    color: #25d366;
    border-color: rgba(37, 211, 102, 0.25);
}

.table-comm-wa:hover {
    background: #25d366;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(37, 211, 102, 0.3);
}

.patient-sec-phone {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Column 4: Nationality */
.patient-nat-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 0.18rem 0.55rem;
    border-radius: 6px;
    white-space: nowrap;
}

/* Column 5: Last Visit */
.patient-last-visit-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.patient-visit-date {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: monospace, inherit;
}

.patient-visit-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Column 6: Actions */
.patient-actions-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.patient-row-btn {
    padding: 0.38rem 0.65rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    font-family: inherit;
}

.patient-row-btn.btn-profile {
    background: rgba(2, 132, 199, 0.1);
    color: var(--brand-primary);
    border-color: rgba(2, 132, 199, 0.25);
}

.patient-row-btn.btn-profile:hover {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.28);
}

.patient-row-btn.btn-edit-row {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-color: rgba(245, 158, 11, 0.25);
}

.patient-row-btn.btn-edit-row:hover {
    background: #f59e0b;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
}

.patient-row-btn.btn-delete-row {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.patient-row-btn.btn-delete-row:hover {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
}

/* Empty State Styling */
.patients-empty-card {
    padding: 3rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.patients-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(2, 132, 199, 0.08);
    border: 1px dashed rgba(2, 132, 199, 0.3);
    color: var(--brand-primary);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.patients-empty-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.patients-empty-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    max-width: 440px;
    margin: 0;
    line-height: 1.5;
}

/* Print Styles */
@media print {
    .sidebar,
    .mobile-header,
    .login-controls,
    .patient-search-container,
    .patients-card-header .patients-header-controls,
    .patients-quick-filter-bar,
    .patient-actions-group,
    .table-comm-btn,
    .quick-actions,
    #openModalBtn,
    #exportPatientsCsvBtn,
    #printPatientsListBtn {
        display: none !important;
    }
    
    .content-area,
    #patients-section,
    .patients-card-wrapper,
    .patients-table-responsive {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .patients-modern-table {
        border-collapse: collapse !important;
    }

    .patients-modern-table th,
    .patients-modern-table td {
        border: 1px solid #cccccc !important;
        color: #000000 !important;
        padding: 8px 10px !important;
    }

    .patient-avatar-box {
        border: 1px solid #999999 !important;
        color: #000000 !important;
    }
}

/* ========================================================
   Innovative Smart Dental Recall & Follow-ups Visual Badge
   ======================================================== */
.innovative-recall-badge {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.12), rgba(16, 185, 129, 0.18));
    border: 1px solid rgba(2, 132, 199, 0.28);
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.08), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: pointer;
    flex-shrink: 0;
}

.innovative-recall-badge:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 22px rgba(2, 132, 199, 0.25), 0 0 12px rgba(16, 185, 129, 0.2);
    border-color: #0284c7;
}

.innovative-recall-badge .recall-orbit-ring {
    animation: recallOrbitRotate 14s linear infinite;
    transform-origin: 16px 16px;
}

.innovative-recall-badge:hover .recall-orbit-ring {
    animation-duration: 4s;
}

@keyframes recallOrbitRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.recall-live-node {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
    animation: liveNodePulse 2s ease-in-out infinite;
}

@keyframes liveNodePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.75; }
}

/* ==========================================================================
   Enterprise Data Grid: Density & Responsive Hybrid Card System
   ========================================================================== */

/* 1. Tabular Figures */
.tabular-nums {
    font-variant-numeric: tabular-nums !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* 2. Density & View Toolbars */
.table-density-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px 4px;
}

.table-density-btn,
.table-view-toggle-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
    white-space: nowrap;
}

.table-density-btn:hover,
.table-view-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(2, 132, 199, 0.08);
}

.table-density-btn.active,
.table-view-toggle-btn.active {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(2, 132, 199, 0.25);
}

/* 3. Three-Tier Table Density System */
/* Compact Tier (~34px row height) */
.table-density-compact table.patients-modern-table tbody td,
.table-density-compact table#masterAgendaTable tbody td,
.table-density-compact table#ledgerMainTable tbody td,
.table-density-compact table#revVsExpensesMasterTable tbody td,
.table-density-compact table#inventoryMainTable tbody td,
.table-density-compact .expenses-table-responsive table tbody td {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.82rem !important;
}
.table-density-compact table.patients-modern-table thead th,
.table-density-compact table#masterAgendaTable thead th,
.table-density-compact table#ledgerMainTable thead th,
.table-density-compact table#revVsExpensesMasterTable thead th,
.table-density-compact table#inventoryMainTable thead th,
.table-density-compact .expenses-table-responsive table thead th {
    padding: 0.45rem 0.65rem !important;
    font-size: 0.74rem !important;
}
.table-density-compact .patient-cell-profile {
    gap: 0.45rem !important;
}
.table-density-compact .patient-avatar-box {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
}
.table-density-compact .patient-name-link {
    font-size: 0.84rem !important;
}
.table-density-compact .patient-row-btn {
    padding: 2px 6px !important;
    font-size: 0.72rem !important;
    height: 26px !important;
}
.table-density-compact .table-comm-btn {
    width: 22px !important;
    height: 22px !important;
}

/* Default Tier (~44px row height) */
.table-density-default table.patients-modern-table tbody td,
.table-density-default table#masterAgendaTable tbody td,
.table-density-default table#ledgerMainTable tbody td,
.table-density-default table#revVsExpensesMasterTable tbody td,
.table-density-default table#inventoryMainTable tbody td,
.table-density-default .expenses-table-responsive table tbody td {
    padding: 0.65rem 0.95rem !important;
    font-size: 0.875rem !important;
}
.table-density-default table.patients-modern-table thead th,
.table-density-default table#masterAgendaTable thead th,
.table-density-default table#ledgerMainTable thead th,
.table-density-default table#revVsExpensesMasterTable thead th,
.table-density-default table#inventoryMainTable thead th,
.table-density-default .expenses-table-responsive table thead th {
    padding: 0.7rem 0.95rem !important;
    font-size: 0.78rem !important;
}

/* Comfortable Tier (~54px row height) */
.table-density-comfortable table.patients-modern-table tbody td,
.table-density-comfortable table#masterAgendaTable tbody td,
.table-density-comfortable table#ledgerMainTable tbody td,
.table-density-comfortable table#revVsExpensesMasterTable tbody td,
.table-density-comfortable table#inventoryMainTable tbody td,
.table-density-comfortable .expenses-table-responsive table tbody td {
    padding: 0.95rem 1.15rem !important;
    font-size: 0.92rem !important;
}
.table-density-comfortable table.patients-modern-table thead th,
.table-density-comfortable table#masterAgendaTable thead th,
.table-density-comfortable table#ledgerMainTable thead th,
.table-density-comfortable table#revVsExpensesMasterTable thead th,
.table-density-comfortable table#inventoryMainTable thead th,
.table-density-comfortable .expenses-table-responsive table thead th {
    padding: 0.95rem 1.15rem !important;
    font-size: 0.82rem !important;
}
.table-density-comfortable .patient-avatar-box {
    width: 38px !important;
    height: 38px !important;
    font-size: 0.92rem !important;
}
.table-density-comfortable .patient-row-btn {
    padding: 5px 10px !important;
    font-size: 0.82rem !important;
    height: 32px !important;
}

/* 4. Hybrid Mobile Cards vs Desktop Table Visibility */
.patient-mobile-card-col,
.agenda-mobile-card-col,
.ledger-mobile-card-col,
.expense-mobile-card-col,
.inventory-mobile-card-col {
    display: none !important;
}

@media (max-width: 768px) {
    .patients-table-responsive.hybrid-card-mode table.patients-modern-table,
    .agenda-table-responsive.hybrid-card-mode table#masterAgendaTable,
    .ledger-table-responsive.hybrid-card-mode table#ledgerMainTable,
    .expenses-table-responsive.hybrid-card-mode table,
    .inventory-table-responsive.hybrid-card-mode table#inventoryMainTable {
        display: block !important;
        border: none !important;
        width: 100% !important;
    }

    .patients-table-responsive.hybrid-card-mode thead,
    .agenda-table-responsive.hybrid-card-mode thead,
    .ledger-table-responsive.hybrid-card-mode thead,
    .expenses-table-responsive.hybrid-card-mode thead,
    .inventory-table-responsive.hybrid-card-mode thead {
        display: none !important;
    }

    .patients-table-responsive.hybrid-card-mode tbody,
    .agenda-table-responsive.hybrid-card-mode tbody,
    .ledger-table-responsive.hybrid-card-mode tbody,
    .expenses-table-responsive.hybrid-card-mode tbody,
    .inventory-table-responsive.hybrid-card-mode tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.65rem !important;
        width: 100% !important;
        padding: 0.25rem 0 !important;
    }

    .patients-table-responsive.hybrid-card-mode tr.patient-table-row,
    .agenda-table-responsive.hybrid-card-mode tr.agenda-table-row,
    .ledger-table-responsive.hybrid-card-mode tr.ledger-table-row,
    .expenses-table-responsive.hybrid-card-mode tr.expense-table-row,
    .inventory-table-responsive.hybrid-card-mode tr.inventory-table-row {
        display: block !important;
        background: var(--bg-surface) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 10px !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04) !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
        overflow: hidden !important;
    }

    .patients-table-responsive.hybrid-card-mode tr.patient-table-row:hover,
    .agenda-table-responsive.hybrid-card-mode tr.agenda-table-row:hover,
    .ledger-table-responsive.hybrid-card-mode tr.ledger-table-row:hover,
    .expenses-table-responsive.hybrid-card-mode tr.expense-table-row:hover,
    .inventory-table-responsive.hybrid-card-mode tr.inventory-table-row:hover {
        transform: translateY(-1px) !important;
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
    }

    .patients-table-responsive.hybrid-card-mode .patient-desktop-col,
    .agenda-table-responsive.hybrid-card-mode .agenda-desktop-col,
    .ledger-table-responsive.hybrid-card-mode .ledger-desktop-col,
    .expenses-table-responsive.hybrid-card-mode .expense-desktop-col,
    .inventory-table-responsive.hybrid-card-mode .inventory-desktop-col {
        display: none !important;
    }

    .patients-table-responsive.hybrid-card-mode .patient-mobile-card-col,
    .agenda-table-responsive.hybrid-card-mode .agenda-mobile-card-col,
    .ledger-table-responsive.hybrid-card-mode .ledger-mobile-card-col,
    .expenses-table-responsive.hybrid-card-mode .expense-mobile-card-col,
    .inventory-table-responsive.hybrid-card-mode .inventory-mobile-card-col {
        display: block !important;
        padding: 0.85rem 0.95rem !important;
        border: none !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Patient Hybrid Card Inner Layout */
    .patient-card-inner {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        width: 100%;
    }

    .patient-card-line-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .patient-card-id-name {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        flex: 1;
        min-width: 0;
    }

    .patient-card-name {
        font-weight: 800;
        font-size: 0.95rem;
        color: var(--text-primary);
        cursor: pointer;
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .patient-card-name:hover {
        color: var(--brand-primary);
    }

    .patient-card-quick-comm {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        flex-shrink: 0;
    }

    .patient-card-line-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }

    .patient-card-subtext {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        font-size: 0.78rem;
        color: var(--text-muted);
        flex-wrap: wrap;
    }

    .patient-card-actions {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        flex-shrink: 0;
    }

    /* Agenda Hybrid Card Inner Layout */
    .agenda-card-inner {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        width: 100%;
    }

    .agenda-card-line-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .agenda-card-time-date {
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        font-weight: 800;
        color: var(--brand-primary);
        font-size: 0.88rem;
    }

    .agenda-card-line-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }

    .agenda-card-actions {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    /* Ledger Hybrid Card Inner Layout */
    .ledger-card-inner {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        width: 100%;
    }

    .ledger-card-line-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .ledger-card-line-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }

    /* Expense Hybrid Card Inner Layout */
    .expense-card-inner {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        width: 100%;
    }

    .expense-card-line-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .expense-card-line-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }

    /* Inventory Hybrid Card Inner Layout */
    .inventory-card-inner {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        width: 100%;
    }

    .inventory-card-line-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .inventory-card-line-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        border-top: 1px dashed var(--border-color);
        padding-top: 0.5rem;
    }
}

/* ==========================================================================
   Universal Enterprise Card & Micro-Metric Formatting System (نظام الكروت الشامل)
   ========================================================================== */

/* 1. Universal Card Elevation & Surface Polish */
.home-card,
.glass-card,
.income-source-card,
.settings-card,
.patient-info-card,
.diag-item-card,
.dmft-stat-card,
.odontogram-inspector-card,
.toggle-switch-card,
.appt-kpi-clickable-card,
.recalls-section-card,
.weekly-overview-card {
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 3px 8px -2px rgba(0, 0, 0, 0.02) !important;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.22s ease !important;
}

/* Tactile & Smooth Hover Micro-Lift */
.home-card:hover,
.glass-card:hover,
.income-source-card:hover,
.settings-card:hover,
.patient-info-card:hover,
.appt-kpi-clickable-card:hover,
.diag-item-card:hover,
.dmft-stat-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 22px -4px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(2, 132, 199, 0.35) !important;
}

/* 2. Universal Tabular Figures for All Financial & Quantitative Metrics */
.stat-value,
.income-source-amount,
.kpi-val-appts,
.kpi-val-patients,
.kpi-val-revenue,
.kpi-val-stock,
.dmft-val,
.tabular-nums,
[id^="kpi"],
[id^="revChartKpi"],
[id^="revExpStrip"],
[id^="invKpi"],
[id^="srcTotal-"],
[id^="srcCount-"],
#ledger-today-revenue,
#ledger-month-revenue,
#ledger-outstanding,
#expensesTableTotalAmount {
    font-variant-numeric: tabular-nums !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
    letter-spacing: -0.02em !important;
}

/* 3. Refined Typographic Hierarchy for Card Stat Labels */
.stat-label {
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
    letter-spacing: normal !important;
    line-height: 1.35 !important;
    margin-bottom: 2px !important;
}

.stat-value {
    font-size: 1.75rem !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    line-height: 1.2 !important;
    margin: 0.3rem 0 0.25rem 0 !important;
}

/* 4. Income Source Channel Cards Refinement */
.income-sources-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)) !important;
    gap: 0.85rem !important;
}

.income-source-card {
    padding: 0.95rem 1.15rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.35rem !important;
    position: relative !important;
    overflow: hidden !important;
}

.income-source-card .income-source-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    font-size: 0.82rem !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
}

.income-source-card .income-source-amount {
    font-size: 1.35rem !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    margin: 0.25rem 0 0.15rem 0 !important;
}

.income-source-card .income-source-sub {
    font-size: 0.76rem !important;
    color: var(--text-muted) !important;
    opacity: 0.85 !important;
}

/* 5. Icon Squircle Boxes Inside KPI Cards */
.home-card [style*="border-radius: 10px"],
.kpi-icon-wrapper {
    border-radius: 10px !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease !important;
    flex-shrink: 0 !important;
}

.home-card:hover [style*="border-radius: 10px"],
.home-card:hover .kpi-icon-wrapper {
    transform: scale(1.08) translateY(-1px) !important;
}

/* 6. Settings Modules & Card Headers */
.settings-card {
    padding: 1.4rem 1.6rem !important;
    margin-bottom: 1.25rem !important;
}

.settings-card-header {
    margin-bottom: 1rem !important;
    padding-bottom: 0.75rem !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.settings-card-header h3 {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
}

/* 7. Patient Profile Widget & Odontogram Cards */
.patient-info-card {
    padding: 1.15rem 1.35rem !important;
}

.dmft-stat-card {
    padding: 0.85rem 1rem !important;
    text-align: center !important;
}

.dmft-stat-card .dmft-val {
    font-size: 1.6rem !important;
    font-weight: 800 !important;
    color: var(--brand-primary) !important;
}

/* 8. Mobile Breakpoint (< 768px) Card Padding Optimization */
@media (max-width: 768px) {
    .home-card,
    .glass-card,
    .settings-card,
    .patient-info-card {
        padding: 0.95rem 1rem !important;
        border-radius: 10px !important;
    }

    .stat-value {
        font-size: 1.45rem !important;
    }

    .income-source-card {
        padding: 0.8rem 0.9rem !important;
    }

    .income-source-card .income-source-amount {
        font-size: 1.15rem !important;
    }

    /* Patients Directory Mobile Responsive Layout */
    .patients-card-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.85rem !important;
        border-radius: 12px !important;
        overflow: hidden !important;
    }

    .patients-card-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.85rem !important;
    }

    .patients-card-title-group {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .patients-header-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }

    .patients-quick-filter-bar {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        padding-bottom: 4px !important;
        gap: 0.35rem !important;
    }

    .patients-filter-pill-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        font-size: 0.78rem !important;
        padding: 0.35rem 0.65rem !important;
    }

    .patient-search-container {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .patient-search-container > div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.65rem !important;
    }

    .patient-search-container input,
    .patient-search-container select {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}

/* ==========================================================================
   DEVICE-SPECIFIC RESPONSIVE SCROLL & INTERACTION CONSTITUTION (MOLARIZE)
   ========================================================================== */

/* ----------------------------------------------------
   1. TABLET UX ("Doctor at Dental Chair" / Touch & Swipe)
   ---------------------------------------------------- */
@media (min-width: 640px) and (max-width: 1024px) {
    /* Horizontal Snap Scroll for Calendar & Appointments */
    .snap-scroll-x,
    .agenda-dual-grid,
    .cal-week-grid,
    .xray-gallery-container,
    .treatment-timeline-scroll {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: smooth !important;
        gap: 1rem !important;
        padding-bottom: 0.75rem !important;
    }

    .snap-scroll-x > *,
    .agenda-dual-grid > *,
    .xray-gallery-card,
    .snap-card {
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
        flex-shrink: 0 !important;
    }

    /* Off-canvas Collapsible Sidebar on Tablet */
    .sidebar {
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
        will-change: transform;
    }

    /* Sticky Patient Agenda & Table Headers on Tablet */
    .table-container th,
    .patients-table th,
    .agenda-day-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 15 !important;
        background-color: var(--bg-surface) !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.04) !important;
    }
}

/* ----------------------------------------------------
   2. MOBILE UX ("Fast & Thumb-Friendly" / < 640px)
   ---------------------------------------------------- */
@media (max-width: 639px) {
    /* Table Horizontal Scroll Container */
    .table-responsive,
    .table-container,
    .invoice-table-responsive,
    .patients-table-responsive,
    .agenda-table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y !important;
        overscroll-behavior-x: contain !important;
        border-radius: 10px !important;
        box-sizing: border-box !important;
    }

    .table-responsive table,
    .table-container table,
    .patients-modern-table {
        min-width: 680px !important;
    }

    /* Bottom Sticky Action Bar for Thumb Reachability */
    .bottom-sticky-actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 9990 !important;
        background: rgba(15, 23, 42, 0.88) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
        padding: 0.65rem 1rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.5rem !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2) !important;
    }

    [data-theme="light"] .bottom-sticky-actions {
        background: rgba(255, 255, 255, 0.92) !important;
        border-top-color: rgba(0, 0, 0, 0.1) !important;
    }

    /* Disable heavy fixed attachment and parallax effects on mobile for 60fps scrolling */
    .parallax-element,
    body {
        background-attachment: scroll !important;
    }

    /* Infinite / Progressive list container styling */
    .infinite-scroll-container {
        max-height: 70vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Floating Action Buttons (FAB) on Mobile */
    .mobile-fab-btn {
        position: fixed !important;
        bottom: 1.25rem !important;
        inset-inline-end: 1.25rem !important;
        z-index: 9995 !important;
        width: 54px !important;
        height: 54px !important;
        border-radius: 50% !important;
        background: var(--brand-primary) !important;
        color: #ffffff !important;
        box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.4rem !important;
        border: none !important;
        cursor: pointer !important;
    }
}

/* ----------------------------------------------------
   3. DESKTOP UX ("Productivity & High Data Density" / > 1024px)
   ---------------------------------------------------- */
@media (min-width: 1025px) {
    /* Double Sticky Header (Top Nav + Table Header) */
    .main-header,
    .top-nav {
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: var(--bg-surface) !important;
        backdrop-filter: blur(10px) !important;
    }

    .table-container th,
    .patients-table th,
    .inventory-table th {
        position: sticky !important;
        top: 64px !important;
        z-index: 90 !important;
        background: var(--bg-surface) !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
    }

    /* Zoom-on-Scroll Viewer for Dental Chart & Panoramic X-rays */
    .zoom-scroll-viewer {
        overflow: hidden !important;
        position: relative !important;
        cursor: grab !important;
        user-select: none !important;
    }

    .zoom-scroll-viewer:active {
        cursor: grabbing !important;
    }

    .zoom-scroll-target {
        transition: transform 0.1s ease-out !important;
        transform-origin: center center !important;
        will-change: transform !important;
    }
}

/* Universal Custom Smooth Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}






/* ==========================================================================
   Clinic Profile & Branding - Mobile & Responsive Layout Optimization
   ========================================================================== */
.branding-layout-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 1.5rem;
    align-items: start;
    width: 100%;
}

.branding-preview-col {
    position: sticky;
    top: 85px;
    z-index: 10;
}

.watermark-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: center;
}

.time-offset-controls-wrap {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

/* Document Type Sub-Tabs inside Live Preview */
.preview-type-btn {
    min-height: 38px;
    touch-action: manipulation;
}

/* Tablet & Mobile Screens (<= 992px) */
@media (max-width: 992px) {
    .branding-layout-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem;
    }

    .branding-preview-col {
        position: static !important;
        top: auto !important;
        order: 2; /* Preview sits cleanly below the form */
        width: 100%;
    }
}

/* Mobile Screens (<= 768px) */
@media (max-width: 768px) {
    #tab-settings-branding {
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    #tab-settings-branding .settings-card {
        padding: 1rem !important;
        border-radius: 12px;
        margin-bottom: 1.25rem;
    }

    #tab-settings-branding .settings-card-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    #tab-settings-branding .settings-card-header > div:last-child {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.6rem !important;
    }

    #tab-settings-branding .settings-card-header button {
        width: 100% !important;
        justify-content: center !important;
        min-height: 44px;
        font-size: 0.9rem !important;
    }

    /* Form Section Groups */
    #tab-settings-branding div[style*="border-radius: 12px"] {
        padding: 0.85rem !important;
        margin-bottom: 1.2rem !important;
    }

    /* Watermark Controls in Single Column on Mobile */
    .watermark-settings-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    /* Live Google Clock Container */
    #tab-settings-branding div[style*="linear-gradient"] {
        padding: 0.85rem !important;
    }

    #liveSettingsClockText {
        font-size: 1.35rem !important;
    }

    /* Time Offset Controls */
    .time-offset-controls-wrap {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }

    .time-offset-controls-wrap #settingTimeOffsetMinutes {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        min-height: 42px;
    }

    .time-offset-controls-wrap button {
        min-height: 40px;
        font-size: 0.8rem !important;
        padding: 0.5rem 0.4rem !important;
        text-align: center;
        justify-content: center;
    }

    .time-offset-controls-wrap button:last-child {
        grid-column: 1 / -1 !important;
    }

    /* Live Preview Paper Canvas */
    #liveStationeryPaperCanvas {
        min-height: 420px !important;
        padding: 12px !important;
        font-size: 0.85rem !important;
        transform-origin: top center;
        overflow-x: auto !important;
        border-width: 1.5px !important;
    }

    /* Color Palette Picker */
    #tab-settings-branding .brand-color-chip {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
    }

    /* Print Setting Toggles Grid */
    #tab-settings-branding .toggle-switch-card {
        padding: 0.75rem !important;
        width: 100% !important;
    }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
    #tab-settings-branding .settings-card {
        padding: 0.75rem !important;
    }

    #liveStationeryPaperCanvas {
        min-height: 380px !important;
        padding: 10px !important;
    }

    .time-offset-controls-wrap {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   MOLARIZE MOBILE UX CONSTITUTION & PWA STYLES
   ========================================================================== */

/* 1. Offline Connectivity Banner */
.pwa-offline-banner,
.modal-offline-warning {
    display: none !important;
}

.pwa-offline-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-offline-pulse {
    width: 8px;
    height: 8px;
    background-color: #ffffff;
    border-radius: 50%;
    animation: offlinePulse 1.5s infinite;
}

@keyframes offlinePulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* 2. Mobile Bottom Navigation Bar (< 768px) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 9800;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.5rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex !important;
    }
    
    /* Adjust main layout bottom padding to clear the mobile bottom bar */
    main, .main-content, body {
        padding-bottom: 70px !important;
    }

    .mobile-only-sticky-bar {
        bottom: 64px !important; /* Sit above bottom nav */
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    transition: color 0.2s ease, transform 0.2s ease;
    border: none;
    background: none;
    cursor: pointer;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item .mobile-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.mobile-nav-item.active {
    color: var(--brand-primary);
    font-weight: 800;
}

.mobile-nav-item.active .mobile-nav-icon {
    transform: translateY(-2px) scale(1.1);
}

/* Speed Dial FAB in Bottom Nav */
.mobile-speed-dial-btn {
    position: relative;
    top: -16px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--accent-cta));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
    border: 3px solid var(--bg-surface);
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mobile-speed-dial-btn.open {
    transform: rotate(45deg) scale(1.05);
}

/* Speed Dial Popover Menu */
.mobile-speed-dial-menu {
    display: none;
    position: fixed;
    bottom: 82px;
    left: 50%;
    transform: translateX(-50%) translateY(20px) scale(0.95);
    z-index: 9850;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 0.75rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    width: 280px;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.mobile-speed-dial-menu.show {
    display: flex !important;
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.mobile-speed-dial-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.mobile-speed-dial-item:active {
    transform: scale(0.97);
    background: rgba(56, 189, 248, 0.12);
}

.mobile-speed-dial-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--brand-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* 3. Mobile Bottom Sheets for Modals (< 640px) */
@media (max-width: 640px) {
    .modal .modal-content {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 22px !important;
        border-top-right-radius: 22px !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        animation: slideUpBottomSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        padding-top: 2rem !important;
    }

    .modal .modal-content::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 42px;
        height: 5px;
        background: var(--border-color);
        border-radius: 10px;
    }

    @keyframes slideUpBottomSheet {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

/* 4. Touch Target Optimizations */
button, input, select, textarea, .sidebar-link, .mobile-nav-item {
    min-height: 42px; /* Touch friendly minimum height */
}

/* Touch feedback ripple effect */
.touch-active {
    opacity: 0.82;
    transform: scale(0.98);
}

/* ==========================================================================
   MOBILE OPTIMIZATIONS FOR PATIENTS DIRECTORY & PATIENT PROFILE CARDS
   ========================================================================== */

/* 1. Patients Table & Records Directory Mobile Responsiveness (< 768px) */
@media (max-width: 768px) {
    #patients-section {
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .patient-search-container {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .patient-search-container > div {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.6rem !important;
    }

    .patient-search-container input,
    .patient-search-container select {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .patients-card-wrapper {
        border-radius: 12px !important;
        margin-top: 0.85rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    .patients-card-header {
        padding: 0.85rem 1rem !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .patients-card-title-group {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .patients-header-controls {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .patients-quick-filter-bar {
        padding: 0.6rem 0.85rem !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        -webkit-overflow-scrolling: touch;
    }

    .patients-table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
    }

    .patients-modern-table {
        min-width: 580px !important;
    }

    .patients-modern-table thead th {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.74rem !important;
    }

    .patients-modern-table tbody td {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.82rem !important;
    }

    .patient-avatar-box {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        font-size: 0.78rem !important;
    }

    .patient-name-link {
        font-size: 0.88rem !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .patient-primary-phone {
        font-size: 0.8rem !important;
    }

    .table-comm-btn {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.75rem !important;
    }

    #patientsPaginationContainer {
        padding: 0.75rem 0.85rem !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.6rem !important;
        text-align: center !important;
    }
}

/* 2. Patient Profile Card (`.patient-info-card`) Mobile Optimization (< 640px) */
@media (max-width: 640px) {
    #patient-profile-section {
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .patient-info-card {
        padding: 0.85rem 0.9rem !important;
        border-radius: 14px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.85rem !important;
    }

    .patient-info-card > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
        gap: 0.75rem !important;
    }

    .patient-avatar {
        width: 52px !important;
        height: 52px !important;
        font-size: 1.5rem !important;
    }

    #profilePatientName {
        font-size: 1.2rem !important;
        word-break: break-word !important;
    }

    /* Sub-details grid on mobile */
    .patient-info-card div[style*="display: flex; gap: 1.5rem"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem 0.75rem !important;
        width: 100% !important;
        font-size: 0.84rem !important;
        padding: 0.6rem !important;
        background: var(--bg-primary);
        border-radius: 10px;
        border: 1px solid var(--border-color);
        box-sizing: border-box !important;
    }

    /* Contact Links row (Call & WhatsApp) on mobile */
    .patient-info-card div[style*="display: flex; gap: 0.5rem; margin-top: 0.55rem"] {
        display: flex !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .patient-info-card #profileCallLink,
    .patient-info-card #profileWaLink {
        flex: 1 !important;
        justify-content: center !important;
        padding: 0.5rem !important;
        min-height: 40px !important;
        font-size: 0.88rem !important;
        font-weight: 700 !important;
    }

    /* Top Status Bar & Alerts */
    .patient-top-status-bar {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .profile-alert-compact {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* AI Logo Color Palette & Themes Hub Styles */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.ai-theme-card {
    transition: all 0.25s ease;
}

.ai-theme-card:hover {
    border-color: var(--brand-primary) !important;
}


