/* ChiroApp - Design System & Core Styles */

/* ========================================
   CSS Custom Properties (Design Tokens)
   ======================================== */
:root {
    --cal-px-per-hour: 80px;
    /* --- VLC-1.0 Design Tokens --- */
    /* Color Tokens */
    --vlc-color-brand-primary: var(--primary-color, #6366f1);
    --vlc-color-status-scheduled: var(--vlc-color-workflow-scheduled, #10b981);
    --vlc-color-status-requested: var(--accent-rose, #ef4444);
    --vlc-color-status-completed: var(--vlc-color-workflow-completed, #94a3b8);
    --vlc-color-status-blocked: var(--vlc-color-workflow-blocked, #6b7280);
    --vlc-color-status-blocked-bg: #f3f4f6;
    --vlc-color-status-blocked-border: var(--vlc-color-workflow-blocked, #6b7280);
    --vlc-color-status-followup: var(--accent-amber, #f59e0b);
    --vlc-color-alert-emergency: #dc2626;
    
    /* --- VLC-1.1 Design Tokens --- */
    --vlc-color-workflow-scheduled: #10b981; /* Green */
    --vlc-color-workflow-requested: #ef4444; /* Red */
    --vlc-color-workflow-followup: #f59e0b;  /* Yellow/Amber */
    --vlc-color-workflow-blocked: #6b7280;   /* Gray */
    --vlc-color-workflow-completed: #94a3b8; /* Muted Gray */
    
    /* Layout & Border Tokens */
    --vlc-border-radius-badge: 4px;
    --vlc-border-radius-card: 12px;
    --vlc-border-radius-avatar: 8px;
    --vlc-border-width-thin: 1px;
    --vlc-border-width-thick: 4px;
    --vlc-border-outline-selected: 2px solid var(--vlc-color-brand-primary);
    --vlc-border-outline-emergency: 2px solid var(--vlc-color-alert-emergency);
    
    /* Spacing Tokens */
    --vlc-spacing-xs: 4px;
    --vlc-spacing-sm: 8px;
    --vlc-spacing-md: 12px;
    --vlc-spacing-lg: 16px;
    
    /* Opacity Tokens */
    --vlc-opacity-standard: 1.0;
    --vlc-opacity-completed: 0.6;
    --vlc-opacity-disabled: 0.5;

    /* Primary Colors - Defaults. BRAND-1677 (owner 2026-11-18; NOT FOR MERGE UNTIL OWNER APPROVES): ChiroApp green is
       the default (was indigo). These are Components.brandPalette(Components.BRAND_GREEN); App.applyThemeColor sets the
       whole scale from the practice's own colour on <html> (inline), so every --primary-* token follows it. */
    --primary-color: #355e3b;
    --primary-color-dark: #2a4b2f;
    --primary-rgb: 53, 94, 59;
    --primary-contrast: #ffffff;
    --primary-text: #355e3b;   /* headings, the Home greeting, accent text (Components.brandPalette) */

    --primary-50: #ecf5ee;
    --primary-100: #daeadc;
    --primary-200: #b9d8be;
    --primary-300: #90c097;
    --primary-400: #5da367;
    --primary-500: var(--primary-color);
    --primary-600: var(--primary-color-dark);
    --primary-700: #223d26;
    --primary-800: #1c311f;
    --primary-900: #142416;

    --secondary-500: #0ea5e9;
    --secondary-600: #0284c7;
    --secondary-rgb: 14, 165, 233;

    /* Accent Colors */
    --accent-teal: #14b8a6;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-emerald: #10b981;

    /* Species Colors */
    --species-human: #6366f1;
    --species-equine: #8b5cf6;
    --species-canine: #f59e0b;
    --species-bovine: #84cc16;
    --species-feline: #ec4899;
    --species-caprine: #14b8a6;
    --species-lagomorpha: #f97316;

    /* Neutral Colors - Light Mode */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.3);
    --shadow-color: rgba(15, 23, 42, 0.08);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Appearance Settings */
    --fading-color-1: rgba(53, 94, 59, 0.15);
    --fading-color-2: rgba(74, 125, 82, 0.1);
    --fading-color-3: rgba(53, 94, 59, 0.08);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;

    /* Z-Index Stacking Hierarchy */
    --z-content: 1;
    --z-quick-access: 900;
    --z-mobile-header: 1000;
    --z-doctor-notif: 1050;
    --z-pwa-overlay: 1100;
    --z-backdrop: 1190;
    --z-sidebar: 1200;
    --z-modal: 100005;

    /* Safe-Area Tokens (VLC-1.2 Layout Additions) */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: rgba(20, 20, 20, 0.8);
    --bg-glass: rgba(20, 20, 20, 0.6);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --border-color: rgba(60, 60, 60, 0.3);
    --shadow-color: rgba(255, 255, 255, 0.05);
}

/* ========================================
   Base Styles & Reset
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    touch-action: manipulation;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overscroll-behavior: none;
}

html.login-page {
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding-top: var(--banner-padding-top, 0px);
    /* overflow-x: hidden; removed to prevent iOS Safari position: fixed bugs */
    overscroll-behavior: none;
    transition: background var(--transition-base), color var(--transition-base);
}

body.login-page {
    width: 100%;
}

body.login-page::before {
    background:
        radial-gradient(ellipse at 20% 20%, rgba(53, 94, 59, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(74, 125, 82, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(53, 94, 59, 0.06) 0%, transparent 60%);
}

/* Background Gradient Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, var(--fading-color-1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, var(--fading-color-2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, var(--fading-color-3) 0%, transparent 60%);
    pointer-events: none;
    z-index: -1;
}

/* ========================================
   App Layout
   ======================================== */
#app {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

/* ========================================
   Sidebar Navigation
   ======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-base), transform var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: -1;
}

/* Responsive Modals Moved to bottom of file */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    padding-top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border-color);
}

.sidebar-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    font-family: inherit;
    font-weight: 500;
    position: relative;
}

.sidebar-action-btn i {
    font-size: 1.05rem;
}

.sidebar-action-btn:hover {
    color: var(--primary-500);
    border-color: var(--primary-400);
    background: rgba(var(--primary-rgb), 0.08);
}

.sidebar-action-label {
    font-size: 0.78rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: var(--font-size-2xl);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.logo-text {
    display: none;
}

.logo-img {
    height: 60px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

/* Icon-only logo + branded text */
.logo-icon-only {
    height: 40px;
    width: 40px;
    max-width: 40px;
    border-radius: var(--radius-md);
}

.logo-brand-text {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.logo-brand-accent {
    color: #355E3B;
}

[data-theme="dark"] .logo-brand-accent {
    color: #4a7d52;
}

/* Mobile header branded logo */
.mobile-logo-icon {
    height: 28px;
    width: 28px;
    max-width: 28px;
    border-radius: 6px;
}

.mobile-brand-text {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
}


.menu-toggle,
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
}

.menu-toggle span,
.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition-fast);
}

.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    padding-top: calc(var(--space-sm) + env(safe-area-inset-top, 0px));
    padding-left: calc(var(--space-md) + env(safe-area-inset-left, 0px));
    padding-right: calc(var(--space-md) + env(safe-area-inset-right, 0px));
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
    margin-bottom: var(--space-md);
}

.mobile-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: -1;
}

.mobile-logo {
    height: 36px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
}


.nav-links {
    list-style: none;
    padding: var(--space-md);
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    margin-bottom: var(--space-xs);
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-md) var(--space-lg);
    opacity: 0.5;
}

.logout-link {
    color: var(--accent-rose) !important;
}

.logout-link:hover {
    background: rgba(244, 63, 94, 0.1) !important;
    color: var(--accent-rose) !important;
}

.nav-icon {
    font-size: var(--font-size-xl);
}

.nav-text {
    font-weight: 500;
}

/* ── Nav Group (Collapsible Sections) ── */
.nav-group {
    list-style: none;
    margin-bottom: var(--space-xs);
}

.nav-group-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: var(--text-secondary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 0;
    user-select: none;
    position: relative;
}

.nav-group-header:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-group-header .nav-icon {
    font-size: var(--font-size-xl);
}

.nav-group-header .nav-text {
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 1;
}

.nav-group-caret {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: transform var(--transition-base);
    margin-left: auto;
}

.nav-group.expanded .nav-group-caret {
    transform: rotate(180deg);
}

/* Active group indicator */
.nav-group.has-active .nav-group-header {
    color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.06);
}

.nav-group.has-active .nav-group-header .nav-icon {
    color: var(--primary-500);
}

.nav-group.has-active .nav-group-caret {
    color: var(--primary-400);
}

/* Collapsible children */
.nav-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease;
    opacity: 0;
}

.nav-group.expanded .nav-group-items {
    max-height: 300px;
    opacity: 1;
}

/* Child nav items — indented */
.nav-group-items .nav-link {
    padding: 0.6rem var(--space-lg) 0.6rem 2.75rem;
    font-size: var(--font-size-sm);
    margin-bottom: 1px;
    border-radius: var(--radius-md);
    position: relative;
}

.nav-group-items .nav-link::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
    transition: all var(--transition-fast);
}

.nav-group-items .nav-link:hover::before {
    background: var(--primary-500);
    opacity: 1;
    transform: translateY(-50%) scale(1.3);
}

.nav-group-items .nav-link.active::before {
    background: white;
    opacity: 1;
}

.nav-group-items .nav-icon {
    font-size: 1rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
}

/* Header QR Code Button */
.header-qr-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.header-qr-btn:hover {
    color: var(--primary-500);
    border-color: var(--primary-400);
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.15);
}

/* ========================================
   Doctor Notification Bell & Dropdown
   ======================================== */
.doctor-notif-dropdown {
    position: fixed;
    right: 0.5rem;
    top: calc(44px + env(safe-area-inset-top, 0px) + 4px);
    width: 370px;
    max-width: calc(100vw - 1rem);
    max-height: min(75vh, 520px);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 15px 50px -5px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.03);
    z-index: var(--z-doctor-notif); /* Layer 4: Notification Alerts dropdown */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: notifSlideIn 0.2s ease-out;
}

[data-theme="dark"] .doctor-notif-dropdown {
    background: #1e293b;
}

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


.doctor-notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.doctor-notif-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.doctor-notif-header button {
    background: none;
    border: none;
    color: var(--primary-500);
    font-size: 0.78rem;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.doctor-notif-header button:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

.doctor-notif-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.doctor-notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}

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

.doctor-notif-item:hover {
    background: var(--bg-secondary, #f1f5f9);
}

.doctor-notif-item.unread {
    background: rgba(var(--primary-rgb), 0.06);
}

[data-theme="dark"] .doctor-notif-item.unread {
    background: rgba(var(--primary-rgb), 0.1);
}

.doctor-notif-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-500);
}

