@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Primary (Indigo/Violet) - Default "Dark Glass" */
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --primary-hover: #7c3aed;
    --accent: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.2);

    /* Secondary & Feedback */
    --secondary: #10b981;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* Backgrounds */
    --bg: #0f172a;
    --bg-gradient: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-heavy: rgba(15, 23, 42, 0.6);

    /* Borders & Accents */
    --border: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);

    /* Text */
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: rgba(255, 255, 255, 0.4);

    /* Gradients */
    --btn-gradient: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    --card-gradient: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
}

/* THEME: LEGACY LIGHT (Cloud, Workspace Vibes) */
body.legacy-light {
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-glow: rgba(79, 70, 229, 0.4);
    --primary-hover: #4338ca;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.15);

    --bg: #f3f4f6;
    --bg-gradient: radial-gradient(circle at top right, #f9fafb, #d1d5db);
    /* Gray 50 to Gray 300 */
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass: rgba(255, 255, 255, 0.75);
    --glass-heavy: rgba(255, 255, 255, 0.95);

    --border: rgba(0, 0, 0, 0.12);
    --glass-border: rgba(0, 0, 0, 0.15);

    --btn-gradient: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    --card-gradient: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(79, 70, 229, 0.03) 100%);

    --text: #0f172a;
    /* Slate 900 */
    --text-muted: #334155;
    /* Slate 700 */
    --text-dim: #64748b;
    /* Slate 500 */
}

/* THEME: DARK GLASS (Default - Violet/Indigo) */
body.dark-glass {
    /* (Defaults are already in :root) */
    opacity: 1;
}

body {
    background: var(--bg-gradient);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    transition: background 1s ease, color 0.5s ease;
}

.delta-pos {
    color: #ef4444 !important;
}

.delta-neg {
    color: #10b981 !important;
}

