:root {
        /* Professional Color Palette - Darker, Muted Blue and Grey */
        --primary-color: #2c5282; 
        --primary-dark: #2a4365;  
        --primary-light: #ebf8ff; 
        --secondary-color: #4A5568; 
        --secondary-dark: #2D3748; 
        
        /* ✨ NEW: Clinical Teal-Tinted Off-Whites for the background */
        --secondary-light: #f1f5f9; 
        --light-gray: #eff5f5; /* Subtle clinical teal tint instead of flat gray */
        
        /* Supporting Colors */
        --success-color: #0d9488; 
        --success-dark: #0f766e;  
        --warning-color: #F59E0B; 
        --danger-color: #EF4444;  
        
        /* Typography & UI Colors */
        --dark-color: #1A202C;    
        --gray-color: #4A5568;    
        --border-color: #cbd5e1; /* Deepened slightly so edges don't vanish on desktop */  
        --white: #ffffff;
        
        /* UI Metrics */
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        /* ✨ UPGRADED: Desktop-Safe Premium Teal-Tinted Shadows */
        --shadow: 0 4px 12px rgba(13, 148, 136, 0.08), 0 2px 4px rgba(13, 148, 136, 0.04);
        --shadow-hover: 0 12px 24px rgba(13, 148, 136, 0.15), 0 6px 12px rgba(13, 148, 136, 0.08);
        --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
        --radius: 8px;
        --radius-lg: 12px;
} /* ✨ CRITICAL FIX: The root block MUST close here! */