.doctor-notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.doctor-notif-icon.type-new_sms { background: rgba(14,165,233,0.12); color: #0ea5e9; }
.doctor-notif-icon.type-invoice_paid { background: rgba(16,185,129,0.12); color: #10b981; }
.doctor-notif-icon.type-appointment_request { background: rgba(245,158,11,0.12); color: #f59e0b; }
.doctor-notif-icon.type-species_correction { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.doctor-notif-icon.type-intake_submitted { background: rgba(var(--primary-rgb), 0.12); color: var(--primary-color); }
.doctor-notif-icon.type-portal_signup { background: rgba(20,184,166,0.12); color: #14b8a6; }
.doctor-notif-icon.type-general { background: var(--bg-secondary); color: var(--text-muted); }
.doctor-notif-icon.type-appointment_confirmed { background: rgba(16,185,129,0.12); color: #10b981; }
.doctor-notif-icon.type-appointment_cancelled { background: rgba(244,63,94,0.12); color: #f43f5e; }
.doctor-notif-icon.type-appointment_rescheduled { background: rgba(14,165,233,0.12); color: #0ea5e9; }
.doctor-notif-icon.type-note_signed { background: rgba(var(--primary-rgb), 0.12); color: var(--primary-color); }
.doctor-notif-icon.type-availability { background: rgba(245,158,11,0.12); color: #f59e0b; }

.doctor-notif-body {
    flex: 1;
    min-width: 0;
}


.doctor-notif-msg {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doctor-notif-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Expanded — show full text on click */
.doctor-notif-item.expanded .doctor-notif-title {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
    white-space: normal;
    word-break: break-word;
}

.doctor-notif-item.expanded .doctor-notif-msg {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
    white-space: pre-wrap;
    word-break: break-word;
}

.doctor-notif-actions {
    display: none;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.doctor-notif-item.expanded .doctor-notif-actions {
    display: flex;
}

.doctor-notif-action-btn {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.doctor-notif-action-btn.primary {
    background: var(--primary-500, #355e3b);
    color: #fff;
}

.doctor-notif-action-btn.primary:hover {
    background: var(--primary-600, #2a4b2f);
}

.doctor-notif-action-btn.outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.doctor-notif-action-btn.outline:hover {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text-primary);
}

.doctor-notif-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
}

.doctor-notif-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 2.5rem 1rem;
    margin: 0;
}

/* Overlay to close dropdown when clicking outside */
.doctor-notif-overlay {
    position: fixed;
    inset: 0;
    z-index: 249;
    background: rgba(0, 0, 0, 0.15);
}

@media (max-width: 600px) {
    .doctor-notif-overlay {
        background: rgba(0, 0, 0, 0.4);
    }
    .doctor-notif-action-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}

.theme-toggle {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

/* ========================================
   Main Content Area
   ======================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-xl);
    transition: margin-left var(--transition-base);
}

/* ========================================
   Pages
   ======================================== */
.page {
    display: none;
    position: relative;
    animation: fadeIn var(--transition-base);
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h1 {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--primary-text, var(--text-primary));   /* BRAND-1677 (owner 2026-11-18): page headings carry the practice colour */
}

.subtitle {
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ========================================
   Glass Card Component
   ======================================== */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px var(--shadow-color);
}

.card {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
}

.card h3 {
    margin-bottom: var(--space-lg);
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   Dashboard Stats Grid
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px var(--shadow-color);
}

.stat-icon {
    font-size: 2.5rem;
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

[data-theme="dark"] .stat-icon {
    background: transparent;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-xl);
}

/* Dashboard Greeting Header. BRAND-1677 (owner 2026-11-18): one solid practice colour for the whole greeting ("Good evening"
   was the light end and the practice name the dark indigo end of a 500 -> 700 gradient). */
.dashboard-greeting-header h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--primary-text, var(--primary-600));
}

/* Task Summary Pills Bar */
.dashboard-tasks-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: var(--space-lg);
    padding: 0;
}

.task-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full, 999px);
    border: 1px solid color-mix(in srgb, var(--pill-color) 30%, transparent);
    background: color-mix(in srgb, var(--pill-color) 8%, transparent);
    color: var(--pill-color);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.task-pill:hover {
    background: color-mix(in srgb, var(--pill-color) 18%, transparent);
    border-color: color-mix(in srgb, var(--pill-color) 50%, transparent);
    transform: translateY(-1px);
}

.task-pill i {
    font-size: 1em;
}

/* Dashboard Empty/Getting Started State */
.dashboard-empty-state {
    grid-column: 1 / -1;
    text-align: center;
}

.dashboard-empty-state .empty-state-content {
    padding: var(--space-xl) 0;
}

.dashboard-empty-state .empty-state-icon {
    font-size: 3rem;
    color: var(--primary-500);
    margin-bottom: var(--space-md);
    opacity: 0.8;
}

.dashboard-empty-state h3 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--space-sm);
}

.dashboard-empty-state p {
    color: var(--text-secondary);
    max-width: 420px;
    margin: 0 auto var(--space-xl);
    line-height: 1.6;
}

.empty-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-md);
}

@media (max-width: 600px) {
    .empty-state-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .dashboard-tasks-bar {
        gap: 6px;
    }
    .task-pill {
        font-size: 0.75rem;
        padding: 5px 10px;
    }
}

/* Attention Card Sections */
.attention-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin: 6px 0 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-md, 8px);
    font-weight: 600;
    font-size: 0.9rem;
}

.attention-count {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* ========================================
   Calendar View (Full Page)
   ======================================== */
.calendar-view {
    width: 100%;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.cal-month-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: var(--space-lg);
}

.cal-day-header {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0 8px;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    gap: 2px;
    min-height: 44px;
}

.cal-day:hover:not(.empty) {
    background: var(--bg-secondary);
}

.cal-day.empty {
    cursor: default;
}

.cal-day.today {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.cal-day.today .cal-dot {
    background: white;
    color: var(--primary-600);
}

.cal-day.selected {
    outline: 2px solid var(--primary-500);
    outline-offset: -2px;
}

.cal-day-num {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
}

.cal-dot-row {
    display: flex;
    gap: 2px;
    justify-content: center;
    flex-wrap: wrap;
}

.cal-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-500);
    color: white;
    font-size: 0.55rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cal-dot.scheduled {
    background: var(--vlc-color-workflow-scheduled, #10b981);
}

.cal-dot.requested {
    background: var(--accent-rose, #ef4444);
}

.cal-dot.followup {
    background: var(--accent-amber, #f59e0b);
}

.cal-dot.completed {
    background: var(--text-muted, #94a3b8);
    width: 14px;
    height: 14px;
    font-size: 0.5rem;
    opacity: 0.7;
}

.cal-day.has-appts:not(.today) {
    background: color-mix(in srgb, var(--primary-500) 8%, transparent);
}

/* Two-panel layout */
.cal-panels {
    display: flex;
    gap: var(--space-lg);
    min-height: 280px;
}

.cal-grid-panel {
    flex: 1;
    min-width: 0;
}

.cal-detail-panel {
    flex: 0 0 380px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg, 12px);
    padding: var(--space-md);
    overflow-y: auto;
    max-height: 700px;
    border: 1px solid var(--border-color);
    scroll-margin-top: 120px;
}

.cal-detail-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    gap: var(--space-sm);
}

.cal-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin: 0;
}

.cal-detail-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

/* Timeline — Vertical Day View */
.cal-timeline {
    position: relative;
    min-height: 200px;
}

.cal-timeline-hours {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-timeline-hours i { font-size: 0.9em; }

/* Hour row — each row represents one hour */
.cal-hour-row {
    display: flex;
    align-items: flex-start;
    position: relative;
    height: var(--cal-px-per-hour, 80px);
    box-sizing: border-box;
    border-top: 1px solid color-mix(in srgb, var(--border-color) 85%, transparent);
}

.cal-hour-row:last-child {
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 85%, transparent);
}

/* Hour label on the left */
.cal-hour-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 52px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 10px;
    transform: translateY(-8px);
    font-variant-numeric: tabular-nums;
    user-select: none;
}

/* Clickable area for the empty hour — subdivided into quarter-hour slots */
.cal-hour-area {
    flex: 1;
    height: 100%;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.cal-quarter-slot {
    flex: 1;
    position: relative;
    transition: background 0.1s ease;
}

.cal-quarter-slot:not(:first-child) {
    border-top: 1px dashed color-mix(in srgb, var(--border-color) 65%, transparent);
}

.cal-quarter-slot:hover {
    background: color-mix(in srgb, var(--primary-500) 6%, transparent);
}

/* After-hours styling */
.cal-hour-row--after-hours {
    background: color-mix(in srgb, var(--text-muted) 5%, transparent);
}

.cal-hour-row--after-hours .cal-hour-label {
    opacity: 0.5;
}

.cal-hour-row--after-hours .cal-quarter-slot:hover {
    background: color-mix(in srgb, var(--primary-500) 3%, transparent);
}

/* Appointment blocks — absolutely positioned in the hour area column */
.cal-appt-block-col {
    position: absolute;
    top: 0;
    left: 52px;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.cal-appt-block {
    position: absolute;
    left: 4px;
    right: 4px;
    background: var(--primary-500);
    color: white;
    border-radius: 6px;
    padding: 4px 8px;
    box-sizing: border-box;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    z-index: 2;
    pointer-events: auto;
    transition: filter 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.cal-appt-block:hover {
    filter: brightness(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 10;
}

.cal-appt-block.requested {
    background: var(--accent-rose, #ef4444);
}

.cal-appt-block.followup {
    background: var(--accent-amber, #f59e0b);
}

.cal-appt-block.completed {
    background: var(--text-muted);
    opacity: 0.7;
}

/* Time Block — bold diagonal stripes so it STANDS OUT */
.cal-appt-block.blocked {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #6b7280;
    border-left: 4px solid #6b7280;
    box-shadow: none;
    font-style: normal;
}

.cal-appt-block.blocked:hover {
    filter: brightness(0.95);
}

.cal-appt-block.blocked .appt-block-name {
    font-weight: 700;
}

/* Monthly calendar dot for blocked time */
.cal-dot.blocked {
    background: var(--vlc-color-workflow-blocked, #6b7280);
    box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--vlc-color-workflow-blocked, #6b7280);
}

/* Day list item status badge */
.cal-appt-status.blocked {
    color: var(--vlc-color-workflow-blocked, #6b7280);
    background: color-mix(in srgb, var(--vlc-color-workflow-blocked, #6b7280) 12%, transparent);
}



/* Dashboard upcoming block item */
.mini-cal-appt-item.is-block {
    border-left: 3px solid var(--vlc-color-workflow-blocked, #6b7280);
    background: repeating-linear-gradient(
        -45deg,
        var(--bg-secondary), var(--bg-secondary) 6px,
        color-mix(in srgb, var(--vlc-color-workflow-blocked, #6b7280) 8%, var(--bg-secondary)) 6px,
        color-mix(in srgb, var(--vlc-color-workflow-blocked, #6b7280) 8%, var(--bg-secondary)) 12px
    );
}

.mini-cal-appt-item.is-block:hover {
    border-color: var(--vlc-color-workflow-blocked, #6b7280);
}

.cal-appt-block .appt-block-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.cal-appt-block .appt-block-detail {
    font-size: 0.68rem;
    font-weight: 400;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compact style for short blocks (15-min) — single line, minimal padding */
.cal-appt-block.compact {
    padding: 2px 6px;
    font-size: 0.7rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    line-height: 1.2;
}

.cal-appt-block.compact .appt-block-name {
    font-size: 0.7rem;
}

.cal-appt-block.compact .appt-block-detail {
    font-size: 0.62rem;
}

/* Location toggle */
.cal-loc-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.cal-loc-toggle button {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cal-loc-toggle button.active {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.cal-closed-msg {
    text-align: center;
    padding: 20px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.cal-closed-msg i { font-size: 1.5rem; display: block; margin-bottom: 8px; opacity: 0.5; }

@media (max-width: 825px) {
    .cal-panels {
        flex-direction: column;
    }
    /* Mobile Calendar Panel Toggles */
    #page-calendar:not(.showing-detail) .cal-detail-panel {
        display: none !important;
    }
    #page-calendar.showing-detail .cal-grid-panel {
        display: none !important;
    }
    #page-calendar.showing-detail .cal-nav {
        display: none !important;
    }
    #page-calendar.showing-detail .cal-back-to-grid {
        display: inline-flex !important;
    }
    .cal-detail-panel {
        flex: none;
        max-height: none;
        width: 100%;
        border: none;
        background: transparent;
        padding: 0;
    }
    .cal-hour-label { width: 44px; font-size: 0.68rem; padding-right: 6px; }
    .cal-appt-block-col { left: 44px; }
    .cal-appt-block { font-size: 0.72rem; padding: 3px 6px; }
}

.cal-appt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-md, 8px);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-bottom: 6px;
    background: var(--bg-card, rgba(255,255,255,0.5));
    border: 1px solid var(--border-color);
}

.cal-appt-item:hover {
    border-color: var(--primary-400);
    box-shadow: 0 2px 6px var(--shadow-color, rgba(0,0,0,0.08));
}

/* Blocked variant for day list */
.cal-appt-item.cal-appt-blocked {
    border: 2px dashed #ff8a65;
    background: repeating-linear-gradient(
        -45deg,
        var(--bg-card), var(--bg-card) 6px,
        color-mix(in srgb, #ff8a65 6%, var(--bg-card)) 6px,
        color-mix(in srgb, #ff8a65 6%, var(--bg-card)) 12px
    );
}

.cal-appt-item.cal-appt-blocked:hover {
    border-color: #e64a19;
}

.cal-appt-item.cal-appt-blocked .cal-appt-icon {
    color: #bf360c;
}



.cal-appt-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.cal-appt-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-appt-info strong {
    font-size: 0.85rem;
    line-height: 1.2;
}

.cal-appt-time {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.cal-appt-status {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
}

.cal-appt-status.completed {
    color: var(--vlc-color-workflow-completed, #94a3b8);
    background: color-mix(in srgb, var(--vlc-color-workflow-completed, #94a3b8) 12%, transparent);
}

.cal-appt-status.scheduled {
    color: var(--vlc-color-workflow-scheduled, #10b981);
    background: color-mix(in srgb, var(--vlc-color-workflow-scheduled, #10b981) 12%, transparent);
}

.cal-appt-status.pending {
    color: var(--accent-amber, #f59e0b);
    background: color-mix(in srgb, var(--accent-amber, #f59e0b) 12%, transparent);
}

/* ========================================
   Mini Calendar (Dashboard) — Compact Widget
   ======================================== */
.mini-cal-widget {
    max-width: 380px;
    margin: 0 auto;
}

.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-cal-header {
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 0 6px;
}

.mini-cal-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 6px 2px;
    min-height: 32px;
}

.mini-cal-day:hover:not(.empty) {
    background: var(--bg-secondary);
}

.mini-cal-day.empty {
    cursor: default;
}

.mini-cal-day.today {
    background: var(--primary-500);
    color: white;
    font-weight: 700;
    border-radius: 8px;
}

.mini-cal-day.has-appts:not(.today) {
    font-weight: 600;
    color: var(--primary-600);
}

.mini-cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary-500);
    position: absolute;
    bottom: 2px;
}

.mini-cal-day.today .mini-cal-dot {
    background: rgba(255,255,255,0.8);
}

/* Upcoming appointments summary below calendar */
.mini-cal-upcoming {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.mini-cal-upcoming-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.mini-cal-appt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--bg-secondary);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.mini-cal-appt-item:hover {
    border-color: var(--primary-400);
    background: color-mix(in srgb, var(--primary-500) 6%, var(--bg-secondary));
}

.mini-cal-appt-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 38px;
    padding: 4px 6px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    line-height: 1;
}

.mini-cal-appt-date .appt-month {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary-500);
    letter-spacing: 0.05em;
}

.mini-cal-appt-date .appt-day {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mini-cal-appt-info {
    flex: 1;
    min-width: 0;
}

.mini-cal-appt-info strong {
    font-size: 0.82rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-cal-appt-info small {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Appointments Sections */
.appointments-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.appointments-section:first-of-type {
    margin-top: var(--space-md);
    border-top: none;
    padding-top: 0;
}

.appointments-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Action Popup */
.action-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn var(--transition-fast);
}

.action-popup {
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-lg);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(20px);
    animation: slideUp var(--transition-base);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.action-popup-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-md);
    text-align: center;
}

.action-popup-btn {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    border-radius: var(--radius-lg);
    cursor: pointer;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all var(--transition-fast);
    outline: none;
}

.action-popup-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.4);
}

.action-popup-btn.delete {
    color: #dc3545;
}

.action-popup-btn.cancel {
    background: transparent;
    color: var(--text-muted);
    border: none;
}

@media (hover: hover) {
    .action-popup-btn:hover {
        background: var(--primary-500);
        color: white;
    }

    .action-popup-btn.delete:hover {
        background: #dc3545;
        color: white;
    }

    .action-popup-btn.cancel:hover {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
}

/* ========================================
   Search & Filter Bar
   ======================================== */
.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    align-items: center;
}

.checkbox-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-sm);
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.search-box .search-icon {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    height: 44px;
    padding: 0 calc(var(--space-md) * 3) 0 calc(var(--space-md) * 3);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box .clear-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 6px;
    margin: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    display: none;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast), transform var(--transition-fast);
    z-index: 2;
}

.search-box .clear-search-btn:hover {
    color: var(--accent-rose, #ef4444);
    transform: translateY(-50%) scale(1.15);
}

.search-box .clear-search-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.search-box input:placeholder-shown ~ .clear-search-btn {
    display: none !important;
}

.search-box input:not(:placeholder-shown) ~ .clear-search-btn {
    display: flex;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.pill {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.pill:hover {
    background: var(--bg-card);
    border-color: var(--primary-400);
    color: var(--primary-500);
}

.pill.active {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    border-color: var(--primary-500);
    color: white;
}

/* ========================================
   Card Grid (Clients/Patients)
   ======================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.entity-card {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
}

@media (hover: hover) {
    .entity-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 40px var(--shadow-color);
    }
}

.entity-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.entity-avatar {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

.entity-avatar.human,
.entity-avatar.equine,
.entity-avatar.canine,
.entity-avatar.bovine,
.entity-avatar.feline,
.entity-avatar.caprine,
.entity-avatar.lagomorpha,
.entity-avatar.ovine,
.entity-avatar.porcine,
.entity-avatar.camelidae,
.entity-avatar.avian,
.entity-avatar.client {
    background: transparent;
    border: 1px solid var(--border-color);
}

.entity-info h4 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.entity-info .species-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-secondary);
}

.entity-details {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.entity-details span {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Click-to-Call / Click-to-Text inline buttons.
   Hidden by default — only shown on actual mobile devices.
   JS phoneActions() also gates rendering via navigator.userAgent check. */
.phone-action-btns {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Show in standalone PWA (installed on phone/tablet) */
@media (display-mode: standalone) {
    .phone-action-btns {
        display: inline-flex !important;
    }
}

/* Show on narrow screens (likely a phone browser, not PWA) */
@media (max-width: 768px) {
    .phone-action-btns {
        display: inline-flex;
    }
}

.phone-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md, 8px);
    background: color-mix(in srgb, var(--primary-500) 12%, transparent);
    color: var(--primary-500);
    font-size: 1.05rem;
    text-decoration: none;
    transition: all var(--transition-fast, 0.15s);
    border: 1px solid color-mix(in srgb, var(--primary-500) 20%, transparent);
    cursor: pointer;
    flex-shrink: 0;
}

.phone-action-btn:hover {
    background: color-mix(in srgb, var(--primary-500) 20%, transparent);
    border-color: var(--primary-400);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.25);
}

.phone-action-btn:active {
    transform: scale(0.95);
}

/* SMS button — green tint */
.phone-action-btn[href^="sms:"] {
    background: color-mix(in srgb, var(--accent-emerald, #10b981) 12%, transparent);
    color: var(--accent-emerald, #10b981);
    border-color: color-mix(in srgb, var(--accent-emerald, #10b981) 25%, transparent);
}

.phone-action-btn[href^="sms:"]:hover {
    background: color-mix(in srgb, var(--accent-emerald, #10b981) 20%, transparent);
    border-color: var(--accent-emerald, #10b981);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}


.card-subsection {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.subsection-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--primary-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
    text-align: center;
    line-height: 1;
}

.btn i,
.btn .ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: inherit;
    line-height: inherit;
    vertical-align: middle;
}

.btn-sm i,
.btn-sm .ph {
    font-size: var(--font-size-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--primary-contrast, white);   /* BRAND-1677: dark text on a very light practice colour */
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--primary-400);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-rose), #e11d48);
    color: white;
}

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

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-card);
    border-color: var(--border-color);
}

/* Delete icon buttons — red trash with red-tinted hover */
.btn-icon .ph-trash,
.btn-icon .ph-x-circle {
    color: var(--accent-rose, #ef4444);
    transition: color var(--transition-fast);
}

.btn-icon:hover .ph-trash,
.btn-icon:hover .ph-x-circle {
    color: #dc2626;
}

.btn-icon:has(.ph-trash):hover,
.btn-icon:has(.ph-x-circle):hover {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}

/* ========================================
   Forms
   ======================================== */
.form-section {
    margin-bottom: var(--space-xl);
}

.form-section h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.subsection-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--primary-400);
    margin-top: var(--space-md);
    margin-bottom: var(--space-md);
    padding-left: var(--space-xs);
    border-left: 3px solid var(--primary-500);
}

.form-hint {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: calc(-1 * var(--space-sm));
    margin-bottom: var(--space-md);
}

.form-group {
    margin-bottom: var(--space-md);
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-group input:not(.area-multiselect-search):not(.acu-point-search):not(.duration-custom-input):not([type="radio"]):not([type="checkbox"]),
.form-group select,
.form-group textarea,
.form-section textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: block;
    padding: 0 var(--space-md);
    height: 44px;
    line-height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.form-group textarea,
.form-section textarea {
    height: auto;
    min-height: 44px;
    line-height: 1.5;
    padding: var(--space-md);
    overflow-y: auto;
    resize: vertical;
}

/* Fix for date inputs on mobile */
input[type="date"],
input[type="datetime-local"],
input[type="time"] {
    min-height: 44px;
    line-height: 44px;
    padding-top: 0;
    padding-bottom: 0;
    /* Ensure good tap target */
    -webkit-appearance: none;
    appearance: none;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-section textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder,
.form-section textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    max-width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}


/* Invoice Line Items */
.invoice-item-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr auto;
    gap: var(--space-sm);
    align-items: end;
    margin-bottom: var(--space-md);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.invoice-item-row .form-group {
    margin-bottom: 0;
}

.invoice-item-row select,
.invoice-item-row input {
    width: 100% !important;
}

.invoice-item-row .price-field {
    min-width: 80px;
}

.invoice-item-row .remove-btn-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 5px;
}

@media (max-width: 768px) {
    .invoice-item-row {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-md);
    }

    .invoice-item-row .form-group:nth-child(1),
    .invoice-item-row .form-group:nth-child(2) {
        grid-column: span 2;
    }

    .invoice-item-row .price-field {
        grid-column: span 1;
    }

    .invoice-item-row .remove-btn-col {
        grid-column: span 1;
        justify-content: flex-start;
        padding-top: 25px;
        /* Align with label height */
    }
}

/* ====== TABS ====== */
.modal-tabs {
    display: flex;
    gap: var(--space-sm);
    border-bottom: none;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.modal-tabs::-webkit-scrollbar {
    display: none;
}

.modal-tab {
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
    font-size: var(--font-size-sm);
    flex: 1 0 auto;
    text-align: center;
    display: flex;
    justify-content: center;
}

@media (hover: hover) {
    .modal-tab:hover {
        background: var(--bg-card);
        border-color: var(--primary-300);
        color: var(--primary-600);
    }
}

.modal-tab.active {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ====== ANATOMY GRIDS ====== */
.anatomy-section {
    margin-bottom: var(--space-xl);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.anatomy-section h4 {
    margin-bottom: var(--space-md);
    color: var(--primary-color);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.anatomy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    width: 100%;
}

.anatomy-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.anatomy-item label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.anatomy-item select,
.anatomy-item input[type="text"] {
    padding: 6px 10px;
    font-size: 0.9rem;
}

/* Anatomy Toggle Buttons */
.anatomy-item-buttons {
    gap: 8px;
}

.anatomy-btn-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.anatomy-toggle-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.anatomy-toggle-btn:hover {
    border-color: var(--primary-400);
    color: var(--primary-600);
    background: var(--bg-glass);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.anatomy-toggle-btn.active {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border-color: var(--primary-500);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}

/* Adjustment method/response details shown when a finding is active */
.anatomy-adj-details {
    margin-top: 6px;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    animation: fadeSlideIn 0.2s ease;
}

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

.anatomy-adj-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.anatomy-adj-select {
    flex: 1;
    min-width: 130px;
    padding: 5px 8px;
    font-size: 0.78rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
}

.anatomy-adj-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

/* "Did Not Treat" toggle badge on each structural finding */
.did-not-treat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.did-not-treat-badge:hover {
    border-color: #f59e0b;
    color: #f59e0b;
}

.did-not-treat-badge.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border-color: #d97706;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.35);
}

.did-not-treat-badge span {
    display: none;
}

@media (min-width: 480px) {
    .did-not-treat-badge span {
        display: inline;
    }
}

/* ====== ICD-10 Diagnosis Tags ====== */
.diagnosis-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    animation: fadeSlideIn 0.2s ease;
}

.diagnosis-tag-remove {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}

.diagnosis-tag-remove:hover {
    color: white;
}

/* ====== ANATOMY SETUP CUSTOMIZATION ====== */
.anatomy-setup-warning {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--warning, #f59e0b) 10%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--warning, #f59e0b) 30%, transparent);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.anatomy-setup-warning i {
    color: var(--warning, #f59e0b);
    font-size: 1.2rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.anatomy-setup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    margin-bottom: 4px;
    border: 2px solid var(--border-color);
    transition: all 0.15s ease;
}

.anatomy-setup-item.is-hidden {
    opacity: 0.45;
    background: var(--bg-tertiary, #f0f0f0);
}

.anatomy-setup-item.dragging {
    opacity: 0.4;
    border-color: var(--primary-400);
    background: rgba(var(--primary-rgb), 0.05);
}

.anatomy-setup-item.drag-over {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.anatomy-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 2px 4px;
    user-select: none;
    touch-action: none;
    flex-shrink: 0;
    transition: color 0.15s;
}

.anatomy-drag-handle:active {
    cursor: grabbing;
}

.anatomy-drag-handle:hover {
    color: var(--primary-500);
}

.anatomy-setup-name {
    flex: 1;
    min-width: 0;
}

.anatomy-setup-name input {
    width: 100%;
    padding: 4px 8px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    transition: all 0.15s;
}

.anatomy-setup-name input:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.anatomy-setup-name input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.anatomy-setup-name .anatomy-original-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 1px;
    font-style: italic;
}

.anatomy-setup-meta {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    padding: 2px 8px 0;
    line-height: 1.2;
}

.anatomy-setup-options {
    flex: 1.5;
    min-width: 0;
}

.anatomy-setup-options input {
    width: 100%;
    padding: 4px 8px;
    font-size: 0.78rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.anatomy-setup-options input:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.anatomy-setup-options input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.anatomy-setup-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.anatomy-setup-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    line-height: 1;
}

.anatomy-setup-actions button:hover {
    background: var(--bg-secondary);
}

.anatomy-setup-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: color-mix(in srgb, var(--primary-500) 6%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--primary-500) 20%, transparent);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.anatomy-setup-hint i {
    color: var(--primary-500);
    font-size: 1rem;
    flex-shrink: 0;
}

.anatomy-setup-hint a {
    color: var(--primary-500);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.anatomy-setup-hint a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .anatomy-setup-item {
        flex-wrap: wrap;
    }
    .anatomy-setup-options {
        width: 100%;
        flex: none;
    }
}

/* ====== EXERCISE SECTIONS ====== */
.exercise-group {
    margin-bottom: var(--space-lg);
}

.exercise-group h4 {
    margin-bottom: var(--space-sm);
    font-size: 1rem;
}


.form-group.inline {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 0;
}

/* ====== NOTECARD ENHANCEMENTS ====== */
.note-summary-box {
    margin: var(--space-md) 0;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.note-summary-box h5 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin: 0 0 4px; /* owner review 2026-11-20 (V13): no browser top margin, the summary starts at the top of its box */
}

/* ECHOCAL-1678 (owner review 2026-11-20 V13): the "Echo draft ready" badge stays on one line like "Draft"; only on a very
   narrow phone (under 375 px) it may wrap to two lines inside the title row instead of widening the card. */
.echo-ready-badge { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 374px) { .echo-ready-badge { white-space: normal; flex-shrink: 1; min-width: 0; } }

.note-summary-box p {
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.note-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.note-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.note-stats i {
    font-size: 1rem;
    color: var(--primary-color);
}

.form-group.inline label {
    margin-bottom: 0;
    white-space: nowrap;
}

/* ====== AI SUMMARY UI ====== */
.summary-type-toggle {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 2px;
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-color);
}

.summary-type-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--text-muted);
    transition: all 0.2s;
}

.summary-type-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.ai-gen-container {
    display: flex;
    justify-content: flex-end;
    margin-top: -10px;
    /* Pull it up closer to the textarea */
    margin-bottom: 10px;
}

.btn-ai-gen {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--primary-color), #818cf8);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-ai-gen:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.4);
}

.btn-ai-gen:active {
    transform: translateY(0);
}

@keyframes sparkle {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }

    100% {
        opacity: 0.5;
        transform: scale(1);
    }
}

.btn-ai-gen i {
    animation: sparkle 2s infinite ease-in-out;
}

.form-group.inline select {
    width: auto;
    min-width: 200px;
    border-radius: var(--radius-lg);
}

/* ====== SOAP Note Form Actions (Mobile-Optimized) ====== */
.note-form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: var(--space-xl);
    padding: var(--space-lg) 0 0;
    border-top: 1px solid var(--border-color);
}

.note-form-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    font-weight: 600;
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
    cursor: pointer;
}

.note-form-action-primary {
    padding: 16px 20px;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.35);
}

.note-form-action-primary:hover {
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.45);
    transform: translateY(-1px);
}

.note-form-action-draft {
    padding: 14px 20px;
    font-size: 0.9rem;
    background: transparent;
    color: var(--primary-500);
    border: 1.5px solid var(--primary-400);
}

.note-form-action-draft:hover {
    background: rgba(var(--primary-rgb), 0.06);
    border-color: var(--primary-500);
}

.note-form-action-cancel {
    padding: 12px 20px;
    font-size: 0.85rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.note-form-action-cancel:hover {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--text-muted);
}

/* On taller/wider screens, use slightly larger gap */
@media (min-width: 480px) {
    .note-form-actions {
        gap: 12px;
    }
}

/* Sticky bottom bar on narrow PWA screens */
@media (max-width: 480px) {
    .note-form-actions {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        margin: var(--space-lg) calc(-1 * var(--space-lg)) 0;
        padding: var(--space-md) var(--space-lg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        z-index: 10;
        gap: 8px;
        border-radius: 0;
    }

    .note-form-action-primary {
        padding: 14px 16px;
        font-size: 0.95rem;
    }

    .note-form-action-draft {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    .note-form-action-cancel {
        padding: 10px 16px;
        font-size: 0.82rem;
    }
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.database-actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.database-actions .btn,
.database-actions .input-group,
.database-actions .input-group .btn {
    flex: 1;
    min-width: 200px;
    width: 100%;

}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-500);
    cursor: pointer;
}

.form-check label {
    cursor: pointer;
    margin-bottom: 0;
}

/* Global safety net: normalize standalone selects that aren't inside .form-group */
select:not([class*="multiselect"]) {
    padding: 0 var(--space-md);
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-sizing: border-box;
}

select:not([class*="multiselect"]):focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

/* Location Toggle Buttons */
.location-toggle-group {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.location-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.location-toggle-btn {
    flex: 1;
    min-width: 30%;
    /* More flexible than fixed px */
    padding: var(--space-md);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    margin-bottom: 0;
}

.location-toggle-btn:hover {
    border-color: var(--primary-400);
    background: var(--bg-glass);
}

.location-toggle-input:checked+.location-toggle-btn {
    border-color: var(--primary-500);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
}

/* Follow-Up toggle (purple) */
#statusFollowup:checked+.location-toggle-btn {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

/* Time Block toggle (amber) */
#statusBlocked:checked+.location-toggle-btn {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.appointment-requested {
    border-left: 4px solid #ef4444 !important;
}

.appointment-scheduled {
    border-left: 4px solid var(--vlc-color-workflow-scheduled, #10b981) !important;
}

.appointment-followup {
    border-left: 4px solid #f59e0b !important;
    /* Yellow/Amber border */
}

.badge-placeholder {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-left: var(--space-xs);
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.action-popup-btn.confirm {
    color: var(--success);
    font-weight: 600;
}

/* ========================================
   Medical Notes
   ======================================== */
.notes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.note-card {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: transform var(--transition-fast);
    cursor: pointer;
}

.note-card:hover {
    transform: translateX(4px);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* Standard Checkbox Customization */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    user-select: none;
    color: var(--text-secondary);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.checkbox-container:hover input~.checkmark {
    background-color: var(--bg-card);
}

.checkbox-container input:checked~.checkmark {
    background-color: var(--primary-500);
    border-color: var(--primary-500);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked~.checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Standalone radio/checkbox inputs (not inside .checkbox-container) */
.form-group input[type="radio"],
.form-group input[type="checkbox"]:not(.checkbox-container input),
.form-section input[type="radio"],
.form-section input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    flex-shrink: 0;
    accent-color: var(--primary-500);
    cursor: pointer;
    margin: 0;
}

/* Radio option card styling */
.radio-option {
    transition: all 0.2s;
}
.radio-option:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color) !important;
}
.radio-option:has(input:checked) {
    background: color-mix(in srgb, var(--primary-500) 6%, transparent);
    border-color: var(--primary-400) !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.setup-section {
    position: relative;
    padding: var(--space-md) 0;
}

.setup-subheading {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--primary-500);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.note-patient-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.note-patient-info .entity-avatar {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
}

.note-patient-info h4 {
    font-weight: 600;
}

.note-patient-info .note-date {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.note-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.note-section h5 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--primary-500);
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.note-section p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========================================
   Intakes List
   ======================================== */
.intakes-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.intake-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.intake-item .entity-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.intake-item-info {
    flex: 1;
}

.intake-item-info h4 {
    font-weight: 600;
    font-size: var(--font-size-base);
}

.intake-item-info p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    opacity: 0;
    visibility: hidden;
    /* z-index is never animated: an overlay raised above another (SCHED-C1-OVERLAY: the import confirmation over the
       migration wizard) must be on top the moment it is visible -- `all` interpolated z-index for ~100 ms and the click
       landed on the wizard (Build 1635 certification, measured). */
    transition: all var(--transition-base), z-index 0s;
    z-index: var(--z-modal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-xl);
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 0 1.5rem 1.5rem;
}

.modal-body .portal-form .form-section:first-child {
    margin-top: 0;
}

/* Slide-Over Panel Variant */
.modal-overlay.slide-over {
    justify-content: flex-end;
    padding: 0;
}

.modal-overlay.slide-over .modal {
    max-width: 560px;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.slide-over.active .modal {
    transform: translateX(0);
}

.modal-overlay.slide-over .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.modal-overlay.slide-over .modal-body {
    padding: 1rem 1.5rem 2rem;
    overflow-y: auto;
}

@media (max-width: 640px) {
    .modal-overlay.slide-over .modal {
        max-width: 100vw;
        width: 100vw;
    }
}

/* Force black text in appointment request review modal */
#requestReviewContent *:not(button):not(.btn):not(.ph):not(i) {
    color: black !important;
}

#requestReviewContent label {
    color: var(--text-muted) !important;
}

/* ========================================
   Form Recovery Banner
   ======================================== */
.form-recovery-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-lg);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.06));
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    animation: recoverySlideIn 0.3s ease-out;
    flex-wrap: wrap;
}

.form-recovery-banner i.ph-clock-counter-clockwise {
    color: #f59e0b;
}

.form-recovery-banner .btn-sm {
    padding: 4px 12px;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-md);
}

.form-recovery-banner .btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.form-recovery-banner .btn-outline:hover {
    background: var(--bg-secondary);
}

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

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    z-index: 20000;
}

.toast {
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-lg);
    color: white;
    font-weight: 500;
    animation: slideIn var(--transition-base);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: 0 8px 32px var(--shadow-color);
}

.toast.success {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
}

.toast.error {
    background: linear-gradient(135deg, var(--accent-rose), #dc2626);
}

.toast.info {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
}

.toast.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastCountdown {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-2xl);
    font-style: italic;
}

/* ========================================
   Recent List
   ======================================== */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.recent-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    cursor: pointer;
}

@media (hover: hover) {
    .recent-item:hover {
        transform: translateX(4px);
        border-color: var(--primary-400);
    }
}

/* Dashboard info tooltip popover */
.dashboard-tooltip {
    position: relative;
}

.dashboard-tooltip-popup {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 400;
    font-style: normal;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px var(--shadow-color);
    white-space: normal;
    width: max-content;
    max-width: 260px;
    z-index: 100;
    pointer-events: none;
    animation: tooltipFadeIn 0.15s ease;
}

.dashboard-tooltip-popup::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--border-color);
}

.dashboard-tooltip-popup::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--bg-card);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.recent-item .entity-avatar {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.recent-item-info h4 {
    font-weight: 600;
    font-size: var(--font-size-base);
}

.recent-item-info p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* ========================================
   Species Chart
   ======================================== */
.species-chart {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    justify-content: center;
}

.species-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    min-width: 80px;
}

.species-stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
}

.species-stat-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.species-stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

/* ========================================
   Appointments
   ======================================== */
.appointments-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.appointment-card {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: transform var(--transition-fast);
}

.appointment-card:hover {
    transform: translateX(4px);
}

.appointment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.appointment-datetime {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.appointment-date {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.appointment-time {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary-500);
}

.appointment-status {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.appointment-status.status-scheduled {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.25));
    color: var(--vlc-color-workflow-scheduled, #10b981);
    border: 1px solid var(--vlc-color-workflow-scheduled, #10b981);
}

.appointment-status.status-requested {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.25));
    color: #ef4444;
    /* Standard Red */
    border: 1px solid #ef4444;
}

.appointment-status.status-followup {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.25));
    color: #f59e0b;
    /* Amber/Yellow for follow-up */
    border: 1px solid #f59e0b;
}

.appointment-status.status-completed {
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.15), rgba(100, 116, 139, 0.25));
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.appointment-status.status-cancelled {
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.15), rgba(100, 116, 139, 0.25));
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.appointment-status-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-confirm-group {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.confirm-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color var(--transition-base);
}

.status-confirm-toggle {
    width: 38px;
    height: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    position: relative;
    transition: all var(--transition-base);
    display: flex;
}

.status-confirm-group:hover .confirm-label {
    color: var(--primary-color);
}

.status-confirm-group:hover .status-confirm-toggle {
    border-color: var(--primary-color);
}

.status-confirm-toggle .switch-handle {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    transition: all var(--transition-base);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.status-confirm-group:hover .switch-handle {
    transform: translateX(18px);
    background: var(--primary-color);
}

.appointment-patient {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.appointment-patient .entity-avatar {
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
}

.appointment-patient-info h4 {
    font-weight: 600;
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-xs);
}

.appointment-patient-info span {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.appointment-notes {
    padding: var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--primary-400);
    margin-bottom: var(--space-md);
}

.appointment-notes p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* ========================================
   Utilities
   ======================================== */
.mt-4 {
    margin-top: var(--space-xl) !important;
}

/* ========================================
   List Editor (Setup Page)
   ======================================== */
.list-editor {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    max-height: 800px;
    overflow-y: auto;
}

.modal {
    background: var(--bg-primary);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent side-scrolling */
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp var(--transition-base);
}

.modal-overlay.active .modal {
    display: block;
}

.list-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.list-item-row:hover {
    border-color: var(--primary-400);
}

.list-item-row span {
    font-weight: 500;
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

.input-group input {
    flex: 1;
}

.list-editor .empty-state {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-muted);
}

/* Color Picker Refinement */
input[type="color"] {
    height: 50px;
    padding: var(--space-xs);
    cursor: pointer;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1024px) {
    /* 
      ════════════════════════════════════════════════════════════════
      DOCUMENTED MOBILE STACKING LAYER HIERARCHY
      ════════════════════════════════════════════════════════════════
      Layer 1: Normal Page Content Flow -> var(--z-content) [1]
      Layer 2: Bottom Navigation Bar (.quick-access-bar) -> var(--z-quick-access) [900]
      Layer 3: Mobile Sticky Header (.mobile-header) -> var(--z-mobile-header) [1000]
      Layer 4: Notification Alerts dropdown (.doctor-notif-dropdown) -> var(--z-doctor-notif) [1050]
      Layer 5: Full-Page PWA Overlays (.avail-notify-page) -> var(--z-pwa-overlay) [1100]
      Layer 6: Dimming Backdrop Overlay (body.sidebar-open::after) -> var(--z-backdrop) [1190]
      Layer 7: Navigation Drawer / Sidebar (.sidebar) -> var(--z-sidebar) [1200]
      Layer 8: Modals and Dialog Prompts (.modal-overlay) -> var(--z-modal) [9999+]
      ════════════════════════════════════════════════════════════════
    */

    .sidebar {
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        z-index: var(--z-sidebar); /* Layer 7: Navigation Drawer / Sidebar */
        top: 0;
        height: 100vh;
        overflow-y: auto !important; /* Ensure sidebar is scrollable independent of locked body */
        -webkit-overflow-scrolling: touch;
        padding-top: calc(56px + env(safe-area-inset-top, 0px));
        box-sizing: border-box;
    }

    .sidebar.open {
        transform: translateX(0);
        width: 100%;
        max-width: 300px;
    }

    /* Hide sidebar header on mobile - mobile-header already shows hamburger + logo */
    .sidebar-header {
        display: none;
    }

    /* Hide sidebar QR/bell on mobile — mobile-header already has them in top-right */
    .sidebar-actions {
        display: none;
    }

    .sidebar .logo-img {
        height: 36px;
        max-width: 100px;
    }

    .main-content {
        margin-left: 0;
        padding: 0.75rem;
        padding-top: calc(80px + env(safe-area-inset-top, 0px));
        padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        /* Space for fixed header */
        position: relative;
        z-index: var(--z-content); /* Layer 1: Normal Page Content Flow */
        overflow-x: hidden;
        box-sizing: border-box;
        width: 100%;
        max-width: 100vw;
    }

    .menu-toggle,
    .mobile-menu-btn {
        display: flex;
        /* Show toggle buttons */
    }

    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: var(--z-mobile-header); /* Layer 3: Mobile Sticky Header */
        /* IOSFIXES-1682: ONE opaque colour, no backdrop-filter anywhere in the header. iOS 26 only paints the status bar a clean
           solid colour when the fixed top bar is opaque; a blurred translucent ::before made it add its own soft blur (fuzzy
           header on the iPhone home-screen app). #fcfdfe = the old 60% white glass composited over --bg-primary, so no visible change. */
        background: #fcfdfe;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 10px var(--shadow-color);
    }
    [data-theme="dark"] .mobile-header { background: #0c0c0c; }
    .mobile-header::before { display: none; }

    /* Remove pseudo element spacer if it exists */
    .main-content::before {
        display: none;
    }

    /* Scroll Lock and Backdrop Overlay Styles when mobile drawer is open */
    body.sidebar-open {
        overflow: hidden !important;
    }

    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: var(--z-backdrop); /* Layer 6: Dimming Backdrop Overlay */
        pointer-events: auto;
        animation: fadeIn 0.2s ease;
    }
}

@media (max-width: 768px) {
    :root {
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
    }

    .page-header {
        flex-direction: column;
        gap: var(--space-md);
    }

    .search-filter-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .search-box {
        max-width: 100%;
        flex: 1;
        min-width: 140px;
    }

    .search-filter-bar > .form-group.inline {
        flex: 0 1 auto;
        min-width: 0;
    }

    .search-filter-bar > .form-group.inline select {
        min-width: 120px;
        max-width: 200px;
        font-size: 0.82rem;
    }

    .page-header>div {
        width: 100%;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-icon {
        width: 52px;
        height: 52px;
        font-size: 1.8rem;
    }

    .card {
        padding: var(--space-md);
        overflow-x: auto;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .note-sections {
        grid-template-columns: 1fr;
    }

    .filter-pills {
        /* Mobile: Grid/Button layout */
        overflow-x: visible;
        flex-wrap: wrap;
        padding-bottom: var(--space-sm);
        max-width: 100%;
        width: 100%;
    }

    .pill {
        flex: 1 0 auto;
        /* Grow to fill space */
        text-align: center;
        min-width: 80px;
        /* Prevent being too small */
        justify-content: center;
    }

    .modal {
        margin: var(--space-sm);
        max-height: calc(100vh - var(--space-md) * 2);
        width: calc(100% - var(--space-sm) * 2);
    }

    .modal-body {
        padding: var(--space-md);
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
        bottom: var(--space-md);
    }

    /* Push toasts above portal bottom nav on mobile */
    body.portal-active .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }

    /* Push toasts above doctor quick-access bar on mobile */
    body.has-quick-access .toast-container {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-box {
        max-width: 100%;
    }

    .entity-actions {
        flex-wrap: wrap;
    }

    .entity-actions .btn {
        flex: 1;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {

    .sidebar,
    .menu-toggle,
    .btn,
    .search-filter-bar,
    .toast-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body::before {
        display: none;
    }

    .glass {
        background: white;
        backdrop-filter: none;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .page {
        display: block !important;
        page-break-after: always;
    }
}

/* Financial Summary Card */
.financial-summary-card {
    grid-column: span 2;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .financial-summary-card {
        grid-column: span 1;
    }
}

.financial-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
    text-align: center;
}

/* Financial Summary Card Improvements */
.financial-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.financial-summary-card.collapsed {
    padding-bottom: 20px;
}

.financial-summary-card.collapsed .financial-card-header {
    margin-bottom: 0;
}

.financial-summary-card.collapsed .financial-card-body {
    display: none;
}

#financialPeriodSelector {
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s;
}

#financialPeriodSelector:hover {
    border-color: var(--primary-color);
}

.progress-section {
    margin: 20px 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 5px;
}

@media (max-width: 768px) {
    .financial-stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .financial-summary-card {
        padding: 15px;
    }

    .financial-card-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .financial-card-header .header-right {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .financial-card-header .header-right select,
    .financial-card-header .header-right .btn {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .financial-stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-main {
        padding: 10px;
    }
}

.stat-main {
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-container {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

.financial-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 640px) {
    .financial-details {
        grid-template-columns: 1fr;
    }
}

.detail-section h4 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-hover);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span {
    color: var(--text-muted);
}

.stat-row strong {
    color: var(--text-primary);
}

/* Financial Report Cards */
.financial-report-card {
    margin-bottom: 20px;
}

.financial-report-card.collapsed {
    padding-bottom: 20px;
}

.financial-report-card.collapsed .financial-card-header {
    margin-bottom: 0;
}

.financial-report-card.collapsed .financial-card-body {
    display: none;
}

.report-table-container {
    overflow-x: auto;
    margin-top: 15px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.report-table thead {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.report-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.report-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--bg-hover);
    color: var(--text-primary);
}

.report-table tbody tr:hover {
    background: var(--bg-hover);
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

@media (max-width: 768px) {
    .financial-report-card {
        overflow: visible;
    }

    .report-table-container {
        overflow-x: hidden;
        max-width: 100%;
    }

    /* Stacked card layout: hide table header, each row becomes a card */
    .report-table {
        font-size: 0.85rem;
        min-width: 0;
        width: 100%;
    }

    .report-table thead {
        display: none;
    }

    .report-table tbody tr {
        display: block;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 10px;
        padding: 10px 12px;
    }

    .report-table tbody tr:hover {
        background: var(--bg-secondary);
    }

    .report-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: 1px solid var(--bg-hover);
        white-space: normal;
        word-break: break-word;
    }

    .report-table td:last-child {
        border-bottom: none;
    }

    .report-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        flex-shrink: 0;
        margin-right: 12px;
    }
}

/* ========================================
   Intake Form Agreements
   ======================================== */
.policy-text-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    max-height: 200px;
    overflow-y: auto;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.5;
}

.checkbox-label-text {
    font-weight: 500;
    color: var(--text-primary);
}

/* ========================================
   Setup Page Categories
   ======================================== */
.setup-category {
    margin-bottom: var(--space-lg);
    scroll-margin-top: 120px;
}

.setup-category-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.setup-category-header:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-500);
}

.setup-category-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.setup-category-header>i:first-child {
    font-size: var(--font-size-xl);
    color: var(--primary-500);
}

.setup-category-toggle {
    font-size: var(--font-size-lg);
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.setup-category.expanded .setup-category-toggle {
    transform: rotate(180deg);
}

.setup-category-content {
    display: none;
    padding: 0 var(--space-sm);
}

.setup-category.expanded .setup-category-content {
    display: block;
    padding: var(--space-lg) var(--space-sm);
}


.setup-category-content .card {
    margin-bottom: var(--space-lg);
    scroll-margin-top: 120px;
}

.setup-category-content .card:last-child {
    margin-bottom: 0;
}

/* Category Preview Pills (shown when collapsed) */
.setup-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 var(--space-lg);
    margin-top: 12px;
    margin-bottom: 12px;
}

.setup-category.expanded .setup-category-pills {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    padding-bottom: 0;
    margin-top: 0;
    pointer-events: none;
}

.setup-category-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.setup-category-pill i {
    font-size: 0.8rem;
    opacity: 0.6;
}

.setup-category-pill:hover {
    background: rgba(var(--primary-rgb), 0.1);
    border-color: var(--primary-400);
    color: var(--primary-600);
    transform: translateY(-1px);
}

.setup-category-pill:active {
    transform: translateY(0);
    background: rgba(var(--primary-rgb), 0.15);
}

/* Exam Test Grid */
/* ROM Region Cards */
.rom-region-card {
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary-500);
    border-radius: var(--radius-md);
}

.rom-region-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.rom-region-card .exam-test-grid {
    gap: 6px;
}

.rom-region-card .exam-test-item {
    background: var(--bg-card);
}

.exam-test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 8px;
}

.exam-test-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    min-height: 36px;
}

.exam-test-label {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
    padding-top: 2px;
    min-width: 0;
}

.exam-test-item select,
.exam-test-item input[type="number"] {
    padding: 4px 6px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    flex-shrink: 0;
    box-sizing: border-box;
}

/* ROM degree input with persistent ° suffix */
.rom-input-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    flex-shrink: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.rom-degree-input {
    border: none !important;
    background: transparent !important;
    text-align: center;
    font-size: 16px !important;
    padding: 4px 2px 4px 6px !important;
    width: 100%;
    min-width: 0;
    flex: 1;
    outline: none;
    color: var(--text-primary);
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    box-sizing: border-box;
    height: auto;
}

.rom-degree-input:focus {
    outline: none;
    box-shadow: none;
}

.rom-input-wrap:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}

.rom-degree-suffix {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-right: 8px;
    flex-shrink: 0;
    user-select: none;
    pointer-events: none;
}

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

    .exam-test-item select,
    .exam-test-item input[type="number"],
    .exam-test-item input[type="text"] {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
        font-size: 16px;
    }

    .rom-input-wrap {
        width: 130px;
        min-width: 130px;
        max-width: 130px;
    }

    /* Prevent iOS auto-zoom on input focus */
    .exam-test-item select {
        font-size: 16px;
    }
}

/* Auto-resize textareas (Plan Narrative, etc.) */
textarea.auto-resize {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    resize: vertical;
    min-height: 4em;
    max-height: 50vh;
    transition: height 0.15s ease;
}

/* Tab Navigation Bar (bottom of each tab) */
.tab-nav-bar {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.tab-nav-bar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.tab-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.tab-nav-top {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tab-nav-top:hover {
    color: var(--primary-500);
}

/* Duration Combo Picker */
.duration-combo {
    display: flex;
    gap: 6px;
    align-items: center;
}

.duration-combo select {
    flex: 1;
    min-width: 0;
}

.duration-combo .duration-custom-input {
    width: 70px;
    text-align: center;
    display: none;
    padding: 0 var(--space-md);
    height: 44px;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
}

.duration-combo .duration-custom-input.visible {
    display: block;
}

.duration-combo .duration-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    display: none;
}

.duration-combo .duration-unit.visible {
    display: block;
}

/* Area Multi-Select */
.area-multiselect {
    position: relative;
}

.area-multiselect-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 var(--space-md);
    height: 44px;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: text;
    align-items: center;
    transition: border-color 0.2s;
    font-size: var(--font-size-base);
    overflow: hidden;
}

.area-multiselect-tags:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.area-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
    border-radius: 999px;
    white-space: nowrap;
    animation: tagPop 0.2s ease;
    line-height: 1.4;
}

@keyframes tagPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.area-tag button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--primary-400);
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
}

.area-tag button:hover {
    color: var(--accent-rose);
}

.area-multiselect-search {
    border: none !important;
    outline: none;
    flex: 1;
    min-width: 60px;
    min-height: 0 !important;
    height: auto !important;
    font-size: 0.82rem;
    background: transparent !important;
    color: var(--text-primary);
    padding: 3px 0 !important;
    box-shadow: none !important;
    display: inline;
}

.area-multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-top: 4px;
    display: none;
}