/* Existing Dashboard Styles */
body.client-mode .admin-only {
    display: none !important;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

iframe {
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.modal {
    display: none;
    /* Layout removal when closed */
    position: fixed;
    z-index: 1000000;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Hardware acceleration hints */
    transform: translate3d(0, 0, 0);
    will-change: opacity, transform;
}

.modal.active {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    padding: 30px;
    border: 2px solid var(--primary);
    width: 95%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    color: var(--text);
    position: relative;
    scrollbar-width: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 20px;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-weight: 800;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    transition: all 0.3s ease;
}

/* Photo Privacy Blur */
.photo-blurred {
    filter: blur(20px);
    transition: filter 0.3s ease;
}

.photo-blur-toggle {
    cursor: pointer;
    position: relative;
}

/* --- BENTO GRID SYSTEM (Tiered Health Narrative) --- */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
}

.bento-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    grid-column: span 4;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* Tier 1: The Hero (Singular Focus) */
.bento-hero {
    grid-column: span 12 !important;
    padding: 32px;
    background: var(--card-gradient);
    border: 1.5px solid var(--primary-glow);
    box-shadow: 0 10px 30px var(--primary-glow);
}

.bento-hero .bento-value {
    font-size: 3.8rem;
    /* Slightly reduced */
    letter-spacing: -0.03em;
    margin-right: 16px;
}

/* Side-by-side Value + Delta Alignment */
.bento-value-group {
    display: flex;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.delta-inline {
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.bento-hero .delta-inline {
    font-size: 2.2rem;
}

/* Tier 2: Tape Measurements (Unified Row) */
.bento-tier-2 {
    grid-column: span 6 !important;
    min-height: 140px;
}

.bento-tier-2 .bento-value {
    font-size: 2.8rem;
}

.bento-tier-2 .delta-inline {
    font-size: 1.6rem;
}

/* Compact Vertical Measurement List */
.bento-side-list {
    grid-column: span 6 !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.measure-row {
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.measure-row:hover {
    background: var(--glass-heavy);
    border-color: var(--primary);
}

/* Tier 3: Composition (Body Fat Trends, BMI) */
.bento-tier-3 {
    grid-column: span 6 !important;
    background: var(--glass);
    border-color: var(--glass-border);
}

.bento-tier-3 .bento-value {
    font-size: 2.2rem;
    /* Increased to fill the wider space */
}

/* Intention Cues (Micro-labels) */
.bento-cue {
    font-size: 0.65rem;
    color: var(--primary);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 4px;
    opacity: 0.9;
}

/* Momentum Glow effect */
.bento-glow-purple::before {
    content: '';
    position: absolute;
    top: -25%;
    left: -25%;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: pulse-glow 8s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from {
        opacity: 0.3;
        transform: scale(0.95);
    }

    to {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

/* Daily Signals Strip (Bottom) */
.signals-strip {
    grid-column: span 12;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 16px;
    padding: 16px 24px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 10px;
    opacity: 0.9;
}

.signal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.signal-item i {
    font-size: 0.85rem;
    opacity: 0.6;
}

.signal-value {
    color: var(--text);
    font-weight: 800;
}

.bento-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    opacity: 0.7;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.bento-value {
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: baseline;
}

.bento-unit {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 600;
    margin-left: 4px;
}

.bento-footer {
    margin-top: auto;
    padding-top: 10px;
    position: relative;
    z-index: 1;
}

.bento-momentum {
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- PREMIUM UI COMPONENTS --- */
.btn-premium {
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--btn-gradient);
    border: none;
    color: white;
    box-shadow: 0 10px 20px var(--accent-glow);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px var(--primary-glow);
    filter: brightness(1.1);
}

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

/* HERO COMPONENT REFINEMENTS */
.welcome-hero {
    padding: 0;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    margin-bottom: 30px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.welcome-hero-top {
    padding: 32px;
    background: var(--card-gradient);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
}

.hero-actions-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

/* INTELLIGENCE PULSE: REAL-TIME SYNC INDICATOR */
.intelligence-pulse {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary-glow);
    position: relative;
}

/* CLS fix: use pseudo-element with opacity instead of box-shadow animation.
   box-shadow is not composited and triggers layout shifts. */
.pulse-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--primary-glow);
    animation: intelligence-pulse-ring 2s infinite;
}

@keyframes intelligence-pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.7;
    }

    70% {
        transform: scale(2.5);
        opacity: 0;
    }

    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.intelligence-pulse.offline .pulse-dot {
    background: var(--error);
    box-shadow: 0 0 10px var(--error);
    animation: none;
    opacity: 0.5;
}

.pulse-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-label {
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
}

.status-value {
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.5px;
}

/* PREMIUM AURA: NIGHT-EYE ENHANCEMENT */
.medication-card.priority {
    position: relative;
    border-color: var(--primary);
    box-shadow: 0 10px 30px -10px var(--primary-glow);
}


.welcome-hero-label {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 800;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.welcome-hero-title {
    font-size: 2.2rem;
    margin: 0 0 12px 0;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.welcome-hero-subtext {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 500;
    font-style: italic;
    opacity: 0.9;
}

.system-status-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* UNIVERSAL MODULE CONTAINERS (High-Fidelity Cards) */
.mj-module-container {
    display: flex;
    flex-direction: column;
    padding: 32px;
    background: var(--glass-heavy);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    margin-bottom: 0;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    color: var(--text);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mj-module-container:hover {
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.15);
}

.ai-coach-panel {
    padding: 0;
    /* Inherit padding from mj-module-container */
    background: transparent;
    border-radius: 0;
    border: none;
    margin: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--text);
}

/* AI Coach Tab Bar */
.ai-coach-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--glass-heavy);
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-coach-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    padding: 10px 24px;
    border-radius: 100px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.ai-coach-tab.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--text);
    box-shadow: 0 0 20px var(--primary-glow);
}

.ai-coach-tab:hover:not(.active) {
    color: var(--text);
    background: var(--glass);
}

/* AI Coach Task Rows */
.ai-task-row {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.ai-task-row:hover {
    background: var(--glass-heavy);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.ai-task-icon-box {
    min-width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
}

.ai-task-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-task-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.ai-task-chevron {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--glass);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

@media (max-width: 1024px) {

    .bento-item,
    .bento-tier-2,
    .bento-tier-3 {
        grid-column: span 6 !important;
    }

    .signals-strip {
        flex-wrap: wrap;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .welcome-hero-top {
        flex-direction: column;
        gap: 20px;
    }

    .hero-actions-container {
        align-items: flex-start;
        width: 100%;
    }

    .intelligence-pulse {
        width: 100%;
        justify-content: center;
    }

    .btn-premium {
        width: 100%;
        justify-content: center;
    }

    .bento-hero .bento-value {
        font-size: 2.8rem;
    }

    .bento-hero .delta-inline {
        font-size: 1.5rem;
    }

    /* Expanded Modal Mobile Optimization */
    .expanded-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .expanded-header-row-2 {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }

    #expanded-metric-pills {
        justify-content: flex-start;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    #expanded-metric-pills::-webkit-scrollbar {
        height: 4px;
    }

    #expanded-metric-pills .metric-pill-btn {
        flex-shrink: 0;
    }

    .expanded-graph-row {
        flex-direction: column !important;
    }

    #expanded-graph-col {
        flex: 1 0 auto !important;
    }

    #trend-comparison-section {
        flex: 1 0 auto !important;
        max-height: none !important;
    }

    #expanded-stats {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 640px) {

    .bento-item,
    .bento-tier-2,
    .bento-tier-3 {
        grid-column: span 12 !important;
    }

    .welcome-hero-title {
        font-size: 1.8rem;
    }
}

/* --- VISUAL JOURNEY (Photo Gallery) --- */
.photo-strip {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 92, 246, 0.3) transparent;
}