/* ✨ Visibly Soft Color Classes for Patient Action Buttons */
.btn-primary { /* Save Treatment */
    background-color: #ccfbf1 !important; /* Deniable soft teal base */
    color: #115e59 !important; 
    border: 1px solid #5eead4 !important; 
    font-weight: 600 !important;
}
.btn-primary:hover { background-color: #99f6e4 !important; }

.btn-success { /* Digital Rx */
    background-color: #d1fae5 !important; /* Soft green base */
    color: #065f46 !important; 
    border: 1px solid #6ee7b7 !important; 
    font-weight: 600 !important;
}
.btn-success:hover { background-color: #a7f3d0 !important; }

.btn-warning { /* Update Treatment */
    background-color: #fef3c7 !important; /* Soft amber base */
    color: #92400e !important; 
    border: 1px solid #fcd34d !important; 
    font-weight: 600 !important;
}
.btn-warning:hover { background-color: #fde68a !important; }

/* ✨ UPGRADED: Soft Blue Background with Branded Navy Blue Text & Border */
.btn-info { 
    background-color: #e0f2fe !important; /* Kept the light blue background you liked */
    color: var(--primary-color) !important; /* Deep Navy Blue from your Dentle logo */
    border: 1px solid var(--primary-color) !important; /* Matching Navy Blue border */
    font-weight: 600 !important;
}
.btn-info:hover { 
    background-color: #bae6fd !important; 
}

/* ✨ NEW: Visible Slate/Grey for Invoice & Blank Rx */
.btn-secondary-soft { 
    background-color: #e2e8f0 !important; 
    color: #334155 !important; 
    border: 1px solid #94a3b8 !important; 
    font-weight: 600 !important;
}
.btn-secondary-soft:hover { background-color: #cbd5e1 !important; }

/* ✨ NEW: Solid, Premium Dark Shades for Bottom Anchor CTAs */
.btn-solid-primary {
    background-color: var(--primary-color) !important; /* Rich Clinic Teal */
    color: var(--white) !important;
    border: 1px solid var(--primary-dark) !important;
    font-weight: 500 !important; /* Toned down to match other buttons */
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.2) !important;
}
.btn-solid-primary:hover { 
    background-color: var(--primary-dark) !important; 
}

.btn-solid-slate {
    background-color: #475569 !important; /* Sophisticated Slate Grey */
    color: #ffffff !important;
    border: 1px solid #334155 !important;
    font-weight: 500 !important;
    box-shadow: 0 2px 4px rgba(71, 85, 105, 0.2) !important;
}
.btn-solid-slate:hover { 
    background-color: #334155 !important; 
}

/* ✨ NEW: True Solid Teal for the Primary CTA */
.btn-solid-teal {
    background-color: var(--success-color) !important; /* Your actual #0d9488 Teal */
    color: var(--white) !important;
    border: 1px solid var(--success-dark) !important;
    font-weight: 500 !important;
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.2) !important;
}
.btn-solid-teal:hover { 
    background-color: var(--success-dark) !important; 
}

/* ✨ NEW: Modern Minimalist Card Interactions & Explicit Borders */
.card {
    border: 1px solid var(--border-color) !important; /* ✨ The missing thin gray border! */
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    box-shadow: var(--shadow) !important;
}
.card:hover {
    box-shadow: var(--shadow-hover) !important;
    transform: translateY(-2px); /* Slight lift effect */
}

/* Keep the master card grounded */
.reports-master-card:hover {
    transform: none; 
    box-shadow: var(--shadow) !important;
}

    * { margin: 0; padding: 0; box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    
    body {
        font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
        /* ✨ Applied subtle clinical teal tint to the whole app body */
        background-color: var(--light-gray); 
        min-height: 100vh;
        color: var(--dark-color);
        line-height: 1.6;
    }

    /* Main Container */
    .main-container {
        max-width: 1440px;
        margin: 0 auto;
        background: var(--white);
        min-height: 100vh;
        box-shadow: var(--shadow-xl);
    }

    /* ==========================================
       PREMIUM BACKGROUND: PERFECT EDGE BLEND & DROP SHADOW
       ========================================== */
    .header {
        background-color: #F0F0F0 !important;
        color: var(--primary-dark);
        position: relative;
        overflow: hidden; 
        z-index: 50; 
        /* ✨ SURGICAL FIX: Darkened to a smokey shadow for clear separation */
        box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.15);
        margin-bottom: 0 !important; 
    }

    .header::before {
        content: ''; 
        position: absolute; 
        top: 0; right: 0; bottom: 0; left: 0;
        background-image: url('https://i.postimg.cc/jShSBF5r/Gemini-Generated-Image-ss3x8iss3x8iss3x-(1).png') !important; 
        background-size: contain !important; 
        background-position: center right !important; 
        background-repeat: no-repeat !important;
        z-index: -1 !important; 
        -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,1) 200px, rgba(0,0,0,0) 980px);
        mask-image: linear-gradient(to left, rgba(0,0,0,1) 200px, rgba(0,0,0,0) 980px);
    }

    .header::after,
    .header-content::before,
    .header-content::after {
        display: none !important;
    }

    .header-content {
        position: relative; z-index: 10 !important; 
        display: flex; align-items: center; justify-content: space-between; 
        max-width: 1200px; margin: 0 auto;
    }
    
    /* ==========================================
       BULLETPROOF SQUARE LOGO VIDEO CONTAINER
       ========================================== */
    .clinic-logo {
        width: 150px !important; 
        height: 150px !important; 
        min-width: 150px !important; 
        min-height: 150px !important;
        max-width: 150px !important; 
        max-height: 150px !important;
        background: transparent; 
        border-radius: 0;
        padding: 0; 
        box-shadow: none; 
        display: block !important; 
        position: relative !important;
        flex-shrink: 0 !important; 
        overflow: hidden !important; 
    }
    
    .clinic-logo video,
    .clinic-logo img { 
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important; 
        height: 100% !important; 
        object-fit: contain !important; 
        object-position: center !important; 
    }

    .clinic-logo video {
        transform: translateZ(0) !important; 
        -webkit-transform: translateZ(0) !important;
        backface-visibility: hidden !important;
    }

    .header-branding { display: flex; align-items: center; gap: 1.5rem; }
    .header-text { text-align: left; }
    .header h1 {
        font-family: 'Plus Jakarta Sans', sans-serif; font-size: 3.5rem; font-weight: 800;
        margin-bottom: -0.5rem; color: var(--primary-dark); text-shadow: none;
    }
    
    .header .subtitle { 
        font-size: 0.95rem; font-weight: 600; 
        color: var(--success-dark); 
        text-align: left; letter-spacing: 0.5px; 
    }
    .header .floating-tagline {
        font-family: 'EB Garamond', serif; position: absolute; bottom: -15px; left: 55%; 
        font-size: 1.5rem; font-style: italic; opacity: 0.7; color: #334155; white-space: nowrap;
    }

    .doctor-info {
        position: absolute; top: 1.0rem; right: 1.5rem; text-align: right;
        font-size: 1rem; color: var(--secondary-dark); z-index: 1;
    }
    .doctor-info .clinic-name { font-weight: 700; font-size: 1.1rem; color: var(--primary-dark); }

    /* ==========================================
       PREMIUM SEGMENTED NAVIGATION
       ========================================== */
    .nav-wrapper {
        display: flex;
        justify-content: center;
        padding: 1.5rem 0 0 0;
        background-color: var(--light-gray) !important; 
        margin-top: 0 !important;
        border-top: none !important; 
        border-bottom: none !important; 
        box-shadow: none; 
        margin-bottom: 0 !important;
        width: 100%;
        overflow-x: auto; 
        position: relative;
        z-index: 10; 
    }

    .nav-tabs {
        display: flex;
        background-color: #e2e8f0 !important; 
        padding: 0.4rem;
        border-radius: 1rem; 
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04); 
        gap: 0.2rem; 
        border: none !important;
        margin: 0 auto;
        white-space: nowrap; 
    }

    .nav-tabs .nav-tab {
        background: transparent;
        border: none; 
        padding: 0.75rem 1.5rem;
        border-radius: 0.75rem; 
        font-family: 'Plus Jakarta Sans', sans-serif;
        font-weight: 600;
        font-size: 0.95rem;
        color: #64748b; 
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.6rem;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-tabs .nav-tab:hover:not(.active) {
        color: #334155; 
        background-color: rgba(255, 255, 255, 0.3); 
    }

    .nav-tabs .nav-tab.active {
        background-color: #ffffff !important; 
        border-color: #ffffff !important; 
        color: var(--primary-dark) !important; 
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 
                    0 2px 4px -1px rgba(0, 0, 0, 0.04),
                    0 0 0 1px rgba(0, 0, 0, 0.02) !important; 
    }
    
    .nav-tabs .nav-tab .icon { font-size: 1.1rem; line-height: 1; }

    /* Content Area */
    .content { padding: 1.5rem 2rem 2rem 2rem; min-height: calc(100vh - 200px); background: var(--light-gray); }
    .tab-content { display: none; animation: fadeIn 0.3s ease; }
    .tab-content.active { display: block; }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

    .dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 1.5rem; }

    /* ==========================================
       MODERN, CRISP PREMIUM CARDS
       ========================================== */
    .card {
        background: var(--white); 
        border-radius: 16px; 
        padding: 1.5rem; 
        border: 1px solid #e2e8f0; 
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); 
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .card:hover { 
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04); 
        transform: translateY(-2px); 
    }
    .card h2 {
        color: var(--primary-dark); 
        font-family: 'Plus Jakarta Sans', 'Montserrat', sans-serif; 
        font-size: 1.15rem;
        font-weight: 700; 
        margin-bottom: 1.25rem; 
        padding-bottom: 0.75rem;
        border-bottom: 1px solid #e2e8f0; 
        display: flex; align-items: center; gap: 0.75rem;
    }

    /* ==========================================
       TINTED MONOCHROMATIC BUTTONS 
       ========================================== */
    .btn {
        background-color: #f0f9ff; 
        /* ✨ SURGICAL FIX: Text color matched back to your exact header brand color */
        color: var(--primary-dark); 
        border: 1px solid rgba(3, 105, 161, 0.15); 
        padding: 0.6rem 1.5rem; 
        border-radius: 6px; 
        cursor: pointer; 
        font-size: 0.9rem; 
        font-weight: 600; 
        letter-spacing: 0.3px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
        display: inline-flex;
        align-items: center; 
        justify-content: center; 
        gap: 0.6rem; 
        margin: 0.25rem;
        min-width: 140px; 
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    }
    .btn:hover { 
        background-color: #e0f2fe; 
        transform: translateY(-1px); 
        box-shadow: 0 3px 6px rgba(3, 105, 161, 0.08); 
    }
    .btn:disabled { background: var(--border-color); color: var(--secondary-color); cursor: not-allowed; opacity: 0.7; box-shadow: none; border: none; }
    .btn:active { transform: translateY(0); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
    
    /* 🛠 PRE-BUILT CLASSES FOR THE PATIENT PAGE (Ready for HTML) 🛠 */
    
    /* Update Treatment (Mint Green) */
    .btn-mint { background-color: #d1fae5 !important; color: #065f46 !important; border: 1px solid #34d399 !important; }
    .btn-mint:hover { background-color: #a7f3d0 !important; }

    /* Digital RX (Light Purple) */
    .btn-purple { background-color: #f3e8ff !important; color: #6b21a8 !important; border: 1px solid #d8b4fe !important; }
    .btn-purple:hover { background-color: #e9d5ff !important; }

    /* Book Next Appointment (White/Outline) */
    .btn-white { background-color: #ffffff !important; color: var(--primary-dark) !important; border: 1px solid #cbd5e1 !important; }
    .btn-white:hover { background-color: #f8fafc !important; border-color: var(--primary-color) !important; }

    /* Generate Invoice (Soft Amber/Gold) */
    .btn-amber { background-color: #fef3c7 !important; color: #92400e !important; border: 1px solid #fcd34d !important; }
    .btn-amber:hover { background-color: #fde68a !important; }
    
    .btn-small { padding: 0.5rem 1rem; font-size: 0.85rem; min-width: 100px; }
    
    .btn-remove, .btn-delete {
        background-color: #f1f5f9; border: 1px solid #e2e8f0; color: var(--secondary-dark);
        font-family: sans-serif; font-size: 1.2rem; font-weight: bold; line-height: 1; padding: 0;
        cursor: pointer; border-radius: 50%; transition: all 0.2s ease; width: 28px; height: 28px;
        display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm);
    }
    .btn-remove:hover, .btn-delete:hover { background-color: #ffe4e6; color: #be123c; border-color: rgba(190, 18, 60, 0.15); }
    .btn-delete { width: 36px; height: 36px; border-radius: 50%; }

    /* ==========================================
       TACTILE INPUT GROUPS & SEARCH
       ========================================== */
    .input-group { margin-bottom: 1.25rem; }
    .input-group label { display: block; margin-bottom: 0.5rem; color: var(--secondary-dark); font-weight: 500; font-size: 0.9rem; }
    .input-group input, .input-group select, .input-group textarea {
        width: 100%; padding: 0.75rem 1.2rem; 
        background: #ffffff;
        border: 1px solid #cbd5e1; 
        border-radius: 8px; 
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
        font-size: 0.95rem; transition: all 0.2s ease;
        font-family: inherit;
    }
    .input-group input:focus, .input-group select:focus, .input-group textarea:focus {
        outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-light);
    }
    .input-group input:disabled, .input-group input[readonly] { background: var(--light-gray); cursor: not-allowed; opacity: 0.7; }
    
    .search-input {
        width: 100%; padding: 0.75rem 1.5rem; 
        background: #ffffff; 
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.03), 0 1px 2px rgba(0,0,0,0.02);
        font-size: 0.95rem; transition: all 0.2s ease;
        font-family: inherit;
    }
    .search-input:focus { outline: none; border-color: var(--primary-color); box-shadow: inset 0 1px 2px rgba(0,0,0,0.02), 0 0 0 3px var(--primary-light); }
    .search-container { display: flex; gap: 0.5rem; align-items: center; }
    .search-container .search-input { flex: 1; }
    textarea { resize: vertical; }
    #patient-history, #modal-history { min-height: 100px; }

    /* Lists & Grid Items */
    .search-results { margin-top: 1.5rem; max-height: 400px; overflow-y: auto; }
    .result-item {
        background: var(--white); padding: 1rem; border-radius: 10px; margin-bottom: 0.75rem;
        display: flex; justify-content: space-between; align-items: center; border: 1px solid #e2e8f0;
        transition: all 0.2s ease;
    }
    .result-item:hover { border-color: var(--primary-color); background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.04); }
    .result-info { flex: 1; }
    .result-info strong { display: block; color: var(--dark-color); font-size: 1rem; margin-bottom: 0.25rem; }
    .result-info small { color: var(--gray-color); font-size: 0.875rem; }

    .ongoing-list { max-height: 500px; overflow-y: auto; padding-right: 0.5rem; }
    
    /* Premium List Items (Ongoing Treatments) */
    .treatment-item {
        background: var(--white); padding: 1.25rem 1.5rem; border-radius: 12px; margin-bottom: 1rem;
        border-left: 4px solid var(--primary-color); 
        box-shadow: 0 2px 6px rgba(0,0,0,0.03); 
        border-top: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
        border-bottom: 1px solid #e2e8f0;
        transition: all 0.2s ease;
    }
    .treatment-item:hover { box-shadow: 0 6px 12px rgba(0,0,0,0.05); transform: translateX(2px); border-left-color: var(--primary-dark); }

    .patient-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }

    /* Treatment Blocks */
    .treatment-block h3 { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
    .treatment-block h3::after { content: '▲'; font-size: 0.9rem; transition: transform 0.4s ease-in-out; }
    .treatment-block.collapsed h3::after { transform: rotate(180deg); }
    .treatment-content { overflow: hidden; transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out, margin 0.4s ease-in-out; max-height: 50000px; }
    .treatment-block.collapsed .treatment-content { max-height: 0; margin-top: 0; padding-top: 0; padding-bottom: 0; }
    .treatment-block {
        background: var(--white); border-radius: 16px; padding: 1.75rem; margin-bottom: 1.5rem;
        border: 1px solid #e2e8f0; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }
    .treatment-block.is-dirty { border-color: var(--warning-color); box-shadow: 0 0 10px rgba(245, 158, 11, 0.2); }
    .treatment-block h3 {
        color: var(--dark-color); font-family: 'Plus Jakarta Sans', 'Montserrat', sans-serif; font-size: 1.25rem; font-weight: 700;
        margin-bottom: 1.75rem; padding-bottom: 1rem; border-bottom: 1px solid #e2e8f0;
    }
    .treatment-block h4 {
        color: var(--dark-color); margin: 1.5rem 0 1rem 0; font-size: 1rem; font-weight: 600;
        padding: 0.75rem 1rem; border-radius: var(--radius-lg);
    }
    .treatment-block h4:first-of-type { background: var(--primary-light); color: var(--primary-dark); }
    .treatment-block h4:last-of-type { background: var(--secondary-light); color: var(--secondary-dark); }

    /* Tables */
    table {
        width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 1rem;
        border-radius: var(--radius-lg); overflow: hidden; border: 1px solid #e2e8f0;
    }
    td, th { vertical-align: middle; }
    th {
        background: var(--light-gray); color: var(--secondary-dark); padding: 0.875rem; text-align: left;
        font-weight: 600; font-size: 0.85rem; font-family: 'Montserrat', sans-serif;
        text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #e2e8f0;
    }
    .visit-table th { background: var(--secondary-light); }
    td { padding: 0.75rem 0.875rem; background: var(--white); border-bottom: 1px solid #e2e8f0; font-size: 0.95rem; }
    td input, td select, td textarea { width: 100%; padding: 0.5rem; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.9rem; }
    tr:hover td { background: var(--light-gray); }
    tr:last-child td { border-bottom: none; }
    .total-row td { padding: 1rem 0.875rem; font-size: 1.05rem; color: var(--primary-dark); border-bottom: none; }
    .total-row-container {
        display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem;
        background: var(--primary-light); font-weight: 600; padding: 1rem 0.875rem;
        font-size: 1.05rem; color: var(--primary-dark); margin-top: 1rem; border-radius: var(--radius-lg);
    }
    .visit-details-textarea { resize: none; overflow-y: auto; max-height: 120px; }

    /* Status Badges */
    .status-badge {
        display: inline-block; padding: 0.35rem 0.75rem; border-radius: 20px;
        font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-family: 'Montserrat', sans-serif;
    }
    .status-ongoing { background: #ecfdf5; color: #15803d; border: 1px solid rgba(21, 128, 61, 0.15); }
    .status-closed { background: #fff1f2; color: #be123c; border: 1px solid rgba(190, 18, 60, 0.15); }
    .status-select-ongoing { background: #ecfdf5 !important; color: #15803d !important; border: 1px solid rgba(21, 128, 61, 0.15) !important; font-weight: 600; border-radius: 6px; }
    .status-select-closed { background: #fff1f2 !important; color: #be123c !important; border: 1px solid rgba(190, 18, 60, 0.15) !important; font-weight: 600; border-radius: 6px; }

    /* Modals & Utils */
    .modal {
        display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 1000; animation: fadeIn 0.3s ease;
    }
    .modal-content {
        position: relative; background: var(--white); margin: 3% auto; padding: 0;
        width: 90%; max-width: 800px; border-radius: 16px; max-height: 90vh;
        overflow: hidden; animation: slideIn 0.3s ease; box-shadow: var(--shadow-xl);
        display: flex; flex-direction: column;
    }
    .modal-header {
        background: var(--primary-color); color: var(--white); padding: 1.5rem 2rem; font-size: 1.25rem;
        font-weight: 600; font-family: 'Plus Jakarta Sans', 'Montserrat', sans-serif;
    }
    .modal-body { padding: 2rem; overflow-y: auto; flex-grow: 1; }
    .modal-footer { padding: 1rem 2rem; background: var(--light-gray); text-align: right; border-top: 1px solid #e2e8f0; }
    .close {
        position: absolute; right: 1.5rem; top: 1.5rem; font-size: 1.5rem; cursor: pointer;
        color: var(--white); background: rgba(255, 255, 255, 0.2); width: 32px; height: 32px;
        border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease;
    }
    .close:hover { background: rgba(255, 255, 255, 0.3); transform: rotate(90deg); }

    .loading { text-align: center; padding: 2rem; }
    .spinner {
        border: 3px solid #e2e8f0; border-top: 3px solid var(--primary-color);
        border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 1rem;
    }
    .btn .spinner { width:20px; height:20px; border-width:2px; margin: 0 8px 0 0; border-color: rgba(3, 105, 161, 0.2); border-top-color: #0f172a; }
    @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
    @keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

    #toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column-reverse; gap: 10px; }
    .toast {
        padding: 1rem 1.5rem; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 0.75rem; font-weight: 500;
        opacity: 0; transform: translateX(100%); animation: slideInToast 0.5s forwards, fadeOutToast 0.5s 3.5s forwards; border-left: 5px solid; min-width: 300px; background: white;
    }
    .toast.error { animation: slideInToast 0.5s forwards, fadeOutToast 0.5s 5.5s forwards; }
    @keyframes slideInToast { to { opacity: 1; transform: translateX(0); } }
    @keyframes fadeOutToast { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
    .toast.success { border-color: var(--success-color); color: var(--dark-color); }
    .toast.error { border-color: var(--danger-color); color: var(--dark-color); }

    .patient-page-footer {
        background: var(--white); border-radius: 16px; padding: 1.75rem; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        border: 1px solid #e2e8f0; margin-top: 1.5rem; display: flex; justify-content: space-between;
        align-items: center; gap: 1rem;
    }
    .footer-action-group { display: flex; align-items: center; gap: 0.75rem; }
    .footer-action-group label { font-weight: 600; color: var(--secondary-dark); margin-bottom: 0; }
    .footer-action-group select { width: auto; min-width: 150px; border-radius: 6px; }
    .footer-action-buttons { display: flex; gap: 1rem; }

    .fast-scroll-track {
        display: none; position: fixed; top: 180px; bottom: 100px; right: 0; width: 30px; z-index: 1000; touch-action: none; 
    }
    .fast-scroll-thumb {
        position: absolute; right: 4px; top: 0; width: 8px; height: 70px; background: var(--primary-color);
        border-radius: 8px; opacity: 0.4; transition: width 0.2s ease, opacity 0.2s ease, background-color 0.2s ease; box-shadow: var(--shadow-sm);
    }
    .fast-scroll-track:active .fast-scroll-thumb, .fast-scroll-thumb.dragging { width: 14px; opacity: 1; background: var(--primary-dark); box-shadow: var(--shadow); }
    .fast-scroll-letter {
        position: absolute; right: 24px; top: 50%; transform: translateY(-50%); background: var(--primary-dark);
        color: white; font-size: 1.5rem; font-weight: bold; width: 40px; height: 40px; display: none; align-items: center;
        justify-content: center; border-radius: 50%; opacity: 0; transition: opacity 0.3s ease; box-shadow: var(--shadow); pointer-events: none;
    }
    .fast-scroll-thumb.dragging .fast-scroll-letter { opacity: 1; }

    html, body { 
        overflow-x: hidden !important; 
        overflow-y: auto !important; 
        touch-action: auto !important; 
        overscroll-behavior: auto !important;
    }

    /* ==========================================
       ODONTOGRAM (VISUAL TEETH CHART) CSS 
       ========================================== */
    #odontogram-container { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; }
    .odontogram-wrapper { display: flex; flex-direction: column; gap: 1rem; width: max-content; margin: 0 auto; }
    .odontogram-row { display: flex; gap: 1rem; flex-wrap: nowrap; }
    .odontogram-quadrant {
        display: flex; gap: 0.25rem; padding: 0.5rem; background: white; border-radius: 12px;
        box-shadow: var(--shadow-sm); border: 1px solid #e2e8f0;
    }
    .tooth-wrapper { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; width: 40px; }
    .tooth-number { font-size: 0.85rem; font-weight: 700; color: var(--secondary-color); cursor: pointer; padding: 2px 6px; border-radius: 4px; transition: all 0.2s; user-select: none; }
    .tooth-number:hover { background: var(--primary-light); color: var(--primary-dark); }
    .tooth-number.selected { background: var(--primary-color); color: white; }
    .tooth-svg { width: 36px; height: 36px; cursor: pointer; }
    .tooth-svg .surface { fill: white; stroke: #e2e8f0; stroke-width: 4; transition: fill 0.2s; }
    .tooth-svg .surface:hover { fill: var(--primary-light); }
    .tooth-svg .surface.selected { fill: var(--primary-color); stroke: var(--primary-dark); }
    .tooth-wrapper.whole-selected .surface { fill: var(--primary-color) !important; stroke: var(--primary-dark) !important; opacity: 0.6; }

    /* ==========================================
       SIDE PANEL (QUICK ACTIONS)
       ========================================== */
    .quick-action-panel {
        position: fixed; 
        top: 15px; 
        right: -160px; 
        background: var(--white);
        box-shadow: -4px 0 15px rgba(0,0,0,0.1);
        border-radius: 12px 0 0 12px;
        display: flex;
        align-items: stretch; 
        transition: right 0.3s ease-in-out;
        z-index: 99999;
        touch-action: pan-y; 
    }
    .quick-action-panel:hover, .quick-action-panel.active { right: 0; }
    .quick-action-handle {
        background: var(--white);
        width: 14px; 
        height: auto; 
        min-height: unset; 
        border-radius: 12px 0 0 12px; 
        border: 1px solid #e2e8f0;
        border-right: none;
        cursor: pointer;
        display: flex; 
        align-items: center; 
        justify-content: center; 
        user-select: none;
        box-shadow: -2px 0 4px rgba(0,0,0,0.03); 
    }
    .quick-action-content { display: flex; flex-direction: column; gap: 12px; padding: 15px; width: 160px; }
    .quick-action-btn {
        background: var(--light-gray); border: 1px solid #e2e8f0; color: var(--primary-dark);
        padding: 10px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; font-family: 'Montserrat', sans-serif;
        cursor: pointer; text-align: left; transition: all 0.2s;
    }
    .quick-action-btn:hover { background: var(--primary-light); border-color: var(--primary-color); }

    /* ==========================================
       FULLCALENDAR OVERRIDES (MONTH VIEW COLORS)
       ========================================== */
    #calendar-tab .card { padding: 0.5rem !important; }
    #calendar table { margin: 0; border-collapse: collapse; border-radius: 0; }
    #calendar th, #calendar td { padding: 0 !important; border: 1px solid #e2e8f0 !important; background: transparent; }
    #calendar .fc-scrollgrid td, #calendar .fc-scrollgrid th { border: 1px solid #e2e8f0 !important; }
    .fc-col-header-cell-cushion { display: flex !important; flex-direction: column !important; align-items: center; padding: 4px !important; }
    .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky > th,
    .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky > td { border-bottom: 2px solid #e2e8f0 !important; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
    
    /* ✨ SURGICAL FIX: Removed all forced background overrides entirely. 
       FullCalendar will now natively inject your light blue/rosy red colors here */
    .fc-daygrid-event { 
        display: flex !important; 
        align-items: center !important; 
        padding: 2px 5px !important; 
        overflow: hidden !important; 
        gap: 4px !important; 
        font-size: 0.75rem !important; 
        line-height: 1.2 !important; 
        margin: 2px 1px !important; 
        border-radius: 6px !important; /* Kept the sharp curved edges */
        box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
        border-width: 1px !important;
        border-style: solid !important;
    }
    
    .fc-daygrid-event-dot { display: none !important; }
    .fc-event-title { text-overflow: ellipsis !important; overflow: hidden !important; white-space: nowrap !important; font-size: 0.75rem !important; font-weight: 600 !important; flex-grow: 1 !important; color: inherit !important; }
    .fc .fc-daygrid-body-unbalanced .fc-daygrid-day-events { min-height: 1.5em !important; }

    #calendar.expanded-columns .fc-timeGridWeek-view .fc-scrollgrid {
        min-width: 800px !important;
    }
    #calendar.expanded-columns .fc-timeGridWeek-view {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .fc-daygrid-more-link {
        font-weight: 600;
        color: var(--primary-dark) !important;
        background: #e2e8f0;
        padding: 2px 6px;
        border-radius: 4px;
        display: block;
        text-align: center;
        margin-top: 2px;
    }
    .fc-popover {
        background-color: var(--white) !important;
        border-radius: 12px !important;
        box-shadow: var(--shadow-lg) !important;
        border: 1px solid #e2e8f0 !important;
        z-index: 10000 !important;
        overflow: hidden;
    }
    .fc-popover-header {
        background: var(--light-gray) !important;
        color: var(--dark-color) !important;
        font-weight: 600;
        padding: 8px 12px !important;
    }
    .fc-popover-body {
        background-color: var(--white) !important;
        padding: 8px !important;
    }

    .fc-event-time { display: none !important; }

    .fc .fc-scrollgrid,
    .fc .fc-col-header-cell {
        border-top: 1px solid #e2e8f0 !important;
    }
    .fc .fc-day-today { background-color: transparent !important; }
    .fc .fc-daygrid-day.fc-day-today {
        background-color: var(--light-gray) !important; 
        box-shadow: inset 0 0 0 1px var(--primary-color) !important; 
    }
    .fc .fc-col-header-cell.fc-day-today {
        background-color: var(--light-gray) !important;
        box-shadow: inset 0 0 0 1px var(--primary-color) !important; 
    }
    .fc .fc-timegrid-col.fc-day-today {
        background-color: transparent !important;
        box-shadow: none !important;
    }

    @media (min-width: 769px) {
        #calendar-tab .card { max-width: 1100px; margin: 1rem auto; padding: 2.5rem !important; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); border-radius: 16px; }
    }

    /* ==========================================
       PRINT ENGINE
       ========================================== */
    #invoice-template, #rx-template { display: none; font-family: 'Montserrat', sans-serif; color: #333; max-width: 800px; margin: 0 auto; }
    @media print {
        .main-container, .modal, #toast-container, .fast-scroll-track, .quick-action-panel { display: none !important; }
        body { background: white; margin: 0; padding: 0; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
        body.print-mode-invoice #invoice-template { display: block !important; width: 100%; }
        body.print-mode-rx #rx-template { display: flex !important; flex-direction: column; width: 100%; min-height: 95vh; }
        @page { margin: 1.5cm; }
    }

    /* ==========================================
       V4 MINIMALIST BI DASHBOARD & SKELETON
       ========================================== */
    .reports-master-card {
        background: var(--white);
        border-radius: 16px;
        padding: 1.5rem;
        border: 1px solid #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        margin-bottom: 2rem;
    }
       
    .timeframe-toggles {
        display: flex; background: var(--light-gray); border-radius: 8px; padding: 4px;
        width: fit-content; border: 1px solid #e2e8f0; margin-bottom: 1.5rem;
    }
    .timeframe-btn {
        background: transparent; border: none; padding: 6px 16px; font-size: 0.85rem; font-weight: 600;
        color: var(--gray-color); border-radius: 6px; cursor: pointer; transition: all 0.2s;
    }
    .timeframe-btn:hover { color: var(--primary-dark); }
    .timeframe-btn.active { background: var(--primary-color); color: var(--white); box-shadow: var(--shadow-sm); }
    
    .kpi-grid {
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem;
    }
    .kpi-grid .card {
        padding: 1.25rem; display: flex; flex-direction: column; justify-content: center; border-left-width: 3px; border-radius: 12px;
    }
    .kpi-grid .card h3 {
        font-size: 0.75rem !important; font-weight: 500; letter-spacing: 0.5px; color: var(--gray-color); margin-bottom: 0.25rem;
    }
    .kpi-grid .card p {
        font-size: 1.6rem !important; font-weight: 600; color: var(--dark-color); margin: 0;
    }
    
    .chart-card { position: relative; overflow: hidden; }
    .chart-wrapper { position: relative; height: 300px; width: 100%; max-width: 100%; }

    @keyframes pulse-skeleton {
        0% { background-color: #e2e8f0; }
        50% { background-color: var(--secondary-light); }
        100% { background-color: #e2e8f0; }
    }

    .skeleton-text {
        color: transparent !important;
        background-color: #e2e8f0;
        border-radius: 4px;
        animation: pulse-skeleton 1.5s infinite ease-in-out;
        display: inline-block;
        min-width: 80px;
        user-select: none;
        pointer-events: none;
    }
    
    .skeleton-chart {
        background-color: var(--light-gray);
        border-radius: var(--radius);
        animation: pulse-skeleton 1.5s infinite ease-in-out;
        height: 100%;
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 5;
        display: none;
    }
    .skeleton-chart.active {
        display: block;
    }

    .dashboard-toolbar {
        display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
        background: var(--white); padding: 0 0 10px 0; margin-bottom: 1rem; border-bottom: 1px solid #e2e8f0;
    }
    .toolbar-group { display: flex; align-items: center; gap: 8px; }
    .toolbar-select {
        padding: 6px 10px; border-radius: 6px; border: 1px solid #cbd5e1;
        font-size: 0.8rem; font-weight: 500; color: var(--secondary-dark); background: #ffffff;
        cursor: pointer; outline: none; transition: all 0.2s;
    }
    .toolbar-select:hover { border-color: var(--primary-color); }
    .toolbar-btn {
        padding: 6px 12px; border-radius: 6px; border: 1px solid #cbd5e1;
        background: var(--white); font-size: 0.8rem; font-weight: 500; color: var(--secondary-dark);
        cursor: pointer; transition: all 0.2s;
    }
    .toolbar-btn:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-color); }
    .toolbar-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: transparent; }

    
    /* ==========================================
       ALL MOBILE OVERRIDES (max-width: 768px)
       ========================================== */
    @media (max-width: 768px) {
        html { scroll-behavior: auto !important; }
        .input-group input, .input-group select, .input-group textarea, .search-input { transition: none !important; }
        
        .header { 
            border-bottom: 1px solid #e2e8f0; 
            background-color: #F0F0F0 !important; 
            background-image: none !important; 
            color: var(--primary-dark);
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 10px rgba(0,0,0,0.05);
        }
        
        .header::before { 
            background-image: url('https://i.postimg.cc/pLhYsk6q/Gemini-Generated-Image-7xp7ek7xp7ek7xp7.png') !important; 
            background-size: cover !important; 
            background-position: bottom right !important; 
            width: 100% !important; 
            height: 100% !important; 
            top: 0 !important; 
            right: 0 !important; 
            border-width: 0 !important;
            -webkit-mask-image: linear-gradient(to bottom right, rgba(0,0,0,0) 48%, rgba(0,0,0,1) 65%) !important;
            mask-image: linear-gradient(to bottom right, rgba(0,0,0,0) 48%, rgba(0,0,0,1) 65%) !important;
        }
        .header::after { 
            width: 130px; height: 130px; 
            right: -10px; bottom: -20px; top: auto; 
            box-shadow: none; 
        }

        .header-content { 
            flex-direction: column; align-items: stretch; text-align: center; gap: 0; 
            position: relative; z-index: 10 !important;
        }

        .header-content::before { 
            width: 220px; height: 220px; 
            right: -20px; top: 10px; bottom: auto;
            border: 1.5px solid rgba(13, 148, 136, 0.15); 
        }
        .header-content::after { 
            display: none; 
        }
        
        .header-branding { 
            display: grid !important;
            grid-template-columns: auto auto;
            grid-template-areas: 
                "logo title"
                "subtitle subtitle";
            align-items: center !important; 
            justify-content: center !important; 
            gap: 0px 15px !important; 
            margin-bottom: 15px;
        }
        
        .clinic-logo { grid-area: logo; width: 85px !important; height: 85px !important; flex-shrink: 0; overflow: visible !important; } 
        
        .header-text { display: contents !important; }
        
        .header h1 { 
            grid-area: title;
            font-size: 2.8rem !important; 
            margin-bottom: 0; 
            line-height: 0; 
            color: var(--primary-dark);
            text-align: left !important;
        }
        
        .header .subtitle { 
            grid-area: subtitle;
            width: 100% !important; 
            font-size: 0.95rem !important; 
            color: var(--success-dark) !important; 
            font-weight: 700 !important;
            text-align: center !important;
            margin-top: 0px !important;
            white-space: nowrap !important;
        }
        
        .header .floating-tagline { 
            position: relative !important; bottom: auto !important; left: auto !important; 
            font-size: 1.2rem !important; margin-top: 0px !important; opacity: 0.8; 
            color: var(--secondary-color); white-space: normal; text-align: center; 
        }
        
        .doctor-info { 
            position: relative !important; top: auto !important; right: auto !important; text-align: center; 
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            padding: 5px 0 !important; 
            width: 100%; margin-top: 5px !important; 
            z-index: 10 !important;
        }
        
        .nav-tabs { 
            display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px; padding: 15px 12px !important; 
            background: #e2e8f0 !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.04) !important; 
        }
        .nav-tab { 
            border-radius: 8px !important; padding: 12px 5px !important; font-size: 0.85rem !important; 
            background: transparent !important; 
            border: 1px solid #cbd5e1 !important; 
            color: #475569 !important; 
            box-shadow: none !important; display: flex; align-items: center; justify-content: center; 
        }
        .nav-tab.active { 
            background: #ffffff !important; border-color: #ffffff !important; color: var(--primary-dark) !important; 
            font-weight: 700 !important; box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
        }
        .nav-tab.active::after { display: none !important; }

        .content { padding: 1rem; }
        .card { padding: 1.25rem; }
        .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
        .patient-info { grid-template-columns: 1fr; }
        .modal-content { width: 95%; margin: 5% auto; border-radius: 12px; }
        .input-group { min-width: 100%; }
        
        .btn { 
            width: 100% !important; 
            margin: 0.4rem 0 !important; 
            box-sizing: border-box !important;
            display: flex;
            justify-content: center;
        }
        
        .search-container { flex-direction: column; align-items: stretch; }
        .search-container .search-input, .search-container .btn { width: 100%; margin-left: 0; margin-right: 0; }
        
        .patient-page-footer { flex-direction: column; align-items: stretch; padding: 1.25rem; margin-top: 1.5rem; }
        .footer-action-buttons { justify-content: space-between; flex-direction: column; }
        .footer-action-buttons .btn { flex-grow: 1; width: 100%; }

        .treatment-content > div:last-child { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; }
        .treatment-content > div:last-child > .btn:first-child:last-child { grid-column: 1 / -1; }
        .treatment-content > div:last-child .btn { width: 100%; min-width: 0 !important; margin: 0 !important; padding: 10px 4px; font-size: 0.8rem; line-height: 1.2; white-space: normal; height: 100%; text-align: center; }
        .treatment-content { max-height: none !important; transition: none !important; }
        .treatment-block.collapsed .treatment-content { display: none !important; }

        #treatment-blocks table, #database-tab table { border: none; box-shadow: none; }
        #treatment-blocks table tfoot { display: none; }
        #treatment-blocks thead, #database-tab thead { display: none; }
        #treatment-blocks tr, #database-tab tr { display: block; margin-bottom: 1rem; border: 1px solid #e2e8f0; border-radius: 10px; padding: 1rem; background: var(--white); box-shadow: var(--shadow-sm); }
        #treatment-blocks .total-row, #database-tab .total-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 1rem; }
        #treatment-blocks .total-row td, #database-tab .total-row td { display: inline; border: none; padding: 0; background: transparent !important; }
        #treatment-blocks td, #database-tab td { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0.5rem; text-align: right; border: none; border-bottom: 1px solid #e2e8f0; }
        #treatment-blocks tr td:last-child, #database-tab tr td:last-child { border-bottom: none; }
        #treatment-blocks td::before, #database-tab td::before { font-weight: 600; color: var(--secondary-dark); text-align: left; padding-right: 1rem; }
        
        #patient-tbody td:nth-of-type(1)::before { content: "Reg No:"; }
        #patient-tbody td:nth-of-type(2)::before { content: "Name:"; }
        #patient-tbody td:nth-of-type(3)::before { content: "Age:"; }
        #patient-tbody td:nth-of-type(4)::before { content: "Sex:"; }
        #patient-tbody td:nth-of-type(5)::before { content: "Mobile:"; }
        #patient-tbody td:nth-of-type(6)::before { content: "Status:"; }
        #patient-tbody td:nth-of-type(7)::before { content: "Action:"; }
        #patient-tbody td:nth-of-type(8) { justify-content: flex-end; }
        #patient-tbody td:nth-of-type(8)::before { content: ""; }

        [id^="treatment-table-"] td:nth-of-type(1)::before { content: "Service:"; }
        [id^="treatment-table-"] td:nth-of-type(2)::before { content: "Teeth:"; }
        [id^="treatment-table-"] td:nth-of-type(3)::before { content: "Cost (₹):"; }
        [id^="treatment-table-"] td:nth-of-type(4)::before { content: "Discount:"; }
        [id^="treatment-table-"] td:nth-of-type(5)::before { content: "Remove:"; }
        [id^="treatment-table-"] td:nth-of-type(5) { justify-content: flex-end; }

        [id^="visit-table-"] td:nth-of-type(1)::before { content: "Date:"; }
        [id^="visit-table-"] td:nth-of-type(2)::before { content: "Details:"; }
        [id^="visit-table-"] td:nth-of-type(3)::before { content: "Payment (₹):"; }
        [id^="visit-table-"] td:nth-of-type(4)::before { content: "Remaining (₹):"; }
        
        td input, td select, td textarea { flex-grow: 1; max-width: 65%; }

        .tooth-svg { width: 26px; height: 26px; }
        .tooth-wrapper { width: 30px; }
        .tooth-number { font-size: 0.75rem; padding: 2px 4px; }
        .odontogram-quadrant { padding: 0.25rem; gap: 0.15rem; }

        .fc-toolbar.fc-header-toolbar { 
            display: flex !important; 
            flex-direction: column !important; 
            gap: 15px !important; 
            margin-bottom: 1.5rem !important; 
            padding: 0 12px !important;
            box-sizing: border-box !important;
        }
        
        .fc-toolbar-chunk:first-child {
            display: flex !important;
            flex-direction: row !important;
            justify-content: center !important;
            align-items: center !important;
            width: 100% !important;
            gap: 15px !important;
            flex-wrap: nowrap !important; 
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            padding: 0 !important;
        }
        
        .fc-toolbar-chunk:first-child .fc-button-group,
        .fc-toolbar-chunk:first-child > * {
            display: flex !important;
            align-items: center !important;
            flex-shrink: 0 !important;
            margin: 0 !important;
        }

        .fc-toolbar-chunk:first-child .fc-button {
            background: var(--white) !important;
            border: 1px solid #cbd5e1 !important;
            color: var(--secondary-dark) !important;
            border-radius: var(--radius) !important;
            padding: 4px 10px !important; 
            font-size: 0.85rem !important; 
            height: 32px !important; 
            box-shadow: var(--shadow-sm) !important;
            flex-shrink: 0 !important; 
        }

        .fc-toolbar-title { 
            font-size: 1.05rem !important; 
            font-weight: 700 !important; 
            color: var(--primary-dark) !important;
            text-align: center !important;
            flex-grow: 0 !important;
            flex-shrink: 1 !important; 
            white-space: nowrap !important; 
            overflow: hidden !important;
            text-overflow: ellipsis !important; 
            margin: 0 !important; 
            line-height: 32px !important; 
            display: block !important;
        }

        .fc-toolbar-chunk:last-child {
            display: flex !important;
            flex-direction: row !important;
            justify-content: space-between !important;
            align-items: center !important;
            width: 100% !important;
            gap: 8px !important;
            flex-wrap: nowrap !important;
        }
        .fc-toolbar-chunk:last-child .fc-button-group { 
            display: flex !important;
            flex-grow: 1 !important;
            border-radius: 6px !important; 
            box-shadow: var(--shadow-sm) !important;
        }
        .fc-toolbar-chunk:last-child .fc-button-group .fc-button {
            flex: 1 !important; 
            padding: 8px 2px !important; 
            font-size: 0.75rem !important; 
        }
        
        .fc-expandWeek-button { 
            background: var(--white) !important;
            border: 1px solid #cbd5e1 !important;
            border-radius: 6px !important;
            padding: 8px 12px !important;
            flex-shrink: 0 !important;
            margin-left: 0 !important;
            box-shadow: var(--shadow-sm) !important;
            position: relative;
            color: transparent !important; 
            min-width: 85px !important;
            height: 35px !important;
        }
        .fc-expandWeek-button::after {
            content: '⤢ Expand';
            color: var(--primary-dark) !important;
            font-size: 0.75rem !important;
            font-weight: 600 !important;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 100%;
            text-align: center;
        }
        .fc-expandWeek-button:hover::after { color: var(--primary-color) !important; }
        
        #calendar.expanded-columns .fc-expandWeek-button {
            background: var(--primary-color) !important;
            border-color: var(--primary-dark) !important;
        }
        #calendar.expanded-columns .fc-expandWeek-button::after {
            content: '>< Shrink';
            color: var(--white) !important;
        }

        .fc .fc-col-header-cell-cushion { font-size: 0.8rem !important; padding: 4px !important; }

        .timeframe-toggles { width: 100%; justify-content: space-between; }
        .timeframe-btn { flex: 1; text-align: center; padding: 6px 4px; font-size: 0.8rem; }
        
        .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
        .kpi-grid .card { padding: 1rem 0.75rem; text-align: center; }
        .kpi-grid .card p { font-size: 1.3rem !important; }
        
        .dashboard-toolbar { flex-direction: column; align-items: stretch; border: none; padding-bottom: 0; }
        .toolbar-group { flex-wrap: wrap; justify-content: space-between; }
        .toolbar-select { flex: 1; min-width: 100px; }

        #reports-tab > div:nth-child(3) { grid-template-columns: 1fr !important; gap: 1rem !important; width: 100% !important; max-width: 100vw !important; box-sizing: border-box !important; }
        #reports-tab > div:nth-child(3) .card { padding: 1rem 0.5rem !important; width: 100% !important; box-sizing: border-box !important; overflow: hidden !important; }
        .chart-wrapper { height: 250px; width: 100% !important; max-width: 100% !important; position: relative; }
        
        .quick-action-panel { display: flex !important; }
    }

    /* ==========================================
       IMAGE HANDOFF & TAGLINE CORRECTIONS
       ========================================== */

    .clinic-logo img { 
        transform: scale(0.88) !important; 
        animation: smoothLogoFade 0.3s ease-in-out forwards !important; 
    }

    @keyframes smoothLogoFade {
        0% { opacity: 0; }
        100% { opacity: 1; }
    }

    .header .floating-tagline {
        bottom: 5px !important; 
    }

    /* ✨ FIX 1: Mobile Chart Overflow Control */
    .chart-wrapper {
        position: relative;
        width: 100%;
        max-width: 100%; /* Prevents breaking out of the card */
        overflow-x: auto; /* Allows horizontal swiping on tiny screens */
        -webkit-overflow-scrolling: touch; /* Smooth swiping on iOS */
    }
    .chart-wrapper canvas {
        max-width: 100% !important;
        height: auto !important; /* Forces canvas to scale down */
    }

    /* ✨ FIX 2: Mobile Dropdown Menu Visibility */
    #patient-status {
        font-weight: 600;
        cursor: pointer;
        outline: none;
        transition: all 0.2s ease;
    }
    /* Forces the native mobile picker menu to be readable */
    #patient-status option {
        background-color: var(--white) !important;
        color: var(--dark-color) !important;
    }
    /* Gives distinct text colors to the options in the menu */
    #patient-status option[value="Ongoing"] {
        color: var(--success-dark) !important;
        font-weight: bold;
    }
    #patient-status option[value="Closed"] {
        color: var(--secondary-color) !important;
        font-weight: bold;
    }




    /* ✨ NEW: Crisp SVG UI Icon Styling */
    .ui-icon {
        width: 1.25em;
        height: 1.25em;
        vertical-align: -0.2em;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
        margin-right: 6px;
        display: inline-block;
    }


    /* ✨ FIX: Odontogram Visibility & Sticky Hover Overrides */
        #odontogramModal > div, 
        #odontogramModal > div:hover,
        #odontogramModal > div:active,
        #odontogramModal .modal-content, 
        #odontogramModal .modal-content:hover,
        #odontogramModal .modal-content:active,
        #odontogramModal .card,
        #odontogramModal .card:hover,
        #odontogramModal .card:active {
            background-color: #ffffff !important; /* Forces pure white */
            transform: none !important; /* Kills the hover lift effect on mobile tap */
        }
        
        /* Ensure the SVG background never inherits the sticky blue hover */
        #odontogramModal svg,
        #odontogramModal svg:hover,
        #odontogramModal svg:active {
            background-color: #ffffff !important;
        }
    
    /* Ensure the SVG teeth themselves aren't inheriting a weird fill color */
    #odontogramModal svg {
        background-color: #ffffff !important;
    }