[data-theme="dark"] .area-multiselect-dropdown {
    background: #1e1e1e;
}

.area-multiselect-dropdown.open {
    display: block;
}

.area-multiselect-dropdown .area-group-label {
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}

.area-multiselect-dropdown .area-option {
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
}

.area-multiselect-dropdown .area-option:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

.area-multiselect-dropdown .area-option.selected {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-600);
    font-weight: 600;
}

/* Acupuncture Point Picker */
.acu-point-picker {
    position: relative;
}

.acu-point-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 var(--space-md);
    height: 44px;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: text;
    align-items: center;
    transition: border-color 0.2s;
    font-size: var(--font-size-base);
    overflow: hidden;
}

.acu-point-tags:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1);
}

.acu-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald, #059669);
    border-radius: 999px;
    white-space: nowrap;
    animation: tagPop 0.2s ease;
}

.acu-tag button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: rgba(16, 185, 129, 0.5);
    padding: 0;
    line-height: 1;
}

.acu-tag button:hover {
    color: var(--accent-rose);
}

.acu-point-search {
    border: none !important;
    outline: none;
    flex: 1;
    min-width: 100px;
    min-height: 0 !important;
    height: auto !important;
    font-size: 0.85rem;
    background: transparent !important;
    color: var(--text-primary);
    padding: 3px 0 !important;
    box-shadow: none !important;
    display: inline;
}

.acu-point-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-top: 4px;
    display: none;
}

[data-theme="dark"] .acu-point-dropdown {
    background: #1e1e1e;
}

.acu-point-dropdown.open {
    display: block;
}

.acu-point-dropdown .acu-group-label {
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}

