:root {
            --primary:#2563eb;
            --primary-dark:#1d4ed8;
            --primary-soft:#eff6ff;
            --accent:#7c3aed;
            --success:#16a34a;
            --danger:#dc2626;
            --warning:#c2410c;
            --text:#1e293b;
            --muted:#64748b;
            --border:#e2e8f0;
            --surface:#ffffff;
            --surface-soft:#f8fafc;
            --radius-sm:0.75rem;
            --radius:1rem;
            --radius-lg:1.5rem;
            --control-height:42px;
            --shadow-card:0 6px 20px rgba(15,23,42,0.05);
        }
        * { margin:0; padding:0; box-sizing:border-box; }
        body { font-family:'Inter',sans-serif; background:#f0f2f5; color:var(--text); }
        .cloud-hidden { display:none !important; }
        .auth-gate { min-height:100vh; display:grid; place-items:center; padding:1.25rem; background:radial-gradient(circle at 15% 15%,rgba(124,58,237,0.15),transparent 32%),radial-gradient(circle at 85% 85%,rgba(37,99,235,0.15),transparent 35%),#f8fafc; }
        .auth-gate.hidden { display:none; }
        .auth-card { width:100%; max-width:430px; min-width:0; padding:2rem; border:1px solid #e2e8f0; border-radius:2rem; background:rgba(255,255,255,0.96); box-shadow:0 25px 60px rgba(15,23,42,0.14); }
        .auth-card .brand-mark { margin-bottom:1rem; }
        .auth-eyebrow { display:flex; align-items:center; gap:0.4rem; margin-bottom:0.45rem; color:#4f46e5; font-size:0.72rem; font-weight:700; }
        .auth-card h1 { margin-bottom:0.45rem; font-size:1.45rem; }
        .auth-card > p { margin-bottom:1.25rem; color:#64748b; font-size:0.82rem; line-height:1.65; }
        .auth-card label { display:block; margin-bottom:0.3rem; font-size:0.78rem; font-weight:600; }
        .auth-card input { width:100%; min-height:46px; margin-bottom:0.9rem; padding:0.65rem 0.8rem; border:1px solid #cbd5e1; border-radius:var(--radius); background:white; }
        .auth-card input:focus { border-color:#93c5fd; box-shadow:0 0 0 3px rgba(37,99,235,0.1); outline:none; }
        input[type="password"] { direction:ltr; text-align:left; unicode-bidi:isolate; }
        .auth-actions { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:0.65rem; margin-top:0.35rem; }
        .auth-actions button { width:100%; }
        .auth-link { display:block; margin:0.85rem auto 0; border:0; background:none; color:#2563eb; cursor:pointer; font-size:0.76rem; font-weight:600; }
        .auth-message { min-height:1.2rem; margin-top:0.85rem; color:#64748b; font-size:0.76rem; line-height:1.5; text-align:center; }
        .auth-message.error { color:#dc2626; }
        .auth-message.success { color:#15803d; }
        .subscription-gate { margin-top:1rem; padding-top:1.1rem; border-top:1px solid #e2e8f0; text-align:center; }
        .subscription-icon { width:48px; height:48px; margin:0 auto 0.8rem; border-radius:1rem; display:grid; place-items:center; background:#eff6ff; color:#2563eb; font-size:1.1rem; }
        .subscription-gate h2 { margin-bottom:0.45rem; font-size:1.15rem; }
        .subscription-gate p { margin-bottom:0.85rem; color:#64748b; font-size:0.82rem; line-height:1.65; }
        .subscription-meta { margin-bottom:0.9rem; padding:0.7rem; border:1px solid #e2e8f0; border-radius:1rem; background:#f8fafc; color:#475569; font-size:0.76rem; line-height:1.6; }
        .subscription-plans { display:grid; gap:0.7rem; margin:0.9rem 0; }
        .subscription-plan { display:block; width:100%; padding:0.9rem; border:1px solid #dbeafe; border-radius:1.1rem; background:#ffffff; color:var(--text); text-decoration:none; text-align:right; cursor:pointer; font:inherit; box-shadow:0 4px 14px rgba(37,99,235,0.08); transition:transform .18s,box-shadow .18s,border-color .18s; }
        .subscription-plan:hover { transform:translateY(-1px); border-color:#93c5fd; box-shadow:0 8px 22px rgba(37,99,235,0.13); }
        .subscription-plan.disabled { opacity:0.62; pointer-events:auto; cursor:not-allowed; }
        .subscription-plan strong { display:block; margin-bottom:0.25rem; font-size:0.9rem; color:#1e293b; }
        .subscription-plan .plan-price { display:flex; align-items:baseline; justify-content:space-between; gap:0.6rem; color:#2563eb; font-weight:800; }
        .subscription-plan .plan-price span { color:#64748b; font-size:0.72rem; font-weight:600; }
        .subscription-plan small { display:block; margin-top:0.35rem; color:#64748b; line-height:1.5; }
        .subscription-gate .btn-outline { width:100%; margin-top:0.45rem; text-decoration:none; }
        button,input,select,textarea { font:inherit; }
        button,select { -webkit-tap-highlight-color:transparent; }
        button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible {
            outline:3px solid rgba(37,99,235,0.2);
            outline-offset:2px;
        }
        input,select,textarea { color:var(--text); }
        .app-layout { display:flex; flex-direction:column; min-height:100vh; }
        .app-body { display:flex; flex:1; }
        .sidebar { width:260px; background:white; border-left:1px solid #e2e8f0; display:flex; flex-direction:column; padding:1.5rem 1rem; flex-shrink:0; overflow-y:auto; }
        .sidebar .logo { margin-bottom:2rem; text-align:center; display:flex; flex-direction:column; align-items:center; gap:0.3rem; }
        .sidebar .logo h1 { font-size:1.4rem; font-weight:700; }
        .sidebar .logo p { font-size:0.7rem; color:#64748b; letter-spacing:0.5px; font-weight:500; }
        .sidebar nav { flex:1; }
        .sidebar nav a { display:flex; align-items:center; gap:0.7rem; padding:0.75rem 1rem; border-radius:1rem; text-decoration:none; color:#475569; font-weight:500; margin-bottom:0.2rem; transition:0.2s; font-size:0.83rem; }
        .sidebar nav a:hover, .sidebar nav a.active { background:#eff6ff; color:#2563eb; }
        .sidebar .stats-mini { display:flex; gap:0.8rem; margin-top:1rem; }
        .sidebar .stat-mini { flex:1; background:#f8fafc; border-radius:1rem; padding:0.6rem; text-align:center; }
        .sidebar .stat-mini .num { font-weight:700; font-size:1.2rem; color:#2563eb; }
        .sidebar .stat-mini .label { font-size:0.7rem; color:#64748b; }
        .sidebar .btn-primary { margin-top:1rem; width:100%; justify-content:center; }
        .main { flex:1; display:flex; flex-direction:column; overflow:hidden; }
        .topbar { background:rgba(255,255,255,0.94); backdrop-filter:blur(12px); padding:0.7rem 1.5rem; border-bottom:1px solid #e2e8f0; display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
        .topbar h2 { font-size:1.1rem; font-weight:600; }
        .topbar-actions { display:flex; align-items:center; gap:0.5rem; }
        .cloud-status { min-height:34px; padding:0.35rem 0.65rem; border:1px solid #cbd5e1; border-radius:999px; display:inline-flex; align-items:center; gap:0.35rem; color:#64748b; background:#f8fafc; font-size:0.68rem; font-weight:700; white-space:nowrap; }
        .cloud-status.syncing { color:#1d4ed8; border-color:#bfdbfe; background:#eff6ff; }
        .cloud-status.synced { color:#15803d; border-color:#bbf7d0; background:#f0fdf4; }
        .cloud-status.error { color:#b91c1c; border-color:#fecaca; background:#fef2f2; }
        .cloud-status i { font-size:0.72rem; }
        .panel { display:none; flex:1; padding:1.5rem; overflow-y:auto; }
        .panel.active-panel { display:flex; flex-direction:column; }
        @keyframes fade { from{opacity:0;transform:translateY(6px);} to{opacity:1;transform:translateY(0);} }
        .toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:1rem; margin-bottom:1.5rem; }
        .search-box { min-height:var(--control-height); background:white; border:1px solid var(--border); border-radius:var(--radius); padding:0 0.85rem; display:flex; align-items:center; gap:0.5rem; box-shadow:0 1px 2px rgba(0,0,0,0.03); transition:border-color .2s,box-shadow .2s; }
        .search-box:focus-within { border-color:#93c5fd; box-shadow:0 0 0 3px rgba(37,99,235,0.1); }
        .search-box i { color:#94a3b8; }
        .search-box input { border:none; padding:0; width:220px; min-height:40px; outline:none; border-radius:0; background:transparent; }
        .btn-primary,.btn-outline,.btn-export,.quick-action-btn,.dial-btn {
            min-height:var(--control-height);
            padding:0.55rem 1.1rem;
            border-radius:var(--radius);
            font-size:0.84rem;
            font-weight:600;
            line-height:1.1;
            cursor:pointer;
            display:inline-flex;
            align-items:center;
            justify-content:center;
            gap:0.45rem;
            white-space:nowrap;
            transition:background-color .18s,border-color .18s,color .18s,box-shadow .18s,transform .18s;
        }
        .btn-primary,.quick-action-btn,.dial-btn { background:var(--primary); color:white; border:1px solid var(--primary); box-shadow:0 4px 12px rgba(37,99,235,0.16); }
        .btn-primary:hover,.quick-action-btn:hover,.dial-btn:hover { background:var(--primary-dark); border-color:var(--primary-dark); box-shadow:0 6px 16px rgba(37,99,235,0.22); transform:translateY(-1px); }
        .btn-primary:active,.quick-action-btn:active,.dial-btn:active,.btn-outline:active,.btn-export:active { transform:translateY(0); }
        .btn-primary.btn-success-solid { background:var(--success); border-color:var(--success); box-shadow:0 4px 12px rgba(22,163,74,0.16); }
        .btn-primary.btn-success-solid:hover { background:#15803d; border-color:#15803d; box-shadow:0 6px 16px rgba(22,163,74,0.22); }
        .btn-primary.btn-accent { background:var(--accent); border-color:var(--accent); box-shadow:0 4px 12px rgba(124,58,237,0.16); }
        .btn-primary.btn-accent:hover { background:#6d28d9; border-color:#6d28d9; box-shadow:0 6px 16px rgba(124,58,237,0.22); }
        .btn-outline { background:white; border:1px solid #cbd5e1; color:#334155; box-shadow:0 1px 2px rgba(15,23,42,0.02); }
        .btn-outline:hover { background:var(--surface-soft); border-color:#94a3b8; }
        .btn-export { background:#f8fafc; border:1px solid #cbd5e1; color:#334155; }
        .btn-export:hover { background:#e2e8f0; }
        .toolbar select,.messaging-card select,.msg-template-box select,.billing-row select,.billing-row input,
        .messaging-card textarea,.msg-template-box textarea,.magic-input-row input {
            min-height:var(--control-height);
            border:1px solid #cbd5e1 !important;
            border-radius:var(--radius) !important;
            background:white;
            padding:0.55rem 0.8rem !important;
            transition:border-color .2s,box-shadow .2s;
        }
        .toolbar select:focus,.messaging-card select:focus,.msg-template-box select:focus,.billing-row select:focus,
        .billing-row input:focus,.messaging-card textarea:focus,.msg-template-box textarea:focus,.magic-input-row input:focus {
            border-color:#93c5fd !important;
            box-shadow:0 0 0 3px rgba(37,99,235,0.1);
            outline:none;
        }
        .table-wrapper { background:white; border-radius:1.5rem; overflow-x:auto; box-shadow:var(--shadow-card); border:1px solid #eef2f6; flex:1; }
        table { width:100%; border-collapse:collapse; font-size:0.85rem; }
        th { text-align:right; padding:1rem 1rem; background:#f8fafc; border-bottom:1px solid #e2e8f0; font-weight:600; }
        td { padding:0.9rem 1rem; border-bottom:1px solid #f0f2f5; vertical-align:middle; word-break:break-word; overflow-wrap:anywhere; }
        tr.clickable-row { cursor:pointer; transition: background 0.15s; }
        tr.clickable-row:hover { background:#f8fafc; }
        .badge { background:#e2e8f0; padding:0.2rem 0.6rem; border-radius:1rem; font-size:0.7rem; font-weight:600; display:inline-flex; white-space:nowrap; word-break:normal; overflow-wrap:normal; }
        .actions { white-space:nowrap; }
        .actions i { width:34px; height:34px; margin:0 1px; border-radius:10px; display:inline-grid; place-items:center; cursor:pointer; font-size:0.95rem; transition:background-color .15s,transform .15s; }
        .actions i:hover { background:#f1f5f9; transform:translateY(-1px); }
        .fa-edit { color:#3b82f6; }
        .fa-trash-alt { color:#ef4444; }
        .fa-exchange-alt { color:#f59e0b; }
        .fa-calendar-alt { color:#8b5cf6; }
        .fa-sticky-note { color:#8b5cf6; }
        .clickable-name { color:#2563eb; cursor:pointer; text-decoration:none; }
        .clickable-name:hover { color:#1d4ed8; }
        .modal { position:fixed; top:0; left:0; width:100%; height:100%; background:#00000066; backdrop-filter:blur(3px); display:flex; align-items:center; justify-content:center; z-index:2000; }
        .modal-card { background:white; width:90%; max-width:520px; border-radius:2rem; padding:1.8rem; box-shadow:0 25px 50px rgba(15,23,42,0.22); max-height:90vh; overflow-y:auto; }
        .modal-card.wide { max-width:780px; }
        .modal-card h3 { margin-bottom:1.2rem; }
        .modal-card label { font-weight:500; font-size:0.9rem; margin-bottom:0.2rem; display:block; }
        .modal-card input, .modal-card select, .modal-card textarea { width:100%; min-height:var(--control-height); padding:0.65rem 0.75rem; margin-bottom:1rem; border:1px solid #cbd5e1; border-radius:var(--radius); background:white; transition:border-color .2s,box-shadow .2s; }
        .modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus { border-color:#93c5fd; box-shadow:0 0 0 3px rgba(37,99,235,0.1); outline:none; }
        .modal-actions { display:flex; justify-content:flex-end; gap:0.5rem; margin-top:1rem; }
        .profile-header { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; }
        .profile-header-actions { display:flex; gap:0.4rem; flex-shrink:0; }
        .profile-header-actions .btn-primary { min-height:36px; padding:0.45rem 0.85rem; font-size:0.78rem; }
        .profile-contact { display:flex; align-items:center; flex-wrap:wrap; gap:0.35rem 1rem; margin-bottom:0.35rem; color:#475569; }
        .alert-banner { background:#fff3cd; color:#856404; padding:0.7rem 1.2rem; border-radius:1rem; margin-bottom:1rem; font-size:0.85rem; display:flex; align-items:center; gap:0.5rem; }
        .image-section { margin:1rem 0; padding:1rem; background:#f8fafc; border-radius:1rem; }
        .image-preview { display:flex; flex-wrap:wrap; gap:0.5rem; margin:0.5rem 0; }
        .image-thumb { position:relative; width:100px; height:100px; border-radius:0.5rem; overflow:hidden; border:1px solid #e2e8f0; }
        .image-thumb img { width:100%; height:100%; object-fit:cover; }
        .image-thumb .delete-img { position:absolute; top:2px; right:2px; background:rgba(0,0,0,0.6); color:white; border-radius:50%; width:20px; height:20px; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:0.7rem; }
        .after-upload-row { display:flex; align-items:center; gap:0.5rem; margin-top:0.65rem; }
        .after-upload-row #afterDateInput { width:auto; min-width:170px; margin:0; }
        .after-upload-row #addAfterBtn { margin:0; align-self:stretch; }
        .treatment-item, .appointment-item { background:#fff; border:1px solid #e2e8f0; border-radius:1rem; padding:0.8rem; margin:0.5rem 0; display:flex; justify-content:space-between; align-items:center; cursor:pointer; word-break:break-word; overflow-wrap:anywhere; }
        .appointment-completed { opacity:0.7; text-decoration:line-through; }
        .appointment-actions { display:flex; gap:0.4rem; align-items:center; flex-shrink:0; }
        .btn-small { min-height:32px; padding:0.35rem 0.75rem; font-size:0.75rem; border-radius:0.7rem; border:1px solid #cbd5e1; background:white; color:#334155; cursor:pointer; font-weight:600; white-space:nowrap; display:inline-flex; align-items:center; justify-content:center; gap:0.3rem; transition:.18s; }
        .btn-small:hover { background:#f8fafc; border-color:#94a3b8; }
        .btn-small.danger { border-color:#fecaca; color:#dc2626; background:#fff5f5; }
        .btn-small.warning { border-color:#fed7aa; color:#c2410c; background:#fff7ed; }
        .btn-small.success { border-color:#bbf7d0; color:#16a34a; background:#f0fdf4; }
        .btn-small.google { border-color:#c7d2fe; color:#4338ca; background:#eef2ff; }
        .btn-small.billing { border-color:#e2e8f0; color:#475569; background:transparent; }
        .btn-small.billing:hover { background:#f1f5f9; }
        .treatment-date { font-weight:600; color:#2563eb; }
        .delete-treatment, .delete-appointment { color:#ef4444; cursor:pointer; }
        .delete-appointment { width:34px; height:34px; display:inline-grid; place-items:center; border-radius:10px; transition:background-color .15s; }
        .delete-appointment:hover { background:#fef2f2; }
        .medical-item { display:flex; align-items:center; gap:0.5rem; margin-bottom:0.5rem; }
        .medical-item label { min-width:120px; font-size:0.85rem; }
        .medical-item input[type="text"], .medical-item input[type="date"] { flex:1; padding:0.4rem 0.6rem; border:1px solid #cbd5e1; border-radius:0.5rem; font-size:0.85rem; }
        .medical-checkboxes { display:flex; gap:0.45rem; align-items:center; }
        .medical-checkboxes label,.questionnaire-table label { min-width:0; min-height:32px; padding:0.25rem 0.55rem; border:1px solid #e2e8f0; border-radius:0.65rem; background:white; font-size:0.8rem; display:inline-flex; align-items:center; gap:0.35rem; cursor:pointer; transition:background-color .15s,border-color .15s,color .15s; }
        .medical-checkboxes label:hover,.questionnaire-table label:hover { background:#f8fafc; border-color:#cbd5e1; }
        .modal-card input[type="checkbox"],.medical-checkboxes input[type="checkbox"],.questionnaire-table input[type="checkbox"] {
            appearance:none;
            -webkit-appearance:none;
            -webkit-tap-highlight-color:transparent;
            width:17px;
            height:17px;
            min-height:17px;
            flex:0 0 17px;
            margin:0;
            padding:0;
            border:1.5px solid #94a3b8;
            border-radius:5px;
            background:white;
            display:grid;
            place-content:center;
            box-shadow:none;
            cursor:pointer;
        }
        .modal-card input[type="checkbox"]::before {
            content:'';
            width:8px;
            height:4px;
            border-right:2px solid white;
            border-bottom:2px solid white;
            transform:rotate(45deg) scale(0);
            transform-origin:center;
            transition:transform .1s ease-in-out;
            margin-top:-2px;
        }
        .modal-card input[type="checkbox"]:checked { background:var(--primary); border-color:var(--primary); }
        .modal-card input[type="checkbox"]:checked::before { transform:rotate(45deg) scale(1); }
        .modal-card input[type="checkbox"]:focus,.modal-card input[type="checkbox"]:focus-visible {
            outline:none !important;
            outline-width:0 !important;
            box-shadow:none !important;
        }
        .questionnaire-table { width:100%; border-collapse:collapse; margin-top:0.5rem; }
        .questionnaire-table td { padding:0.4rem 0.5rem; border-bottom:1px solid #e2e8f0; vertical-align:middle; font-size:0.8rem; }
        .questionnaire-table td:first-child { text-align:right; font-weight:500; width:55%; }
        .questionnaire-table td:last-child { display:flex; gap:0.8rem; align-items:center; white-space:nowrap; }
        .questionnaire-table input[type="text"], .questionnaire-table input[type="date"], .questionnaire-table input[type="email"] { width:100%; padding:0.3rem 0.5rem; border:1px solid #cbd5e1; border-radius:0.4rem; font-size:0.8rem; }
        .tx-type-wrapper { position:relative; }
        .tx-type-wrapper input { padding-left:2rem; }
        .tx-type-wrapper .tx-list-icon { position:absolute; left:8px; top:50%; transform:translateY(-50%); cursor:pointer; color:#64748b; font-size:1rem; }
        .date-picker-row { cursor:pointer; }
        .date-picker-row input { cursor:pointer; }
        .calendar-toolbar { display:flex; justify-content:space-between; align-items:center; gap:0.75rem; flex-wrap:wrap; margin-bottom:0.5rem; }
        .calendar-hint { color:#64748b; font-size:0.8rem; line-height:1.5; }
        .material-option { display:flex !important; align-items:center; gap:0.5rem; margin:0; cursor:pointer; flex:1; min-width:0; }
        .material-option span { overflow-wrap:anywhere; }
        .material-row { display:flex; gap:0.5rem; align-items:center; margin-bottom:0.5rem; }
        .holiday-row,.google-event-row { display:flex; align-items:center; gap:0.5rem; margin-bottom:0.6rem; }
        .holiday-row input { margin-bottom:0; }
        .google-event-row { justify-content:space-between; padding:0.65rem; border:1px solid #e2e8f0; border-radius:1rem; background:#f8fafc; }
        .google-event-row span { color:#64748b; font-size:0.78rem; }
        .google-sync-status { margin-bottom:0.85rem; padding:0.75rem 0.9rem; border:1px solid #dbeafe; border-radius:1rem; background:#eff6ff; color:#1e3a8a; font-size:0.82rem; line-height:1.6; }
        .google-sync-status span { color:#475569; }
        .calendar { background:white; border-radius:1.5rem; padding:1.5rem; box-shadow:0 4px 12px rgba(0,0,0,0.03); }
        .calendar-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:1rem; }
        .calendar-header .btn-outline { width:42px; padding:0; }
        .calendar-grid { display:grid; grid-template-columns: repeat(7, 1fr); gap:0.3rem; }
        .calendar-day-name { text-align:center; font-weight:600; font-size:0.8rem; color:#64748b; padding:0.3rem; }
        .calendar-day { text-align:center; padding:0.5rem; border-radius:0.5rem; cursor:pointer; font-size:0.9rem; }
        .calendar-day:hover { background:#f0f2f5; }
        .calendar-day.today { background:#e0e7ff; font-weight:bold; }
        .calendar-day.selected { background:#2563eb; color:white; }
        .calendar-day.other-month { color:#cbd5e1; }
        .calendar-day.past { color:#cbd5e1; opacity:0.5; pointer-events:none; }
        .calendar-day.holiday { background:#fef3c7; font-weight:bold; }
        .calendar-day.has-appointments:not(.selected) { background:#166534; color:white; }
        .appointments-for-date { margin-top:1rem; }
        .appointments-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:0.5rem; }
        .appointments-header h4 { margin:0; }
        .summary-box { background:#f8fafc; border-radius:1rem; padding:1rem; margin-bottom:1rem; display:flex; flex-wrap:wrap; gap:1rem; justify-content:center; align-items:center; }
        .progress-bar-bg { background:#e2e8f0; border-radius:1rem; height:0.8rem; flex:1; }
        .progress-bar-fill { background:#2563eb; border-radius:1rem; height:100%; transition: width 0.3s; }
        .finance-summary-table { width:100%; border-collapse:collapse; margin-top:1rem; }
        .finance-summary-table th { background:#f1f5f9; }
        .finance-summary-table td, .finance-summary-table th { border:1px solid #e2e8f0; padding:0.5rem; text-align:center; }
        #retentionContent { width:100%; max-width:1180px; margin:0 auto; }
        .retention-hero { position:relative; overflow:hidden; display:flex; align-items:center; justify-content:space-between; gap:1.5rem; margin-bottom:1rem; padding:1.5rem; border-radius:var(--radius-lg); color:white; background:linear-gradient(135deg,#1d4ed8 0%,#4f46e5 55%,#7c3aed 100%); box-shadow:0 16px 35px rgba(79,70,229,0.2); }
        .retention-hero::after { content:''; position:absolute; width:240px; height:240px; border-radius:50%; background:rgba(255,255,255,0.1); left:-70px; top:-120px; }
        .retention-hero > * { position:relative; z-index:1; }
        .retention-eyebrow { display:inline-flex; align-items:center; gap:0.4rem; margin-bottom:0.65rem; color:#ddd6fe; font-size:0.75rem; font-weight:700; }
        .retention-hero h3 { margin:0 0 0.4rem; font-size:1.35rem; }
        .retention-hero p { margin:0; max-width:650px; color:#e0e7ff; font-size:0.85rem; line-height:1.65; }
        .retention-hero .btn-outline { color:#312e81; border-color:white; background:white; flex-shrink:0; box-shadow:0 8px 20px rgba(30,41,59,0.15); }
        .retention-hero .btn-outline:hover { background:#eef2ff; border-color:#eef2ff; }
        .retention-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:0.8rem; margin-bottom:1rem; }
        .retention-stat { display:grid; grid-template-columns:1fr auto; align-items:center; gap:0.15rem 1rem; padding:1rem 1.1rem; border:1px solid #e2e8f0; border-radius:var(--radius); background:white; box-shadow:var(--shadow-card); }
        .retention-stat span { color:#475569; font-size:0.78rem; font-weight:600; }
        .retention-stat strong { grid-row:span 2; font-size:1.7rem; color:#2563eb; }
        .retention-stat small { color:#94a3b8; font-size:0.68rem; }
        .retention-stat.warning strong { color:#c2410c; }
        .retention-stat.danger strong { color:#dc2626; }
        .retention-groups { display:grid; gap:0.75rem; }
        .retention-group { overflow:hidden; border:1px solid #e2e8f0; border-radius:var(--radius); background:white; box-shadow:0 3px 14px rgba(15,23,42,0.04); }
        .retention-header { width:100%; min-height:74px; display:flex; align-items:center; gap:0.8rem; padding:0.8rem 1rem; border:0; background:white; text-align:right; cursor:pointer; color:var(--text); }
        .retention-header:hover { background:#f8fafc; }
        .retention-group-icon { width:42px; height:42px; border-radius:12px; display:grid; place-items:center; flex-shrink:0; background:#eff6ff; color:#2563eb; }
        .retention-group-icon.soft { background:#f1f5f9; color:#64748b; }
        .retention-group-icon.warning { background:#fff7ed; color:#c2410c; }
        .retention-group-icon.danger { background:#fef2f2; color:#dc2626; }
        .retention-group-copy { display:flex; flex:1; min-width:0; flex-direction:column; gap:0.15rem; }
        .retention-group-copy strong { font-size:0.9rem; }
        .retention-group-copy small { color:#64748b; font-size:0.72rem; }
        .retention-count { min-width:32px; height:28px; padding:0 0.55rem; border-radius:999px; display:grid; place-items:center; background:#eff6ff; color:#2563eb; font-size:0.78rem; font-weight:700; }
        .retention-chevron { color:#94a3b8; transition:transform .2s; }
        .retention-group.open .retention-chevron { transform:rotate(180deg); }
        .retention-list { display:none; padding:0 0.75rem 0.75rem; border-top:1px solid #f1f5f9; background:#f8fafc; }
        .retention-group.open .retention-list { display:grid; gap:0.55rem; padding-top:0.75rem; }
        .retention-client-card { display:grid; grid-template-columns:auto minmax(160px,1fr) minmax(150px,0.8fr) auto auto; align-items:center; gap:0.8rem; padding:0.7rem; border:1px solid #e2e8f0; border-radius:0.9rem; background:white; }
        .retention-avatar { width:38px; height:38px; display:grid; place-items:center; border-radius:12px; color:#4338ca; background:#eef2ff; font-weight:700; }
        .retention-client-main,.retention-last-visit { min-width:0; display:flex; flex-direction:column; gap:0.15rem; }
        .retention-client-main strong { color:#2563eb; font-size:0.84rem; }
        .retention-client-main span,.retention-last-visit span { color:#64748b; font-size:0.7rem; }
        .retention-last-visit strong { color:#334155; font-size:0.76rem; font-weight:600; }
        .retention-days-badge { padding:0.3rem 0.55rem; border-radius:999px; color:#475569; background:#f1f5f9; font-size:0.68rem; font-weight:700; white-space:nowrap; }
        .retention-days-badge.warning { color:#9a3412; background:#ffedd5; }
        .retention-days-badge.danger { color:#b91c1c; background:#fee2e2; }
        .retention-client-actions { display:flex; align-items:center; gap:0.35rem; }
        .retention-empty { min-height:120px; display:flex; align-items:center; justify-content:center; flex-direction:column; gap:0.25rem; color:#64748b; text-align:center; }
        .retention-empty i { margin-bottom:0.2rem; color:#16a34a; font-size:1.4rem; }
        .retention-empty strong { color:#334155; font-size:0.84rem; }
        .retention-empty span { font-size:0.72rem; }
        .overdue-row { background:#fee2e2; }
        .inventory-low { background:transparent; }
        .status-dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-left:5px; }
        .status-dot.green { background:#16a34a; }
        .status-dot.red { background:#dc2626; }
        .toggle-switch { position:relative; display:inline-flex; align-items:center; gap:0.4rem; cursor:pointer; user-select:none; }
        .toggle-switch input { display:none; }
        .toggle-slider { width:36px; height:20px; background:#cbd5e1; border-radius:20px; transition:0.2s; position:relative; flex-shrink:0; }
        .toggle-slider::before { content:''; position:absolute; width:16px; height:16px; border-radius:50%; background:white; top:2px; left:2px; transition:0.2s; }
        .toggle-switch input:checked + .toggle-slider { background:#2563eb; }
        .toggle-switch input:checked + .toggle-slider::before { transform:translateX(16px); }
        .toggle-label { font-size:0.8rem; font-weight:500; color:#1e293b; line-height:1.2; }
        .tooltip-bubble { position:absolute; background:white; border:1px solid #e2e8f0; border-radius:1rem; padding:0.8rem 1rem; box-shadow:0 10px 25px rgba(0,0,0,0.15); z-index:500; max-width:300px; font-size:0.85rem; display:none; }
        .msg-template-box { background:#f8fafc; border-radius:1rem; padding:1rem; margin-bottom:1rem; }
        .msg-template-box select { padding:0.5rem; border-radius:1rem; border:1px solid #cbd5e1; font-size:0.9rem; }
        .msg-template-box textarea { font-size:0.9rem; border-radius:1rem; padding-right:0.75rem; }
        .messaging-card { background:white; border-radius:1.5rem; padding:1.5rem; box-shadow:0 4px 12px rgba(0,0,0,0.03); }
        .messaging-card select, .messaging-card textarea { font-size:0.9rem; border-radius:1rem; }
        .messaging-card textarea { padding-right:0.75rem; }
        .magic-input-row { display:flex; align-items:center; gap:0.5rem; margin-bottom:1rem; flex-wrap:wrap; }
        .magic-input-row label { font-size:0.8rem; font-weight:500; white-space:nowrap; }
        .magic-input-row input { flex:1; min-width:200px; padding:0.5rem; border:1px solid #cbd5e1; border-radius:1rem; font-size:0.85rem; }
        .treatment-meta { font-size:0.8rem; color:#64748b; }
        footer { font-size:0.7rem; text-align:center; color:#64748b; padding:1rem 1.5rem; border-top:1px solid #e2e8f0; background:white; display:flex; justify-content:center; align-items:center; gap:1.5rem; flex-wrap:wrap; }
        footer .footer-links { display:flex; gap:1rem; }
        footer .footer-links a, footer .footer-links button { color:#64748b; text-decoration:none; cursor:pointer; font-size:0.7rem; background:none; border:none; font-family:inherit; }
        footer .footer-links a:hover, footer .footer-links button:hover { color:#2563eb; text-decoration:underline; }
        .dashboard-columns { display:flex; gap:1.5rem; margin-bottom:1rem; }
        .dashboard-columns > * { flex:1; min-width:0; }
        .dashboard-stats-panel { background:white; border-radius:1.5rem; padding:1.5rem; box-shadow:var(--shadow-card); border:1px solid #eef2f6; }
        .dashboard-stats-panel .stat-row { display:flex; justify-content:space-between; padding:0.4rem 0; border-bottom:1px solid #f0f2f5; font-size:0.9rem; cursor:default; }
        .dashboard-stats-panel .stat-row.clickable { cursor:pointer; }
        .dashboard-stats-panel .stat-row.hidden-row { text-decoration:line-through; color:#94a3b8; }
        .task-input-row { display:flex; align-items:center; gap:0.5rem; margin:0.3rem 0; }
        .task-input-row input { flex:1; min-height:38px; padding:0.5rem 0.65rem; border:1px solid #cbd5e1; border-radius:0.75rem; font-size:0.85rem; transition:border-color .2s,box-shadow .2s; }
        .task-input-row input:focus { border-color:#93c5fd; box-shadow:0 0 0 3px rgba(37,99,235,0.1); outline:none; }
        .task-number { font-weight:600; min-width:1.5rem; color:#2563eb; }
        .task-completed { text-decoration:line-through; color:#16a34a; font-weight:500; background:transparent !important; }
        .task-completed input { text-decoration:line-through; color:#16a34a; background:transparent; }
        .task-done-btn, .task-delete-btn { width:34px; height:34px; cursor:pointer; font-size:0.9rem; padding:0; border-radius:0.65rem; border:none; background:transparent; display:grid; place-items:center; }
        .task-done-btn { color:#16a34a; }
        .task-done-btn:hover { background:#bbf7d0; }
        .task-delete-btn { color:#dc2626; }
        .task-delete-btn:hover { background:#fecaca; }
        .collapse-toggle { cursor:pointer; font-size:1rem; color:#64748b; transition:0.2s; }
        .collapse-toggle:hover { color:#1e293b; }
        .billing-settings-card { background:white; border-radius:1.5rem; padding:1.5rem; margin-bottom:1.5rem; box-shadow:0 4px 12px rgba(0,0,0,0.03); border:1px solid #eef2f6; }
        .billing-row { display:flex; align-items:center; gap:1.5rem; flex-wrap:wrap; margin-bottom:1rem; }
        .billing-row > div { flex:1; min-width:150px; }
        .retention-days-input { width:62px; padding:0.28rem 0.45rem; border:1px solid #cbd5e1; border-radius:0.55rem; text-align:center; font-size:0.85rem; }
        .spinner { display:inline-block; width:1.5rem; height:1.5rem; border:3px solid #e2e8f0; border-top:3px solid #2563eb; border-radius:50%; animation: spin 0.8s linear infinite; }
        @keyframes spin { to { transform: rotate(360deg); } }
        .nav-icon-dashboard { color:#4f5b7a; }
        .nav-icon-calendar { color:#7c3aed; }
        .nav-icon-customers { color:#be185d; }
        .nav-icon-treatments { color:#047857; }
        .nav-icon-leads { color:#b45309; }
        .nav-icon-retention { color:#b91c1c; }
        .nav-icon-messaging { color:#4338ca; }
        .nav-icon-billing { color:#1d4ed8; }
        .nav-icon-inventory { color:#0f766e; }
        .nav-icon-finance { color:#c2410c; }
        .sidebar nav a.active i { color:#2563eb; }
        .brand-mark { width:100px; height:56px; padding:0 0.7rem; border-radius:18px; display:grid; place-items:center; color:white; font-size:0.9rem; font-weight:800; letter-spacing:-0.5px; white-space:nowrap; background:linear-gradient(145deg,#2563eb 0%,#6d5ce7 54%,#ec4899 100%); box-shadow:0 12px 24px rgba(99,102,241,0.24),inset 0 1px 0 rgba(255,255,255,0.32); position:relative; overflow:hidden; }
        .brand-mark::after { content:''; position:absolute; width:42px; height:42px; border:1px solid rgba(255,255,255,0.2); border-radius:50%; top:-18px; left:-13px; }
        .sidebar .logo h1 { letter-spacing:-0.7px; }
        .topbar-brand { display:flex; align-items:center; gap:0.7rem; }
        .topbar-brand .brand-mark { display:none; width:72px; height:38px; padding:0 0.45rem; border-radius:12px; font-size:0.64rem; box-shadow:none; }
        .toast-stack { position:fixed; top:1rem; left:1rem; z-index:3000; display:flex; flex-direction:column; gap:0.65rem; width:min(360px,calc(100vw - 2rem)); pointer-events:none; }
        .toast { background:white; border:1px solid #e2e8f0; border-right:4px solid #2563eb; border-radius:1rem; padding:0.9rem 1rem; box-shadow:0 18px 40px rgba(15,23,42,0.16); display:flex; align-items:flex-start; gap:0.7rem; animation:toastIn .22s ease-out; pointer-events:auto; }
        .toast.success { border-right-color:#16a34a; }
        .toast.error { border-right-color:#dc2626; }
        .toast.warning { border-right-color:#d97706; }
        .toast i { margin-top:0.15rem; }
        .toast.success i { color:#16a34a; }
        .toast.error i { color:#dc2626; }
        .toast.warning i { color:#d97706; }
        .toast.info i { color:#2563eb; }
        .toast-content { flex:1; font-size:0.86rem; line-height:1.5; }
        .toast-close { border:0; background:transparent; color:#94a3b8; cursor:pointer; font-size:1rem; padding:0; }
        @keyframes toastIn { from{opacity:0;transform:translateY(-8px);} to{opacity:1;transform:translateY(0);} }
        .confirm-icon { width:52px; height:52px; display:grid; place-items:center; border-radius:16px; background:#eff6ff; color:#2563eb; font-size:1.25rem; margin-bottom:1rem; }
        .confirm-icon.danger { background:#fef2f2; color:#dc2626; }
        .field-error { border-color:#ef4444 !important; box-shadow:0 0 0 3px rgba(239,68,68,0.1); }
        .field-error-text { display:block; color:#dc2626; font-size:0.73rem; margin:-0.65rem 0 0.75rem; }
        .state-box { min-height:150px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; gap:0.45rem; color:#64748b; padding:2rem 1rem; }
        .state-box i { width:46px; height:46px; display:grid; place-items:center; border-radius:15px; background:#eff6ff; color:#2563eb; font-size:1.1rem; }
        .state-box strong { color:#334155; font-size:0.95rem; }
        .state-box.error i { color:#dc2626; background:#fef2f2; }
        .backup-warning { display:flex; align-items:flex-start; gap:0.65rem; background:#fff7ed; color:#9a3412; border:1px solid #fed7aa; border-radius:var(--radius); padding:0.85rem; font-size:0.8rem; line-height:1.55; margin:1rem 0; }
        .backup-warning i { margin-top:0.15rem; }
        .backup-summary { display:grid; grid-template-columns:repeat(4,1fr); gap:0.65rem; margin:1rem 0; }
        .backup-summary div { background:#f8fafc; border:1px solid #eef2f6; border-radius:var(--radius); padding:0.8rem; text-align:center; }
        .backup-summary strong { display:block; color:var(--primary); font-size:1.1rem; margin-bottom:0.15rem; }
        .backup-summary span { color:var(--muted); font-size:0.72rem; }
        .backup-actions { display:grid; grid-template-columns:1fr 1fr; gap:0.75rem; margin-top:1rem; }
        .backup-actions button { width:100%; }
        .empty-row td { height:170px; text-align:center; color:#64748b; }
        .empty-row td::before { display:none !important; }
        button:disabled { opacity:0.65; cursor:not-allowed; transform:none !important; }
        .btn-spinner { width:14px; height:14px; border:2px solid rgba(255,255,255,0.45); border-top-color:white; border-radius:50%; animation:spin .7s linear infinite; }
        @media (max-width:1180px) and (min-width:901px) {
            .sidebar { width:230px; padding-inline:0.75rem; }
            .panel { padding:1.1rem; }
            .dashboard-columns { gap:1rem; }
            .toolbar { gap:0.65rem; }
        }
        @media (max-width:900px) {
            body { background:#f8fafc; padding-bottom:78px; }
            .app-body { display:block; }
            .main { min-width:0; overflow:visible; }
            .sidebar { position:fixed; z-index:1100; bottom:0; left:0; right:0; width:100%; height:72px; padding:0.35rem 0.45rem max(0.35rem,env(safe-area-inset-bottom)); border-left:0; border-top:1px solid #e2e8f0; box-shadow:0 -8px 25px rgba(15,23,42,0.08); overflow-x:auto; overflow-y:hidden; scroll-snap-type:x proximity; scrollbar-width:none; }
            .panel { padding-bottom:calc(5.5rem + env(safe-area-inset-bottom)); }
            .sidebar::-webkit-scrollbar { display:none; }
            .sidebar .logo,.sidebar .stats-mini,.sidebar > .btn-primary,.sidebar > .btn-outline { display:none; }
            .sidebar nav { display:flex; flex:1; gap:0.15rem; min-width:max-content; }
            .sidebar nav a { min-width:68px; height:62px; margin:0; padding:0.45rem 0.4rem; flex-direction:column; justify-content:center; gap:0.25rem; border-radius:0.85rem; font-size:0.63rem; white-space:nowrap; scroll-snap-align:center; }
            .sidebar nav a i { font-size:1rem; }
            .topbar { position:sticky; top:0; z-index:900; padding:0.65rem 0.9rem; box-shadow:0 4px 18px rgba(15,23,42,0.05); }
            .topbar-actions .btn-outline { width:42px; padding:0; }
            .topbar-actions .btn-outline i { margin:0; }
            .topbar-actions .btn-outline { font-size:0; gap:0; }
            .topbar-actions .btn-outline i { font-size:0.85rem; }
            .cloud-status { width:34px; padding:0; justify-content:center; }
            .cloud-status span { display:none; }
            .topbar-brand .brand-mark { display:grid; }
            .topbar h2 { font-size:1rem; }
            .panel { padding:1rem; overflow:visible; }
            .dashboard-columns { flex-direction:column; gap:1rem; }
            .dashboard-stats-panel,.billing-settings-card,.messaging-card { padding:1rem; border-radius:1.15rem; }
            .toolbar { gap:0.6rem; margin-bottom:1rem; align-items:stretch; }
            .toolbar > * { flex:1 1 calc(50% - 0.6rem); min-width:0; }
            .toolbar .search-box { flex-basis:100%; }
            .search-box input { width:100%; min-width:0; }
            .calendar { padding:0.8rem; border-radius:1rem; }
            .calendar-grid { gap:0.12rem; }
            .calendar-day-name { font-size:0.62rem; padding:0.2rem 0; overflow:hidden; }
            .calendar-day { padding:0.45rem 0.1rem; font-size:0.78rem; }
            .appointment-item,.treatment-item { align-items:flex-start; gap:0.7rem; }
            .appointment-actions { flex-wrap:wrap; justify-content:flex-end; }
            .appointment-action-row { align-items:stretch !important; }
            .appointment-action-row > span { flex-basis:100%; }
            .appointment-action-row .btn-small { flex:1 1 calc(50% - 0.5rem); min-height:38px; }
            .modal { align-items:flex-end; padding-top:2rem; }
            .modal-card,.modal-card.wide { width:100%; max-width:none; max-height:92vh; border-radius:1.5rem 1.5rem 0 0; padding:1.25rem; }
            .modal-actions { position:sticky; bottom:-1.25rem; background:white; padding:0.8rem 0 1.25rem; z-index:2; }
            .modal-actions button { flex:1; justify-content:center; min-height:44px; }
            .billing-row { gap:0.75rem; }
            .billing-row > div { flex-basis:100%; }
            .messaging-card > div,.msg-template-box > div,.magic-input-row { flex-wrap:wrap !important; }
            .messaging-card select,.messaging-card button,.magic-input-row input,.magic-input-row button { min-height:44px; }
            footer { padding-bottom:1rem; }
            .toast-stack { top:0.7rem; left:0.7rem; width:calc(100vw - 1.4rem); }
            .table-wrapper { background:transparent; box-shadow:none; border:0; overflow:visible; }
            .table-wrapper table,.table-wrapper tbody { display:block; width:100%; }
            .table-wrapper thead { display:none; }
            .table-wrapper tr { display:block; background:white; border:1px solid #e2e8f0; border-radius:1rem; margin-bottom:0.75rem; padding:0.45rem 0.8rem; box-shadow:0 3px 12px rgba(15,23,42,0.04); }
            .table-wrapper td { display:flex; align-items:center; justify-content:space-between; gap:1rem; width:100%; padding:0.55rem 0; border-bottom:1px solid #f1f5f9; text-align:left; }
            .table-wrapper td:last-child { border-bottom:0; }
            .table-wrapper td::before { content:attr(data-label); color:#64748b; font-size:0.72rem; font-weight:600; text-align:right; }
            .table-wrapper td.actions { justify-content:flex-end; min-height:42px; }
            .table-wrapper td.actions::before { margin-left:auto; }
            .finance-summary-table td { text-align:left; }
            .empty-row { padding:0 !important; }
            .empty-row td { display:block; height:auto; border:0; padding:0 !important; }
            .questionnaire-table,.questionnaire-table tbody { display:block; width:100%; }
            .questionnaire-table tr { display:block; padding:0.65rem 0; border-bottom:1px solid #e2e8f0; }
            .questionnaire-table td,.questionnaire-table td:first-child,.questionnaire-table td:last-child { display:flex; width:100%; border:0; padding:0.25rem 0; white-space:normal; }
            .questionnaire-table td:last-child { flex-wrap:wrap; }
            .questionnaire-table input[type="text"],.questionnaire-table input[type="date"],.questionnaire-table input[type="email"],.questionnaire-table select { min-height:42px; }
            .image-section { padding:0.85rem; }
            .after-upload-row { align-items:stretch; flex-wrap:wrap; }
            .after-upload-row #afterDateInput { width:100%; min-width:0; flex:1 1 100%; }
            .after-upload-row #addAfterBtn { width:100%; }
            .task-input-row { gap:0.35rem; }
            .task-number { min-width:1.1rem; font-size:0.78rem; }
            .profile-header { display:block; }
            .profile-header h3 { margin-bottom:0.65rem; line-height:1.45; }
            .profile-header-actions { display:none; }
            .profile-contact { align-items:flex-start; flex-direction:column; gap:0.25rem; }
            .backup-summary { grid-template-columns:repeat(2,1fr); }
            .retention-hero { align-items:stretch; flex-direction:column; padding:1.2rem; }
            .retention-hero .btn-outline { width:100%; }
            .retention-stats { grid-template-columns:1fr; gap:0.55rem; }
            .retention-stat { padding:0.8rem 0.9rem; }
            .retention-client-card { grid-template-columns:auto minmax(0,1fr) auto; gap:0.65rem; }
            .retention-last-visit { grid-column:2 / 4; }
            .retention-days-badge { grid-column:3; grid-row:1; }
            .retention-client-actions { grid-column:1 / 4; }
            .retention-client-actions .btn-small { flex:1; min-height:38px; }
        }
        @media (max-width:480px) {
            .auth-card { padding:1.4rem; border-radius:1.5rem; }
            .auth-actions { grid-template-columns:1fr; }
            .panel { padding:0.75rem 0.75rem calc(5.25rem + env(safe-area-inset-bottom)); }
            .toolbar > * { flex-basis:100%; }
            .btn-primary,.btn-outline,.btn-export,.quick-action-btn { min-height:42px; justify-content:center; }
            .summary-box { align-items:stretch; flex-direction:column; }
            .topbar .btn-export { padding:0.45rem 0.7rem; font-size:0.72rem; }
            .medical-item { align-items:flex-start; flex-direction:column; }
            .medical-item label { min-width:0; }
            .medical-item input[type="text"],.medical-item input[type="date"] { width:100%; }
            .modal-card h3 { font-size:1.05rem; }
            .billing-row .btn-primary { width:100%; }
            .messaging-card > div:last-child { align-items:stretch !important; }
            .messaging-card > div:last-child > * { flex:1; }
            .task-input-row input { min-width:0; }
            .backup-actions { grid-template-columns:1fr; }
        }
        @media (prefers-reduced-motion:reduce) {
            *,*::before,*::after { scroll-behavior:auto !important; transition-duration:0.01ms !important; animation-duration:0.01ms !important; animation-iteration-count:1 !important; }
        }