.photo-strip::-webkit-scrollbar {
    height: 6px;
}

.photo-strip::-webkit-scrollbar-track {
    background: transparent;
}

.photo-strip::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 10px;
}

.photo-tile {
    flex: 0 0 200px;
    height: 280px;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.photo-tile:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), 0 0 20px var(--primary-glow);
}

.photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.3s ease;
}

.photo-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.9));
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
}

.photo-blur-overlay {
    position: absolute;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.photo-tile:hover .photo-blur-overlay {
    opacity: 1;
}

/* ── Deferred Module Hydration (Phase 2) ──────────────────────────
 * Spec: docs/specs/deferred-module-hydration/spec.md v1.1.0 §8
 * ──────────────────────────────────────────────────────────────── */

/* §8.1 Skeleton Shimmer */
.skeleton-block {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.skeleton-shimmer {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.04) 100%);
    background-size: 200% 100%;
    animation: dmh-shimmer 1.5s ease-in-out infinite;
}

@keyframes dmh-shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Sprint 2 R4.3: Chart skeleton — shows while chart library lazy-loads */
.chart-skeleton {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 20px 24px 32px;
    min-height: 200px;
    position: relative;
}

.chart-skeleton::before {
    /* Faux Y-axis */
    content: '';
    position: absolute;
    left: 20px;
    top: 20px;
    bottom: 28px;
    width: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.chart-skeleton::after {
    /* Faux X-axis */
    content: '';
    position: absolute;
    left: 20px;
    right: 24px;
    bottom: 28px;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.chart-skeleton-bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 0%,
            rgba(255, 255, 255, 0.08) 50%,
            rgba(255, 255, 255, 0.04) 100%);
    background-size: 200% 100%;
    animation: dmh-shimmer 1.5s ease-in-out infinite;
}

.chart-skeleton-label {
    position: absolute;
    bottom: 8px;
    left: 20px;
    right: 24px;
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.08);
    font-weight: 600;
}

/* §8.2 Hydration Transitions */
.module-skeleton {
    opacity: 1;
    transition: opacity 200ms ease-out;
}

.module-hydrating {
    opacity: 0.3;
}

.module-hydrated {
    opacity: 1;
    transition: opacity 200ms ease-out;
}

/* §6.6 Error State */
.module-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.4));
    font-size: 0.9rem;
    font-weight: 600;
    padding: 24px;
}

.module-error i {
    font-size: 1.5rem;
    color: #f59e0b;
    opacity: 0.7;
}

.module-retry-btn {
    margin-top: 4px;
    padding: 8px 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted, rgba(255, 255, 255, 0.5));
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.module-retry-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary, #8b5cf6);
    color: var(--text, #f8fafc);
}

/* ── Sprint 4 CLS ──────────────────────────────────────────────── */
/* Reserve space for containers that fill during hydration to       */
/* prevent layout shifts. Use min-height only (never fixed height). */

/* 4A+: Main modules container — prevents shift when cards insert  */
#client-modules {
    min-height: 1500px;
    /* measured: 1517px */
}

/* 4B: AI Coach status elements — prevents reflow on hydration     */
#ai-coach-hero-status {
    min-height: 24px;
    /* ~1 line of status text */
}

.intelligence-pulse {
    min-height: 55px;
    /* measured: 55px */
}


/* 4D: Health Overview — shift 0.0588 from content population      */
#health-overview-container {
    min-height: 660px;
    /* measured: 676px */
}

/* 4E: AI Coach bottom panel — shift 0.0135+0.0245 from tab render */
#ai-coach-container {
    min-height: 800px;
    /* measured: 809px */
}

/* 4F: Hero actions area — shift from buttons appearing            */
.hero-actions-container {
    min-height: 160px;
    /* measured: 165px */
}

/* 4G: GLP-1 Hero — static placeholder reserves space              */
#glp1-hero-container {
    min-height: 660px;
    /* measured: 676px */
}