.acu-point-dropdown .acu-option {
    padding: 5px 12px;
    font-size: 0.83rem;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.acu-point-dropdown .acu-option:hover {
    background: rgba(16, 185, 129, 0.08);
}

.acu-point-dropdown .acu-option.selected {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald, #059669);
    font-weight: 600;
}

.acu-point-dropdown .acu-option .acu-point-code {
    font-weight: 700;
    min-width: 50px;
}

.acu-point-dropdown .acu-option .acu-point-desc {
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ACUDICTATE-1675: free point dictation (keyboard mic or typing), reviewed before adding */
.acu-dictate { margin-top: 8px; }
.acu-dictate [hidden] { display: none !important; }
.acu-dictate-panel { margin-top: 4px; padding: 10px; border: 1px solid var(--border-color, #e2e8f0); border-radius: 8px; background: var(--bg-secondary, transparent); }
.acu-dictate-panel .form-hint { margin: 0 0 8px; }
.acu-dictate-text { width: 100%; box-sizing: border-box; font-size: max(16px, 1rem); min-height: 72px; }
.acu-dictate-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.acu-dictate-review:not(:empty) { margin-top: 10px; }
.acu-dictate-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.acu-dictate-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.95rem; line-height: 1.35; overflow-wrap: anywhere; }
.acu-dictate-row input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 auto; }
.acu-dictate-side { color: var(--text-muted); font-size: 0.85rem; }
.acu-dictate-warn .acu-dictate-note { color: var(--warning-700, #b45309); font-size: 0.85rem; }

/* ECHO-FORM-1675: values Echo filled are marked "Suggested by Echo" and reviewed before save (390 px: wraps, no side scroll) */
.echo-review { margin: 0 0 1rem; padding: 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--primary-500, #355e3b) 35%, transparent); background: color-mix(in srgb, var(--primary-500, #355e3b) 6%, var(--bg-secondary, transparent)); max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere; }
.echo-review-head { display: flex; align-items: center; gap: 6px; font-size: 0.98rem; color: var(--text-primary); }
.echo-review-head i { color: var(--primary-500, #355e3b); }
.echo-review-hint { margin: 6px 0 8px; }
.echo-review-sub-head { margin: 10px 0 4px; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.echo-review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.echo-review-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 0.92rem; line-height: 1.35; min-width: 0; }
.echo-review-where { color: var(--text-secondary); }
.echo-review-sub { color: var(--text-muted); font-size: 0.85rem; }
.echo-review-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.echo-review-unmatched { color: var(--warning-700, #b45309); }
.echo-review-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.echo-review-ack { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.95rem; }
.echo-review-ack input[type="checkbox"] { width: 22px; height: 22px; flex: 0 0 auto; }
.echo-suggested { box-shadow: inset 3px 0 0 var(--primary-500, #355e3b); padding-left: 6px; border-radius: 4px; }
.echo-badge { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 0; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; color: var(--primary-600, #2a4b2f); background: color-mix(in srgb, var(--primary-500, #355e3b) 12%, transparent); max-width: 100%; }
.echo-badge-inline { margin: 0; }
.echo-badge-undo { border: 0; background: transparent; color: inherit; text-decoration: underline; font: inherit; padding: 2px 4px; cursor: pointer; min-height: 24px; }
/* ECHO-FORM-1675 (found by tests/journeys/echoform1675_browser.cjs): a finding's method / response row made the Structural
   Findings item wider than a phone (450 px in a 349 px cell, clipped) because a grid item never shrinks below its longest
   select option. The item may shrink to its cell; the selects wrap inside it. */
.anatomy-item { min-width: 0; }
.anatomy-adj-select { max-width: 100%; }
.modal-tab.echo-tab-has::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: var(--primary-500, #355e3b); vertical-align: middle; }

/* Reports Tabs */
.reports-tab.active {
    color: var(--primary-600) !important;
    border-bottom-color: var(--primary-600) !important;
}

.reports-tab:hover:not(.active) {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

/* Analytics Dashboard */
.analytics-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.analytics-stat-card {
    padding: 1.25rem;
    text-align: center;
    border-radius: var(--radius-lg);
}
.analytics-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.5rem;
}
.analytics-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.analytics-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.analytics-bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 0.5rem;
    min-height: 150px;
    padding-top: 0.5rem;
}
.analytics-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.analytics-bar {
    width: 100%;
    max-width: 40px;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}
.analytics-bar-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.analytics-bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}
@media (max-width: 768px) {
    .analytics-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Exam Section Collapsible Cards */
.exam-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    background: var(--bg-card);
    overflow: hidden;
}

.exam-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    background: var(--bg-secondary);
    transition: background var(--transition-fast);
    user-select: none;
}

.exam-section-header:hover {
    background: var(--bg-tertiary, var(--bg-hover, #e2e8f0));
}

.exam-section-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
}

.exam-section-toggle {
    transition: transform var(--transition-base);
    font-size: var(--font-size-lg);
    color: var(--text-muted);
}

.exam-section.open .exam-section-toggle {
    transform: rotate(180deg);
}

.exam-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.3s ease, opacity 0.3s ease;
    padding: 0 1rem;
    opacity: 0;
}

.exam-section.open .exam-section-content {
    max-height: 5000px;
    padding: 0.75rem 1rem 1rem;
    opacity: 1;
}

/* Anatomy Section Minimization */
.anatomy-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    background: var(--bg-card);
    overflow: hidden;
}

.anatomy-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    cursor: pointer;
    background: var(--bg-secondary);
    transition: background var(--transition-fast);
    user-select: none;
}

.anatomy-section-header:hover {
    background: var(--bg-tertiary, var(--bg-hover, #e2e8f0));
}

.anatomy-section-header h4 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
}

.anatomy-toggle-icon {
    transition: transform var(--transition-base);
    font-size: var(--font-size-lg);
    color: var(--text-muted);
}

.anatomy-section.active .anatomy-toggle-icon {
    transform: rotate(180deg);
}

.anatomy-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, padding 0.3s ease, opacity 0.3s ease;
    padding: 0 var(--space-md);
    opacity: 0;
}

.anatomy-section.active .anatomy-section-content {
    max-height: 5000px;
    /* Large value to accommodate contents */
    padding: var(--space-md);
    opacity: 1;
}


/* ====== COMMUNICATION CENTER (Phase 4) ====== */

/* Header */
.comm-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Group sections */
.comm-group {
    margin-bottom: 1.25rem;
}

.comm-group:last-child {
    margin-bottom: 0;
}

.comm-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
}

.comm-group-header i {
    font-size: 0.95rem;
    color: var(--primary-500);
}

.comm-group-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--primary-500);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.comm-group-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Event card */
.comm-event-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.comm-event-card:hover {
    border-color: color-mix(in srgb, var(--primary-500) 30%, var(--border-color));
}

.comm-event-card.expanded {
    border-color: var(--primary-500);
    box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.08);
}

/* Event header */
.comm-event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    gap: 12px;
}

.comm-event-header:hover {
    background: var(--bg-secondary);
}

.comm-event-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.comm-event-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.comm-event-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 1px;
}

.comm-event-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.comm-event-channels {
    display: flex;
    align-items: center;
    gap: 4px;
}

.comm-event-toggle {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.comm-event-card.expanded .comm-event-toggle {
    transform: rotate(180deg);
}

/* Trigger badges (Auto/Manual) */
.comm-trigger-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.comm-trigger-auto {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.comm-trigger-manual {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-500);
}

[data-theme="dark"] .comm-trigger-auto {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

[data-theme="dark"] .comm-trigger-manual {
    background: rgba(var(--primary-rgb), 0.15);
    color: #a5b4fc;
}

/* Auto-send badge (note_to_client card header) */
.comm-autosend-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
    margin-left: 8px;
    vertical-align: middle;
    transition: background 0.25s ease, color 0.25s ease;
}

.comm-autosend-badge.on {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.comm-autosend-badge.off {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

[data-theme="dark"] .comm-autosend-badge.on {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
}

[data-theme="dark"] .comm-autosend-badge.off {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

/* Event body — collapsible */
.comm-event-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.25s ease, opacity 0.25s ease;
    padding: 0 14px;
    opacity: 0;
}

.comm-event-card.expanded .comm-event-body {
    max-height: 3000px;
    padding: 8px 14px 14px;
    opacity: 1;
    overflow: visible;
}

/* Channel section inside event body */
.comm-channel {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 0.6rem;
}

.comm-channel:last-of-type {
    margin-bottom: 0.5rem;
}

.comm-channel-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    flex-wrap: nowrap;
    min-width: 0;
}

.comm-channel-editor {
    /* Container for inputs — inherits standard form styling */
}

/* Reset button inside event body */
.comm-reset-btn {
    font-size: 0.75rem;
}

/* Responsive */
@media (max-width: 640px) {
    .comm-event-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .comm-event-header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .comm-event-desc {
        display: none;
    }

    .comm-trigger-badge {
        font-size: 0.62rem;
        padding: 2px 6px;
    }
}

/* ====== GOVERNANCE LAYER (Phase 8) ====== */

/* Dashboard panel at top of Communication Center */
.comm-governance-panel {
    padding: 1rem;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.04), rgba(var(--primary-rgb), 0.03));
    border: 1px solid rgba(var(--primary-rgb), 0.12);
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
}

.comm-governance-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.comm-governance-header h4 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.comm-governance-header i.toggle-icon {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.comm-governance-panel.expanded .comm-governance-header i.toggle-icon {
    transform: rotate(180deg);
}

.comm-governance-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease;
}

.comm-governance-panel.expanded .comm-governance-body {
    max-height: 2000px;
    opacity: 1;
}

/* Stat cards grid */
.comm-governance-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.comm-gov-stat {
    padding: 0.6rem 0.75rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    text-align: center;
}

.comm-gov-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.comm-gov-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

/* Decommission readiness traffic light */
.comm-decommission-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.comm-decommission-status.ready {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #059669;
}

.comm-decommission-status.partial {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #d97706;
}

.comm-decommission-status.blocked {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

[data-theme="dark"] .comm-decommission-status.ready {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}

[data-theme="dark"] .comm-decommission-status.partial {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
}

[data-theme="dark"] .comm-decommission-status.blocked {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.comm-decommission-status i {
    font-size: 1.1rem;
}

/* Missing events list in governance panel */
.comm-missing-events {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}

.comm-missing-event-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border-radius: 999px;
    white-space: nowrap;
}

[data-theme="dark"] .comm-missing-event-chip {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

/* Per-event cutover control strip */
.comm-cutover-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.78rem;
}

/* Cutover status badges */
.comm-cutover-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.comm-cutover-badge.legacy {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

.comm-cutover-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.comm-cutover-badge.locked {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

[data-theme="dark"] .comm-cutover-badge.legacy {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
}

[data-theme="dark"] .comm-cutover-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

[data-theme="dark"] .comm-cutover-badge.locked {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

/* Shadow match rate badge */
.comm-shadow-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
}

.comm-shadow-badge.good {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
}

.comm-shadow-badge.warn {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
}

.comm-shadow-badge.bad {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
}

.comm-shadow-badge.none {
    background: rgba(100, 116, 139, 0.06);
    color: var(--text-muted);
}

/* Cutover action buttons in strip */
.comm-cutover-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.comm-cutover-btn {
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.comm-cutover-btn.enable {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border-color: rgba(16, 185, 129, 0.25);
}

.comm-cutover-btn.enable:hover {
    background: #059669;
    color: white;
}

.comm-cutover-btn.rollback {
    background: rgba(239, 68, 68, 0.06);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.2);
}

.comm-cutover-btn.rollback:hover {
    background: #dc2626;
    color: white;
}

/* Cutover metadata (timestamp, rollback count) */
.comm-cutover-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.comm-cutover-meta .rollback-warn {
    color: #d97706;
    font-weight: 600;
}

/* System-locked indicator */
.comm-system-lock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 999px;
}

.comm-system-lock i {
    font-size: 0.78rem;
}

/* Responsive governance */
@media (max-width: 640px) {
    .comm-governance-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .comm-cutover-strip {
        flex-direction: column;
        align-items: flex-start;
    }

    .comm-cutover-actions {
        margin-left: 0;
        width: 100%;
    }
}

/* ====== TENANT OVERRIDE PANEL (Phase 9) ====== */

.tenant-override-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.6rem;
}

.tenant-override-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tenant-override-item {
    padding: 8px 10px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.tenant-override-item:hover {
    border-color: rgba(var(--primary-rgb), 0.3);
}

.tenant-override-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tenant-override-item-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.tenant-override-item-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.comm-cutover-badge.disabled {
    background: rgba(100, 116, 139, 0.08);
    color: #94a3b8;
}

[data-theme="dark"] .comm-cutover-badge.disabled {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}

[data-theme="dark"] .tenant-override-item {
    background: rgba(30, 30, 30, 0.6);
}

/* ====== COMMUNICATION INTELLIGENCE (Phase 10) ====== */

/* Health badge — inline score pill in event header */
.comm-health-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 7px;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.01em;
    line-height: 1.3;
    cursor: default;
}

.comm-health-green {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.comm-health-yellow {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.comm-health-red {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

[data-theme="dark"] .comm-health-green {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
}

[data-theme="dark"] .comm-health-yellow {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

[data-theme="dark"] .comm-health-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Event action row (Reset + History buttons) */
.comm-event-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}

.comm-history-btn {
    font-size: 0.75rem;
}

/* ── Version History Modal ── */
.comm-history-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: commModalFadeIn 0.2s ease;
}

@keyframes commModalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.comm-history-modal {
    background: var(--bg-card, #fff);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 580px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: commModalSlideUp 0.25s ease;
}

@keyframes commModalSlideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.comm-history-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.comm-history-modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.comm-history-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.comm-history-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Channel tabs inside modal header */
.comm-history-channel-tabs {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.comm-history-tab {
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.comm-history-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.comm-history-tab.active {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.comm-history-modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
}

/* Empty state */
.comm-history-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.comm-history-empty p {
    margin: 0.4rem 0 0;
}

/* History entry list */
.comm-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comm-history-entry {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: border-color 0.15s ease;
}

.comm-history-entry:hover {
    border-color: color-mix(in srgb, var(--primary-500) 30%, var(--border-color));
}

.comm-history-entry-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.comm-history-entry-who,
.comm-history-entry-when {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.comm-history-entry-subject {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.comm-history-entry-body {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 6px;
    word-break: break-word;
}

.comm-restore-btn {
    font-size: 0.7rem !important;
    padding: 3px 10px !important;
}

/* Responsive modal */
@media (max-width: 640px) {
    .comm-history-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 14px 14px 0 0;
    }

    .comm-history-modal-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .comm-history-channel-tabs {
        width: 100%;
        justify-content: flex-start;
    }

    .comm-event-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Email Template Sub-sections */
.email-template-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.email-template-section:last-child {
    margin-bottom: 0;
}

.email-template-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.email-template-header:hover {
    background: var(--bg-secondary);
}

.email-template-header h4 {
    flex: 1;
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 500;
}

.email-template-toggle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.email-template-section.expanded .email-template-toggle {
    transform: rotate(180deg);
}

.email-template-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.2s ease;
    padding: 0 var(--space-md);
}

.email-template-section.expanded .email-template-content {
    max-height: 2000px;
    padding: var(--space-md);
    overflow: visible;
}

/* ====== PLACEHOLDER PICKER ====== */
.placeholder-picker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px solid rgba(var(--primary-rgb), 0.18);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.placeholder-picker-trigger:hover {
    background: rgba(var(--primary-rgb), 0.14);
    border-color: rgba(var(--primary-rgb), 0.3);
    color: var(--primary-600);
}

.placeholder-picker-trigger i {
    font-size: 0.82rem;
}

.placeholder-picker-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.placeholder-picker-dropdown {
    position: fixed;
    z-index: 99999;
    width: 320px;
    max-height: 300px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.placeholder-picker-dropdown.drop-down {
    animation: pickerSlideDown 0.18s ease-out;
}

@keyframes pickerSlideUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.placeholder-picker-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.placeholder-picker-search input {
    width: 100%;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md, 8px) !important;
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    min-height: 0 !important;
    height: auto !important;
    box-shadow: none !important;
}

.placeholder-picker-search input:focus {
    border-color: var(--primary-400) !important;
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.1) !important;
    outline: none;
}

.placeholder-picker-list {
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
}

.placeholder-picker-group-label {
    padding: 6px 12px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.placeholder-picker-option {
    display: flex;
    flex-direction: column;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.placeholder-picker-option:last-child {
    border-bottom: none;
}

.placeholder-picker-option:hover {
    background: rgba(var(--primary-rgb), 0.06);
}

.placeholder-picker-option-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.placeholder-picker-option-label .pp-token {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.08);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.placeholder-picker-option-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1.3;
}

.placeholder-picker-option-example {
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.7;
    font-style: italic;
    margin-top: 1px;
}

.placeholder-picker-empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Dark theme adjustments */
[data-theme="dark"] .placeholder-picker-dropdown {
    background: #1e1e1e;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .placeholder-picker-option:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

/* Placeholder validation warning badge */
.placeholder-warning {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.7rem;
    font-weight: 500;
    color: #d97706;
    background: rgba(245, 158, 11, 0.08);
    border-radius: 6px;
    margin-top: 4px;
}

.placeholder-warning i {
    font-size: 0.78rem;
}

/* Inline validation badge shown on save for unknown placeholders */
.placeholder-warning-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-top: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #b45309;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 8px;
    animation: fadeIn 0.2s ease;
}

.placeholder-warning-badge i {
    font-size: 0.9rem;
    color: #d97706;
}

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

[data-theme="dark"] .placeholder-warning-badge i {
    color: #f59e0b;
}

/* ====== TEMPLATE PREVIEW ENGINE ====== */
.tpl-preview-panel {
    margin-top: 8px;
}

.tpl-preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--primary-500);
    background: transparent;
    border: 1px solid var(--primary-500);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tpl-preview-toggle:hover {
    background: var(--primary-500);
    color: white;
}

.tpl-preview-toggle i {
    font-size: 0.85rem;
}

.tpl-preview-content {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.2s ease;
    margin-top: 0;
}

.tpl-preview-content.open {
    max-height: 800px;
    overflow: visible;
    opacity: 1;
    margin-top: 10px;
}

/* Resolved placeholder highlight */
.preview-resolved {
    color: var(--primary-600);
    font-weight: 600;
}

/* Unknown placeholder warning */
.preview-unknown {
    display: inline;
    padding: 1px 5px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #b45309;
    background: rgba(245, 158, 11, 0.12);
    border-radius: 3px;
}

/* Future component token chip */
.preview-component {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

.preview-component i {
    font-size: 0.72rem;
}

/* Component preview blocks — structured content rendered from registry */
.preview-component-block {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.78rem;
    line-height: 1.5;
}

/* Email channel — rich bordered card */
.preview-component-email {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* SMS channel — compact inline block */
.preview-component-sms {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #14532d;
}

/* Push channel — minimal notification card */
.preview-component-push {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 8px 12px;
    font-size: 0.76rem;
    color: #334155;
    font-weight: 500;
}

/* --- Email Preview --- */
.tpl-preview-email {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    font-size: 0.78rem;
    line-height: 1.55;
}

.tpl-preview-email-subject {
    padding: 8px 14px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.76rem;
    color: #334155;
}

.tpl-preview-email-body {
    padding: 14px;
    background: white;
    color: #334155;
    font-size: 0.78rem;
    line-height: 1.6;
}

.tpl-preview-email-footer {
    border-top: 1px solid #e2e8f0;
    padding: 10px 14px;
    text-align: center;
    background: #f8fafc;
}

/* --- SMS Preview --- */
.tpl-preview-sms {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.tpl-preview-sms-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #22c55e;
    border-bottom: 1px solid var(--border-color);
}

.tpl-preview-sms-bubble {
    margin: 10px;
    padding: 10px 14px;
    background: #dcfce7;
    border-radius: 16px 16px 4px 16px;
    font-size: 0.8rem;
    color: #14532d;
    line-height: 1.5;
    max-width: 85%;
    margin-left: auto;
}

.tpl-preview-charcount {
    padding: 4px 12px 8px;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: right;
}

.tpl-preview-charcount-warn {
    color: #d97706;
    font-weight: 600;
}

/* --- Push Preview --- */
.tpl-preview-push {
    padding: 8px 0;
}

.tpl-preview-push-device {
    max-width: 320px;
    margin: 0 auto;
}

.tpl-preview-push-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.tpl-preview-push-app {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tpl-preview-push-time {
    margin-left: auto;
    font-weight: 400;
    text-transform: lowercase;
    letter-spacing: 0;
}

.tpl-preview-push-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.tpl-preview-push-body {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* --- Dark Mode --- */
[data-theme="dark"] .preview-resolved {
    color: var(--primary-400);
}

[data-theme="dark"] .preview-unknown {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .preview-component {
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

[data-theme="dark"] .preview-component-email {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    box-shadow: none;
}

[data-theme="dark"] .preview-component-sms {
    background: rgba(22, 101, 52, 0.2);
    border-color: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

[data-theme="dark"] .preview-component-push {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .tpl-preview-email {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

[data-theme="dark"] .tpl-preview-email-subject {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .tpl-preview-email-body {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .tpl-preview-email-footer {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

[data-theme="dark"] .tpl-preview-sms-bubble {
    background: #166534;
    color: #dcfce7;
}

[data-theme="dark"] .tpl-preview-push-card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Floating Collapse Button */
.floating-collapse-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-500);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1000;
    transition: transform 0.2s ease, background 0.2s ease;
}

.floating-collapse-btn:hover {
    transform: scale(1.1);
    background: var(--primary-600);
}

.floating-collapse-btn.visible {
    display: flex;
}

@media (max-width: 768px) {
    .floating-collapse-btn {
        bottom: 100px;
        right: 15px;
        width: 45px;
        height: 45px;
    }
}

/* ====== CLIENT BALANCE BADGES ====== */
.client-balance-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.client-balance-badge.balance-owed {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    cursor: pointer;
}

.client-balance-badge.balance-owed:hover {
    background: rgba(239, 68, 68, 0.2);
}

.client-balance-badge.balance-clear {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

/* ====== CLIENT CARD STATUS BADGES ====== */
.client-badges-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.client-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.client-status-badge.also-patient-badge {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-color);
}

.client-status-badge.patient-count-badge {
    background: rgba(168, 85, 247, 0.1);
    color: #9333ea;
}

.client-status-badge.portal-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.client-status-badge.package-badge {
    background: rgba(139, 92, 246, 0.08);
    color: #7c3aed;
    border: 1px solid rgba(139, 92, 246, 0.15);
}

.client-status-badge.package-badge:hover {
    background: rgba(139, 92, 246, 0.15);
}

/* Compact address link with hover animation */
.client-address-link {
    transition: all 0.2s ease;
}

.client-address-link:hover i.ph-map-pin {
    animation: pin-bounce 0.4s ease;
}

@keyframes pin-bounce {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-1px); }
}

/* Last visit date */
.client-last-visit {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.client-last-visit.no-visits {
    color: var(--text-muted);
    opacity: 0.7;
}


.dashboard-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    margin-top: var(--space-sm);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-500);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    width: 100%;
    text-align: center;
}

.dashboard-view-all:hover {
    background: rgba(var(--primary-rgb), 0.05);
    border-color: var(--primary-400);
    color: var(--primary-600);
}

/* ====== LAST VISIT CARRY-FORWARD ====== */
.last-visit-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-400);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.last-visit-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.last-visit-header:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.03));
}

.last-visit-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.last-visit-title i {
    font-size: 1.2rem;
    color: var(--primary-500);
}

.last-visit-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
    white-space: nowrap;
}

.last-visit-toggle {
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.last-visit-card.expanded .last-visit-toggle {
    transform: rotate(180deg);
}

.last-visit-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
    padding: 0 var(--space-lg);
}

.last-visit-card.expanded .last-visit-content {
    max-height: 2000px;
    padding: 0 var(--space-lg) var(--space-lg);
}

.last-visit-field {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

.last-visit-field:last-child {
    border-bottom: none;
}

.last-visit-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.last-visit-value {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
}

.carry-badge {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--primary-500);
    margin-left: 6px;
    opacity: 0.85;
}

/* ====== SOAP SECTION CARDS ====== */
.soap-section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border-left: 4px solid var(--border-color);
}

.soap-subjective { border-left-color: #3b82f6; }
.soap-objective { border-left-color: #10b981; }
.soap-assessment { border-left-color: #f59e0b; }
.soap-plan { border-left-color: #8b5cf6; }

.soap-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.soap-section-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.soap-section-desc {
    margin: 2px 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.soap-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.02em;
}

.soap-letter-s { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.soap-letter-o { background: linear-gradient(135deg, #10b981, #059669); }
.soap-letter-a { background: linear-gradient(135deg, #f59e0b, #d97706); }
.soap-letter-p { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.soap-section-card .form-group {
    margin-bottom: var(--space-md);
}

.soap-section-card .form-group:last-child {
    margin-bottom: 0;
}

.soap-section-card label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.soap-section-card label i {
    font-size: 1.1rem;
    opacity: 0.7;
}

.soap-section-card textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.soap-section-card textarea:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    outline: none;
    background: var(--bg-card);
}

@media (max-width: 576px) {
    .soap-section-card {
        padding: var(--space-md);
    }

    .soap-letter {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 1.2rem;
    }

    .soap-section-header h3 {
        font-size: 1rem;
    }
}

/* ====== ENHANCED NOTE FORM STYLES ====== */

.anatomy-tab-layout {
    display: flex;
    gap: var(--space-xl);
    align-items: flex-start;
    min-height: 500px;
}

.anatomy-diagram-sidebar {
    flex: 0 0 250px;
    position: sticky;
    top: 10px;
    z-index: 10;
}

.anatomy-findings-grid {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.anatomy-findings-grid .anatomy-section {
    width: 100%;
}

/* Spinal Diagram */
.spinal-diagram-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.spinal-diagram-header {
    margin-bottom: var(--space-md);
    text-align: center;
}

.spinal-diagram-header h5 {
    margin: 0;
    font-size: 1rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.spinal-diagram-header small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 4px;
}

.spinal-diagram-view {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    border-radius: var(--radius-md);
    padding: 0;
    min-height: 450px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.3s;
}

.spinal-diagram-view:hover {
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.03), 0 0 0 2px var(--primary-300);
}

.spinal-diagram-view svg {
    max-width: 100%;
    max-height: 100%;
    z-index: 2;
}

.diagram-expand-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 5;
    pointer-events: none;
}

.spinal-diagram-view:hover .diagram-expand-hint {
    opacity: 1;
}

/* Hide expand hint in full-size views (inline page & pop-out window) */
.anatomy-view-container .diagram-expand-hint,
.canvas .diagram-expand-hint {
    display: none !important;
}
.anatomy-view-container .spinal-diagram-view,
.canvas .spinal-diagram-view {
    cursor: default;
}
.anatomy-view-container .spinal-diagram-view:hover,
.canvas .spinal-diagram-view:hover {
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.03);
}

.spinal-segment {
    cursor: pointer;
    transition: all 0.2s;
}

.spinal-segment:hover {
    filter: drop-shadow(0 0 5px rgba(225, 29, 72, 0.4));
}

.spinal-segment path {
    transition: fill 0.3s, stroke 0.3s, stroke-width 0.3s;
}

.spinal-segment.has-finding path {
    fill: var(--accent-rose) !important;
    fill-opacity: 0.85;
    stroke: #be123c;
    stroke-width: 3px;
    animation: findingPulse 2s ease-in-out infinite;
}

@keyframes findingPulse {
    0%, 100% { fill-opacity: 0.85; }
    50% { fill-opacity: 0.55; }
}

/* Media & Video */
.video-upload-container {
    padding: var(--space-xl);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
    text-align: center;
    transition: border-color 0.3s;
}

.video-upload-container:hover {
    border-color: var(--primary-color);
}

#videoPreview {
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
}

/* Responsive Anatomy Layout */
@media (max-width: 900px) {
    .anatomy-tab-layout {
        flex-direction: column;
    }

    .anatomy-diagram-sidebar {
        width: 100%;
        flex: none;
        position: relative;
        top: 0;
        margin-bottom: var(--space-lg);
    }

    .anatomy-findings-grid {
        width: 100%;
    }

    .anatomy-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .anatomy-toggle-btn {
        padding: 10px 18px;
        font-size: 0.95rem;
        min-height: 42px;
    }

    .anatomy-btn-group {
        gap: 8px;
    }
}

@media (max-width: 576px) {
    .anatomy-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .anatomy-toggle-btn {
        padding: 10px 20px;
        font-size: 1rem;
        min-height: 44px;
        flex: 1;
        min-width: 0;
    }

    .anatomy-btn-group {
        gap: 8px;
        width: 100%;
    }

    .anatomy-item label {
        font-size: 0.95rem;
    }

    .anatomy-section-header h4 {
        font-size: 1rem;
    }

    .anatomy-section-content {
        padding: 0 var(--space-sm);
    }

    .anatomy-section.active .anatomy-section-content {
        padding: var(--space-sm);
    }
}

/* ====== AUTHENTICATION UI ====== */
.login-container {
    height: 100vh;
    height: 100dvh;
    width: 100%;
    flex: 1;
    /* Take full width in flex container */
    display: flex;
    align-items: center;
    justify-content: center;
    background: 
        radial-gradient(circle at top right, rgba(53, 94, 59, 0.18), transparent),
        radial-gradient(circle at bottom left, rgba(74, 125, 82, 0.12), transparent),
        radial-gradient(ellipse at center, rgba(53, 94, 59, 0.05), transparent);
    padding: var(--space-md);
    position: relative;
    z-index: 1000;
    overflow: hidden;

    /* Brand green overrides for login page elements */
    --primary-color: #355E3B;
    --primary-color-dark: #2a4d30;
    --primary-500: #355E3B;
    --primary-600: #2a4d30;
    --primary-700: #1f3d24;
    /* BRAND-1660: the light tints too (were the indigo app defaults, e.g. the staff-invite info box) */
    --primary-rgb: 53, 94, 59;
    --primary-50: #eef5ef;
    --primary-100: #dcebdf;
    --primary-200: #b9d7bf;
    --primary-300: #8fbb98;
    --primary-400: #5f9268;
}

.login-container .btn-primary {
    background: linear-gradient(135deg, #355E3B, #2a4d30);
    box-shadow: 0 4px 15px rgba(53, 94, 59, 0.3);
}

.login-container .btn-primary:hover {
    background: linear-gradient(135deg, #2a4d30, #1f3d24);
    box-shadow: 0 6px 20px rgba(53, 94, 59, 0.4);
}

.login-container a {
    color: #355E3B;
}

.login-container .encryption-badge {
    color: #355E3B;
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    max-height: 95vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.login-box::-webkit-scrollbar {
    display: none;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo {
    width: 100px;
    height: 100px;
    margin-bottom: var(--space-md);
    object-fit: contain;
}

.login-header h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.login-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.login-tab {
    flex: 1;
    padding: var(--space-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.login-tab.active {
    background: var(--bg-card);
    color: var(--primary-500);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.login-form .form-group {
    margin-bottom: var(--space-lg);
}

.login-form input {
    width: 100%;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.login-footer {
    margin-top: var(--space-xl);
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ====== BRAND-1660: ChiroApp auth pages (owner 2026-11-01) ======
   Reset Password and Verify Email use the same ChiroApp theme as Sign In (.login-container): ChiroApp green buttons,
   the ChiroApp logo, the glass card. .auth-page lets the page itself scroll on a short screen (no hidden inner
   scroll); .auth-card-wide is a comfortable two-column card on laptops; phones get full width with margins. */
.login-container .btn-block { width: 100%; justify-content: center; }
.login-container .pw-strength-box { background: rgba(53, 94, 59, 0.04) !important; }
.login-container.auth-page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    padding: var(--space-lg) var(--space-md);
}
.login-container.auth-page .login-box {
    max-height: none;
    overflow: visible;
    padding: var(--space-xl);
    background: var(--bg-card);
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
}
.auth-header { margin-bottom: var(--space-lg); }
.auth-header h2 { margin: 0.25rem 0 0.35rem; font-size: var(--font-size-xl); color: var(--text-primary); }
.auth-header p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }
.auth-header .auth-hint {
    margin-top: 0.5rem; color: var(--text-muted); font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.auth-header .auth-hint i { color: var(--accent-amber, #f59e0b); font-size: 1rem; }
.login-logo.auth-logo { width: 56px; height: 56px; margin-bottom: var(--space-sm); }
.auth-code-input { text-align: center; font-size: 1.4rem !important; letter-spacing: 8px; font-weight: 700; }
.auth-code-input-lg { font-size: 1.8rem !important; letter-spacing: 10px; }
.login-form .form-group label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.35rem; }
.auth-footer-link { text-align: center; margin: var(--space-md) 0 0; font-size: 0.9rem; }
.auth-footer-link a { font-weight: 500; text-decoration: none; }
.auth-footer-link a:hover { text-decoration: underline; }
.auth-status { color: var(--text-muted); font-size: 0.8rem; margin: 0.5rem 0 0; text-align: center; }
.login-box.auth-card { max-width: 440px; }
@media (min-width: 768px) {
    .login-box.auth-card-wide { max-width: 720px; }
    /* the two password fields side by side; their requirement list spans both columns underneath */
    .auth-card-wide .auth-grid-2 {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--space-lg); row-gap: 0;
        align-items: start; margin-bottom: var(--space-md);
    }
    .auth-card-wide .auth-grid-2 > .form-group { display: contents; }
    .auth-card-wide .auth-grid-2 > .form-group:first-child > label { grid-area: 1 / 1; }
    .auth-card-wide .auth-grid-2 > .form-group:first-child > input { grid-area: 2 / 1; }
    .auth-card-wide .auth-grid-2 > .form-group:last-child > label { grid-area: 1 / 2; }
    .auth-card-wide .auth-grid-2 > .form-group:last-child > input { grid-area: 2 / 2; }
    .auth-card-wide .auth-grid-2 > .form-group:last-child > div { grid-area: 3 / 2; }
    .auth-card-wide .auth-grid-2 .pw-strength-box {
        grid-area: 4 / 1 / 5 / 3; display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between;
        column-gap: var(--space-md);
    }
    .auth-card-wide .pw-strength-box > div:first-child { grid-column: 1 / -1; }
    .login-container.auth-page .login-box { padding: var(--space-lg) var(--space-2xl) var(--space-xl); }
    .login-container.auth-page .login-form .form-group { margin-bottom: var(--space-md); }
    .login-container.auth-page .auth-header { margin-bottom: var(--space-md); }
    .login-logo.auth-logo { width: 48px; height: 48px; }
}
@media (min-width: 768px) and (max-height: 760px) {
    /* a 1366x768 laptop browser shows ~650 px: keep the whole card on screen */
    .login-container.auth-page { padding: var(--space-sm) var(--space-md); }
    .login-container.auth-page .login-box { padding: var(--space-md) var(--space-2xl) var(--space-lg); }
    .login-logo.auth-logo { width: 40px; height: 40px; margin-bottom: var(--space-xs); }
}
@media (max-width: 480px) {
    .login-container.auth-page { padding: var(--space-md); align-items: flex-start; }
    .login-container.auth-page .login-box { padding: var(--space-lg); border-radius: var(--radius-lg); }
}
[data-theme="dark"] .login-container.auth-page .login-box { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
[data-theme="dark"] .login-container a { color: #8fbb98; }

/* ====== BRAND-1662: ChiroApp-owned lock screens (owner 2026-11-01) ======
   Subscription / trial / paused / contact-support lock screens are ChiroApp's own pages: ChiroApp green and logo,
   whatever colour the practice chose (the app's --primary-* follow the practice). Same variables as .login-container. */
.lockout-container.chiroapp-theme {
    --primary-color: #355E3B;
    --primary-color-dark: #2a4d30;
    --primary-rgb: 53, 94, 59;
    --primary-50: #eef5ef;
    --primary-100: #dcebdf;
    --primary-200: #b9d7bf;
    --primary-300: #8fbb98;
    --primary-400: #5f9268;
    --primary-500: #355E3B;
    --primary-600: #2a4d30;
    --primary-700: #1f3d24;
    --primary: #355E3B;
    background:
        radial-gradient(circle at top right, rgba(53, 94, 59, 0.18), transparent),
        radial-gradient(circle at bottom left, rgba(74, 125, 82, 0.12), transparent);
}
.lockout-container.chiroapp-theme .lockout-card { background: var(--bg-card); box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08); margin: auto 0; /* safe centring: never clips a tall card */ }
.lockout-container.chiroapp-theme .btn-primary {
    background: linear-gradient(135deg, #355E3B, #2a4d30);
    box-shadow: 0 4px 15px rgba(53, 94, 59, 0.3);
}
.lockout-container.chiroapp-theme .btn-primary:hover { background: linear-gradient(135deg, #2a4d30, #1f3d24); }
.lockout-container.chiroapp-theme a { color: #355E3B; }
.lockout-container.chiroapp-theme .lockout-tier-recommended {
    background: rgba(53, 94, 59, 0.08);
    box-shadow: 0 4px 20px rgba(53, 94, 59, 0.15);
}
@media (max-width: 480px) {
    .lockout-container.chiroapp-theme { padding: var(--space-md); }
    .lockout-container.chiroapp-theme .lockout-card { padding: var(--space-lg); }
}
.auth-lock-icon {
    width: 64px; height: 64px; margin: 0 auto var(--space-sm); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(53, 94, 59, 0.1); color: #355E3B; font-size: 2rem;
}

/* Height-based Adaptive Adjustments */
@media (max-height: 800px) {
    .login-box {
        padding: var(--space-xl);
    }

    .login-header {
        margin-bottom: var(--space-lg);
    }

    .login-logo {
        width: 80px;
        height: 80px;
    }
}

@media (max-height: 650px) {
    .login-box {
        padding: var(--space-lg);
    }

    .login-header {
        margin-bottom: var(--space-md);
    }

    .login-logo {
        width: 60px;
        height: 60px;
    }

    .login-footer {
        margin-top: var(--space-lg);
    }

    .login-form .form-group {
        margin-bottom: var(--space-md);
    }
}

/* ====== FORM VALIDATION ====== */
.input-error {
    border-color: var(--status-error) !important;
    background-color: var(--bg-card);
    /* Ensure contrast */
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.error-text {
    color: var(--status-error);
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
}

/* ====== FORM VALIDATION ====== */
.input-error {
    border-color: var(--status-error) !important;
    background-color: var(--bg-card);
    /* Ensure contrast */
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1);
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* ====== PATIENT PORTAL UI ====== */
.portal-layout {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.portal-content {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: var(--space-xl);
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.portal-header {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.portal-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.portal-brand h1 {
    font-size: var(--font-size-lg);
    font-weight: 700;
    margin: 0;
}

.portal-user {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.portal-practice-info-card {
    margin-bottom: var(--space-xl);
}

.portal-practice-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-md);
}

.practice-info-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.practice-info-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-100);
    color: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.practice-info-details {
    min-width: 0;
}

.practice-info-details h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.practice-info-details p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-word;
    overflow-wrap: break-word;
}


.portal-welcome {
    margin-bottom: var(--space-xl);
    padding: var(--space-xl);
}

/* Portal Notification Alerts */
.portal-notification-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-md);
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.25);
    transition: opacity 0.2s, transform 0.2s;
}

.portal-notification-icon {
    font-size: 1.3rem;
    color: var(--primary-500);
    padding-top: 2px;
}

.portal-notification-content {
    flex: 1;
}

.portal-notification-content p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    line-height: 1.5;
}

.portal-notification-content small {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

.portal-notification-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.portal-notification-dismiss:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.08);
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-xl);
}

.portal-section h3 {
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--primary-500);
}

.portal-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.portal-list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: transform var(--transition-fast);
}

.portal-list-item:hover {
    transform: translateX(4px);
}

/* CALENDAR-1677 (variant B): on phones the "Add to calendar" button of a Confirmed appointment sits on its own line under the
   details (left-aligned, full text) so the date / time keeps its width. Desktop unchanged. */
@media (max-width: 600px) {
    .portal-list-item.portal-appt-row { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }
}

.note-summary-preview {
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-500);
    margin-bottom: 1.25rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.note-summary-preview .summary-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-summary-preview.expanded .summary-content {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
}

.note-summary-preview .read-more-hint {
    font-size: 0.75rem;
    color: var(--primary-600);
    font-weight: 600;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.note-summary-preview.expanded .read-more-hint span::after {
    content: 'Show less';
}

.note-summary-preview:not(.expanded) .read-more-hint span::after {
    content: 'Read more';
}

@media (max-width: 768px) {
    .portal-header {
        padding: var(--space-md);
        padding-top: calc(var(--space-md) + env(safe-area-inset-top, 0px));
    }

    .portal-user span {
        display: block;
        font-size: 0.85rem;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ========================================
   Portal Tabbed Navigation (Mobile & Desktop)
   ======================================== */

.portal-tab-content {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.portal-tab-content.active {
    display: block;
}

.portal-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 0.35rem 0.5rem;
    padding-bottom: calc(0.35rem + env(safe-area-inset-bottom, 0.5rem));
    padding-left: env(safe-area-inset-left, 0.5rem);
    padding-right: env(safe-area-inset-right, 0.5rem);
    z-index: 9999;
}

.portal-bottom-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.portal-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    flex: 1;
    background: transparent;
    border: none;
    cursor: pointer;
}

.portal-nav-item i {
    font-size: 1.5rem;
    margin-bottom: 2px;
    transition: transform var(--transition-fast);
}

.portal-nav-item:hover {
    color: var(--text-primary);
}

.portal-nav-item.active {
    color: var(--primary-600);
}

.portal-nav-item.active i {
    transform: translateY(-2px);
}

.portal-nav-item:active {
    background: var(--bg-hover);
}

/* Desktop Navigation overrides */
@media (min-width: 769px) {
    .portal-bottom-nav {
        display: none;
    }

    .portal-desktop-nav {
        width: 260px;
        flex-shrink: 0;
        background: transparent;
        padding-right: var(--space-xl);
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
    }

    .portal-layout-inner {
        display: flex;
        align-items: flex-start;
        gap: var(--space-xl);
        padding: 0 var(--space-xl);
    }

    .portal-nav-item.desktop-only {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: var(--space-md);
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
        background: var(--primary-color, #10b981);
        color: #fff;
        border: 1px solid transparent;
        border-radius: var(--radius-md);
    }

    .portal-nav-item.desktop-only i {
        margin-bottom: 0;
        font-size: 1.25rem;
        color: #fff;
    }

    .portal-nav-item.desktop-only:hover {
        filter: brightness(0.9);
    }

    .portal-nav-item.desktop-only.active {
        filter: brightness(0.8);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .portal-tab-container {
        flex: 1;
        min-width: 0;
        /* Prevent flex overflow */
    }

    /* Dark mode overrides for active tab */
    [data-theme="dark"] .portal-nav-item.desktop-only.active {
        filter: brightness(0.8);
        border-color: rgba(255, 255, 255, 0.15);
        color: #fff;
    }
}

/* Mobile specific spacing */
@media (max-width: 768px) {
    .portal-layout {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        /* Space for the bottom nav + safe area */
    }

    .portal-desktop-nav {
        display: none;
    }

    .portal-layout-inner {
        flex-direction: column;
        padding: 0;
        transition: none;
        transform: none;
    }

    .portal-content {
        padding: var(--space-sm) var(--space-sm);
        gap: var(--space-md);
        width: 100%;
        min-width: 0;
    }

    .portal-welcome {
        padding: var(--space-md);
        width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .portal-welcome .card {
        overflow: hidden;
    }

    .portal-practice-info-grid {
        grid-template-columns: 1fr;
    }

    .portal-legal-footer {
        width: 100%;
    }

    /* Security section mobile stacking fix */
    #portal2faSection {
        padding: 1rem !important;
        overflow: hidden;
    }

    #portal2faSection > div {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    #portal2faSection button {
        align-self: flex-start;
    }
}

/* Portal Profile Card */
.portal-profile-card {
    transition: all 0.3s ease;
    overflow: hidden;
}

.profile-card-header:hover {
    background: rgba(var(--primary-rgb), 0.05);
}

#profile-card-content {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* Portal Action Buttons - Uses Admin Theme Color */
.portal-action-btn-appointment {
    background: var(--primary-color, #10b981) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.portal-action-btn-appointment:hover {
    filter: brightness(0.9) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.portal-action-btn-intake {
    background: var(--primary-color, #10b981) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.portal-action-btn-intake:hover {
    filter: brightness(0.9) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

/* Portal Layout Refinements */
.portal-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamburger-menu-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background 0.2s;
    display: none;
    /* Hidden by default on mobile, handled by media queries */
}

.hamburger-menu-btn:hover {
    background: var(--bg-secondary);
}

.desktop-only-flex {
    display: flex;
}

/* Sidebar Toggle Logic */
.portal-layout-inner {
    display: flex;
    transition: all 0.3s ease;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 var(--space-md);
}

.portal-desktop-nav {
    width: 260px;
    transition: transform 0.3s ease, width 0.3s ease, opacity 0.3s ease;
    transform-origin: left;
}

.portal-layout:not(.sidebar-open) .portal-desktop-nav {
    width: 0;
    transform: scaleX(0);
    opacity: 0;
    pointer-events: none;
    padding: 0;
    margin: 0;
}

.portal-layout:not(.sidebar-open) .portal-content {
    margin-left: 0;
}

/* Professional Services UI */
.portal-services-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.portal-services-section h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.services-grid-professional {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.service-item-professional {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.service-item-professional:hover {
    transform: translateY(-2px);
    border-color: var(--primary-300);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.service-item-professional i {
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.service-item-professional.clinic i {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
}

.service-item-professional.mobile i {
    background: rgba(var(--secondary-rgb), 0.1);
    color: var(--secondary-600);
}

.service-details {
    display: flex;
    flex-direction: column;
}

.service-name {
    font-weight: 600;
    color: var(--text-primary);
}

.service-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.no-services-hint {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem;
}

/* Button Refinements - width and glow */
.portal-action-btn-appointment {
    width: 100% !important;
    margin-bottom: 0.5rem !important;
}

.portal-action-btn-appointment:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
}

.portal-action-btn-intake {
    width: 100% !important;
}

.portal-action-btn-intake:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    .hamburger-menu-btn {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hamburger-menu-btn {
        display: flex !important;
    }

    .portal-bottom-nav {
        display: none !important;
    }
}

/* Global Portal Action Button Width Fix */
.portal-tab-content .btn-block.btn-outline[class*="portal-action-btn"] {
    width: 100% !important;
    max-width: none !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
}

/* ========================================
   Migration Wizard
   ======================================== */
.migration-wizard-modal {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.wizard-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg) var(--space-xl);
    gap: 0;
    border-bottom: 1px solid var(--border-color);
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    opacity: 0.65;
    transition: all var(--transition-fast);
}

.wizard-step.active,
.wizard-step.completed {
    opacity: 1;
}

.wizard-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.wizard-step.active .wizard-step-number {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: white;
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.4);
}

.wizard-step.completed .wizard-step-number {
    background: var(--status-success);
    border-color: var(--status-success);
    color: white;
}

.wizard-step-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.wizard-step.active .wizard-step-label {
    color: var(--primary-500);
}

.wizard-step-line {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 var(--space-sm);
    min-width: 20px;
    max-width: 60px;
    align-self: center;
    margin-bottom: 18px;
}

.wizard-content .form-hint {
    color: var(--text-secondary);
}

.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
    animation: fadeIn var(--transition-normal);
}

/* Drop Zone */
.wizard-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    background: var(--bg-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.wizard-drop-zone:hover,
.wizard-drop-zone.drag-over {
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.05);
}

.wizard-drop-zone.drag-over {
    transform: scale(1.01);
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.15);
}

.wizard-file-badge {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: var(--radius-md);
    font-weight: 600;
}

.wizard-file-badge i {
    font-size: 1.5rem;
    color: var(--primary-500);
}

/* Wizard Tables */
.wizard-table-scroll {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.wizard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.wizard-table th {
    background: var(--bg-secondary);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
}

.wizard-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.wizard-table tr:last-child td {
    border-bottom: none;
}

.wizard-table tr:hover td {
    background: rgba(var(--primary-rgb), 0.03);
}

.wizard-mapping-table td select {
    width: 100%;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

/* Data Type Cards */
.wizard-data-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.wizard-data-type-card {
    cursor: pointer;
}

.wizard-data-type-card input[type="radio"] {
    display: none;
}

.wizard-type-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    transition: all var(--transition-fast);
}

.wizard-type-inner i {
    font-size: 2.5rem;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.wizard-type-inner span {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.wizard-data-type-card input:checked+.wizard-type-inner {
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.06);
    box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.12);
}

.wizard-data-type-card input:checked+.wizard-type-inner i {
    color: var(--primary-500);
}

.wizard-data-type-card:hover .wizard-type-inner {
    border-color: rgba(var(--primary-rgb), 0.4);
}

/* Radio Option Cards */
.wizard-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.wizard-radio-card {
    cursor: pointer;
}

.wizard-radio-card input[type="radio"] {
    display: none;
}

.wizard-radio-inner {
    padding: var(--space-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    transition: all var(--transition-fast);
    position: relative;
}

.wizard-radio-inner strong {
    display: inline;
    margin-right: var(--space-sm);
}

.wizard-radio-inner p {
    margin: var(--space-sm) 0 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.wizard-radio-card input:checked+.wizard-radio-inner {
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.06);
}

.wizard-radio-card:hover .wizard-radio-inner {
    border-color: rgba(var(--primary-rgb), 0.3);
}

.recommended-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    vertical-align: middle;
}

.caution-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    vertical-align: middle;
}

/* Wizard Summary */
.wizard-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
}

.wizard-summary-card {
    text-align: center;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.wizard-summary-card .summary-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-500);
    display: block;
}

.wizard-summary-card .summary-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: 4px;
}

.wizard-final-warning {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    color: #92400e;
}

.wizard-final-warning i {
    font-size: 1.5rem;
    color: #d97706;
    flex-shrink: 0;
}

.wizard-final-warning p {
    margin: 0;
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

/* Wizard Footer */
.wizard-footer {
    display: flex;
    align-items: center;
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--border-color);
    gap: var(--space-md);
}

/* Imported Stub Badge */
.imported-stub-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    white-space: nowrap;
}

.imported-stub-badge i {
    font-size: 0.8rem;
}

@media (max-width: 600px) {
    .wizard-data-type-grid {
        grid-template-columns: 1fr;
    }

    .wizard-stepper {
        padding: var(--space-md);
    }

    .wizard-step-label {
        font-size: 0.6rem;
    }

    .wizard-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .wizard-step-line {
        min-width: 12px;
    }
}

/* ========================================
   SMS Messaging
   ======================================== */

/* SMS Setup Card Styles */
.sms-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
}

.sms-status-badge.not-connected {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.sms-status-badge.not-connected i {
    color: #dc2626;
}

.sms-status-badge.connected {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.sms-status-badge.connected i {
    color: #10b981;
}

.sms-setup-options {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.sms-option-btn {
    flex: 1;
    min-width: 200px;
    padding: var(--space-lg) !important;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    text-align: center;
    border: 2px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

.sms-option-btn i {
    font-size: 2rem;
    color: var(--primary-500);
}

.sms-option-btn:hover {
    border-color: var(--primary-400) !important;
    background: rgba(var(--primary-rgb), 0.05) !important;
    transform: translateY(-2px);
}

.sms-option-btn.selected {
    border-color: var(--primary-500) !important;
    background: rgba(var(--primary-rgb), 0.08) !important;
    box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.12);
}

/* Guide Panel */
.sms-guide-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    animation: fadeIn var(--transition-normal);
}

.sms-guide-panel h4 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    color: var(--primary-600);
    font-size: var(--font-size-lg);
}

.sms-setup-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
}

.sms-setup-steps li {
    counter-increment: step;
    position: relative;
    padding-left: 3rem;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.sms-setup-steps li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sms-setup-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    background: var(--primary-500);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.sms-setup-steps li strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sms-setup-steps li p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.sms-setup-steps li a {
    color: var(--primary-500);
    text-decoration: underline;
}

.sms-webhook-url {
    display: block;
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--font-size-sm);
    color: var(--primary-600);
    word-break: break-all;
    user-select: all;
}

.sms-pricing-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}

.sms-pricing-disclaimer i {
    font-size: 1.2rem;
    color: var(--primary-500);
    flex-shrink: 0;
    margin-top: 2px;
}

.sms-pricing-disclaimer p {
    margin: 0;
}

.sms-pricing-disclaimer a {
    color: var(--primary-500);
    text-decoration: underline;
}

/* Credentials Panel */
.sms-credentials-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    animation: fadeIn var(--transition-normal);
}

.sms-credentials-panel h4 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.sms-verify-result {
    margin-top: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.sms-verify-result.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.sms-verify-result.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.sms-credentials-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.sms-credentials-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--font-size-sm);
    white-space: nowrap;
}

/* ====== Messaging Page Layout ====== */
.sms-container {
    display: flex;
    max-height: min(600px, calc(100vh - 180px));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: var(--bg-card);
}

.sms-conversations-panel {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.sms-conversations-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.sms-conversations-header .search-box {
    margin: 0;
}

.sms-conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
}

.sms-conversation-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sms-conversation-item:hover {
    background: var(--bg-hover);
}

.sms-conversation-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.sms-conversation-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.sms-conversation-info {
    flex: 1;
    min-width: 0;
}

.sms-conversation-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sms-conversation-preview {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sms-conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.sms-conversation-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sms-unread-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-500);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Panel */
.sms-chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sms-chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    color: var(--text-muted);
}

.sms-chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sms-chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.sms-chat-contact-info {
    flex: 1;
}

.sms-chat-contact-info h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sms-chat-phone {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.sms-chat-actions {
    flex-shrink: 0;
}

/* Chat Messages */
.sms-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.sms-message {
    max-width: 70%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.2s ease;
}

.sms-message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    border-bottom-right-radius: 4px;
}

.sms-message.received {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.sms-message-time {
    font-size: 0.65rem;
    margin-top: 4px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sms-message.sent .sms-message-time {
    justify-content: flex-end;
    color: rgba(255, 255, 255, 0.8);
}

.sms-message.received .sms-message-time {
    color: var(--text-muted);
}

/* Per-message delete button — hidden until hover */
.sms-msg-delete-btn {
    background: none;
    border: none;
    padding: 0 2px;
    cursor: pointer;
    color: inherit;
    opacity: 0;
    font-size: 0.7rem;
    transition: opacity 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.sms-message:hover .sms-msg-delete-btn {
    opacity: 0.6;
}

.sms-msg-delete-btn:hover {
    opacity: 1 !important;
    color: var(--danger, #ef4444) !important;
}

.sms-message.sent .sms-msg-delete-btn:hover {
    color: rgba(255, 200, 200, 1) !important;
}

.sms-message-date-divider {
    text-align: center;
    padding: var(--space-sm) 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    position: relative;
}

.sms-message-date-divider::before,
.sms-message-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border-color);
}

.sms-message-date-divider::before {
    left: 0;
}

.sms-message-date-divider::after {
    right: 0;
}

/* Compose Area */
.sms-chat-compose {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.sms-chat-compose textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.sms-chat-compose textarea:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.sms-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50% !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sms-send-btn i {
    font-size: 1.2rem;
}

/* New Message Modal */
.sms-new-message-form .sms-recipient-select {
    margin-bottom: var(--space-md);
}

/* Mobile Back Button */
.sms-back-btn {
    display: none;
}

/* ====== Notification Preferences Grid ====== */
.notif-pref-grid {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.notif-pref-header {
    display: grid;
    grid-template-columns: 1fr 52px 52px 52px;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.notif-pref-header .notif-pref-ch-col {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.notif-pref-row {
    display: grid;
    grid-template-columns: 1fr 52px 52px 52px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
    transition: background 0.15s ease;
}

.notif-pref-row:last-child {
    border-bottom: none;
}

.notif-pref-row:hover {
    background: color-mix(in srgb, var(--primary-500) 4%, var(--bg-card));
}

.notif-pref-label-col {
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.notif-pref-ch-col {
    display: flex;
    align-items: center;
    justify-content: center;
}

.notif-pref-ch-col input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-500);
}

.notif-info-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: help;
    opacity: 0.6;
    transition: opacity 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.notif-info-icon:hover {
    opacity: 1;
    color: var(--primary-500);
}

/* Hide SMS column when Twilio not configured */
.notif-sms-col.notif-sms-hidden {
    display: none;
}

/* Responsive: on narrow screens, show event names shorter */
@media (max-width: 480px) {
    .notif-pref-header,
    .notif-pref-row {
        grid-template-columns: 1fr 40px 40px 40px;
        padding: 8px;
    }
    .notif-pref-label-col {
        font-size: 0.78rem;
    }
    .notif-pref-ch-col input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
}

/* ====== Mobile Availability Notifications ====== */
.avail-notify-card {
    border-left: 3px solid var(--primary-500);
}

.avail-notify-card h4 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: var(--space-sm);
}

.avail-channel-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.avail-channel-options .checkbox-container {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.avail-sms-note {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
    margin-left: var(--space-sm);
}

.avail-template-section {
    margin-top: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.avail-template-section h5 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.avail-char-count {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.avail-char-count .green {
    color: #059669;
}

.avail-char-count .yellow {
    color: #d97706;
}

.avail-char-count .red {
    color: #dc2626;
}

.avail-segment-warning {
    font-weight: 600;
}

/* Page Header Actions */
.page-header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .page-header-actions {
        width: 100%;
    }
    .page-header-actions .btn {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        font-size: var(--font-size-sm);
        padding: var(--space-sm) var(--space-md);
    }
}

/* Notify Availability Full Page */
.avail-notify-page {
    position: fixed;
    top: 0;
    left: var(--sidebar-width, 260px);
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 20%, var(--fading-color-1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, var(--fading-color-2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, var(--fading-color-3) 0%, transparent 60%),
        var(--bg-primary);
    z-index: var(--z-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--space-xl);
    padding-top: calc(var(--space-xl) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
    animation: fadeSlideIn 0.25s ease;
}

.avail-notify-page-body {
    /* Removed max-width to match other tabs in Communications Center */
}

@media (max-width: 1024px) {
    .avail-notify-page {
        left: 0;
        z-index: var(--z-pwa-overlay); /* Layer 5: Full-Page PWA Overlays */
        padding: var(--space-md);
        /* Account for fixed mobile header height (~56px) + safe area */
        padding-top: calc(70px + env(safe-area-inset-top, 0px));
        /* Account for quick-access-bar height (68px) + safe area */
        padding-bottom: calc(var(--space-md) + 68px + env(safe-area-inset-bottom, 0px));
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.avail-back-btn {
    margin-bottom: var(--space-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.avail-back-btn:hover {
    color: var(--primary-500);
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.08);
}

.avail-selector-section {
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.avail-selector-section h4 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

/* City Grid */
.avail-city-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-sm);
}

.avail-city-chip {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

.avail-city-chip:hover {
    border-color: var(--primary-400);
    background: rgba(var(--primary-rgb), 0.05);
}

.avail-city-chip.selected {
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
    font-weight: 600;
}

.avail-city-chip .avail-city-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-left: auto;
}

/* Date Inputs */
.avail-date-inputs .form-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.avail-date-input {
    max-width: 200px;
}

.avail-date-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.avail-date-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 12px;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
    border-radius: 100px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.avail-date-tag .remove-date {
    cursor: pointer;
    opacity: 0.6;
    font-size: 1rem;
    line-height: 1;
}

.avail-date-tag .remove-date:hover {
    opacity: 1;
}

/* Preview Panel */
.avail-preview-panel {
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.avail-preview-panel h4 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.avail-preview-stats {
    display: flex;
    gap: var(--space-lg);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

.avail-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 90px;
}

.avail-stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-500);
}

.avail-stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.avail-client-preview-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.avail-client-preview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-sm);
}

.avail-client-preview-item:last-child {
    border-bottom: none;
}

.avail-client-preview-channels {
    display: flex;
    gap: var(--space-xs);
    color: var(--text-muted);
    font-size: 1rem;
}

/* Send Section */
.avail-send-section {
    margin-top: var(--space-xl);
    text-align: center;
}

.avail-send-progress {
    margin-top: var(--space-md);
}

.avail-progress-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.avail-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-400));
    border-radius: 100px;
    width: 0%;
    transition: width 0.3s ease;
}

.avail-send-results {
    margin-top: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
}

.avail-send-results.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #059669;
}

.avail-send-results.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #dc2626;
}

/* ====== Send Results Modal ====== */
.send-results-modal {
    max-width: 100%;
}

.send-results-success-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    flex-wrap: wrap;
}

.send-results-stat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.send-results-fail-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: #dc2626;
    margin-bottom: var(--space-sm);
}

.send-results-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.send-results-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

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

.send-results-item:hover {
    background: var(--bg-hover);
}

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

.send-results-item-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 2px;
}

.send-results-item-header strong {
    font-size: var(--font-size-sm);
}

.send-results-channel-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.send-results-contact {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.send-results-error {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    font-size: var(--font-size-xs);
    color: #dc2626;
    line-height: 1.4;
}

.send-results-error i {
    flex-shrink: 0;
    margin-top: 1px;
}

.send-results-view-btn {
    flex-shrink: 0;
    font-size: var(--font-size-xs) !important;
    white-space: nowrap;
}

.send-results-hint {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin: 0;
}

/* ====== Notification Report Banner ====== */
.notification-report-banner {
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    animation: fadeSlideIn 0.3s ease;
}

.notification-report-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    flex-wrap: wrap;
}

.notification-report-banner-content span {
    flex: 1;
    min-width: 0;
}

.notification-report-dismiss {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    line-height: 1;
}

.notification-report-dismiss:hover {
    color: #dc2626;
    background: rgba(239, 68, 68, 0.1);
}

@keyframes slideUp {
    from {
        opacity: 1;
        max-height: 60px;
        margin-bottom: var(--space-md);
    }
    to {
        opacity: 0;
        max-height: 0;
        margin-bottom: 0;
        padding: 0;
        overflow: hidden;
    }
}

/* ====== SMS Responsive ====== */
@media (max-width: 1024px) {
    .sms-container {
        height: calc(100dvh - 140px);
        max-height: calc(100dvh - 140px);
        border-radius: var(--radius-lg);
        overflow: hidden;
        max-width: 100%;
        box-sizing: border-box;
    }

    .sms-conversations-panel {
        width: 100%;
        min-width: unset;
        border-right: none;
        max-height: 100%;
        overflow-y: auto;
    }

    .sms-conversations-panel.hidden-mobile {
        display: none;
    }

    .sms-chat-panel.hidden-mobile {
        display: none;
    }

    /* Landscape Phone Fixes */
    @media (max-height: 600px) and (orientation: landscape) {
        #page-messages .page-header {
            display: none !important;
        }
        #page-messages {
            padding: 0 !important;
        }
        .sms-container {
            max-height: 100dvh !important;
            height: 100dvh !important;
            border-radius: 0;
            border: none;
        }
        .sms-chat-header {
            padding: 4px 8px !important;
        }
        .sms-chat-compose {
            padding: 4px !important;
        }
        .sms-chat-actions {
            margin-top: 0 !important;
        }
    }

    .sms-chat-panel {
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .sms-chat-active {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .sms-chat-header {
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        flex-shrink: 0;
        flex-wrap: wrap;
    }

    .sms-chat-header .sms-chat-contact-info h3 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sms-chat-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 4px;
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Icon-only buttons on mobile to reduce header height */
    .sms-chat-actions .btn span {
        display: none;
    }

    .sms-chat-actions .btn {
        padding: 6px 8px !important;
        min-width: 34px;
    }

    .sms-chat-messages {
        flex: 1;
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .sms-message {
        max-width: 85%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .sms-chat-compose {
        flex-shrink: 0;
        padding: var(--space-sm);
        max-width: 100%;
        box-sizing: border-box;
    }

    .sms-chat-compose textarea {
        min-width: 0;
        width: 100%;
        font-size: 16px;
        /* Prevents iOS auto-zoom on focus */
    }

    .sms-credentials-panel input {
        font-size: 16px;
        /* Prevents iOS auto-zoom on focus */
    }

    .sms-back-btn {
        display: flex !important;
    }

    .sms-setup-options {
        flex-direction: column;
    }

    .sms-option-btn {
        min-width: unset;
    }



    /* Credential panel mobile fixes */
    .sms-credentials-panel {
        padding: var(--space-md);
    }

    .sms-credentials-panel .form-group {
        margin-bottom: var(--space-md);
    }

    .sms-credentials-actions {
        flex-direction: column;
    }

    .sms-credentials-actions .btn {
        width: 100%;
    }

    .sms-pricing-disclaimer {
        font-size: 0.78rem;
        padding: var(--space-sm) var(--space-md);
    }

    /* Guide panel mobile */
    .sms-guide-panel {
        padding: var(--space-md);
    }

    .sms-setup-steps li {
        padding-left: var(--space-sm);
    }
}

/* Extra small screens */
@media (max-width: 390px) {
    .sms-container {
        height: calc(100dvh - 120px);
        max-height: calc(100dvh - 120px);
        border-radius: var(--radius-md);
    }

    .sms-conversation-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }

    .sms-chat-header {
        padding: var(--space-sm) var(--space-md);
    }
}

/* ====== ROUTE PLANNER ====== */
.route-planner-bar {
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.route-planner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}

.route-planner-header:hover {
    background: var(--bg-hover);
}

.route-planner-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.route-planner-title i {
    color: var(--primary-500);
    font-size: 1.2rem;
}

.route-planner-badge {
    background: var(--primary-500);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 100px;
    min-width: 18px;
    text-align: center;
}

.route-planner-chevron {
    color: var(--text-muted);
    font-size: 1.2rem;
    transition: transform 0.25s ease;
}

.route-planner-chevron.expanded {
    transform: rotate(180deg);
}

.route-planner-body {
    padding: 0 var(--space-lg) var(--space-lg);
    animation: fadeIn 0.2s ease;
}

.route-planner-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.route-planner-date {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.route-planner-date input[type="date"] {
    max-width: 160px;
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    height: 36px;
    line-height: 36px;
}

.route-planner-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 3px;
}

.route-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    flex: 1;
}

.route-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.route-tab.active {
    background: var(--bg-card);
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Route Date Strip — horizontal scrollable date pills */
.route-date-strip {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 12px;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-sm) 0 var(--space-md);
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}

.route-date-strip::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.route-date-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 56px;
    padding: 8px 6px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
    scroll-snap-align: start; /* snap scroll */
}

.route-date-pill:hover {
    border-color: var(--primary-400);
    background: rgba(var(--primary-rgb), 0.04);
}

.route-date-pill.active {
    border-color: var(--primary-500);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.route-date-pill.today {
    border-color: var(--primary-color);
}

.route-date-pill.today.active {
    border-color: var(--primary-500);
}

.route-date-day {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.route-date-pill.active .route-date-day {
    color: rgba(255,255,255,0.8);
}

.route-date-num {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.route-date-pill.active .route-date-num {
    color: white;
}

.route-date-badge {
    font-size: 0.55rem;
    font-weight: 700;
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-600);
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
}

.route-date-pill.active .route-date-badge {
    background: rgba(255,255,255,0.25);
    color: white;
}

.route-date-empty {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-style: italic;
}

.route-planner-info {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(var(--primary-rgb), 0.06);
    border: 1px solid rgba(var(--primary-rgb), 0.12);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.route-planner-info i {
    color: var(--primary-500);
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.route-planner-stops {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--space-md);
}

.route-stop {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.route-stop:hover {
    border-color: var(--primary-300);
    background: rgba(var(--primary-rgb), 0.03);
}

.route-stop-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 4px;
}

.route-stop-info {
    flex: 1;
    min-width: 0;
    overflow: visible;
}

.route-stop-client {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    word-break: break-word;
}

.route-stop-patient {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.route-stop-address {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    display: flex;
    align-items: baseline;
    gap: 4px;
    word-break: break-word;
    overflow-wrap: break-word;
    margin-top: 2px;
    min-width: 0;
}

.route-stop-address span {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.route-stop-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.route-time-edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.route-time-edit-btn:hover {
    border-color: var(--border-color);
    background: var(--bg-hover);
    color: var(--text-primary);
}

.route-time-editor {
    display: flex;
    align-items: center;
    gap: 4px;
}

.route-time-input {
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    height: 28px;
}

.route-time-save-btn,
.route-time-cancel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    padding: 0;
}

.route-time-save-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary-600);
    border-color: var(--primary-400);
}

.route-time-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: #fca5a5;
}

.route-stop-status {
    flex-shrink: 0;
    margin-top: 2px;
}

.route-stop-status .status-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
}

.route-planner-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.route-planner-warnings {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.route-planner-warnings i {
    color: var(--accent-amber);
}

.route-distance-summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(var(--primary-rgb), 0.06);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.route-distance-summary strong {
    color: var(--primary-600);
}

@media (max-width: 768px) {
    .route-planner-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .route-planner-tabs {
        justify-content: center;
    }

    .route-planner-actions {
        flex-direction: column;
    }

    .route-planner-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .route-stop {
        flex-wrap: wrap;
    }

    .route-stop-info {
        overflow: hidden;
    }

    .route-stop-time {
        width: 100%;
        padding-left: calc(28px + var(--space-md));
    }
}
/* ====== MILEAGE TRACKING ====== */
.mileage-summary-bar {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.mileage-stat {
    flex: 1;
    min-width: 120px;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: center;
    backdrop-filter: blur(10px);
}

.mileage-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.mileage-stat-value.mileage-business {
    color: #059669;
}

.mileage-stat-value.mileage-personal {
    color: var(--text-muted);
}

.mileage-stat-value.mileage-deduction {
    color: var(--primary-500);
}

.mileage-stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mileage-date-range {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    width: 100%;
}

.mileage-date-range span {
    flex-shrink: 0;
    text-align: center;
    min-width: 20px;
}

.mileage-date-range input[type="date"] {
    flex: 1 1 0;
    min-width: 0;
    max-width: 50%;
    padding: 6px 10px;
    font-size: var(--font-size-sm);
    height: 36px;
    line-height: 36px;
    box-sizing: border-box;
}

.mileage-trips-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.mileage-trip-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.mileage-trip-card:hover {
    border-color: var(--primary-300);
    background: rgba(var(--primary-rgb), 0.03);
}

.mileage-trip-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.mileage-trip-icon.business {
    background: rgba(5, 150, 105, 0.1);
    color: #059669;
}

.mileage-trip-icon.personal {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.mileage-trip-icon.unclassified {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.mileage-trip-info {
    flex: 1;
    min-width: 0;
}

.mileage-trip-route {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mileage-trip-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    display: flex;
    gap: var(--space-md);
    margin-top: 2px;
}

.mileage-trip-distance {
    font-weight: 700;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.mileage-trip-classify {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mileage-classify-btn {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    background: transparent;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-muted);
}

.mileage-classify-btn:hover {
    border-color: var(--primary-400);
    color: var(--primary-600);
}

.mileage-classify-btn.active-business {
    background: rgba(5, 150, 105, 0.1);
    border-color: #059669;
    color: #059669;
    font-weight: 600;
}

.mileage-classify-btn.active-personal {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
    color: var(--text-secondary);
    font-weight: 600;
}

.mileage-linked-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    color: var(--primary-500);
    font-weight: 500;
}

@media (max-width: 768px) {
    .mileage-summary-bar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .mileage-stat {
        min-width: calc(50% - var(--space-sm));
    }

    .mileage-trip-card {
        flex-wrap: wrap;
    }

    .mileage-trip-classify {
        width: 100%;
        justify-content: center;
        margin-top: var(--space-sm);
    }

    .mileage-date-range {
        flex-wrap: nowrap;
        justify-content: center;
    }

    .mileage-date-range input[type="date"] {
        max-width: none;
    }
}

/* ====== GOOGLE INTEGRATION CARD ====== */
.google-integration-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.google-status-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.google-status-badge.connected {
    color: var(--success-600, #16a34a);
}

.google-status-badge strong {
    display: block;
    font-size: 1rem;
}

.google-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.google-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.google-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem;
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border-color, #e2e8f0);
    position: relative;
}

.google-feature-item.active {
    background: color-mix(in srgb, var(--success-500, #22c55e) 8%, transparent);
    border-color: color-mix(in srgb, var(--success-500, #22c55e) 25%, transparent);
}

.google-feature-item.upcoming {
    opacity: 0.65;
    background: var(--bg-secondary);
}

.google-feature-item > i {
    font-size: 1.3rem;
    color: var(--primary-500, #2a4b2f);
    margin-top: 2px;
    flex-shrink: 0;
}

.google-feature-item strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.google-feature-item span:not(.feature-badge) {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.feature-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--primary-100, #e0e7ff);
    color: var(--primary-700, #4338ca);
    padding: 2px 6px;
    border-radius: 4px;
}

.feature-badge.active-badge {
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
}

.feature-badge.paused-badge {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.google-feature-item.paused {
    background: color-mix(in srgb, var(--warning-500, #eab308) 6%, transparent);
    border-color: color-mix(in srgb, var(--warning-500, #eab308) 20%, transparent);
    opacity: 0.8;
}

.google-status-badge.expired {
    color: var(--warning-600, #d97706);
}

.google-connected-since {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
    text-align: right;
}

/* Disconnected state - benefits list */
.google-benefits-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.25rem 0;
}

.google-benefit-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md, 10px);
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid transparent;
    transition: border-color 0.2s, background 0.2s;
}

.google-benefit-item:hover {
    border-color: color-mix(in srgb, var(--primary-500, #2a4b2f) 25%, transparent);
    background: color-mix(in srgb, var(--primary-500, #2a4b2f) 4%, var(--bg-secondary, #f8f9fa));
}

.google-benefit-item > i {
    font-size: 1.5rem;
    color: var(--primary-500, #2a4b2f);
    margin-top: 2px;
    flex-shrink: 0;
}

.google-benefit-item strong {
    display: block;
    margin-bottom: 3px;
    font-size: 0.95rem;
}

.google-benefit-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.google-connect-actions {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
}

.google-connect-actions .btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    gap: 0.5rem;
}

.google-not-configured {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: color-mix(in srgb, var(--warning-500, #eab308) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--warning-500, #eab308) 30%, transparent);
    border-radius: var(--radius-md, 10px);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.google-not-configured i {
    color: var(--warning-500, #eab308);
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Help section */
.google-help-section {
    margin-top: 1rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-md, 10px);
    overflow: hidden;
}

.google-help-section summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    user-select: none;
}

.google-help-section summary:hover {
    color: var(--primary-500, #2a4b2f);
}

.google-help-content {
    padding: 1rem;
    font-size: 0.88rem;
    line-height: 1.6;
}

.google-help-content ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

.google-help-content li {
    margin-bottom: 0.4rem;
}

.google-help-content a {
    color: var(--primary-500, #2a4b2f);
    text-decoration: underline;
}

@media (max-width: 600px) {
    .google-features-grid {
        grid-template-columns: 1fr;
    }
    .google-integration-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ====== PATIENT PHOTO GRID ====== */
.patient-photo-grid-section {
    margin-bottom: 1rem;
}
.patient-photo-grid-section > label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}
.patient-photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.photo-slot {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: var(--bg-secondary, #f8f9fa);
    border: 2px dashed var(--border-color, #e2e8f0);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.photo-slot:hover {
    border-color: var(--primary, #355e3b);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.15);
}
.photo-slot.has-photo {
    border-style: solid;
    border-color: var(--border-color, #e2e8f0);
}
.photo-slot-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.3rem;
    color: var(--text-muted, #94a3b8);
    font-size: 0.8rem;
    font-weight: 500;
}
.photo-slot-empty i {
    font-size: 1.4rem;
}
.photo-slot-empty.uploading {
    color: var(--primary, #355e3b);
}
.photo-slot-empty.uploading i {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.photo-slot-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-slot-star,
.photo-slot-remove {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    z-index: 2;
}
.photo-slot-star {
    bottom: 6px;
    left: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-muted, #94a3b8);
}
.photo-slot-star.active {
    background: var(--warning-500, #f59e0b);
    color: white;
}
.photo-slot-star:hover {
    background: var(--warning-500, #f59e0b);
    color: white;
}
.photo-slot-remove {
    top: 6px;
    right: 6px;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    font-size: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.photo-slot:hover .photo-slot-remove {
    opacity: 1;
}
.patient-photo-locked {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: var(--radius-md, 8px);
    font-size: 0.85rem;
    color: var(--text-muted, #94a3b8);
    border: 1px solid var(--border-color, #e2e8f0);
}
.patient-photo-locked i {
    font-size: 1.1rem;
}
.patient-photo-locked a {
    color: var(--primary, #355e3b);
    font-weight: 600;
}

/* ====== NOTE MEDIA TAB ENHANCEMENTS ====== */
.note-photos-section {
    margin-bottom: 1.5rem;
}
.note-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.note-photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e8f0);
}
.note-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.note-photo-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    font-size: 0.7rem;
    padding: 0.25rem 0.4rem;
    text-align: center;
}
.note-photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.note-photo-item:hover .note-photo-remove {
    opacity: 1;
}
.note-media-locked {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    background: var(--bg-secondary, #f8f9fa);
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-color, #e2e8f0);
}
.note-media-locked i {
    font-size: 2rem;
}
.note-media-locked a {
    color: var(--primary, #355e3b);
    font-weight: 600;
}

/* Patient profile picture in lists */
.patient-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border-color, #e2e8f0);
}

@media (max-width: 480px) {
    .patient-photo-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
}

/* ═══════════════════════════════════════════
   ONBOARDING WALKTHROUGH
   ═══════════════════════════════════════════ */

.wt-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top, 20px) 0 env(safe-area-inset-bottom, 0) 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wt-overlay.visible {
    opacity: 1;
}

body.wt-active {
    overflow: hidden;
}

.wt-container {
    width: 95%;
    max-width: 640px;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.05);
    overflow: hidden;
    animation: wtSlideUp 0.4s ease;
}

@keyframes wtSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Header / Progress */
.wt-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.wt-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wt-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary, rgba(255,255,255,0.08));
    border-radius: 4px;
    overflow: hidden;
}

.wt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color, #355e3b), var(--primary-color, #355e3b));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.wt-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    white-space: nowrap;
}

.wt-skip-btn {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1.3rem;
}
.wt-skip-btn:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.08));
    color: var(--text-primary, #fff);
}

/* Body */
.wt-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    min-height: 200px;
}

.wt-body.wt-slide-out {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.2s ease;
}
.wt-body.wt-slide-in {
    animation: wtFadeIn 0.3s ease;
}

@keyframes wtFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Slide */
.wt-slide-header {
    text-align: center;
    margin-bottom: 24px;
}

.wt-slide-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-color, #355e3b), var(--primary-600, #2a4b2f));
    color: white;
    font-size: 1.5rem;
    margin-bottom: 12px;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--primary-color, #355e3b) 25%, transparent);
}

.wt-slide-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--text-primary, #fff);
}

.wt-slide-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary, #aaa);
    margin: 0;
    line-height: 1.5;
}

/* Footer / Navigation */
.wt-footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.wt-nav-btn {
    min-width: 110px;
}

/* ── Welcome Slide ── */
.wt-welcome-content {
    text-align: center;
}

.wt-welcome-logo {
    margin-bottom: 16px;
}

.wt-welcome-text {
    font-size: 0.95rem;
    color: var(--text-secondary, #aaa);
    line-height: 1.6;
    margin-bottom: 24px;
}

.wt-welcome-highlights {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
}

.wt-highlight {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-primary, #fff);
}

.wt-highlight i {
    font-size: 1.2rem;
    color: var(--primary-color, #355e3b);
    flex-shrink: 0;
}

/* ── Practice Type Cards ── */
.wt-practice-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wt-type-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary, rgba(255,255,255,0.03));
}

.wt-type-card:hover {
    border-color: var(--primary-color, #355e3b);
    background: color-mix(in srgb, var(--primary-color, #355e3b) 5%, transparent);
}

.wt-type-card.selected {
    border-color: var(--primary-color, #355e3b);
    background: color-mix(in srgb, var(--primary-color, #355e3b) 10%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-color, #355e3b) 30%, transparent);
}

.wt-type-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-tertiary, rgba(255,255,255,0.06));
    flex-shrink: 0;
}

.wt-type-card.selected .wt-type-icon {
    background: color-mix(in srgb, var(--primary-color, #355e3b) 20%, transparent);
    color: var(--primary-color, #355e3b);
}

.wt-type-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wt-type-info strong {
    font-size: 0.95rem;
    color: var(--text-primary, #fff);
}

.wt-type-info span {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
}

.wt-type-check {
    font-size: 1.3rem;
    color: var(--text-muted, #888);
}

.wt-type-card.selected .wt-type-check {
    color: var(--primary-color, #355e3b);
}

/* ── Species Grid ── */
.wt-species-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.wt-species-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 10px;
    border: 1.5px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary, #fff);
}

.wt-species-btn:hover {
    border-color: var(--primary-color, #355e3b);
}

.wt-species-btn.selected {
    border-color: var(--primary-color, #355e3b);
    background: color-mix(in srgb, var(--primary-color, #355e3b) 10%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-color, #355e3b) 30%, transparent);
}

.wt-species-icon {
    font-size: 1.8rem;
}

.wt-species-name {
    font-size: 0.8rem;
    font-weight: 600;
}

/* ── Hints ── */
.wt-hint {
    margin-top: 16px;
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Feature Tour Points ── */
.wt-feature-points {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wt-point {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.wt-point > i {
    font-size: 1.2rem;
    color: var(--primary-color, #355e3b);
    margin-top: 2px;
    flex-shrink: 0;
}

.wt-point > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wt-point strong {
    font-size: 0.9rem;
    color: var(--text-primary, #fff);
}

.wt-point span {
    font-size: 0.82rem;
    color: var(--text-secondary, #aaa);
    line-height: 1.4;
}

/* ── Badges ── */
.wt-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

.wt-badge-free {
    background-color: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.wt-badge-credits {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

/* ── Form (Interactive Slides) ── */
.wt-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
}

.wt-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wt-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #aaa);
}

.wt-form-group input {
    padding: 10px 14px;
    border: 1.5px solid var(--border-color, rgba(255,255,255,0.15));
    border-radius: 10px;
    background: var(--bg-secondary, rgba(255,255,255,0.05));
    color: var(--text-primary, #fff);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.wt-form-group input:focus {
    outline: none;
    border-color: var(--primary-color, #355e3b);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color, #355e3b) 15%, transparent);
}

/* ── Tier Info ── */
.wt-tier-current {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color, #355e3b) 10%, transparent), color-mix(in srgb, var(--primary-color, #355e3b) 8%, transparent));
    border: 1px solid color-mix(in srgb, var(--primary-color, #355e3b) 20%, transparent);
    margin-bottom: 16px;
}

.wt-tier-current > i {
    font-size: 1.5rem;
    color: var(--accent-amber, #f59e0b);
}

.wt-tier-current > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wt-tier-current strong {
    color: var(--text-primary, #fff);
}

.wt-tier-current span {
    font-size: 0.82rem;
    color: var(--text-secondary, #aaa);
}

.wt-tier-note {
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.wt-tier-note i {
    color: var(--primary-color, #355e3b);
    margin-top: 2px;
}

/* ── Upsell ── */
.wt-upsell-features {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.wt-upsell-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.wt-upsell-item > i {
    font-size: 1.2rem;
    color: var(--accent-amber, #f59e0b);
    margin-top: 2px;
}

.wt-upsell-item strong {
    color: var(--text-primary, #fff);
    font-size: 0.9rem;
}

.wt-upsell-item span {
    font-size: 0.82rem;
    color: var(--text-secondary, #aaa);
}

.wt-upsell-item > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wt-upsell-cta-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted, #888);
    padding: 12px;
    border-radius: 10px;
    background: var(--bg-secondary, rgba(255,255,255,0.03));
}

.wt-upsell-hint {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-size: 0.82rem;
    color: var(--accent-amber, #f59e0b);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Complete Slide ── */
.wt-complete {
    text-align: center;
}

.wt-complete-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto 20px;
}

.wt-action-btn {
    width: 100%;
    justify-content: center;
}

.wt-complete-hint {
    font-size: 0.82rem;
    color: var(--text-muted, #888);
}

/* ── Permissions (Staff Tour) ── */
.wt-permissions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.wt-perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.wt-perm-item.granted {
    background: rgba(34, 197, 94, 0.08);
    color: var(--accent-emerald, #22c55e);
}

.wt-perm-item.denied {
    background: rgba(239, 68, 68, 0.06);
    color: var(--text-muted, #888);
}

.wt-perm-item i {
    font-size: 1rem;
}

/* ── Resume Banner ── */
.wt-resume-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 0 0 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color, #355e3b) 10%, transparent), color-mix(in srgb, var(--primary-color, #355e3b) 8%, transparent));
    border: 1px solid color-mix(in srgb, var(--primary-color, #355e3b) 20%, transparent);
    animation: wtFadeIn 0.3s ease;
}

.wt-resume-banner > i {
    font-size: 1.2rem;
    color: var(--primary-color, #355e3b);
}

.wt-resume-banner > span {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
}

.wt-resume-dismiss {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    border-radius: 6px;
}

.wt-resume-dismiss:hover {
    background: rgba(255,255,255,0.05);
}

/* ── First-Visit Tooltips ── */
.wt-first-tooltip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 0 12px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.04));
    border: 1px solid rgba(245, 158, 11, 0.2);
    animation: wtFadeIn 0.4s ease;
    font-size: 0.85rem;
    color: var(--text-secondary, #aaa);
}

.wt-first-tooltip > i {
    font-size: 1.1rem;
    color: var(--accent-amber, #f59e0b);
    flex-shrink: 0;
}

.wt-first-tooltip > span {
    flex: 1;
}

.wt-first-tooltip > button {
    background: none;
    border: none;
    color: var(--text-muted, #888);
    cursor: pointer;
    padding: 4px;
    font-size: 0.9rem;
    border-radius: 6px;
    flex-shrink: 0;
}

.wt-first-tooltip > button:hover {
    background: rgba(255,255,255,0.05);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .wt-overlay {
        padding: 0;
        align-items: stretch;
    }

    .wt-container {
        width: 100%;
        max-height: none;
        height: 100dvh;
        height: 100vh;
        border-radius: 0;
        border: none;
        box-shadow: none;
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .wt-header {
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.04);
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .wt-body {
        padding: 20px 20px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .wt-slide-icon {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
        border-radius: 14px;
        margin-bottom: 10px;
    }

    .wt-slide-title {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .wt-slide-subtitle {
        font-size: 0.82rem;
    }

    .wt-slide-header {
        margin-bottom: 18px;
    }

    .wt-feature-points {
        gap: 10px;
    }

    .wt-point {
        gap: 10px;
        padding: 10px 12px;
        background: rgba(255, 255, 255, 0.04);
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.05);
    }

    .wt-point > i {
        font-size: 1.1rem;
    }

    .wt-point strong {
        font-size: 0.85rem;
    }

    .wt-point span {
        font-size: 0.78rem;
    }

    .wt-footer {
        padding: 14px 20px;
        background: rgba(255, 255, 255, 0.04);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .wt-nav-btn {
        min-width: 90px;
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .wt-welcome-text {
        font-size: 0.88rem;
        margin-bottom: 18px;
    }

    .wt-welcome-highlights {
        max-width: 280px;
        gap: 10px;
    }

    .wt-highlight {
        font-size: 0.85rem;
        gap: 10px;
    }

    .wt-type-card {
        padding: 12px 14px;
        gap: 12px;
    }

    .wt-type-icon {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
        border-radius: 8px;
    }

    .wt-type-info strong {
        font-size: 0.88rem;
    }

    .wt-type-info span {
        font-size: 0.75rem;
    }

    .wt-species-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .wt-species-btn {
        padding: 12px 8px;
    }

    .wt-species-icon {
        font-size: 1.5rem;
    }

    .wt-species-name {
        font-size: 0.72rem;
    }

    .wt-permissions-grid {
        grid-template-columns: 1fr;
    }

    .wt-upsell-hint {
        font-size: 0.78rem;
        padding: 10px 12px;
    }

    .wt-form-group label {
        font-size: 0.8rem;
    }

    .wt-form-group input {
        padding: 10px 12px;
        font-size: 0.88rem;
    }

    .wt-complete-actions {
        gap: 8px;
    }

    .wt-action-btn {
        padding: 10px 16px;
        font-size: 0.88rem;
    }
}

/* ========================================
   Cancelled Subscription Lockout Screen
   ======================================== */
.lockout-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: var(--space-xl);
    box-sizing: border-box;
    z-index: 1;
}

.lockout-card {
    max-width: 480px;
    width: 100%;
    padding: var(--space-2xl);
    border-radius: var(--radius-xl);
    text-align: center;
}

.lockout-logo {
    height: 48px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    margin-bottom: var(--space-lg);
}

.lockout-icon {
    font-size: 3.5rem;
    color: var(--accent-amber);
    margin-bottom: var(--space-md);
}

.lockout-card h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.lockout-subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    margin-bottom: var(--space-xl);
}

.lockout-dates {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    margin-bottom: var(--space-lg);
}

.lockout-date-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
}

.lockout-date-row span {
    color: var(--text-muted);
}

.lockout-date-row strong {
    color: var(--text-primary);
}

.lockout-days-remaining {
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-xs);
    padding-top: var(--space-sm);
}

.lockout-days-remaining strong.text-danger {
    color: var(--accent-rose);
}

.lockout-warning {
    font-size: var(--font-size-sm);
    color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-lg);
}

.lockout-download-btn {
    width: 100%;
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-base);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.lockout-reactivate {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.lockout-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0 auto;
    padding: var(--space-sm);
    transition: color var(--transition-fast);
}

.lockout-logout:hover {
    color: var(--accent-rose);
}

/* ── Trial Expired Tier Selection ── */
.lockout-tier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.lockout-tier-card {
    position: relative;
    padding: var(--space-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.lockout-tier-card:hover {
    border-color: var(--primary-400);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.lockout-tier-recommended {
    border-color: var(--primary-500);
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.15);
}

.lockout-tier-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lockout-tier-card h3 {
    margin: 0 0 var(--space-sm);
    font-size: 1rem;
    font-weight: 700;
}

.lockout-tier-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.lockout-tier-price span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

.lockout-tier-patients {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.lockout-tier-btn {
    width: 100%;
    font-size: 0.85rem;
}

/* Cancel Subscription Link */
.cancel-sub-link {
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    border: none;
    background: none;
    text-decoration: underline;
    padding: var(--space-sm) 0;
    transition: color 0.2s;
}

.cancel-sub-link:hover {
    color: var(--accent-rose);
}

@media (max-width: 480px) {
    .lockout-tier-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Quick Access Bar — Mobile Bottom Nav
   ======================================== */
.quick-access-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-quick-access);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
}

.quick-access-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--bg-primary);
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
    border-top: 1px solid var(--border-color);
}

@media (max-width: 1024px) {
    .quick-access-bar.active {
        display: flex;
        align-items: stretch;
        justify-content: space-around;
    }

    /* Add breathing room for main content so bar doesn't cover it */
    body.has-quick-access .main-content {
        padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }
}

/* Hide when sidebar is open */
.sidebar.open ~ .quick-access-bar,
body.sidebar-open .quick-access-bar {
    display: none !important;
}

/* ── Tab Item ── */
.quick-access-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px 8px;
    background: none;
    border: none;
    color: var(--text-muted, #64748b);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.02em;
}

.quick-access-tab i,
.quick-access-tab svg {
    font-size: 1.5rem;
    transition: transform 0.2s ease, color 0.2s ease;
    width: 1.5rem;
    height: 1.5rem;
}

.quick-access-tab:active i,
.quick-access-tab:active svg {
    transform: scale(0.88);
}

/* Active state */
.quick-access-tab.active {
    color: var(--primary-500, #355e3b);
}

.quick-access-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2.5px;
    border-radius: 0 0 4px 4px;
    background: var(--primary-500, #355e3b);
    animation: qa-indicator-in 0.25s ease;
}

@keyframes qa-indicator-in {
    from { width: 0; opacity: 0; }
    to { width: 24px; opacity: 1; }
}

/* ── Center Action "+" Button ── */
.quick-access-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 6px;
    background: none;
    border: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.quick-access-center-inner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500, #355e3b), var(--primary-600, #2a4b2f));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.35), 0 0 0 3px color-mix(in srgb, var(--bg-primary, #0f172a) 80%, transparent);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: -18px;
}

.quick-access-center:active .quick-access-center-inner {
    transform: scale(0.92);
}

.quick-access-center-inner.sheet-open {
    transform: rotate(45deg);
    background: linear-gradient(135deg, var(--accent-rose, #ef4444), #dc2626);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35), 0 0 0 3px color-mix(in srgb, var(--bg-primary, #0f172a) 80%, transparent);
}

/* ── Quick Action Sheet ── */
.quick-action-sheet-overlay {
    position: fixed;
    inset: 0;
    z-index: 899;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.quick-action-sheet-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.quick-action-sheet {
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 901;
    background: var(--bg-card, #1e293b);
    border-radius: 16px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    padding: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-action-sheet.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    background: var(--bg-secondary, rgba(255,255,255,0.05));
    color: var(--text-primary, #fff);
    font-size: 0.72rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    min-width: 76px;
}

.quick-action-btn i {
    font-size: 1.4rem;
    color: var(--primary-400, #818cf8);
}

.quick-action-btn:active {
    background: rgba(var(--primary-rgb), 0.15);
    transform: scale(0.95);
}

/* ── Setup: Quick Access Config ── */
.qa-tab-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.qa-tab-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color, rgba(255,255,255,0.1));
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    color: var(--text-secondary, #aaa);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.qa-tab-chip i {
    font-size: 1rem;
}

.qa-tab-chip:hover {
    border-color: var(--primary-400, #818cf8);
}

.qa-tab-chip.selected {
    border-color: var(--primary-500, #355e3b);
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-400, #818cf8);
}

.qa-tab-chip.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Mini preview bar in settings */
.qa-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 10px 8px;
    margin-top: 12px;
    border-radius: 12px;
    background: var(--bg-secondary, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.qa-preview-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    padding: 4px 8px;
}

.qa-preview-tab i {
    font-size: 1rem;
}

.qa-preview-tab.center {
    color: #fff;
}

.qa-preview-tab.center i {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

/* ========================================
   Help Video Tutorial Cards
   ======================================== */
.help-video-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    border-color: var(--primary-400, #818cf8) !important;
}

.help-video-card:hover div[style*="background:rgba(0,0,0,0.15)"] {
    background: rgba(0,0,0,0.05) !important;
}

/* ========================================
   Searchable Select Combobox
   ======================================== */
.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: var(--radius-md, 8px);
    background: var(--bg-primary, #ffffff);
    color: var(--text-main, #1e293b);
    font-size: var(--font-size-sm, 0.9rem);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: text;
    box-sizing: border-box;
}

.searchable-select-input::placeholder {
    color: var(--text-muted, #64748b);
}

.searchable-select-input:focus {
    border-color: var(--primary-400, #818cf8);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.searchable-select-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #64748b);
    pointer-events: none;
    font-size: 1rem;
    transition: transform 0.2s;
}

.searchable-select.open .searchable-select-chevron {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 90vw;
    z-index: 1000;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 12px 36px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.15);
    max-height: 220px;
    overflow-y: auto;
    display: none;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
}

.searchable-select.open .searchable-select-dropdown {
    display: block;
    animation: ss-dropdown-in 0.15s ease;
}

@keyframes ss-dropdown-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.searchable-select-item {
    padding: 9px 12px;
    font-size: 0.88rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-main, #1e293b);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: normal;
    line-height: 1.4;
    word-break: break-word;
}

.searchable-select-item:hover,
.searchable-select-item.highlighted {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-300, #a5b4fc);
}

.searchable-select-item.selected {
    background: rgba(var(--primary-rgb), 0.18);
    font-weight: 600;
}

.searchable-select-item--special {
    color: var(--primary-400, #818cf8);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    margin-bottom: 2px;
    padding-bottom: 10px;
}

.searchable-select-empty {
    padding: 12px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    font-style: italic;
}

.searchable-select-match {
    font-weight: 700;
    color: var(--primary-300, #a5b4fc);
    text-decoration: underline;
    text-decoration-color: rgba(var(--primary-rgb), 0.3);
}

/* Highlight missing fields */
.input-error {
    border-color: #ef4444 !important;
    background-color: #fdf2f2 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

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

.toggle-slider {
    position: relative;
    display: inline-block;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

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

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--primary-500);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Sticky Action Bar (Database Cleanup, etc) */
.sticky-action-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 260px);
    right: 0;
    z-index: 800;
    background: transparent;
}

.sticky-action-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: -120px; /* Extends below the bar to block scroll transparency */
    z-index: -1;
    background: var(--bg-primary);
    -webkit-backdrop-filter: blur(0px);
    backdrop-filter: blur(0px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

@media (max-width: 1024px) {
    .sticky-action-bar {
        left: 0;
    }
    body.has-quick-access .sticky-action-bar {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }
}


/* ========================================
   Skeleton Loaders (Phase 2 UX Improvement)
   ======================================== */
.skeleton-loader {
    display: inline-block;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-secondary, #e2e8f0);
    border-radius: var(--radius-sm, 4px);
}

[data-theme="dark"] .skeleton-loader {
    background-color: rgba(255, 255, 255, 0.05);
}

.skeleton-loader::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: shimmer 1.5s infinite;
}

[data-theme="dark"] .skeleton-loader::after {
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.1) 60%,
        rgba(255, 255, 255, 0)
    );
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

.skeleton-card {
    width: 100%;
    height: 120px;
    border-radius: var(--radius-md, 8px);
    margin-bottom: var(--space-md, 1rem);
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.skeleton-text.short {
    width: 50%;
}

.skeleton-text.title {
    height: 1.5rem;
    width: 70%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-md, 1rem);
    width: 100%;
}

.skeleton-item-row {
    display: flex;
    align-items: center;
    gap: var(--space-md, 1rem);
    padding: var(--space-sm, 0.5rem);
    border: 1px solid var(--border-color, rgba(0,0,0,0.1));
    border-radius: var(--radius-md, 8px);
}


/* Offline mode styles */
body.is-offline .online-only-btn {
    display: none !important;
}

/* Global Sync Indicator */
.sync-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    padding: 6px;
    cursor: default;
    transition: color 0.3s ease;
    position: relative;
}
.sync-indicator.synced { color: var(--accent-emerald, #10b981); }
.sync-indicator.unsaved { color: var(--accent-amber, #f59e0b); }
.sync-indicator.syncing { color: var(--secondary-500, #0ea5e9); }
.sync-indicator.offline { color: var(--text-muted, #94a3b8); }
.sync-indicator.stuck {
    color: var(--accent-rose, #ef4444);
    animation: sync-stuck-pulse 2s ease-in-out infinite;
    position: relative;
}
.sync-indicator.quarantined {
    color: var(--accent-rose, #ef4444);
    animation: sync-quarantined-pulse 1.5s ease-in-out infinite;
    position: relative;
}
@keyframes sync-stuck-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes sync-quarantined-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.75; }
}
.sync-stuck-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--accent-rose, #ef4444);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sync-repair-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    margin-bottom: 8px;
}
.fa-spin { animation: spin 2s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ========================================
   Communication Center — Channel Pills & Overview Dashboard
   Step 8 & 9
   ======================================== */

/* ── Channel Toggle Pills ── */
.comm-channel-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.comm-channel-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border-color, rgba(255,255,255,0.12));
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    color: var(--text-muted, #64748b);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.comm-channel-pill i {
    font-size: 0.9rem;
}

.comm-channel-pill:hover {
    border-color: var(--primary-400, #818cf8);
    color: var(--text-secondary, #cbd5e1);
}

.comm-channel-pill.active {
    border-color: var(--primary-500, #355e3b);
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary-300, #a5b4fc);
}

.comm-channel-pill.active i {
    color: var(--primary-400, #818cf8);
}

/* ── Collapsed Summary Badges ── */
.comm-collapsed-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.comm-summary-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.comm-summary-badge.on {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-emerald, #10b981);
}

.comm-summary-badge.off {
    background: rgba(239, 68, 68, 0.08);
    color: var(--text-muted, #64748b);
    text-decoration: line-through;
    opacity: 0.6;
}

/* ── Communication Overview Dashboard ── */
.comm-overview-dashboard {
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: var(--radius-lg, 12px);
    padding: 20px;
    margin-bottom: 24px;
}

.comm-overview-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.comm-overview-header i {
    font-size: 1.3rem;
    color: var(--primary-400, #818cf8);
}

.comm-overview-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.comm-overview-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    background: var(--bg-secondary, rgba(255,255,255,0.04));
    padding: 3px 10px;
    border-radius: 12px;
}

.comm-overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.comm-overview-table thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #64748b);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.comm-overview-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: background 0.15s;
}

.comm-overview-table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.04);
}

.comm-overview-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.comm-dash-label {
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
}

.comm-dash-channels {
    display: flex;
    gap: 4px;
}

.comm-dash-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
}

.comm-dash-dot.on {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald, #10b981);
}

.comm-dash-dot.off {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-muted, #64748b);
    opacity: 0.5;
}

.comm-dash-custom i {
    color: var(--primary-400, #818cf8);
    font-size: 0.9rem;
}

.comm-dash-default {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    opacity: 0.6;
}

@media (max-width: 600px) {
    .comm-overview-table {
        font-size: 0.75rem;
    }
    .comm-overview-dashboard {
        padding: 14px;
    }
    .comm-dash-dot {
        width: 18px;
        height: 18px;
        font-size: 0.6rem;
    }
}

/* ── Section Group Headers (Doctor Alerts, etc.) ── */
.comm-section-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.comm-section-group-header > i {
    font-size: 1.15rem;
    color: var(--primary-400, #818cf8);
    flex-shrink: 0;
}

.comm-section-group-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.comm-section-group-desc {
    width: 100%;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: -4px;
}

/* ── Doctor Alerts Preference Grid (Step 9A) ── */
.comm-doctor-alerts {
    margin-top: 8px;
}

.comm-doctor-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.comm-doctor-header-row,
.comm-doctor-row {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    gap: 12px;
}

.comm-doctor-header-row {
    padding: 6px 12px;
}

.comm-doctor-row:last-child {
    border-bottom: none;
}

.comm-doctor-event-label {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
}

.comm-doctor-event-label i {
    font-size: 1.1rem;
    color: var(--primary-400, #818cf8);
    flex-shrink: 0;
}

.comm-doctor-channels {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.comm-doctor-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    transition: all 0.2s;
    min-width: 72px;
    justify-content: center;
    user-select: none;
}

.comm-doctor-toggle i {
    font-size: 0.85rem;
}

.comm-doctor-toggle input[type="checkbox"] {
    display: none;
}

.comm-doctor-toggle:has(input:checked) {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald, #10b981);
}

.comm-doctor-toggle:hover {
    border-color: var(--primary-400, #818cf8);
}

.comm-doctor-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

@media (max-width: 600px) {
    .comm-doctor-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .comm-doctor-channels {
        width: 100%;
        justify-content: flex-start;
    }
    .comm-doctor-toggle {
        min-width: 60px;
        font-size: 0.7rem;
    }
}

/* ========================================
   SearchableSelect Component (v1)
   ======================================== */

/* Wrapper — relative positioning anchor */
.ss-wrapper {
    position: relative;
    width: 100%;
}

/* Native <select> — hidden but form-participating + accessible.
   Do NOT use display:none or visibility:hidden. */
.ss-wrapper select.ss-native-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Search input */
.ss-input {
    width: 100%;
    padding: 10px 36px 10px 12px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: var(--radius-md, 8px);
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1e293b);
    font-size: var(--font-size-sm, 0.9rem);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: text;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.ss-input::placeholder {
    color: var(--text-muted, #64748b);
}

.ss-input:focus {
    border-color: var(--primary-400, #818cf8);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

/* Chevron */
.ss-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #64748b);
    pointer-events: none;
    font-size: 1rem;
    transition: transform 0.2s;
}

.ss-wrapper.ss-open .ss-chevron {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown panel */
.ss-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(90vw, 440px);
    z-index: 1000;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, rgba(255,255,255,0.12));
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 12px 36px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.15);
    max-height: 260px;
    overflow-y: auto;
    display: none;
    padding: 4px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.ss-wrapper.ss-open .ss-dropdown {
    display: block;
    animation: ss-fade-in 0.15s ease;
}

@keyframes ss-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Option item */
.ss-item {
    padding: 10px 12px;
    font-size: 0.88rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary, #f1f5f9);
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: normal;
    line-height: 1.4;
    word-break: break-word;
    min-height: 44px;     /* Touch target */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.ss-item:hover,
.ss-item.ss-highlighted {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-300, #a5b4fc);
}

.ss-item.ss-selected {
    background: rgba(var(--primary-rgb), 0.18);
    font-weight: 600;
}

.ss-item.ss-selected::after {
    content: '\2713';
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--primary-400, #818cf8);
    flex-shrink: 0;
}

/* Custom "Add..." row */
.ss-item.ss-custom {
    color: var(--primary-400, #818cf8);
    font-weight: 600;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
    margin-top: 2px;
    padding-top: 10px;
}

.ss-item.ss-custom i {
    font-size: 1rem;
    flex-shrink: 0;
}

/* Group header */
.ss-group-label {
    padding: 8px 12px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #64748b);
    pointer-events: none;
    user-select: none;
}

.ss-group-label:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
    padding-top: 8px;
}

/* Empty state */
.ss-empty {
    padding: 14px 12px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    font-style: italic;
}

/* "Show all N results" button */
.ss-show-more {
    padding: 10px 12px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-400, #818cf8);
    cursor: pointer;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
    margin-top: 2px;
    border-radius: 0 0 6px 6px;
    transition: background 0.1s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.ss-show-more:hover {
    background: rgba(var(--primary-rgb), 0.08);
}

/* Search match highlight */
.ss-match {
    font-weight: 700;
    color: var(--primary-300, #a5b4fc);
    text-decoration: underline;
    text-decoration-color: rgba(var(--primary-rgb), 0.3);
}

/* ── Dark theme adjustments ── */
[data-theme="dark"] .ss-dropdown {
    background: var(--bg-card, #1e293b);
    border-color: var(--border-color, rgba(255,255,255,0.1));
}

/* ── Mobile optimizations ── */
@media (max-width: 600px) {
    .ss-dropdown {
        max-height: 220px;
        max-width: 95vw;
    }

    .ss-item {
        padding: 12px;
        font-size: 0.92rem;
    }
}

/* Deep link highlights */
@keyframes deepLinkPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(53, 94, 59, 0.6);
        background-color: rgba(53, 94, 59, 0.12);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(53, 94, 59, 0);
        background-color: rgba(53, 94, 59, 0.04);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(53, 94, 59, 0);
        background-color: transparent;
    }
}
.deep-link-pulse {
    animation: deepLinkPulse 1.5s 3 ease-in-out !important;
    border-color: var(--primary-600) !important;
    transition: all 0.3s ease;
}

/* ==========================================================================
   ROUTE PLANNER STYLES (SCH-003)
   ========================================================================== */
/* Split layout responsive grid */
.route-planner-layout {
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: stretch;
    margin-top: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.route-planner-left {
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.route-planner-right {
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

@media (max-width: 900px) {
    .route-planner-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .route-planner-left, .route-planner-right {
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }
    .route-planner-left .card {
        padding: 1rem !important;
    }
    .route-planner-right {
        order: 2; /* Put map card naturally below appointment list */
        height: 320px !important;
        min-height: 320px !important;
        max-height: 320px !important;
    }
    .map-card {
        height: 320px !important;
        min-height: 320px !important;
        max-height: 320px !important;
    }
    #routePlannerMap, #routePlannerMapPlaceholder {
        height: 320px !important;
        min-height: 320px !important;
        max-height: 320px !important;
    }
}

/* Route Summary Panel */
.route-summary-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
    .route-summary-panel {
        grid-template-columns: repeat(2, 1fr);
    }
}

.route-summary-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 12px;
    padding: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.route-summary-card .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-400, #818cf8);
    margin-bottom: 2px;
}

.route-summary-card .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #94a3b8);
    font-weight: 600;
}

[data-theme="light"] .route-summary-card {
    background: rgba(0, 0, 0, 0.02);
}

/* Enhanced Stop Cards */
.route-planner-stops {
    display: flex;
    flex-direction: column;
    gap: 0px; /* Flush layout with leg line between them */
}

/* Travel time connector leg */
.route-leg-travel-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 2rem;
    border-left: 2px dashed var(--border-color, rgba(255,255,255,0.12));
    padding: 10px 0 10px 16px;
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
}

.route-leg-travel-time i {
    color: var(--primary-400, #818cf8);
}

/* Route Stop Card Sizing Boundaries */
.route-stop-card {
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 12px;
    padding: 1rem;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

@media (max-width: 480px) {
    .route-stop-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

.route-stop-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-400, rgba(53, 94, 59, 0.3));
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Active stop highlights */
.route-stop-card.active {
    border-color: var(--primary-500, #355e3b);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
    background: rgba(var(--primary-rgb), 0.05);
}

.route-stop-card.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-500, #355e3b);
    border-radius: 12px 0 0 12px;
}

/* Unmappable address warning */
.route-stop-card.unmappable {
    border-color: var(--accent-amber, #f59e0b) !important;
    background: rgba(245, 158, 11, 0.03);
}

.route-stop-card.unmappable::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-amber, #f59e0b);
    border-radius: 12px 0 0 12px;
}

/* Stop Card Elements */
.route-stop-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-500, #355e3b);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.route-stop-card.unmappable .route-stop-badge {
    background: var(--accent-amber, #f59e0b);
}

.route-stop-content {
    flex: 1;
    min-width: 0;
}

.route-stop-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.route-stop-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary, #ffffff);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-stop-time {
    font-size: 0.8rem;
    color: var(--primary-400, #818cf8);
    font-weight: 600;
    white-space: nowrap;
}

.route-stop-address {
    font-size: 0.82rem;
    color: var(--text-secondary, #94a3b8);
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-stop-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.route-stop-meta {
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Conflict and correction warning banners */
.route-stop-conflict {
    margin-top: 6px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-rose, #ef4444);
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.route-stop-correction {
    margin-top: 6px;
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-amber, #f59e0b);
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.route-stop-card.completed {
    opacity: 0.65;
}
.route-stop-card.completed .route-stop-badge {
    background: var(--accent-emerald, #10b981);
}

/* UI Remediation styles */
#clientProfilePatientsList {
    max-height: 400px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.action-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    margin-bottom: var(--space-md);
}

.action-popup-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Google health banner styles */
.google-health-banner {
    position: fixed;
    inset: calc(12px + var(--safe-area-top, 0px)) auto auto 50%;
    transform: translateX(-50%);
    width: calc(100% - 48px);
    max-width: 800px;
    background: rgba(239, 68, 68, 0.08);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(239, 68, 68, 0.25);
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg, 12px);
    padding: var(--space-md, 12px) var(--space-lg, 20px);
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg, 20px);
    z-index: 9999;
    color: var(--text-primary);
    font-size: var(--font-size-sm, 14px);
    margin: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Override browser default popover styles to prevent stretching */
.google-health-banner:popover-open {
    display: flex;
    inset: calc(12px + var(--safe-area-top, 0px)) auto auto 50%;
    height: auto;
    max-height: fit-content;
}

.google-health-banner-content {
    display: flex;
    align-items: center;
    gap: var(--space-md, 12px);
    flex: 1;
}

.google-health-warn-icon {
    font-size: 1.4rem;
    color: var(--danger-500, #ef4444);
    flex-shrink: 0;
}

.google-health-banner-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md, 12px);
    flex-shrink: 0;
}

.google-health-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 6px);
    transition: background 0.2s;
}

.google-health-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

@media (max-width: 640px) {
    .google-health-banner {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md, 12px);
        inset: calc(12px + var(--safe-area-top, 0px)) auto auto 50%;
        width: calc(100% - 32px);
    }
    .google-health-banner-actions {
        justify-content: flex-end;
    }
}






/* ====== MOBILE-1671: nothing wider than the screen, nothing cut off or painted on top of other text (owner 2026-11-11) ======
   Measured by tests/journeys/mobile1671_overflow_browser.cjs at 360-1440 px for every page / tab / modal / Setup category,
   the portal and the public pages. Long names / emails / ids wrap instead of pushing a box past the screen edge. */
@media (max-width: 420px) {
    /* phone header: menu, logo, Quick Share, sync, (attached Superadmin), bell and sign-out fit at 360 px */
    .mobile-header { padding-left: calc(0.5rem + env(safe-area-inset-left, 0px)); padding-right: calc(0.5rem + env(safe-area-inset-right, 0px)); }
    .mobile-header > div { min-width: 0; }
    .mobile-header > div:first-child { gap: 4px !important; }
    .mobile-header > div:last-child { gap: 2px !important; flex-shrink: 0; }
}
/* Report / invoice tab rows wrap onto a second line instead of running past the screen edge */
.reports-tabs { flex-wrap: wrap; }
/* Clinic Inbox: a long client / patient name wraps inside its column (it was painted over the date beside it) */
.clinic-inbox-item-header > div, .clinic-inbox-item-header > div > div { min-width: 0; }
.clinic-inbox-item-title-block, .clinic-inbox-item-title-block * { overflow-wrap: anywhere; }
/* Text that carries information is never cut to "..." inside a page, card, list row or dialog: it wraps instead. */
:is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer, .doctor-notif-dropdown) [style*="text-overflow:ellipsis"],
:is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer, .doctor-notif-dropdown) [style*="text-overflow: ellipsis"] {
    white-space: normal !important; overflow-wrap: anywhere; text-overflow: clip !important; max-width: 100% !important;
}
@media (max-width: 600px) {
    /* a row of "label ... buttons" that does not fit puts its buttons on the next line (instead of running past the edge
       or crushing the label into a one-word column) */
    :is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer) [style*="justify-content:space-between"],
    :is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer) [style*="justify-content: space-between"] { flex-wrap: wrap; }
    :is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer) [style*="flex:1"][style*="min-width:0"],
    :is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer) [style*="flex: 1"][style*="min-width: 0"] { flex-basis: min(9rem, 100%) !important; }
    /* Reports > Practice Analytics: the chart cards stack (two side by side were 154 px wide with 278 px of bars) */
    #analyticsContainer > div[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
}
/* Setup > Staff & Team: a long name / email wraps and the buttons move under it on a narrow screen */
#activeStaffList > div > div:first-child, #pendingInvitesList > div > div:first-child { flex-wrap: wrap; gap: 8px; }
#activeStaffList > div > div:first-child > div:first-child, #pendingInvitesList > div > div:first-child > div:first-child { min-width: 0; }
#activeStaffList strong, #activeStaffList div, #pendingInvitesList strong, #pendingInvitesList div { overflow-wrap: anywhere; }
/* Clinic Inbox review drawer: the title wraps beside "Edit Details" instead of being cut to "Review Sub..." */
#reviewDrawer .review-drawer-header { flex-wrap: wrap; gap: 8px; }
#reviewDrawer .review-drawer-header h3 { white-space: normal; overflow: visible; text-overflow: clip; flex: 1 1 9rem; overflow-wrap: anywhere; }
/* Form fields inside a row may shrink with the row (a read-only link box kept its ~20-character minimum and pushed its
   Copy button past the card edge) */
:is(#page-content, #modalOverlay, .modal, #portal-view-container, .review-drawer) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { min-width: 0; max-width: 100%; }
#gbpConnectionCard > div:first-child { flex-wrap: wrap; }
/* review drawer values (a long email address) wrap inside the drawer instead of running out of it */
#reviewDrawer .review-field-value, #reviewDrawer .review-field-group { overflow-wrap: anywhere; min-width: 0; }
/* Note form: the Previous / Next buttons under each tab wrap instead of running past the form edge */
.tab-nav-bar-inner { flex-wrap: wrap; }
.tab-nav-bar-inner > * { min-width: 0; }
@media (max-width: 600px) {
    /* Setup > Notifications overview: tighter cells so EVENT / CHANNELS / TEMPLATE fit a phone */
    .comm-overview-dashboard { padding: 10px; }
    .comm-overview-table thead th, .comm-overview-table td { padding: 6px 5px; }
    .comm-overview-table thead th { letter-spacing: 0.02em; }
    .comm-overview-table td { overflow-wrap: anywhere; }
}

/* ====== MOBILE-1671 SAFE AREA (owner 2026-11-11: on an iPhone the Help pop-up's title sat under the clock) ======
   index.html asks for viewport-fit=cover + a black-translucent status bar, so the page draws under the status bar /
   Dynamic Island and the home indicator. Every fixed or full-screen layer keeps its controls clear of them;
   env(safe-area-inset-*) is the real inset on an iPhone and 0 everywhere else (nothing moves on a desktop or Android). */
.modal-overlay {
    padding: max(var(--space-lg), env(safe-area-inset-top, 0px)) max(var(--space-lg), env(safe-area-inset-right, 0px))
             max(var(--space-lg), env(safe-area-inset-bottom, 0px)) max(var(--space-lg), env(safe-area-inset-left, 0px));
}
.modal-overlay.slide-over { padding: 0; }
.modal-overlay.slide-over .modal-header { padding-top: calc(1rem + env(safe-area-inset-top, 0px)); }
.modal-overlay.slide-over .modal-body { padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); }
.action-popup-overlay { padding-top: env(safe-area-inset-top, 0px); }
.action-popup { padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px)); max-height: calc(90vh - env(safe-area-inset-top, 0px)); }
.lockout-container {
    padding: max(var(--space-xl), env(safe-area-inset-top, 0px)) max(var(--space-xl), env(safe-area-inset-right, 0px))
             max(var(--space-xl), env(safe-area-inset-bottom, 0px)) max(var(--space-xl), env(safe-area-inset-left, 0px));
}
.toast-container { bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px)); }
.floating-collapse-btn { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
.sticky-action-bar { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (max-width: 768px) {
    .modal-overlay {
        padding: max(var(--space-md), env(safe-area-inset-top, 0px)) max(var(--space-md), env(safe-area-inset-right, 0px))
                 max(var(--space-md), env(safe-area-inset-bottom, 0px)) max(var(--space-md), env(safe-area-inset-left, 0px));
    }
    .modal { max-height: calc(100vh - var(--space-md) * 2 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
    .toast-container { bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px)); }
    body.portal-active .toast-container, body.has-quick-access .toast-container { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 480px) {
    .note-form-actions { padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px)); }
}
/* Full-screen layers the app builds in code (inline position:fixed; inset:0): their content starts below the status bar
   and ends above the home indicator
   (a transparent border the size of the inset: 0 everywhere but an iPhone, and the layer's own padding is untouched.) */
[style*="position:fixed"][style*="inset:0"], [style*="position: fixed"][style*="inset: 0"] {
    border-top: env(safe-area-inset-top, 0px) solid transparent !important;
    border-bottom: env(safe-area-inset-bottom, 0px) solid transparent !important;
    box-sizing: border-box;
}
/* bars / notices the app builds in code along the bottom edge sit above the home indicator; full-screen ones built with
   top/left/right/bottom or width/height 100% keep their content below the status bar */
#billingSetupBanner { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important; }
#departedChangesBanner { bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important; }
#settingsReplacedNotice { bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; }
#recordsReplacedNotice { bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important; }
#permRefusalNotice { bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; }
#impersonation-pill { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }
#moduleRecoveryOverlay, #offlineRecoveryOverlay, #anatomyExpandOverlay,
[style*="position:fixed;top:0;left:0;width:100%;height:100%"] {
    border-top: env(safe-area-inset-top, 0px) solid transparent !important;
    border-bottom: env(safe-area-inset-bottom, 0px) solid transparent !important;
    box-sizing: border-box;
}
/* Clients > Client Map (full-screen page with padding:0 !important): its title bar starts below the status bar */
#clientMapHeader { padding-top: calc(0.75rem + env(safe-area-inset-top, 0px)) !important; }
/* Portal / note viewer "PDF Version: Client-Friendly | Professional" row: the two-button switch moves under its label
   instead of being cut off at the screen edge */
#pdfVersionToggle { max-width: 100%; flex-wrap: wrap; }
div:has(> #pdfVersionToggle) { flex-wrap: wrap; }
/* phone menu drawer and review drawer: their last item (Logout, Approve) scrolls clear of the home indicator */
.sidebar { padding-bottom: env(safe-area-inset-bottom, 0px); }
#reviewDrawer .review-drawer-body, #reviewDrawer .review-drawer-pane-left, #reviewDrawer .review-drawer-pane-right { scroll-padding-bottom: env(safe-area-inset-bottom, 0px); }
#reviewDrawer { padding-bottom: env(safe-area-inset-bottom, 0px); box-sizing: border-box; }

/* ==========================================================================================================
   REDESIGN-DASH (lane/1657-redesign-dashboard, owner 2026-10-27): ChiroApp design system "cx" + New look (beta)
   Namespaced: tokens are --cx-*, components are .cx-*, and the shell restyle applies ONLY under
   body.cx-new-look (set by js/modules/home-redesign.js when the Superadmin new-look switch is on for the practice).
   Nothing here changes the classic UI. --cx-ready tells the script this stylesheet generation is loaded
   (a stale cached stylesheet keeps the classic look instead of an unstyled new one).
   Contrast: every text/background pair below meets WCAG AA (4.5:1) in light and dark.
   ========================================================================================================== */
:root {
    --cx-ready: 2;   /* HOME-V2 (1669): this generation carries Home v2 */
    /* Brand (logo green) */
    --cx-brand: #355e3b;
    --cx-brand-strong: #2a4a2f;
    --cx-brand-ink: #1f3d26;
    --cx-brand-soft: #e7efe8;
    --cx-on-brand: #ffffff;
    /* Surfaces + text */
    --cx-bg: #f4f6f5;
    --cx-surface: #ffffff;
    --cx-surface-2: #f8faf9;
    --cx-border: #dfe5e1;
    --cx-text: #0f172a;
    --cx-text-2: #475569;
    --cx-link: #1d4ed8;
    --cx-focus: #2563eb;
    /* Tones (tile backgrounds / ink) */
    --cx-clinical-bg: #f3f0ff; --cx-clinical-icon: #e4dcff; --cx-clinical-ink: #5b21b6;
    --cx-scheduling-bg: #ecf8f2; --cx-scheduling-icon: #d1f0e0; --cx-scheduling-ink: #065f46;
    --cx-billing-bg: #fff7e8; --cx-billing-icon: #fde9bf; --cx-billing-ink: #8a3c0c;
    /* Badges */
    --cx-success-bg: #dcfce7; --cx-success-ink: #14532d;
    --cx-info-bg: #dbeafe; --cx-info-ink: #1e3a8a;
    --cx-neutral-bg: #e2e8f0; --cx-neutral-ink: #334155;
    --cx-danger-bg: #fee2e2; --cx-danger-ink: #991b1b;
    /* Spacing / radius / shadow / type */
    --cx-space-1: 4px; --cx-space-2: 8px; --cx-space-3: 12px; --cx-space-4: 16px; --cx-space-5: 24px; --cx-space-6: 32px;
    --cx-radius-sm: 8px; --cx-radius-md: 12px; --cx-radius-lg: 16px; --cx-radius-pill: 999px;
    --cx-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
    --cx-shadow-2: 0 8px 24px rgba(15, 23, 42, 0.12);
    --cx-font-xs: 0.75rem; --cx-font-sm: 0.875rem; --cx-font-base: 1rem; --cx-font-lg: 1.125rem;
    --cx-font-xl: 1.375rem; --cx-font-2xl: 1.75rem;
    --cx-touch: 44px;
}
[data-theme="dark"] {
    --cx-brand: #6fae79;
    --cx-brand-strong: #8cc595;
    --cx-brand-ink: #b9e0bf;
    --cx-brand-soft: #1b2a1e;
    --cx-on-brand: #0b1a0e;
    --cx-bg: #0b0f0d;
    --cx-surface: #141a17;
    --cx-surface-2: #1a221e;
    --cx-border: #2a3530;
    --cx-text: #f1f5f9;
    --cx-text-2: #cbd5e1;
    --cx-link: #93c5fd;
    --cx-focus: #93c5fd;
    --cx-clinical-bg: #221a3a; --cx-clinical-icon: #31265a; --cx-clinical-ink: #d8ccff;
    --cx-scheduling-bg: #10291f; --cx-scheduling-icon: #173a2c; --cx-scheduling-ink: #a7f3d0;
    --cx-billing-bg: #2c2110; --cx-billing-icon: #3d2e14; --cx-billing-ink: #fcd9a0;
    --cx-success-bg: #14361f; --cx-success-ink: #bbf7d0;
    --cx-info-bg: #172554; --cx-info-ink: #bfdbfe;
    --cx-neutral-bg: #253041; --cx-neutral-ink: #e2e8f0;
    --cx-danger-bg: #3f1515; --cx-danger-ink: #fecaca;
    --cx-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --cx-shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ---- Components (usable on any page; no effect until a .cx-* class is used) ---- */
.cx-card {
    background: var(--cx-surface);
    border: 1px solid var(--cx-border);
    border-radius: var(--cx-radius-lg);
    box-shadow: var(--cx-shadow-1);
    padding: var(--cx-space-4);
    color: var(--cx-text);
    min-width: 0;
}
.cx-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--cx-space-3);
    margin-bottom: var(--cx-space-3);
}
.cx-card-header h2 {
    margin: 0;
    font-size: var(--cx-font-lg);
    font-weight: 700;
    color: var(--cx-text);
    display: inline-flex;
    align-items: center;
    gap: var(--cx-space-2);
    letter-spacing: -0.01em;
}
.cx-card-header h2 > i { color: var(--cx-brand); font-size: 1.3rem; }
.cx-attention .cx-card-header h2 > i { color: #c2410c; }
[data-theme="dark"] .cx-attention .cx-card-header h2 > i { color: #fdba74; }
.cx-link {
    background: none; border: 0; padding: var(--cx-space-2); margin: calc(-1 * var(--cx-space-2));
    color: var(--cx-link); font: inherit; font-size: var(--cx-font-sm); font-weight: 600; cursor: pointer;
    min-height: var(--cx-touch);
}
.cx-link:hover { text-decoration: underline; }
.cx-empty {
    margin: 0; padding: var(--cx-space-4); text-align: center; color: var(--cx-text-2); font-size: var(--cx-font-sm);
    display: flex; align-items: center; justify-content: center; gap: var(--cx-space-2);
}
.cx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cx-chevron { color: var(--cx-text-2); font-size: 1.1rem; flex-shrink: 0; }

.cx-badge {
    display: inline-flex; align-items: center; flex-shrink: 0;
    font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
    padding: 2px 8px; border-radius: var(--cx-radius-sm); line-height: 1.5;
}
.cx-badge--success { background: var(--cx-success-bg); color: var(--cx-success-ink); }
.cx-badge--info { background: var(--cx-info-bg); color: var(--cx-info-ink); }
.cx-badge--neutral { background: var(--cx-neutral-bg); color: var(--cx-neutral-ink); }
.cx-badge--danger { background: var(--cx-danger-bg); color: var(--cx-danger-ink); }

.cx-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.5rem;
    padding: 0 var(--cx-space-2); border-radius: var(--cx-radius-pill);
    background: var(--cx-neutral-bg); color: var(--cx-neutral-ink); font-size: var(--cx-font-xs); font-weight: 700;
}
.cx-count--active { background: var(--cx-brand); color: var(--cx-on-brand); }

.cx-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--cx-touch); padding: 0 var(--cx-space-4);
    border-radius: var(--cx-radius-md); border: 1px solid transparent;
    font: inherit; font-size: var(--cx-font-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.cx-btn--sm { min-height: 36px; padding: 0 var(--cx-space-3); }
.cx-btn--primary { background: var(--cx-brand); color: var(--cx-on-brand); }
.cx-btn--primary:hover { background: var(--cx-brand-strong); }
.cx-btn--secondary { background: var(--cx-surface); color: var(--cx-brand-ink); border-color: var(--cx-brand); }
.cx-btn--ghost { background: var(--cx-brand-soft); color: var(--cx-brand-ink); }
.cx-btn:disabled { opacity: 0.6; cursor: default; }
.cx-icon-btn {
    width: var(--cx-touch); height: var(--cx-touch); display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--cx-radius-pill); border: 0; background: var(--cx-surface-2); color: var(--cx-text); cursor: pointer; font-size: 1.2rem;
}
.cx-avatar {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--cx-radius-md);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cx-brand-soft); color: var(--cx-brand-ink); font-size: 1.3rem;
}
.cx-avatar svg { width: 1.3rem; height: 1.3rem; }

/* List row */
.cx-rows { list-style: none; margin: 0; padding: 0; }
.cx-rows > li + li { border-top: 1px solid var(--cx-border); }
.cx-row {
    display: flex; align-items: center; gap: var(--cx-space-3); width: 100%; min-height: 52px;
    padding: var(--cx-space-2) var(--cx-space-1); background: none; border: 0; color: var(--cx-text);
    font: inherit; text-align: left; cursor: pointer;
}
.cx-row-icon { color: var(--cx-text-2); font-size: 1.3rem; display: inline-flex; }
.cx-row-label { flex: 1; font-size: var(--cx-font-base); font-weight: 500; min-width: 0; }
.cx-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cx-row-sub { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-row-note { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-row--unavailable { cursor: default; }
.cx-money { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Appointment row */
.cx-appt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--cx-space-2); }
.cx-appt {
    border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); background: var(--cx-surface);
    overflow: hidden;
}
.cx-appt-main {
    display: flex; align-items: center; gap: var(--cx-space-3); width: 100%;
    padding: var(--cx-space-3); background: none; border: 0; color: var(--cx-text); font: inherit; text-align: left; cursor: pointer;
}
.cx-appt-time { width: 3.6rem; flex-shrink: 0; font-weight: 700; font-size: var(--cx-font-base); line-height: 1.15; display: flex; flex-direction: column; }
.cx-appt-time small { font-size: var(--cx-font-xs); font-weight: 600; color: var(--cx-text-2); }
.cx-appt-time--none { font-size: var(--cx-font-xs); color: var(--cx-text-2); font-weight: 600; }
.cx-appt-rail { width: 3px; align-self: stretch; border-radius: 2px; background: var(--cx-brand); flex-shrink: 0; }
.cx-appt--completed .cx-appt-rail { background: var(--cx-neutral-ink); opacity: 0.4; }
.cx-appt--checked_in .cx-appt-rail { background: #2563eb; }
.cx-appt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cx-appt-title { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--cx-space-2); row-gap: 2px; font-weight: 700; font-size: var(--cx-font-base); min-width: 0; }
/* Names wrap instead of being cut to "Oli..." on a phone; the status badge moves under the name when needed. */
.cx-appt-title > .cx-truncate { white-space: normal; overflow-wrap: anywhere; }
.cx-appt-sub { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-appt-sub.cx-truncate { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cx-appt-actions {
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--cx-space-2);
    padding: 0 var(--cx-space-3) var(--cx-space-3);
}

/* Needs-attention tile */
.cx-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--cx-space-2); }
.cx-tile {
    display: flex; flex-direction: column; border-radius: var(--cx-radius-md); min-width: 0;
    border: 1px solid transparent; overflow: hidden;
}
.cx-tile--clinical { background: var(--cx-clinical-bg); color: var(--cx-clinical-ink); --cx-tone-icon: var(--cx-clinical-icon); }
.cx-tile--scheduling { background: var(--cx-scheduling-bg); color: var(--cx-scheduling-ink); --cx-tone-icon: var(--cx-scheduling-icon); }
.cx-tile--billing { background: var(--cx-billing-bg); color: var(--cx-billing-ink); --cx-tone-icon: var(--cx-billing-icon); }
.cx-tile-main, .cx-tile--unavailable {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex: 1;
    padding: var(--cx-space-3); background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.cx-tile--unavailable { cursor: default; }
.cx-tile-icon {
    width: 36px; height: 36px; border-radius: var(--cx-radius-sm); background: var(--cx-tone-icon);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: var(--cx-space-2);
}
.cx-tile-label { font-weight: 700; font-size: var(--cx-font-sm); color: var(--cx-text); }
.cx-tile-count { font-size: var(--cx-font-2xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--cx-text); }
.cx-tile-caption { font-size: var(--cx-font-xs); line-height: 1.35; font-weight: 600; }
.cx-tile-main .cx-chevron { position: absolute; right: var(--cx-space-2); bottom: var(--cx-space-2); color: inherit; }
.cx-tile-older {
    background: none; border: 0; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
    color: inherit; font: inherit; font-size: var(--cx-font-xs); font-weight: 700; text-decoration: underline;
    padding: var(--cx-space-2) var(--cx-space-3); min-height: 36px; text-align: left; cursor: pointer;
}
.cx-tile-older:disabled { text-decoration: none; cursor: default; opacity: 0.85; }

/* Tabs */
.cx-tabs { display: flex; gap: var(--cx-space-2); padding: 0 var(--cx-space-4) var(--cx-space-3); }
.cx-tab {
    flex: 1; min-height: 40px; border-radius: var(--cx-radius-pill); border: 1px solid var(--cx-border);
    background: var(--cx-surface); color: var(--cx-text); font: inherit; font-size: var(--cx-font-sm); font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--cx-space-2);
}
.cx-tab[aria-selected="true"] { background: var(--cx-brand); border-color: var(--cx-brand); color: var(--cx-on-brand); }
.cx-tab[aria-selected="true"] .cx-count { background: var(--cx-on-brand); color: var(--cx-brand-ink); }

/* Sheet (drill-down list): bottom sheet on phones, centred dialog from tablet up -- same component, same actions */
.cx-sheet-overlay {
    position: fixed; inset: 0; z-index: 100004; display: none;
    background: rgba(15, 23, 42, 0.45);
}
.cx-sheet-overlay.cx-open { display: block; }
.cx-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; display: flex; flex-direction: column;
    background: var(--cx-surface); color: var(--cx-text); border-radius: var(--cx-radius-lg) var(--cx-radius-lg) 0 0;
    box-shadow: var(--cx-shadow-2); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.cx-sheet-header { display: flex; align-items: center; justify-content: space-between; gap: var(--cx-space-3); padding: var(--cx-space-4); }
.cx-sheet-header h2 { margin: 0; font-size: var(--cx-font-lg); display: inline-flex; align-items: center; gap: var(--cx-space-2); }
.cx-sheet-total { margin: 0; padding: 0 var(--cx-space-4) var(--cx-space-2); color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-sheet-total strong { color: var(--cx-text); }
.cx-sheet-body { overflow-y: auto; padding: 0 var(--cx-space-4) var(--cx-space-4); -webkit-overflow-scrolling: touch; }
.cx-sheet-row { display: flex; align-items: center; gap: var(--cx-space-2); }
.cx-sheet-row > .cx-row { flex: 1; min-width: 0; }
@media (min-width: 768px) {
    .cx-sheet {
        left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%);
        width: min(600px, 92vw); max-height: 80vh; border-radius: var(--cx-radius-lg);
    }
}

.cx-card :focus-visible, .cx-sheet :focus-visible, .cx-home-top :focus-visible {
    outline: 2px solid var(--cx-focus); outline-offset: 2px; border-radius: var(--cx-radius-sm);
}

/* ---- New look: the home screen ---- */
#cxHomeTop, #cxHomeMain { display: none; }
#page-dashboard.cx-home-active #cxHomeTop { display: block; }
#page-dashboard.cx-home-active #cxHomeMain { display: grid; }
/* HOME-V2 (1669): the new home shows EVERY classic card (see HomeRedesign.CLASSIC_PARITY); classic elements that carry
   their own controls are moved into their v2 place, so everything else of the classic page is hidden while it is on.
   The classic dashboard keeps rendering underneath, so switching back is instant. */
/* INT-1677: the one-time Help Center notice (js/help-center.js, #helpCenterNotice) is shown in the new look too. */
#page-dashboard.cx-home-active > :not(#cxHomeTop):not(#cxHomeMain):not(#helpCenterNotice) { display: none !important; }

.cx-home-top { padding: var(--cx-space-2) 0 var(--cx-space-4); }
.cx-greeting { margin: 0; font-size: var(--cx-font-2xl); font-weight: 800; letter-spacing: -0.02em; color: var(--primary-text, var(--cx-brand-ink)); line-height: 1.2; }
.cx-date { margin: var(--cx-space-1) 0 0; color: var(--cx-text-2); font-size: var(--cx-font-base); font-weight: 500; }
.cx-home { gap: var(--cx-space-4); margin-bottom: var(--cx-space-4); align-items: start; grid-template-columns: minmax(0, 1fr); }
.cx-side { display: grid; gap: var(--cx-space-4); min-width: 0; }
@media (min-width: 1025px) {
    .cx-home { grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); }
    .cx-greeting { font-size: 2rem; }
}
/* Phones: the greeting stays within two lines and the Today header (title + count + Calendar) on one line. */
@media (max-width: 480px) {
    .cx-greeting { font-size: 1.5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
    .cx-today .cx-card-header { gap: var(--cx-space-2); flex-wrap: nowrap; }
    .cx-today .cx-card-header h2 { font-size: var(--cx-font-base); gap: 6px; white-space: nowrap; min-width: 0; }
    .cx-today .cx-card-header h2 > span { overflow: hidden; text-overflow: ellipsis; }
    .cx-today .cx-card-header h2 > i { display: none; }   /* the title itself says what it is; room for the full title */
    .cx-today .cx-card-header .cx-count { min-width: 1.5rem; padding: 0 6px; }
    .cx-today .cx-link { white-space: nowrap; flex-shrink: 0; }
    .cx-hide-narrow { display: none; }
}
@media (max-width: 400px) {
    .cx-tile-main, .cx-tile--unavailable { padding: var(--cx-space-2); }
    .cx-tile-count { font-size: var(--cx-font-xl); }
    .cx-appt-time { width: 3.1rem; }
}

/* ---- New look: shell ----
   Owner 2026-11-04: the MENUS (desktop sidebar, phone hamburger menu, header, bottom nav) look and behave exactly like
   classic with the new look on; only page content (Home, Inbox page) is restyled. No menu rule lives here. */
body.cx-new-look { background: var(--cx-bg); }
body.cx-new-look .main-content { background: var(--cx-bg); }

/* ---- REDESIGN-DASH r2 (owner answers 2026-10-28) ----
   Accent = the practice's own Primary Color (owner Q3). Owner 2026-10-28: when the practice never chose a colour (unset,
   or still one of the old indigo defaults) the new look shows ChiroApp green instead (display only; the
   stored setting is not changed). Soft / ink shades are mixed from it. */
/* Computed on body (not :root) so the new look's green fallback (body-level --primary-color, js/modules/home-redesign.js
   applyAccent) reaches these tokens too. BRAND-1677 (owner 2026-11-18; NOT FOR MERGE UNTIL OWNER APPROVES): on every
   body, not only body.cx-new-look -- a --cx-* token used outside the new look follows the practice colour too (it was the
   literal :root green); the text on it follows --primary-contrast (white, or dark ink on a very light practice colour). */
body {
    --cx-on-brand: var(--primary-contrast, #ffffff);
    --cx-brand: var(--primary-color, #355e3b);
    --cx-brand-strong: var(--primary-color-dark, #2a4a2f);
    --cx-brand-ink: color-mix(in srgb, var(--primary-color, #355e3b) 72%, #000);
    --cx-brand-soft: color-mix(in srgb, var(--primary-color, #355e3b) 11%, #fff);
}
[data-theme="dark"] body.cx-new-look {
    --cx-brand: color-mix(in srgb, var(--primary-color, #355e3b) 62%, #fff);
    --cx-brand-strong: color-mix(in srgb, var(--primary-color, #355e3b) 45%, #fff);
    --cx-brand-ink: color-mix(in srgb, var(--primary-color, #355e3b) 30%, #fff);
    --cx-brand-soft: color-mix(in srgb, var(--primary-color, #355e3b) 22%, #141a17);
}

/* Appointment card: 1-2 main buttons always shown; tapping the card expands it to the rest. */
.cx-appt-caret { transition: transform 180ms ease; }
.cx-appt[data-expanded="true"] .cx-appt-caret { transform: rotate(180deg); }
.cx-appt[data-expanded="true"] { border-color: color-mix(in srgb, var(--cx-brand) 45%, var(--cx-border)); box-shadow: var(--cx-shadow-1); }
.cx-appt-actions { justify-content: flex-start; padding-left: calc(3.6rem + 3px + var(--cx-space-3) * 3 + 40px - var(--cx-space-3)); }
.cx-appt-more {
    display: grid; grid-template-rows: 0fr; visibility: hidden;
    transition: grid-template-rows 200ms cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 200ms;
}
.cx-appt[data-expanded="true"] .cx-appt-more { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows 200ms cubic-bezier(0.2, 0, 0, 1), visibility 0s; }
.cx-appt-more-inner {
    min-height: 0; overflow: hidden; display: flex; flex-wrap: wrap; gap: var(--cx-space-2);
    padding: 0 var(--cx-space-3); border-top: 1px solid transparent;
}
.cx-appt[data-expanded="true"] .cx-appt-more-inner { padding: var(--cx-space-3); border-top-color: var(--cx-border); background: var(--cx-surface-2); }
.cx-act { min-height: var(--cx-touch); text-decoration: none; }
.cx-btn--sm.cx-act { padding: 0 var(--cx-space-3); }
.cx-empty-inline { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
@media (max-width: 600px) {
    .cx-appt-actions { padding-left: var(--cx-space-3); }
    .cx-appt-actions .cx-act { flex: 1 1 0; justify-content: center; }
    .cx-appt-more-inner .cx-act { flex: 1 1 calc(50% - var(--cx-space-2)); justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
    .cx-appt-more, .cx-appt[data-expanded="true"] .cx-appt-more, .cx-appt-caret { transition: none; }
}

/* Clinic Inbox card (home): one card, a count per type; each opens the Inbox page on that tab. */
.cx-inbox-cells { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--cx-space-2); }
.cx-inbox-cell {
    width: 100%; min-height: 76px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: var(--cx-space-3); border-radius: var(--cx-radius-md); border: 1px solid var(--cx-border);
    background: var(--cx-surface-2); color: var(--cx-text); font: inherit; text-align: left; cursor: pointer;
}
.cx-inbox-cell > i { font-size: 1.25rem; color: var(--cx-brand); }
.cx-inbox-label { font-size: var(--cx-font-sm); font-weight: 600; line-height: 1.2; }
.cx-inbox-cell:disabled { cursor: default; opacity: 0.8; }
@media (max-width: 400px) { .cx-inbox-cell { padding: var(--cx-space-2); } .cx-inbox-label { font-size: var(--cx-font-xs); } }

/* (1663: no menu item / badge for the Inbox page: the menus are exactly classic; the home's Inbox card opens it.) */

/* Inbox page: the classic inbox widget, restyled (same markup, same buttons, same approval). */
body.cx-new-look #page-inbox .clinic-inbox-widget {
    background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-lg);
    box-shadow: var(--cx-shadow-1); padding: var(--cx-space-4); color: var(--cx-text);
}
body.cx-new-look #page-inbox .clinic-inbox-title { display: none; }
body.cx-new-look #page-inbox .clinic-inbox-tabs { display: flex; gap: var(--cx-space-2); flex-wrap: wrap; border: 0; margin-bottom: var(--cx-space-3); }
body.cx-new-look #page-inbox .clinic-inbox-tab {
    flex: 1 1 0; min-height: 44px; border-radius: 999px; border: 1px solid var(--cx-border); background: var(--cx-surface);
    color: var(--cx-text); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
body.cx-new-look #page-inbox .clinic-inbox-tab.active { background: var(--cx-brand); border-color: var(--cx-brand); color: var(--cx-on-brand); }
body.cx-new-look #page-inbox .clinic-inbox-tab.active .clinic-inbox-badge { background: var(--cx-on-brand); color: var(--cx-brand-ink); }
body.cx-new-look #page-inbox .clinic-inbox-item { border-radius: var(--cx-radius-md); border-color: var(--cx-border); }
body.cx-new-look #page-inbox .page-subtitle { color: var(--cx-text-2); margin: 4px 0 0; }

/* Setup: "Home screen buttons" */
.cx-layout-heading { margin: var(--cx-space-4) 0 var(--cx-space-2); font-size: var(--cx-font-base); }
.cx-layout-heading small { font-weight: 500; color: var(--text-secondary, #64748b); }
.cx-layout-table { width: 100%; border-collapse: collapse; font-size: var(--cx-font-sm); }
.cx-layout-table th, .cx-layout-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-color, #e2e8f0); text-align: left; vertical-align: middle; }
.cx-layout-table thead th { font-size: var(--cx-font-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary, #64748b); }
.cx-layout-select { min-height: 40px; width: 100%; max-width: 15rem; }
.cx-layout-preview { margin-top: var(--cx-space-3); display: grid; gap: var(--cx-space-2); }
.cx-layout-preview p { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cx-layout-error { color: #b91c1c; font-weight: 600; margin: var(--cx-space-2) 0 0; }
@media (max-width: 600px) {
    .cx-layout-table thead { display: none; }
    .cx-layout-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--border-color, #e2e8f0); }
    .cx-layout-table th[scope="row"] { grid-column: 1 / -1; border: 0; padding: 0; }
    .cx-layout-table td { border: 0; padding: 0; }
    .cx-layout-table td::before { display: block; font-size: 0.7rem; color: var(--text-secondary, #64748b); }
    .cx-layout-table td:nth-of-type(1)::before { content: 'Clinic visits'; }
    .cx-layout-table td:nth-of-type(2)::before { content: 'House-call visits'; }
    .cx-layout-select { max-width: none; }
}

/* ---- HOME-V2 (Build 1669, owner 2026-11-09) ----
   Today's Appointments first, then the classic card order; one calm attention strip; numbers-first tiles; every list
   opens in place. No pills / chips (counts are plain numbers, status is plain coloured text), no emoji. Poppins
   headlines (falls back to Inter), Phosphor line icons. Same layout and behaviour on phone, tablet and desktop: one
   column up to 1024px, two columns above. */
.cx-new-look { --cx-head: 'Poppins', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; }
.cx-new-look .cx-greeting, .cx-v2 h2, .cx-v2 .cx-tile-count, .cx-v2 .cx-tile-money, .cx-v2 .cx-num, .cx-v2 .cx-inbox-cell .cx-count,
.cx-v2 .cx-appt-time, .cx-v2 .cx-strip-text strong, .cx-new-look #page-inbox h1 { font-family: var(--cx-head); }
.cx-new-look .cx-greeting { font-weight: 700; letter-spacing: -0.025em; color: var(--primary-text, var(--cx-brand-ink)); }   /* BRAND-1677 */
#page-dashboard.cx-home-active #cxHomeMain { display: block; }
.cx-v2 { display: flex; flex-direction: column; gap: var(--cx-space-4); }
.cx-v2 h2 { font-weight: 600; }
.cx-cols { display: flex; flex-direction: column; gap: var(--cx-space-4); }
.cx-col { display: contents; }
.cx-cols > .cx-col > div:empty { display: none; }
.cx-o1 { order: 1; } .cx-o2 { order: 2; } .cx-o3 { order: 3; } .cx-o4 { order: 4; } .cx-o5 { order: 5; } .cx-o6 { order: 6; }
@media (min-width: 1025px) {
    .cx-cols { flex-direction: row; align-items: flex-start; }
    .cx-col { display: flex; flex-direction: column; gap: var(--cx-space-4); min-width: 0; }
    .cx-col--main { flex: 1.45 1 0; }
    .cx-col--side { flex: 1 1 0; min-width: 340px; }
}
.cx-v2 .cx-card { padding: var(--cx-space-4) var(--cx-space-4) var(--cx-space-4); border-radius: 18px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.05); }
.cx-v2 .cx-card-header h2 { font-size: 1.1rem; }
@keyframes cx-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cx-panel, .cx-strip-body, .cx-inbox-detail, .cx-other-body, .cx-briefing-body { animation: cx-reveal 180ms ease-out; }
@media (prefers-reduced-motion: reduce) { .cx-panel, .cx-strip-body, .cx-inbox-detail, .cx-other-body, .cx-briefing-body { animation: none; } }

/* numbers and status: plain, never pills */
.cx-v2 .cx-count, .cx-v2 .cx-num { background: none; min-width: 0; height: auto; padding: 0; border-radius: 0; color: var(--cx-text-2); font-size: 0.95em; font-weight: 600; font-variant-numeric: tabular-nums; }
.cx-v2 .cx-count--active { background: none; color: var(--cx-brand-ink); font-weight: 700; }
.cx-status { font-size: var(--cx-font-xs); font-weight: 700; letter-spacing: 0.02em; color: var(--cx-success-ink); white-space: nowrap; }
.cx-status--completed, .cx-status--seen, .cx-status--blocked { color: var(--cx-text-2); }
.cx-status--checked_in { color: var(--cx-info-ink); }
.cx-status--no_show, .cx-status--unpaid { color: var(--cx-danger-ink); }
.cx-status--partial { color: var(--cx-billing-ink); }
.cx-eyebrow { margin: 0; font-size: var(--cx-font-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--cx-text-2); display: flex; align-items: center; gap: 6px; }
.cx-eyebrow--brand { color: var(--cx-brand-ink); }
.cx-hint { color: var(--cx-text-2); font-size: var(--cx-font-sm); font-weight: 500; }
.cx-link--inline { margin: var(--cx-space-1) 0 0; padding: var(--cx-space-2) 0; display: inline-flex; align-items: center; gap: 4px; min-height: 0; }
.cx-btn--block { width: 100%; }
.cx-btn--danger { background: var(--cx-surface); color: var(--cx-danger-ink); border-color: color-mix(in srgb, var(--cx-danger-ink) 45%, transparent); }
.cx-icon-btn--sm { width: 36px; height: 36px; font-size: 1rem; border-radius: var(--cx-radius-sm); }
.cx-tone--chargeback, .cx-tone--failed { color: var(--cx-danger-ink); }
.cx-tone--overdue { color: var(--cx-billing-ink); }

/* attention strip (calm: soft amber, one line until opened) */
.cx-strip { border: 1px solid color-mix(in srgb, #d97706 30%, transparent); background: var(--cx-billing-bg); border-radius: 18px; color: var(--cx-text); overflow: hidden; }
.cx-strip-head { width: 100%; display: flex; align-items: center; gap: var(--cx-space-3); padding: var(--cx-space-3) var(--cx-space-4); background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.cx-strip-icon { width: 34px; height: 34px; border-radius: 50%; background: #c2410c; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
.cx-strip-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cx-strip-text strong { font-size: 1rem; font-weight: 600; color: var(--cx-billing-ink); }
.cx-strip-text small { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-strip-more { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: var(--cx-font-sm); color: var(--cx-billing-ink); flex-shrink: 0; }
.cx-strip[data-open="true"] .cx-strip-more i { transform: rotate(180deg); }
.cx-strip-body { padding: 0 var(--cx-space-4) var(--cx-space-3); display: grid; gap: var(--cx-space-2); }
.cx-strip-item { background: var(--cx-surface); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); padding: var(--cx-space-3); min-width: 0; }
.cx-strip-item-head { display: flex; gap: var(--cx-space-3); align-items: flex-start; margin-bottom: var(--cx-space-2); }
.cx-strip-item-head > i { font-size: 1.3rem; color: #c2410c; margin-top: 1px; }
.cx-strip-item-head span { display: flex; flex-direction: column; min-width: 0; }
.cx-strip-item-head small { color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-alert-kind { font-size: var(--cx-font-xs); font-weight: 700; margin-left: 6px; }

/* classic content shown in its v2 place: the classic frame is dropped, its controls stay */
.cx-slot { min-width: 0; }
.cx-slot > .card, .cx-slot > div > .card, .cx-slot .card.glass { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; border-radius: 0 !important; backdrop-filter: none !important; }
.cx-strip-item .cx-slot strong:first-child { display: none; }
.cx-strip-item .cx-slot .form-hint { margin-top: 0 !important; }
.cx-slot select, .cx-slot .form-input { max-width: 100% !important; }
.cx-slot .btn { border-radius: var(--cx-radius-md); }
.cx-slot .btn-primary { background: var(--cx-brand) !important; border-color: var(--cx-brand) !important; color: var(--cx-on-brand) !important; }
.cx-slot h3 { font-family: var(--cx-head); }
/* the briefing's own heading block repeats the card title: hidden; the narrative + the four assistants stay */
.cx-briefing-body .cx-slot > .card > div:first-child { display: none !important; }
.cx-briefing-body .cx-slot > .card > div { background: none !important; border-color: var(--cx-border) !important; }
.cx-briefing-body .cx-slot [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
.cx-briefing-body .cx-slot h4 { font-family: var(--cx-head); }

/* Today */
.cx-today-sub { display: flex; align-items: center; justify-content: space-between; gap: var(--cx-space-3); margin: calc(-1 * var(--cx-space-1)) 0 var(--cx-space-3); color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-switch { display: inline-flex; align-items: center; gap: var(--cx-space-2); cursor: pointer; font-weight: 600; color: var(--cx-text-2); min-height: var(--cx-touch); position: relative; }
.cx-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cx-switch-track { width: 38px; height: 22px; border-radius: 11px; background: var(--cx-neutral-bg); position: relative; transition: background 0.15s; flex-shrink: 0; }
.cx-switch-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.cx-switch input:checked + .cx-switch-track { background: var(--cx-brand); }
.cx-switch input:checked + .cx-switch-track::after { transform: translateX(16px); }
.cx-switch input:focus-visible + .cx-switch-track { outline: 2px solid var(--cx-focus); outline-offset: 2px; }
.cx-v2 .cx-appt { border-radius: 14px; }
.cx-v2 .cx-appt-time { width: 4.6rem; font-size: 1.05rem; font-weight: 600; flex-direction: column; align-items: flex-start; gap: 2px; }
.cx-v2 .cx-appt-clock { white-space: nowrap; }
.cx-v2 .cx-appt-clock small { font-size: 0.72rem; margin-left: 2px; }
.cx-v2 .cx-appt-dur { font-family: Inter, system-ui, sans-serif; font-size: var(--cx-font-xs); font-weight: 500; color: var(--cx-text-2); }
.cx-v2 .cx-appt-time--none { font-family: Inter, system-ui, sans-serif; }
.cx-v2 .cx-appt-sub.cx-truncate { -webkit-line-clamp: 3; }
.cx-strip-body[hidden], .cx-briefing-body[hidden] { display: none; }
.cx-v2 .cx-appt-actions { padding-left: calc(4.6rem + 3px + var(--cx-space-3) * 3 + 40px - var(--cx-space-3)); }
.cx-v2 .cx-appt-title { font-weight: 600; }
.cx-appt--scheduled .cx-appt-rail, .cx-appt-rail--scheduled { background: var(--cx-brand); }
.cx-appt-rail--completed { background: var(--cx-neutral-ink); opacity: 0.4; }
.cx-appt-rail--block, .cx-appt-rail--blocked { background: repeating-linear-gradient(180deg, #d97706 0 4px, transparent 4px 7px); }
.cx-appt--completed .cx-appt-title > .cx-truncate { color: var(--cx-text-2); }
.cx-block, .cx-mini { border: 1px dashed var(--cx-border); border-radius: 14px; background: var(--cx-surface); }
.cx-mini { border-style: solid; }
.cx-block-main, .cx-mini-main { display: flex; align-items: center; gap: var(--cx-space-3); width: 100%; padding: var(--cx-space-3); background: none; border: 0; color: var(--cx-text); font: inherit; text-align: left; cursor: pointer; }
.cx-avatar--block { background: #fff3e0; color: #9a3412; }
[data-theme="dark"] .cx-avatar--block { background: #3d2e14; color: #fcd9a0; }
.cx-tomorrow { margin-top: var(--cx-space-4); display: grid; gap: var(--cx-space-2); }
.cx-today-empty { display: grid; gap: var(--cx-space-3); }
.cx-today-empty .cx-empty { padding: var(--cx-space-2) 0; justify-content: flex-start; }

/* Route */
.cx-progress-head { display: flex; justify-content: space-between; font-size: var(--cx-font-sm); color: var(--cx-text-2); margin-bottom: 6px; }
.cx-progress-head strong { color: var(--cx-text); }
.cx-progress { height: 8px; border-radius: 4px; background: var(--cx-neutral-bg); overflow: hidden; margin-bottom: var(--cx-space-3); }
.cx-progress > span { display: block; height: 100%; background: var(--cx-brand); border-radius: 4px; }
.cx-route-next { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: var(--cx-space-3); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); background: var(--cx-surface-2); margin-bottom: var(--cx-space-3); }
.cx-route-name { font-family: var(--cx-head); font-weight: 600; font-size: 1rem; }
.cx-route-where { color: var(--cx-text-2); font-size: var(--cx-font-sm); overflow-wrap: anywhere; }
.cx-route-next .cx-btn { margin-top: var(--cx-space-2); }
.cx-route-done { display: flex; align-items: center; gap: var(--cx-space-2); color: var(--cx-success-ink); font-weight: 600; margin: 0 0 var(--cx-space-3); }

/* tiles: numbers first; the open tile is marked; its list opens under the tiles */
.cx-v2 .cx-tiles[data-tiles="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cx-v2 .cx-tiles[data-tiles="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cx-v2 .cx-tiles[data-tiles="1"] { grid-template-columns: minmax(0, 1fr); }
.cx-v2 .cx-tile { border-radius: 14px; border: 1px solid color-mix(in srgb, currentColor 14%, transparent); }
.cx-v2 .cx-tile[data-open="true"] { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }
.cx-v2 .cx-tile-count { font-size: 2rem; font-weight: 600; line-height: 1.05; }
.cx-tile-money { font-size: 1.05rem; font-weight: 600; color: var(--cx-text); font-variant-numeric: tabular-nums; }
.cx-v2 .cx-tile-caption { color: inherit; opacity: 0.9; padding-right: 1.2rem; }
.cx-v2 .cx-tile-main .cx-chevron { transition: transform 0.15s; }
.cx-v2 .cx-tile[data-open="true"] .cx-chevron { transform: rotate(180deg); }
.cx-panel { margin-top: var(--cx-space-3); border-top: 1px solid var(--cx-border); padding-top: var(--cx-space-3); display: grid; gap: var(--cx-space-3); }
.cx-panel-head { display: flex; align-items: center; justify-content: space-between; }
.cx-panel-head strong { font-family: var(--cx-head); font-weight: 600; font-size: 1rem; }
.cx-panel-total { margin: 0; color: var(--cx-text-2); font-size: var(--cx-font-sm); }
.cx-panel-total strong { color: var(--cx-text); font-size: 1rem; }
.cx-group { display: grid; gap: 2px; }
.cx-v2 .cx-sheet-row { display: flex; align-items: center; gap: var(--cx-space-2); }
.cx-v2 .cx-sheet-row > .cx-row { flex: 1; min-width: 0; }
.cx-v2 .cx-money small { font-weight: 500; color: var(--cx-text-2); }

/* Clinic Inbox: count cells act as tabs (underlined when selected) */
.cx-v2 .cx-inbox-cell { min-height: 84px; background: var(--cx-surface-2); border-radius: 14px; gap: 2px; }
.cx-v2 .cx-inbox-cell .cx-count { font-size: 1.6rem; font-weight: 600; color: var(--cx-text); line-height: 1.1; }
.cx-v2 .cx-inbox-cell[aria-pressed="true"] { border-color: var(--cx-brand); box-shadow: inset 0 -3px 0 var(--cx-brand); background: var(--cx-brand-soft); }
.cx-v2 .cx-inbox-label { color: var(--cx-text-2); font-weight: 600; }
.cx-inbox-list { margin-top: var(--cx-space-3); }
.cx-inbox .cx-empty { justify-content: flex-start; padding: var(--cx-space-3) 0 0; }
.cx-inbox-item[data-expanded="true"] { background: var(--cx-surface-2); border-radius: var(--cx-radius-md); }
.cx-inbox-caret { transition: transform 0.15s; }
.cx-inbox-item[data-expanded="true"] .cx-inbox-caret { transform: rotate(180deg); }
.cx-inbox-detail { padding: 0 var(--cx-space-3) var(--cx-space-3) calc(40px + var(--cx-space-3) + var(--cx-space-1)); }
.cx-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px var(--cx-space-3); margin: 0 0 var(--cx-space-3); font-size: var(--cx-font-sm); }
.cx-dl dt { color: var(--cx-text-2); font-weight: 600; }
.cx-dl dd { margin: 0; overflow-wrap: anywhere; }
.cx-dl--inline { margin: var(--cx-space-2) 0; }
.cx-inbox-actions, .cx-spam-actions { display: flex; flex-wrap: wrap; gap: var(--cx-space-2); }
.cx-spam { margin-top: var(--cx-space-3); border-top: 1px solid var(--cx-border); }
.cx-spam-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--cx-space-2); padding: var(--cx-space-2) 0; }
@media (max-width: 480px) { .cx-inbox-detail { padding-left: var(--cx-space-3); } }

/* Briefing (collapsible) */
.cx-card-toggle { width: 100%; display: flex; align-items: center; gap: var(--cx-space-3); background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; min-height: var(--cx-touch); }
.cx-card-toggle h2 { flex: 1; margin: 0; font-size: 1.1rem; display: inline-flex; align-items: center; gap: var(--cx-space-2); }
.cx-card-toggle h2 > i { color: var(--cx-brand); font-size: 1.3rem; }
.cx-briefing[data-open="true"] .cx-card-toggle .cx-chevron { transform: rotate(180deg); }
.cx-briefing-body { margin-top: var(--cx-space-3); }

/* Other items */
.cx-other li[data-expanded="true"] > .cx-row .cx-chevron { transform: rotate(180deg); }
.cx-other-body { padding: 0 0 var(--cx-space-3) var(--cx-space-1); }
.cx-transfer, .cx-trip { padding: var(--cx-space-3) 0; display: grid; gap: var(--cx-space-1); }
.cx-transfer-head { display: flex; gap: var(--cx-space-3); align-items: center; }
.cx-trip-head { display: flex; justify-content: space-between; gap: var(--cx-space-3); }
.cx-age { font-weight: 700; margin-left: 4px; color: var(--cx-text-2); }
.cx-age--warn { color: var(--cx-billing-ink); }
.cx-age--critical { color: var(--cx-danger-ink); }

/* Welcome (classic empty state) */
.cx-welcome { text-align: center; display: grid; justify-items: center; gap: var(--cx-space-2); padding: var(--cx-space-6) var(--cx-space-4) !important; }
.cx-welcome-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--cx-brand-soft); color: var(--cx-brand); display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem; }
.cx-welcome h2 { margin: 0; font-size: 1.3rem; }
.cx-welcome p { margin: 0; color: var(--cx-text-2); max-width: 36rem; }
.cx-welcome-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--cx-space-2); margin-top: var(--cx-space-2); }

/* In-app Back (new-look sub-pages; the installed app has no browser Back) */
.cx-back { display: none; }
body.cx-new-look .cx-back {
    display: inline-flex; align-items: center; gap: 6px; min-height: var(--cx-touch); padding: 0 var(--cx-space-3) 0 var(--cx-space-2);
    margin: 0 0 var(--cx-space-2); border: 1px solid var(--cx-border); border-radius: var(--cx-radius-md); background: var(--cx-surface);
    color: var(--cx-brand-ink); font: inherit; font-weight: 600; cursor: pointer;
}
body.cx-new-look .cx-back i { font-size: 1.15rem; }
/* Inbox page tabs: underline, not pills (owner: no pill / chip styling) */
body.cx-new-look #page-inbox .clinic-inbox-tab { border-radius: 0; border: 0; border-bottom: 3px solid transparent; background: none; }
body.cx-new-look #page-inbox .clinic-inbox-tab.active { background: none; color: var(--cx-brand-ink); border-bottom-color: var(--cx-brand); }
body.cx-new-look #page-inbox .clinic-inbox-tab.active .clinic-inbox-badge, body.cx-new-look #page-inbox .clinic-inbox-badge { background: none; color: inherit; padding: 0; }
body.cx-new-look #page-inbox .clinic-inbox-tabs { border-bottom: 1px solid var(--cx-border); gap: 0; }
/* the classic inbox items' tag badges read as plain coloured words on the new look (no pills) */
body.cx-new-look #page-inbox .clinic-inbox-item .badge { background: none !important; border: 0 !important; padding: 0 !important; border-radius: 0 !important; }
body.cx-new-look #page-inbox .clinic-inbox-item .badge > span[style*="border-radius: 50%"] { display: none !important; }

@media (max-width: 480px) {
    .cx-v2 .cx-card { padding: var(--cx-space-3); }
    .cx-v2 .cx-appt-time { width: 4.1rem; font-size: 0.98rem; }
    .cx-v2 .cx-appt-actions { padding-left: var(--cx-space-3); }
    .cx-v2 .cx-tile-count { font-size: 1.6rem; }
    .cx-v2 .cx-tile-money { font-size: 0.92rem; }
    .cx-v2 .cx-inbox-cell .cx-count { font-size: 1.35rem; }
    .cx-strip-head { padding: var(--cx-space-3); }
    .cx-strip-body { padding: 0 var(--cx-space-3) var(--cx-space-3); }
    .cx-today-sub { flex-wrap: wrap; }
}

/* ---- HOME-V2 polish (owner 2026-11-09, after the first preview) ----
   Compact appointment rows (time | patient + species / client · visit, one line each | status at the right), the phone
   "Up next" card, links in the practice accent (owner rule: primaryColor drives accent / buttons / links; ChiroApp green
   when the practice never chose one), calmer spacing. Content and behaviour unchanged. */
.cx-v2 .cx-link { color: var(--cx-brand); }
.cx-v2 .cx-link:hover { color: var(--cx-brand-strong); }
.cx-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cx-v2 .cx-appt-main, .cx-v2 .cx-block-main, .cx-v2 .cx-mini-main { gap: var(--cx-space-3); padding: 10px var(--cx-space-3); align-items: center; }
.cx-v2 .cx-appt-text { gap: 1px; }
.cx-appt-line1 { font-size: 0.97rem; color: var(--cx-text); line-height: 1.3; }
.cx-appt-line1 strong { font-weight: 600; }
.cx-species { color: var(--cx-text-2); font-weight: 500; }
.cx-appt-line2 { font-size: var(--cx-font-sm); color: var(--cx-text-2); line-height: 1.3; }
.cx-appt-room { color: var(--cx-text); font-weight: 600; }   /* ROOM-ON-HOME (owner Q2 2026-11-11): the visit's room leads line 2 */
.cx-appt-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 6px; flex-shrink: 0; align-self: stretch; }
.cx-appt-side .cx-chevron { margin-top: auto; }
.cx-v2 .cx-avatar { width: 36px; height: 36px; font-size: 1.15rem; border-radius: 10px; }
.cx-v2 .cx-appt-list { gap: var(--cx-space-2); }
.cx-v2 .cx-appt-actions { padding: 0 var(--cx-space-3) var(--cx-space-3) calc(4.6rem + 3px + var(--cx-space-3) * 3 + 36px - var(--cx-space-3)); gap: var(--cx-space-2); }
.cx-v2 .cx-appt-actions .cx-act, .cx-v2 .cx-appt-more-inner .cx-act { min-height: 40px; }
.cx-v2 .cx-card-header { margin-bottom: var(--cx-space-3); }
.cx-v2 .cx-card + .cx-card { margin-top: 0; }
.cx-v2 .cx-tile-main { padding: var(--cx-space-3) var(--cx-space-3) var(--cx-space-4); gap: 2px; }
.cx-v2 .cx-tile-caption { line-height: 1.3; }
.cx-v2 .cx-rows .cx-row { min-height: 52px; }
/* rows never grow wider than their card (grid items + one-line text) */
.cx-v2 .cx-appt-list { grid-template-columns: minmax(0, 1fr); }
.cx-v2 .cx-appt-list > li { min-width: 0; }
.cx-v2 .cx-appt-main, .cx-v2 .cx-block-main, .cx-v2 .cx-mini-main { position: relative; min-width: 0; }
.cx-v2 .cx-appt-text { flex: 1 1 auto; min-width: 0; }
/* status top-right, caret bottom-right: the patient line leaves room for the status, the visit line runs under it */
.cx-v2 .cx-appt-side { position: absolute; top: 10px; right: var(--cx-space-3); bottom: 10px; }
.cx-v2 .cx-appt-main .cx-appt-line1, .cx-v2 .cx-block-main .cx-appt-line1, .cx-v2 .cx-mini-main .cx-appt-line1 { padding-right: 5.6rem; }
.cx-v2 .cx-appt-main .cx-appt-line2, .cx-v2 .cx-block-main .cx-appt-line2, .cx-v2 .cx-mini-main .cx-appt-line2 { padding-right: 1.6rem; }
/* Up next (phone): the next visit, a countdown, its real actions */
.cx-upnext { display: none; }
@media (max-width: 600px) {
    .cx-upnext { display: grid; gap: var(--cx-space-3); margin: 0 0 var(--cx-space-4); padding: var(--cx-space-4); border-radius: 16px;
        background: var(--cx-brand); color: var(--cx-on-brand); box-shadow: 0 6px 18px color-mix(in srgb, var(--cx-brand) 30%, transparent); }
    .cx-upnext-head { display: flex; justify-content: space-between; gap: var(--cx-space-2); font-size: var(--cx-font-sm); font-weight: 600; opacity: 0.95; }
    .cx-upnext-head span:first-child { display: inline-flex; align-items: center; gap: 6px; }
    .cx-upnext-who { display: flex; align-items: center; gap: var(--cx-space-3); min-width: 0; }
    .cx-upnext .cx-avatar { background: color-mix(in srgb, var(--cx-on-brand) 18%, transparent); color: var(--cx-on-brand); }
    .cx-upnext .cx-appt-line1 { color: var(--cx-on-brand); font-family: var(--cx-head); font-size: 1.1rem; }
    .cx-upnext .cx-species, .cx-upnext .cx-appt-line2 { color: color-mix(in srgb, var(--cx-on-brand) 85%, transparent); }
    .cx-upnext .cx-appt-room { color: var(--cx-on-brand); }
    .cx-upnext-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cx-space-2); }
    .cx-upnext-actions > :nth-child(3):last-child { grid-column: 1 / -1; }
    .cx-upnext-actions .cx-btn { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .cx-upnext-actions .cx-btn { min-height: 42px; padding: 0 var(--cx-space-2); }
    .cx-upnext-actions .cx-btn--primary { background: var(--cx-on-brand); color: var(--cx-brand-ink); }
    .cx-upnext-actions .cx-btn--secondary { background: transparent; color: var(--cx-on-brand); border-color: color-mix(in srgb, var(--cx-on-brand) 55%, transparent); }
    .cx-v2 .cx-appt-time { width: 3.9rem; font-size: 0.95rem; }
    .cx-v2 .cx-appt-actions { padding-left: var(--cx-space-3); }
    .cx-v2 .cx-appt-actions .cx-act { flex: 1 1 0; }
    .cx-v2 .cx-appt-main, .cx-v2 .cx-block-main, .cx-v2 .cx-mini-main { gap: 10px; padding: 10px; }
    .cx-v2 .cx-status { font-size: 0.7rem; }
    .cx-v2 .cx-appt-side { right: 10px; }
    .cx-v2 .cx-appt-main .cx-appt-line1, .cx-v2 .cx-block-main .cx-appt-line1, .cx-v2 .cx-mini-main .cx-appt-line1 { padding-right: 4.9rem; }
}

/* PLACEHOLDER-1663: New client (placeholder) fields -- two columns on a desktop, ONE column on a phone (the name field
   used to be squeezed by the email field's inline grid-column: span 2). */
.placeholder-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md, 12px); }
.placeholder-fields .form-group { min-width: 0; margin-bottom: 0; }
.placeholder-fields input { width: 100%; box-sizing: border-box; }
.placeholder-fields .placeholder-field-name, .placeholder-fields .placeholder-field-address { grid-column: 1 / -1; }
.placeholder-req { color: var(--danger-500, #dc2626); font-weight: 700; }
.placeholder-why { color: var(--text-secondary, #6b7280); }
.placeholder-why.is-problem { color: var(--danger-600, #b91c1c); font-weight: 600; }
@media (max-width: 640px) { .placeholder-fields { grid-template-columns: minmax(0, 1fr); } }
.placeholder-status { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--bg-secondary, #f3f4f6); font-size: 0.85rem; }
.placeholder-status.is-problem { border: 1px solid var(--warning-500, #d97706); }
.placeholder-link-box { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px 10px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; }
.placeholder-link-box input[type=checkbox] { width: auto; flex: 0 0 auto; }

/* ====== IOSZOOM-1674 (owner 2026-11-13: tapping a form field on an iPhone zoomed the page in) ======
   iOS Safari auto-zooms the page when a text-entry control whose computed font-size is under 16px takes focus, which shifts the
   layout left and cuts it off. User zoom stays enabled (accessibility); instead every text-entry control on a touch screen is
   at least 16px. The rule is late and !important so it also beats a small class font-size and an inline style="font-size:..".
   Check boxes, radios, ranges, colour / file pickers and buttons never zoom, so they are left alone. */
@media (pointer: coarse), (max-width: 1100px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea,
    [contenteditable=""],
    [contenteditable="true"],
    [contenteditable="plaintext-only"] {
    font-size: max(16px, 1rem) !important;
  }
}

/* IOSZOOM-1674: while a text field has focus on a touch screen the fixed bottom bars (the Home / Patients / + / Schedule / Notes
   tab bar, the portal tab bar, floating buttons, the sticky Save bar) are hidden, so they never cover the field or its dropdown
   above the keyboard. body.ioszoom-field-focus is set by a tiny focusin / focusout listener in js/components.js, which removes it
   ~150 ms AFTER the field loses focus (1674-int: an immediate :has(:focus) rule re-showed the portal tab bar between pointerdown
   and the click, so tapping "Update Patient" right after typing landed on the tab bar and nothing was saved). */
@media (pointer: coarse), (max-width: 1100px) {
  body.ioszoom-field-focus .quick-access-bar, body.ioszoom-field-focus .portal-bottom-nav, body.ioszoom-field-focus .floating-collapse-btn,
  body.ioszoom-field-focus .sticky-action-bar, body.ioszoom-field-focus .note-form-actions, body.ioszoom-field-focus .quick-action-sheet,
  body.ioszoom-field-focus #impersonation-pill {
    display: none !important;
  }
}

/* ── VETINBOX-1676: Clinic Inbox "Vet forms" tab (classic widget + new-look Inbox page), intake link, ready-made forms
   picker. Every piece fits 360 / 390 px without a side scroll; touch targets are at least 44 px on phones. ── */
.vf-inbox { min-width: 0; }
.vf-inbox-section { margin-bottom: 16px; min-width: 0; }
.vf-inbox-heading { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.vf-inbox-hint { margin: 0 0 8px; }
.vf-inbox-row { padding: 10px 0; border-bottom: 1px solid var(--border-color); min-width: 0; }
.vf-inbox-row-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.vf-inbox-who, .vf-inbox-meta { margin: 2px 0; overflow-wrap: anywhere; min-width: 0; }
.vf-inbox-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.vf-intake-link, .vf-autofile-note {
    display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; padding: 8px 10px; border-radius: 8px;
    font-size: 0.85rem; overflow-wrap: anywhere; min-width: 0;
    background: color-mix(in srgb, var(--primary, #355E3B) 8%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--primary, #355E3B) 25%, transparent);
}
.vf-intake-link > span, .vf-autofile-note { flex: 1 1 200px; }
.vf-autofile-manual, .vf-intake-ambiguous {
    background: color-mix(in srgb, var(--warning, #f59e0b) 12%, var(--bg-secondary));
    border-color: color-mix(in srgb, var(--warning, #f59e0b) 45%, transparent);
}
.vf-file, .vf-link { margin-top: 8px; padding: 10px; border: 1px solid var(--border-color); border-radius: 8px; display: grid; gap: 6px; min-width: 0; }
.vf-file select, .vf-link select { width: 100%; max-width: 100%; min-height: 44px; font-size: 16px; }
.vf-inbox-done > summary { cursor: pointer; padding: 8px 0; font-weight: 600; color: var(--text-secondary); }
.vf-attached-badge {
    display: inline-flex; align-items: center; gap: 3px; font-size: 0.7em; font-weight: 700; padding: 2px 6px; border-radius: 4px;
    white-space: nowrap; color: var(--primary, #355E3B); background: color-mix(in srgb, var(--primary, #355E3B) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary, #355E3B) 30%, transparent);
}
.vf-intake-attached { margin-bottom: var(--space-md, 12px); padding: 10px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--primary, #355E3B) 30%, transparent); }
.vf-intake-attached-row { display: flex; gap: 6px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 4px 0; overflow-wrap: anywhere; }
.vf-preset-row { display: flex; align-items: center; }
.vf-preset-text { min-width: 0; }
.vf-preset-kind { margin: 0 0 0 6px; }   /* (.form-hint's negative top margin would pull it over the name) */
.cx-inbox-cells:has(> li:nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .cx-inbox-cells:has(> li:nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .vf-inbox-actions .btn, .vf-intake-link .btn, .vf-intake-attached .btn, .vf-setup-inbox-pointer .btn { min-height: 44px; min-width: 44px; }
    .vf-inbox-done > summary { min-height: 44px; display: flex; align-items: center; }
    /* the form type goes UNDER the form name, small and muted, full width (owner 2026-11-14) */
    .vf-preset-row { align-items: center; min-height: 44px; }
    .vf-preset-text { display: flex; flex-direction: column; flex: 1 1 auto; }
    .vf-preset-title { overflow-wrap: anywhere; }
    .vf-preset-kind { margin: 2px 0 0; font-size: 0.75rem; font-style: normal; color: var(--text-muted, #64748b); line-height: 1.3; overflow-wrap: anywhere; }
}

/* P2 (owner 2026-11-17): Setup > Patient Notes > Visit Types -- above phone width the per-row length select is as wide as its
   longest choice ("Default length" whole, not "Default leng"). Width only. Phones: see the rule below. */
@media (min-width: 601px) {
    #visitTypesList select.visit-type-duration { max-width: none !important; }
}
/* P2 phones (owner 2026-11-17): on <= 600 px each Visit Types row puts its length select on its OWN line under the visit type
   name (indented to the name), as wide as its longest choice, so "Default length" shows whole and the name keeps the row's
   full width (no squeezing, no mid-word splits). Name, edit and delete stay on the first line. Computers are unchanged. */
@media (max-width: 600px) {
    #visitTypesList .visit-type-row { flex-wrap: wrap; row-gap: 6px; }
    #visitTypesList .visit-type-row::after { content: ''; order: 1; flex: 0 0 100%; height: 0; }
    /* (outranks the MOBILE-1671 [style*="flex:1"][style*="min-width:0"] 9rem basis, which pushed delete onto a line of its own) */
    #visitTypesList .visit-type-row > span[style] { flex-basis: 0 !important; }
    #visitTypesList .visit-type-row > select.visit-type-duration { order: 2; max-width: 100% !important;
        margin-left: calc(1.1rem + 1rem + 16px) !important; }
}
/* P2 phones (owner 2026-11-17): Setup > Appointments > Scheduling Rules "Online booking length" already uses the full width;
   "Use visit-type durations (recommended)" is still longer than a phone line, so on <= 600 px its chosen text wraps onto a
   second line inside the select instead of being cut ("(recom..."). A native select does not grow with wrapped text, so it is
   two lines tall only while that long choice is chosen; one-line choices keep the 44 px box. Computers unchanged. */
@media (max-width: 600px) {
    #autoBookLengthSource:has(option[value="visitTypes"]:checked) { white-space: normal; height: calc(2.6em + 14px); line-height: 1.3;
        padding-top: 6px; padding-bottom: 6px; }
}
/* ══ SQUARE-1675: Square settings + Collect Payment (phone-first: everything wraps at 360-390 px, no side scroll) ══ */
#squareConnectStatus, .sq-flow, .sq-form { max-width: 100%; min-width: 0; }
.sq-box { padding: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border-color); background: var(--bg-secondary); max-width: 100%; box-sizing: border-box; }
.sq-box.sq-dashed { border-style: dashed; }
.sq-box.sq-ok { background: var(--bg-secondary); background: color-mix(in srgb, var(--accent-emerald) 6%, transparent); border-color: var(--accent-emerald); }
.sq-h { margin: 0.5rem 0; font-size: 1.05rem; }
.sq-muted { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0; }
.sq-small { color: var(--text-muted); font-size: 0.78rem; margin: 0.5rem 0 0; }
.sq-error { color: var(--accent-rose); font-size: 0.85rem; margin: 0.5rem 0; }
.sq-warn { color: var(--text-primary); border-left: 3px solid var(--accent-amber); padding-left: 0.5rem; font-size: 0.9rem; margin: 0.5rem 0; }
.sq-green { color: var(--accent-emerald); font-size: 1.5rem; }
.sq-full { width: 100%; max-width: 100%; box-sizing: border-box; }
.sq-gap { margin-top: 0.75rem; }
.sq-row { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.sq-wrap { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; min-width: 0; }
.sq-end { justify-content: flex-end; }
.sq-grow { flex: 1 1 12rem; min-width: 0; }
.sq-break { overflow-wrap: anywhere; word-break: break-word; }
.sq-fieldset { border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.5rem 0.75rem; margin: 0; min-width: 0; }
.sq-radio { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; min-height: 44px; cursor: pointer; }
.sq-review { border-top: 1px solid var(--border-color); padding: 0.6rem 0; }
.sq-cand { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding-top: 0.4rem; }
.sq-option { display: flex; align-items: center; gap: 0.75rem; padding: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border-color); background: var(--bg-primary); cursor: pointer; min-width: 0; }
.sq-option.sq-disabled { opacity: 0.5; cursor: default; background: var(--bg-secondary); }
.sq-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-color); color: var(--bg-card, white); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.2rem; }
.sq-title { font-weight: 600; font-size: 0.95rem; }
#sqChargeFlow input, #sqChargeFlow select, .sq-form input, .sq-form select, .sq-form textarea, #squareConnectStatus select { font-size: 16px; max-width: 100%; }
.sq-list { margin: 0.25rem 0 0.5rem; padding-left: 1.1rem; }
.sq-code { font-size: 2rem; font-weight: 700; letter-spacing: 0.15em; text-align: center; padding: 0.5rem 0; overflow-wrap: anywhere; }
#sqTermFlow input, #sqTermFlow select { font-size: 16px; max-width: 100%; }
/* SQUARE-1677 (owner 2026-11-18): saved cards (both processors), consent tick, card frame, expiry badges, Dashboard line.
   Fits 360px: everything wraps, no fixed widths; inputs 16px (no iOS zoom). Colours are theme tokens only (practice
   branding via App.initBranding; status = --accent-amber / --accent-rose); ChiroApp has no dark mode. */
.sq-client-cards { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); min-width: 0; max-width: 100%; }
.sq-cards { list-style: none; padding-left: 0; }
.sq-card-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-color); min-width: 0; }
.sq-card-row:last-child { border-bottom: 0; }
.sq-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; flex-basis: 100%; padding-left: 1.6rem; }
.sq-radio.sq-card { flex-wrap: wrap; }
.sq-radio.sq-card > .sq-break { flex: 1 1 0; min-width: 0; }
.sq-radio.sq-card > .sq-badges { padding-left: 1.75rem; }
.sq-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.sq-badge-proc { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border-color); }
.sq-badge-warn { background: var(--bg-secondary); background: color-mix(in srgb, var(--accent-amber) 18%, transparent); color: var(--text-primary); border: 1px solid var(--accent-amber); }
.sq-badge-bad { background: var(--bg-secondary); background: color-mix(in srgb, var(--accent-rose) 14%, transparent); color: var(--text-primary); border: 1px solid var(--accent-rose); }
.sq-frame-host { min-height: 100px; }
.sq-frame { width: 100%; max-width: 100%; height: 110px; border: 0; display: block; background: transparent; }
.sq-consent, .sq-switch { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0; min-height: 44px; cursor: pointer; font-size: 1rem; }
.sq-consent input, .sq-switch input { width: 22px; height: 22px; flex: 0 0 auto; margin: 0.1rem 0 0; }
.sq-switch .sq-small { display: block; margin-top: 0.15rem; }
.sq-save-form { margin-top: 0.75rem; min-width: 0; }
.sq-warnbox { background: var(--bg-secondary); background: color-mix(in srgb, var(--accent-amber) 8%, transparent); border-color: var(--accent-amber); }
.sq-differs { color: var(--text-secondary); }
.sq-differs i { color: var(--accent-amber); }
.sq-signup a { font-weight: 600; color: var(--primary-color); }
.sq-dash { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.9rem 1rem; margin-bottom: 1rem; border-radius: var(--radius-md);
    border: 1px solid var(--accent-amber); background: var(--bg-secondary); background: color-mix(in srgb, var(--accent-amber) 8%, transparent); min-width: 0; max-width: 100%; box-sizing: border-box; }
.sq-dash > i { font-size: 1.4rem; color: var(--accent-amber); flex-shrink: 0; }

/* COPY-1677 (owner Q21): small copy icon next to a client's phone / email / address on the client profile, with a "Copied" message. */
.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-color, #d1d5db);
    background: transparent;
    color: var(--text-muted, #6b7280);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}
.copy-btn:hover, .copy-btn:focus-visible { color: var(--primary-500, #355e3b); border-color: var(--primary-500, #355e3b); }
.copy-flash { font-size: 0.8rem; font-weight: 600; color: var(--success, #10b981); }
.copy-flash-fail { color: var(--danger, #ef4444); }

/* CLIENT-LINKS-1677 (owner 2026-11-18): the client profile's email (mailto:) and address (maps) are links. Theme tokens only. */
.client-contact-link { color: var(--primary-500, #355e3b); text-decoration: none; }
.client-contact-link:hover, .client-contact-link:focus-visible { text-decoration: underline; }

/* ====== SYNCAWARE-1677 (owner 2026-11-18, round 2): ICON-ONLY save status -- the cloud (plain when all is saved), a small number
   dot while changes wait, the offline cloud; tapping it shows the words in a small bubble. The line under the phone header shows
   only after changes have waited more than a minute. Plus the "hadn't sent when you left" tip. Theme tokens only (the practice's
   colours via --primary-*; status colours = the cloud indicator's own tokens). Light only (the app has no dark mode). ====== */
.sync-indicator[data-save-state] { cursor: pointer; }
.save-status-dot { position: absolute; top: 0; right: -2px; min-width: 15px; height: 15px; padding: 0 3px; box-sizing: border-box;
    border-radius: 8px; background: var(--accent-amber); color: var(--bg-primary); font-size: 0.55rem; font-weight: 700; line-height: 15px;
    text-align: center; pointer-events: none; }
.sync-indicator[data-save-state="offline"] .save-status-dot { background: var(--text-muted); }
.save-status-detail { position: fixed; z-index: 20002; display: flex; align-items: flex-start; gap: 8px; max-width: min(320px, calc(100vw - 16px));
    box-sizing: border-box; padding: 8px 12px; font-size: 0.82rem; line-height: 1.4; color: var(--text-primary); background: var(--bg-primary);
    border: 1px solid var(--border-color); border-left: 3px solid var(--accent-emerald); border-radius: 10px; box-shadow: 0 8px 24px var(--shadow-color);
    overflow-wrap: anywhere; }
.save-status-detail[data-state="waiting"], .save-status-detail[data-state="saving"] { border-left-color: var(--accent-amber); }
.save-status-detail[data-state="offline"], .save-status-detail[data-state="checking"] { border-left-color: var(--text-muted); }
.save-status-detail > i { font-size: 1.05rem; flex-shrink: 0; color: var(--text-secondary); }
.save-status-strip[hidden], .save-status-desk-line[hidden] { display: none !important; }
/* computer, offline: one line at the top of the page beside the menu (round 3; replaces the banner over the menu) */
.save-status-desk-line { position: sticky; top: 0; z-index: 50; margin: 0 0 var(--space-sm, 0.5rem); padding: 6px 12px; font-size: 0.85rem; line-height: 1.4;
    color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border-color); border-left: 3px solid var(--text-muted);
    border-radius: 8px; overflow-wrap: anywhere; }
@media (max-width: 1024px) { .save-status-desk-line { display: none !important; } }
.save-status-strip { display: none; }
@media (max-width: 1024px) {
    /* under the header row, inside the fixed header (the row itself never wraps or moves) */
    .save-status-strip { position: absolute; top: calc(100% + 4px); left: 8px; right: 8px; box-sizing: border-box; padding: 3px 10px; font-size: 0.78rem; line-height: 1.35;
        color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border-color);
        border-left: 3px solid var(--accent-amber); border-radius: 8px; overflow-wrap: anywhere; }
    .mobile-header.has-save-strip .save-status-strip { display: block; }
    .save-status-strip[data-state="offline"] { border-left-color: var(--text-muted); }
    body.save-strip-on .main-content { padding-top: calc(108px + env(safe-area-inset-top, 0px)); }
}
.leave-unsent-tip { position: fixed; z-index: 20001; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: min(440px, calc(100vw - 24px)); box-sizing: border-box; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px;
    background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border-color); border-left: 4px solid var(--primary-500);
    border-radius: var(--radius-md, 12px); box-shadow: 0 10px 30px var(--shadow-color); overflow-wrap: anywhere; }
.leave-unsent-tip > i { font-size: 1.3rem; color: var(--primary-500); flex-shrink: 0; margin-top: 1px; }
.leave-unsent-tip-body { flex: 1; min-width: 0; }
.leave-unsent-tip-body p { margin: 0; font-size: 0.88rem; line-height: 1.45; }
.leave-unsent-tip-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 1024px) { .leave-unsent-tip { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

/* REQUIRED-FIELDS-1678 (owner rule 2026-11-17): ONE required mark -- red asterisk + screen-reader " (required)" */
.req-mark { color: var(--danger-500, #dc2626); font-weight: 700; margin-left: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.req-missing { border-color: var(--danger-500, #dc2626) !important; }
.req-inline-msg { color: var(--danger-500, #dc2626); font-size: 0.82rem; margin-top: 4px; }

/* IOSFIXES-1682: Echo "Hold to stop" -- a long press must never start a text selection or show the iOS Copy callout. */
[data-echo-hold], [data-echo-hold] * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
[data-echo-hold] { touch-action: manipulation; }
