/* ═══════════════════════════════════════════════════
   Zackher — Design System v2
   Nightscout-inspired: glassmorphism, fluid animations,
   mobile bottom-nav, big glucose numbers
   ═══════════════════════════════════════════════════ */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-card: #1a2236;
    --bg-card-hover: #1f2a42;
    --bg-elevated: #243050;
    --accent: #2dd4bf;
    --accent-dim: #14b8a6;
    --accent-glow: rgba(45, 212, 191, 0.15);
    --accent-glow-strong: rgba(45, 212, 191, 0.3);
    --glucose-low: #f59e0b;
    --glucose-normal: #10b981;
    --glucose-high: #ef4444;
    --glucose-very-high: #dc2626;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #1e293b;
    --border-accent: rgba(45, 212, 191, 0.2);
    --insulin-color: #818cf8;
    --carb-color: #fb923c;
    --danger: #ef4444;
    --danger-dim: #dc2626;
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.03);
    --shadow-elevated: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px rgba(45, 212, 191, 0.1);
    --shadow-glass: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.05);
    --shadow-deep: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
    --glass-bg: rgba(26, 34, 54, 0.65);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 20px;
    --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --t-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --t-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    --bottom-nav-h: 64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }
body { overflow-x: hidden; font-family: 'DM Sans', sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; position: relative; }


/* ── Loading screen ── */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 1.5rem; background: var(--bg-primary); }
.loading-pulse { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; box-shadow: 0 0 40px rgba(45, 212, 191, 0.3); }
@keyframes pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.5; box-shadow: 0 0 20px rgba(45, 212, 191, 0.15); }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 60px rgba(45, 212, 191, 0.4); }
}
.loading-text { font-family: 'Instrument Serif', serif; font-size: 1.5rem; color: var(--text-secondary); letter-spacing: 0.1em; }
.loading-text span { color: var(--accent); }

/* ── Error UI ── */
#blazor-error-ui { display: none; position: fixed; bottom: 0; width: 100%; padding: 1rem; background: var(--danger); color: white; text-align: center; z-index: 9999; }

/* ═══════════════════════════════════
   LAYOUT
   ═══════════════════════════════════ */
.page-layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ── Sidebar (Desktop) ── */
.sidebar {
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform var(--t-smooth);
}
.sidebar-brand { padding: var(--space-xl); border-bottom: 1px solid var(--glass-border); position: relative; overflow: hidden; }
.sidebar-brand::after { content: ''; position: absolute; bottom: 0; left: var(--space-xl); right: var(--space-xl); height: 1px; background: linear-gradient(90deg, transparent, var(--accent-glow-strong), transparent); }
.sidebar-brand h1 { font-family: 'Instrument Serif', serif; font-size: 1.6rem; color: var(--text-primary); letter-spacing: -0.01em; }
.sidebar-brand h1 span { color: var(--accent); }
.sidebar-brand p { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { flex: 1; padding: var(--space-md); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }

.nav-link {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: 0.65rem 0.85rem; border-radius: var(--radius-md);
    text-decoration: none; color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
    transition: all var(--t-fast); cursor: pointer; border: none; background: none; width: 100%; text-align: left;
    position: relative; overflow: hidden;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); transform: translateX(2px); }
.nav-link.active { background: var(--accent-glow); color: var(--accent); box-shadow: inset 0 0 20px rgba(45, 212, 191, 0.05); }
.nav-link.active::before { content: ''; position: absolute; left: 0; top: 25%; bottom: 25%; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; animation: slideIn 0.2s ease; }
@keyframes slideIn { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; transition: transform var(--t-fast); }
.nav-link:hover svg { transform: scale(1.1); }

.nav-section-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: var(--space-lg) 0.85rem var(--space-xs); }
.sidebar-footer { padding: var(--space-md); border-top: 1px solid var(--glass-border); }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; overflow-x: hidden; position: relative; z-index: 1; }

.page-container { max-width: 1280px; margin: 0 auto; padding: var(--space-2xl); overflow-x: hidden; }

/* ── Mobile Header ── */
.mobile-header {
    display: none; align-items: center; justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 50;
}
.mobile-brand { font-family: 'Instrument Serif', serif; font-size: 1.3rem; color: var(--text-primary); }
.mobile-menu-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; border-radius: var(--radius-md); transition: all var(--t-fast); }
.mobile-menu-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    animation: fadeIn 0.2s ease;
}

/* ── Bottom Navigation (Mobile — Nightscout style) ── */
.bottom-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: rgba(17, 24, 39, 0.92);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border); z-index: 200;
    padding: 0 var(--space-xs);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-inner { display: flex; align-items: center; justify-content: space-around; height: 100%; max-width: 500px; margin: 0 auto; }
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 6px 10px; border-radius: var(--radius-md);
    text-decoration: none; color: var(--text-muted); font-size: 0.6rem; font-weight: 600; letter-spacing: 0.03em;
    transition: all var(--t-fast); position: relative; -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 22px; height: 22px; transition: all var(--t-fast); }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active svg { transform: scale(1.15); filter: drop-shadow(0 0 8px rgba(45, 212, 191, 0.4)); }
.bottom-nav-item.active::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 24px; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }

/* ═══════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════ */
.page-header { margin-bottom: var(--space-2xl); }
.page-header h2 { font-family: 'Instrument Serif', serif; font-size: 2rem; font-weight: 400; color: var(--text-primary); letter-spacing: -0.01em; }
.page-header p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 4px; }

/* ═══════════════════════════════════
   CARDS — Glassmorphism
   ═══════════════════════════════════ */
.card {
    background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass); overflow: hidden;
    transition: border-color var(--t-smooth), box-shadow var(--t-smooth), transform var(--t-smooth);
}
.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glass), 0 0 30px rgba(45, 212, 191, 0.04); }
.card:focus-within { border-color: var(--border-accent); box-shadow: var(--shadow-glow); }

.card-header { padding: var(--space-lg) var(--space-xl); border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: var(--space-xl); }
.card-body-compact { padding: var(--space-md) var(--space-xl); }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }

/* ═══════════════════════════════════
   STAT CARDS — stagger animation
   ═══════════════════════════════════ */
.stat-card {
    background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
    padding: var(--space-lg); position: relative; overflow: hidden;
    transition: transform var(--t-spring), box-shadow var(--t-smooth), border-color var(--t-smooth);

}

.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); opacity: 0.6; transition: opacity var(--t-fast), height var(--t-fast); }
.stat-card:hover::before { opacity: 1; height: 3px; }
.stat-card.insulin::before { background: var(--insulin-color); }
.stat-card.carb::before { background: var(--carb-color); }
.stat-card.danger::before { background: var(--danger); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-deep); border-color: var(--border-accent); }

.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: var(--space-xs); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.stat-value.accent { color: var(--accent); }
.stat-value.insulin { color: var(--insulin-color); }
.stat-value.carb { color: var(--carb-color); }
.stat-unit { font-size: 0.875rem; font-weight: 400; color: var(--text-secondary); margin-left: 4px; }
.stat-subtitle { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* Glucose zone glow */
.stat-value.in-range { color: var(--glucose-normal); text-shadow: 0 0 30px rgba(16, 185, 129, 0.3); }
.stat-value.low { color: var(--glucose-low); text-shadow: 0 0 30px rgba(245, 158, 11, 0.3); }
.stat-value.high { color: var(--glucose-high); text-shadow: 0 0 30px rgba(239, 68, 68, 0.3); }
.stat-value.very-high { color: var(--glucose-very-high); text-shadow: 0 0 30px rgba(220, 38, 38, 0.3); }

/* ═══════════════════════════════════
   TABLES
   ═══════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 0.6rem 0.85rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--glass-border); font-weight: 600; }
.data-table td { padding: 0.7rem 0.85rem; font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.02); color: var(--text-secondary); transition: background var(--t-fast); }
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.data-table td.mono { font-family: 'DM Sans', monospace; font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════
   BUTTONS
   ═══════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem; border: none; border-radius: var(--radius-md);
    font-family: 'DM Sans', sans-serif; font-size: 0.825rem; font-weight: 600;
    cursor: pointer; transition: all var(--t-fast); text-decoration: none; white-space: nowrap;
    position: relative; overflow: hidden;
}
.btn::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.15), transparent 70%); opacity: 0; transition: opacity 0.3s ease; }
.btn:active::after { opacity: 1; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--bg-primary); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); box-shadow: 0 4px 24px rgba(45, 212, 191, 0.25); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); border: 1px solid var(--glass-border); }
.btn-secondary:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); border-color: var(--text-muted); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.1); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.95rem; border-radius: var(--radius-md); }
.btn-lg:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(45, 212, 191, 0.2); }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); }

/* ═══════════════════════════════════
   FORMS
   ═══════════════════════════════════ */
.form-group { margin-bottom: var(--space-lg); }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control { width: 100%; padding: 0.6rem 0.85rem; background: rgba(10, 15, 26, 0.6); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: var(--text-primary); font-family: 'DM Sans', sans-serif; font-size: 0.875rem; transition: border-color var(--t-smooth), box-shadow var(--t-smooth), background var(--t-smooth); outline: none; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow), 0 0 24px rgba(45, 212, 191, 0.08); background: rgba(10, 15, 26, 0.8); }
.form-control::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
/* File drop zone */
.file-drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-sm);
    padding: var(--space-2xl) var(--space-xl);
    border: 2px dashed var(--glass-border); border-radius: var(--radius-lg);
    background: rgba(10, 15, 26, 0.4);
    cursor: pointer; transition: all var(--t-smooth); text-align: center;
}
.file-drop-zone:hover {
    border-color: var(--accent); background: rgba(45, 212, 191, 0.04);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.file-drop-zone svg { color: var(--text-muted); transition: color var(--t-smooth); }
.file-drop-zone:hover svg { color: var(--accent); }
.file-drop-text { display: flex; flex-direction: column; gap: 0.25rem; }
.file-drop-text strong { font-size: 0.9rem; color: var(--text-primary); }
.file-drop-text .text-sm { font-size: 0.78rem; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }

.input, input[type="url"], input[type="password"], input[type="text"], input[type="number"], input[type="email"] {
    width: 100%; padding: 0.65rem 0.9rem; background: rgba(10, 15, 26, 0.6); border: 1px solid var(--glass-border); border-radius: var(--radius-md); color: var(--text-primary); font-family: 'DM Sans', sans-serif; font-size: 0.875rem; transition: border-color var(--t-smooth), box-shadow var(--t-smooth), background var(--t-smooth); outline: none;
}
.input:focus, input[type="url"]:focus, input[type="password"]:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow), 0 0 24px rgba(45, 212, 191, 0.08); background: rgba(10, 15, 26, 0.8); }
.input::placeholder, input::placeholder { color: var(--text-muted); }

/* ═══════════════════════════════════
   BADGES
   ═══════════════════════════════════ */
.badge { display: inline-flex; align-items: center; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; }
.badge-accent { background: var(--accent-glow); color: var(--accent); }
.badge-insulin { background: rgba(129, 140, 248, 0.15); color: var(--insulin-color); }
.badge-carb { background: rgba(251, 146, 60, 0.15); color: var(--carb-color); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-muted { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* ═══════════════════════════════════
   GLUCOSE DISPLAY — Big Nightscout number
   ═══════════════════════════════════ */
.glucose-value { font-size: 3.5rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; transition: color var(--t-smooth); }
.glucose-value.in-range { color: var(--glucose-normal); text-shadow: 0 0 40px rgba(16, 185, 129, 0.35); }
.glucose-value.low { color: var(--glucose-low); text-shadow: 0 0 40px rgba(245, 158, 11, 0.35); }
.glucose-value.high { color: var(--glucose-high); text-shadow: 0 0 40px rgba(239, 68, 68, 0.35); }
.glucose-value.very-high { color: var(--glucose-very-high); text-shadow: 0 0 40px rgba(220, 38, 38, 0.35); }
.glucose-direction { font-size: 1.5rem; margin-left: 0.5rem; }

/* ═══════════════════════════════════
   ALERTS
   ═══════════════════════════════════ */
.alert { padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md); font-size: 0.85rem; margin-bottom: var(--space-md); backdrop-filter: blur(8px); animation: alertIn 0.3s ease; }
@keyframes alertIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.2); color: #fca5a5; position: relative; padding-left: var(--space-xl); }
.alert-error::before { content: '!'; position: absolute; left: var(--space-md); top: 50%; transform: translateY(-50%); font-weight: 700; font-size: 0.9rem; }
.alert-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); color: #6ee7b7; position: relative; padding-left: var(--space-xl); }
.alert-success::before { content: '\2713'; position: absolute; left: var(--space-md); top: 50%; transform: translateY(-50%); font-weight: 700; }
.alert-info { background: var(--accent-glow); border: 1px solid var(--border-accent); color: var(--accent); }

/* ═══════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-primary); position: relative; overflow: hidden; }

/* Calm ambient glow — login/signup only */
.auth-page::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(45, 212, 191, 0.10) 0%, transparent 65%);
    pointer-events: none;
    filter: blur(80px);
    animation: authDrift1 40s ease-in-out infinite;
}
.auth-page::after {
    content: '';
    position: absolute;
    bottom: -10%;
    left: -8%;
    width: 550px;
    height: 550px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(129, 140, 248, 0.09) 0%, transparent 65%);
    pointer-events: none;
    filter: blur(80px);
    animation: authDrift2 50s ease-in-out infinite;
}
@keyframes authDrift1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-20px, 15px); }
}
@keyframes authDrift2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(15px, -12px); }
}
.auth-card { width: 100%; max-width: 420px; background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-2xl); padding: var(--space-3xl); position: relative; z-index: 1; box-shadow: var(--shadow-deep); overflow: hidden; }
.auth-card .brand { text-align: center; margin-bottom: var(--space-2xl); }
.auth-card .brand h1 { font-family: 'Instrument Serif', serif; font-size: 2rem; color: var(--text-primary); letter-spacing: -0.01em; }
.auth-card .brand h1 span { color: var(--accent); }
.auth-card .brand p { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.auth-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: var(--space-xl); text-align: center; }
.auth-footer { text-align: center; margin-top: var(--space-xl); font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); text-decoration: none; font-weight: 500; transition: color var(--t-fast); }
.auth-footer a:hover { text-decoration: underline; }

/* ═══════════════════════════════════
   LANDING PAGE — Parallax Design
   ═══════════════════════════════════ */
.landing-page { min-height: 100vh; overflow-x: hidden; overflow-y: auto; }

/* Parallax sections & orbs */
.parallax-section { position: relative; overflow: hidden; }
.parallax-orb {
    position: absolute; border-radius: 50%; pointer-events: none;
    filter: blur(80px); opacity: 0.07; z-index: 0;
}
.orb-1 { width: 600px; height: 600px; top: -150px; right: -200px; background: radial-gradient(circle, var(--accent), transparent 70%); }
.orb-2 { width: 400px; height: 400px; bottom: -100px; left: -150px; background: radial-gradient(circle, rgba(129,140,248,0.8), transparent 70%); }
.orb-3 { width: 300px; height: 300px; top: 40%; left: 50%; background: radial-gradient(circle, rgba(251,146,60,0.6), transparent 70%); }
.orb-4 { width: 500px; height: 500px; top: -80px; left: -100px; background: radial-gradient(circle, var(--accent), transparent 70%); }
.orb-5 { width: 500px; height: 500px; bottom: -150px; right: -120px; background: radial-gradient(circle, rgba(129,140,248,0.7), transparent 70%); }
.orb-6 { width: 600px; height: 600px; top: -200px; left: 30%; background: radial-gradient(circle, var(--accent), transparent 70%); opacity: 0.05; }

/* Nav */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: var(--space-lg) var(--space-2xl); max-width: 1200px; margin: 0 auto; position: relative; z-index: 10; }
.landing-nav .brand { font-family: 'Instrument Serif', serif; font-size: 1.4rem; color: var(--text-primary); text-decoration: none; }
.landing-nav .brand span { color: var(--accent); }
.landing-nav-links { display: flex; align-items: center; gap: var(--space-md); }

/* Hero */
.landing-hero { max-width: 1200px; margin: 0 auto; padding: 5rem var(--space-2xl) 4rem; display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: center; position: relative; z-index: 1; border-radius: var(--radius-2xl); }
.hero-badge {
    display: inline-flex; align-items: center; padding: 0.35rem 1rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(45,212,191,0.15);
    margin-bottom: var(--space-lg);
}
.hero-content h1 { font-family: 'Instrument Serif', serif; font-size: 3.8rem; line-height: 1.05; letter-spacing: -0.025em; color: var(--text-primary); margin-bottom: var(--space-lg); }
.hero-content h1 em { font-style: italic; color: var(--accent); }
.hero-content > p { font-size: 1.1rem; color: var(--text-secondary); line-height: 1.7; max-width: 480px; margin-bottom: var(--space-xl); }
.hero-actions { display: flex; gap: var(--space-md); margin-bottom: var(--space-xl); }
.hero-trust { display: flex; gap: var(--space-lg); flex-wrap: wrap; }
.hero-trust-item {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.8rem; color: var(--text-muted); font-weight: 500;
}
.hero-trust-item svg { color: var(--accent); flex-shrink: 0; }
.hero-visual { position: relative; z-index: 1; }

/* Hero glucose card */
.hero-glucose-card { background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-2xl); padding: var(--space-2xl); box-shadow: var(--shadow-deep), var(--shadow-glow); }
.hero-glucose-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); }
.hero-glucose-header span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.hero-glucose-display { display: flex; align-items: flex-end; gap: var(--space-md); margin-bottom: var(--space-md); }
.hero-glucose-display .value { font-size: 4rem; font-weight: 700; color: var(--glucose-normal); line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 50px rgba(16, 185, 129, 0.3); }
.hero-glucose-display .unit { font-size: 1rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.hero-glucose-display .direction { font-size: 2rem; color: var(--glucose-normal); margin-bottom: 0.2rem; }

/* Hero curved chart */
.hero-curve-chart { margin: 0 calc(-1 * var(--space-2xl)); padding: 0; overflow: hidden; }
.hero-trajectory-svg { width: 100%; height: 80px; display: block; }
.hero-curve-line { stroke-dasharray: 800; stroke-dashoffset: 800; }
.hero-curve-fill { opacity: 0; }

.hero-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); margin-top: var(--space-lg); padding-top: var(--space-lg); border-top: 1px solid var(--glass-border); }
.hero-stats-row.hero-stats-4 { grid-template-columns: repeat(4, 1fr); gap: var(--space-sm); }
.hero-stat-item { text-align: center; }
.hero-stat-item .label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.hero-stat-item .val { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); margin-top: 2px; }
.hero-stat-item .stat-detail { font-size: 0.6rem; color: var(--text-muted); margin-top: 1px; }

/* ═══ How It Works ═══ */
.landing-how-it-works { max-width: 1200px; margin: 0 auto; padding: 5rem var(--space-2xl); position: relative; z-index: 1; border-radius: var(--radius-2xl); }
.landing-how-it-works h2 { font-family: 'Instrument Serif', serif; font-size: 2.2rem; text-align: center; color: var(--text-primary); margin-bottom: var(--space-sm); }
.section-subtitle { text-align: center; color: var(--text-muted); font-size: 0.95rem; margin-bottom: var(--space-3xl); }
.steps-grid { display: flex; align-items: flex-start; justify-content: center; gap: 0; }
.step-card {
    flex: 0 1 260px; text-align: center; padding: var(--space-xl); position: relative;
    background: var(--glass-bg); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl); transition: all var(--t-smooth);
}
.step-card:hover { border-color: var(--border-accent); transform: translateY(-4px); box-shadow: var(--shadow-glow); }
.step-number {
    position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; background: var(--accent); color: var(--bg-primary);
}
.step-icon {
    width: 56px; height: 56px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center;
    margin: var(--space-md) auto var(--space-md); background: var(--accent-glow); color: var(--accent);
}
.step-card h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin-bottom: var(--space-sm); }
.step-card p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; }
.step-connector { display: flex; align-items: center; padding-top: 3rem; flex-shrink: 0; padding: 3rem var(--space-sm) 0; }

/* ═══ Features ═══ */
.landing-features { max-width: 1200px; margin: 0 auto; padding: 4rem var(--space-2xl) 5rem; position: relative; z-index: 1; border-radius: var(--radius-2xl); }
.landing-features h2 { font-family: 'Instrument Serif', serif; font-size: 2.2rem; text-align: center; margin-bottom: var(--space-sm); color: var(--text-primary); }
.landing-features .section-subtitle { margin-bottom: var(--space-3xl); }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-xl); }
.feature-card { background: var(--glass-bg); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: var(--space-xl); transition: all var(--t-smooth); }
.feature-card:hover { border-color: var(--border-accent); transform: translateY(-4px); box-shadow: var(--shadow-glow), var(--shadow-elevated); }
.feature-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--accent-glow); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-md); color: var(--accent); }
.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: var(--space-sm); color: var(--text-primary); }
.feature-card p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }

/* ═══ Stats bar ═══ */
.landing-stats { padding: 3rem var(--space-2xl); position: relative; z-index: 1; }
.stats-bar {
    max-width: 900px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: var(--space-2xl);
    padding: var(--space-xl) var(--space-2xl);
    background: var(--glass-bg); backdrop-filter: blur(12px); border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
}
.stats-item { text-align: center; flex: 1; }
.stats-number { font-size: 2.2rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stats-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.3rem; }
.stats-divider { width: 1px; height: 40px; background: var(--glass-border); flex-shrink: 0; }

/* ═══ CTA section ═══ */
.landing-cta { padding: 5rem var(--space-2xl); position: relative; z-index: 1; border-radius: var(--radius-2xl); }
.cta-content { max-width: 600px; margin: 0 auto; text-align: center; }
.cta-content h2 { font-family: 'Instrument Serif', serif; font-size: 2.4rem; color: var(--text-primary); margin-bottom: var(--space-md); }
.cta-content > p { color: var(--text-secondary); font-size: 1.05rem; line-height: 1.7; margin-bottom: var(--space-xl); }
.cta-actions { display: flex; justify-content: center; gap: var(--space-md); }

/* ═══ Footer ═══ */
.landing-footer { border-top: 1px solid var(--glass-border); padding: 3rem var(--space-2xl) 1.5rem; position: relative; z-index: 1; }
.footer-content { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; gap: var(--space-3xl); margin-bottom: var(--space-2xl); }
.footer-brand a { font-family: 'Instrument Serif', serif; font-size: 1.3rem; color: var(--text-primary); text-decoration: none; }
.footer-brand a span { color: var(--accent); }
.footer-brand p { color: var(--text-muted); font-size: 0.82rem; margin-top: var(--space-sm); max-width: 280px; line-height: 1.5; }
.footer-links { display: flex; gap: var(--space-3xl); }
.footer-col { display: flex; flex-direction: column; gap: var(--space-sm); }
.footer-col h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: var(--space-xs); }
.footer-col a { font-size: 0.85rem; color: var(--text-secondary); text-decoration: none; transition: color var(--t-fast); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom { max-width: 1200px; margin: 0 auto; padding-top: var(--space-lg); border-top: 1px solid var(--glass-border); text-align: center; }
.footer-bottom span { font-size: 0.75rem; color: var(--text-muted); }

/* ═══════════════════════════════════
   DASHBOARD SPECIFICS
   ═══════════════════════════════════ */
.dashboard-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); margin-bottom: var(--space-xl); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); margin-bottom: var(--space-lg); }
.dashboard-full { margin-bottom: var(--space-lg); }

/* Tabs */
.tab-bar { display: flex; border-bottom: 1px solid var(--glass-border); margin-bottom: var(--space-xl); gap: 0; }
.tab-item { padding: 0.65rem 1.2rem; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--t-fast); font-family: 'DM Sans', sans-serif; }
.tab-item:hover { color: var(--text-secondary); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Empty state */
.empty-state { text-align: center; padding: var(--space-3xl) var(--space-xl); color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: var(--space-md); opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ── Setup Hub ───────────────────────────────────────────────────────── */
.setup-hub {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    border: 1px solid rgba(45, 212, 191, 0.18);
    background: linear-gradient(160deg, #111c2e 0%, #0d1525 60%, #10172a 100%);
    padding: 2.5rem 2rem 2rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 0 80px rgba(45, 212, 191, 0.04), 0 24px 48px rgba(0,0,0,0.35);
}

/* Ambient orbs */
.hub-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(70px);
}
.hub-orb-1 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(45,212,191,0.18) 0%, transparent 65%);
    top: -160px; right: -120px;
}
.hub-orb-2 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 65%);
    bottom: -120px; left: -60px;
}

/* Header section */
.hub-header {
    position: relative;
    z-index: 2;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 560px;
}

.hub-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 13px;
    border-radius: 999px;
    border: 1px solid rgba(45, 212, 191, 0.3);
    background: rgba(45, 212, 191, 0.08);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    width: fit-content;
}

.hub-badge-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    animation: hubDotBlink 2s ease-in-out infinite;
}
@keyframes hubDotBlink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

.hub-title {
    font-family: 'Instrument Serif', serif;
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}

.hub-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 280px;
}
.hub-progress-track {
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.07);
    overflow: hidden;
}
.hub-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #2dd4bf, #60a5fa);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    min-width: 2px;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.5);
}
.hub-progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Step cards grid */
.hub-cards {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.hub-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.03);
    text-decoration: none;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
                border-color 0.2s,
                background 0.2s,
                box-shadow 0.2s;
}
.hub-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: rgba(45, 212, 191, 0.3);
    background: rgba(45, 212, 191, 0.05);
    box-shadow: 0 12px 40px rgba(45, 212, 191, 0.1);
}
.hub-card:hover .hub-card-arrow { transform: translateX(4px); opacity: 1; }

.hub-card--done {
    opacity: 0.5;
    pointer-events: none;
    border-color: rgba(45, 212, 191, 0.12);
}
.hub-card--done .hub-card-icon-wrap { filter: grayscale(0.3); }

/* Top row: number + check */
.hub-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.hub-card-num {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    opacity: 0.5;
}
.hub-card-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

/* Icon */
.hub-card-icon-wrap {
    width: 48px; height: 48px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.hub-card-1 .hub-card-icon-wrap { background: rgba(45,212,191,0.12); color: #2dd4bf; }
.hub-card-2 .hub-card-icon-wrap { background: rgba(129,140,248,0.14); color: #818cf8; }
.hub-card-3 .hub-card-icon-wrap { background: rgba(251,146,60,0.12);  color: #fb923c; }

/* Info */
.hub-card-info { flex: 1; }
.hub-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}
.hub-card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.hub-card--done .hub-card-name { color: var(--text-secondary); }

/* Arrow */
.hub-card-arrow {
    color: var(--text-muted);
    opacity: 0.5;
    transition: transform 0.2s, opacity 0.2s;
    align-self: flex-end;
}

/* Mobile */
@media (max-width: 768px) {
    .hub-cards { grid-template-columns: 1fr; }
    .setup-hub { padding: 1.75rem 1.25rem 1.5rem; }
    .hub-orb-1 { width: 200px; height: 200px; top: -80px; right: -60px; }
    .hub-orb-2 { width: 180px; height: 180px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .hub-cards { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════
   MODALS
   ═══════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.15s ease; padding: var(--space-md); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg-secondary); backdrop-filter: blur(var(--glass-blur)); border: 1px solid var(--glass-border); border-radius: var(--radius-2xl); width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-deep); animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes modalSlide { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { padding: var(--space-lg) var(--space-xl); border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: var(--space-xl); }
.modal-footer { padding: var(--space-md) var(--space-xl) var(--space-xl); display: flex; justify-content: flex-end; gap: var(--space-sm); }

/* ═══════════════════════════════════
   SPINNER
   ═══════════════════════════════════ */
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.1); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* Prediction display */
.prediction-card { text-align: center; padding: var(--space-2xl); }
.prediction-values { display: flex; align-items: center; justify-content: center; gap: var(--space-2xl); margin: var(--space-xl) 0; }
.prediction-arrow { color: var(--text-muted); font-size: 1.5rem; }
.prediction-mode { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; background: var(--accent-glow); color: var(--accent); margin-left: var(--space-sm); }

/* Cache status */
.cache-status-bar { display: flex; align-items: center; justify-content: space-between; padding: var(--space-md) var(--space-lg); gap: var(--space-md); flex-wrap: wrap; }
.cache-status-info { display: flex; align-items: center; gap: var(--space-md); min-width: 0; }
.cache-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; animation: dotPulse 2s ease-in-out infinite; }
@keyframes dotPulse { 0%, 100% { box-shadow: 0 0 0 0 currentColor; } 50% { box-shadow: 0 0 0 4px transparent; } }
.cache-status-text { font-size: 0.9rem; color: var(--text-secondary); }

/* Chart containers */
.dashboard-full .card-body { min-height: 200px; }
.dashboard-full .card-body svg { width: 100%; height: auto; display: block; min-height: 180px; max-height: 60vh; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════ */
@media (max-width: 1024px) {
    .grid-4, .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .grid-3, .features-grid { grid-template-columns: repeat(2, 1fr); }
    .landing-hero { grid-template-columns: 1fr; padding-top: 3rem; gap: 2rem; }
    .hero-content { text-align: center; }
    .hero-content > p { margin-left: auto; margin-right: auto; }
    .hero-content h1 { font-size: 2.8rem; }
    .hero-actions { justify-content: center; }
    .hero-trust { justify-content: center; }
    .hero-visual { max-width: 400px; margin: 0 auto; }
    .hero-badge { margin-left: auto; margin-right: auto; }
    .steps-grid { flex-wrap: wrap; gap: var(--space-lg); }
    .step-connector { display: none; }
    .step-card { flex: 0 1 280px; }
    .stats-bar { flex-wrap: wrap; gap: var(--space-lg); }
    .stats-divider { display: none; }
    .stats-item { flex: 0 1 40%; }
    .footer-content { flex-direction: column; gap: var(--space-xl); }
}

/* ═══════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); z-index: 200; bottom: var(--bottom-nav-h); }
    .sidebar.open { transform: translateX(0); background: var(--bg-secondary); backdrop-filter: none; -webkit-backdrop-filter: none; }
    .main-content { margin-left: 0; padding-bottom: calc(var(--bottom-nav-h) + 8px); }
    .mobile-header { display: flex; }
    .bottom-nav { display: block; }

    .page-container { padding: var(--space-md) var(--space-md) var(--space-xl); max-width: 100%; }
    .page-header { text-align: center; margin-bottom: var(--space-lg); }
    .page-header.flex { flex-direction: column; gap: var(--space-sm); text-align: center; }
    .page-header.flex > div { text-align: center; }
    .page-header h2 { font-size: 1.5rem; }
    .page-header p { font-size: 0.8rem; }

    .dashboard-stats { grid-template-columns: 1fr 1fr; gap: var(--space-sm); margin-bottom: var(--space-md); }
    .stat-card { padding: var(--space-md); min-height: 80px; border-radius: var(--radius-md); }
    .stat-value { font-size: 1.4rem; }
    .stat-unit { font-size: 0.7rem; }
    .stat-label { font-size: 0.65rem; }
    .stat-subtitle { font-size: 0.7rem; }

    .dashboard-full { margin-bottom: var(--space-md); }
    .dashboard-full .card-header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); padding: var(--space-md); }
    .dashboard-full .card-header .flex { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
    .dashboard-full .card-body { padding: var(--space-sm); }

    .grid-2, .dashboard-grid { grid-template-columns: 1fr; gap: var(--space-sm); }
    .dashboard-grid .btn-lg { padding: var(--space-md) !important; font-size: 0.9rem; min-height: 48px; border-radius: var(--radius-lg); }

    .card { border-radius: var(--radius-md); }
    .card-header { padding: var(--space-md); }
    .card-body { padding: var(--space-md); }
    .card-body-compact { padding: var(--space-sm) var(--space-md); }
    .card-body-compact, .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 480px; }
    .data-table th, .data-table td { padding: 0.5rem 0.6rem; font-size: 0.8rem; white-space: nowrap; }

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

    .modal { max-width: calc(100vw - var(--space-lg)); max-height: 90vh; margin: var(--space-md); border-radius: var(--radius-xl); }
    .modal-body { padding: var(--space-md); }
    .modal-footer { padding: var(--space-md); }

    .btn { min-height: 40px; padding: 0.6rem 1rem; }
    .btn-sm { min-height: 32px; padding: 0.4rem 0.7rem; font-size: 0.75rem; }
    .grid-4 { grid-template-columns: 1fr 1fr; gap: var(--space-sm); }

    .card .flex.items-center.gap-md { flex-wrap: wrap; }
    .card .flex.items-center.gap-md .form-group { flex: 1 1 auto; min-width: 120px; }
    .card .flex.items-center.gap-md .btn { width: 100%; }

    .cache-status-bar { padding: var(--space-sm) var(--space-md); }
    .cache-status-text { font-size: 0.8rem; }

    .dashboard-full.card { max-width: 100%; overflow: hidden; }
    .dashboard-full .card-body .chart-scroll-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .dashboard-full .card-body .chart-scroll-wrapper { min-height: 300px; }
    .dashboard-full .card-body .chart-scroll-wrapper svg { display: block !important; width: 700px !important; min-width: 700px; height: 300px !important; }

    .landing-nav { padding: var(--space-md); }
    .landing-nav-links .btn-ghost { display: none; }
    .hero-content h1 { font-size: 2.2rem; }
    .hero-glucose-display .value { font-size: 3rem; }
    .hero-glucose-card { padding: var(--space-lg); }
    .hero-stats-row.hero-stats-4 { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }
    .hero-curve-chart { margin: 0 calc(-1 * var(--space-lg)); }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .hero-actions .btn { justify-content: center; }
    .hero-trust { flex-direction: column; align-items: center; gap: var(--space-sm); }
    .features-grid { grid-template-columns: 1fr; }
    .landing-how-it-works { padding: 3rem var(--space-md); }
    .landing-how-it-works h2 { font-size: 1.8rem; }
    .steps-grid { flex-direction: column; align-items: center; }
    .step-card { flex: 1 1 auto; width: 100%; max-width: 320px; }
    .landing-features { padding: 3rem var(--space-md); }
    .landing-features h2 { font-size: 1.8rem; }
    .landing-stats { padding: 2rem var(--space-md); }
    .stats-bar { padding: var(--space-lg); gap: var(--space-md); }
    .stats-number { font-size: 1.6rem; }
    .stats-item { flex: 0 1 45%; }
    .landing-cta { padding: 3rem var(--space-md); }
    .cta-content h2 { font-size: 1.8rem; }
    .cta-actions { flex-direction: column; align-items: stretch; }
    .landing-footer { padding: 2rem var(--space-md) 1rem; }
    .footer-links { gap: var(--space-xl); }
    .footer-content { gap: var(--space-lg); }
    .landing-hero { padding: 2.5rem var(--space-md) 2rem; }
}

/* ═══════════════════════════════════
   RESPONSIVE — Small phones
   ═══════════════════════════════════ */
@media (max-width: 380px) {
    .page-container { padding: var(--space-sm) var(--space-sm) var(--space-lg); }
    .dashboard-stats { grid-template-columns: 1fr; gap: var(--space-sm); }
    .stat-card { display: flex; align-items: center; justify-content: space-between; padding: var(--space-sm) var(--space-md); min-height: auto; }
    .stat-card::before { width: 3px; height: 100%; right: unset; }
    .stat-value { font-size: 1.3rem; }
    .page-header h2 { font-size: 1.3rem; }
    .grid-4 { grid-template-columns: 1fr; }
    .modal { max-width: calc(100vw - var(--space-md)); margin: var(--space-xs); }
}

/* ═══════════════════════════════════
   UTILITIES
   ═══════════════════════════════════ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-variant-numeric: tabular-nums; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* ═══════════════════════════════════
   FORGOT PASSWORD (Login page)
   ═══════════════════════════════════ */
.btn-link-subtle {
    background: none; border: none; padding: 0;
    color: var(--accent); font-size: 0.9rem;
    cursor: pointer; text-decoration: none;
    transition: opacity 0.2s ease;
}
.btn-link-subtle:hover { opacity: 0.8; text-decoration: underline; }

.fp-step-content { margin-top: var(--space-md); padding-bottom: var(--space-lg); }

.fp-icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto var(--space-md);
}

.fp-code-input {
    max-width: 200px; letter-spacing: 6px;
    font-size: 1.3rem; text-align: center;
    font-weight: 700; margin: 0 auto;
    display: block;
}

.fp-success-content { text-align: center; }
.fp-success-icon {
    width: 80px; height: 80px; border-radius: 50%;
    background: var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

/* ═══════════════════════════════════
   FEEDBACK PAGE
   ═══════════════════════════════════ */
.feedback-page { position: relative; }

.feedback-banner-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

.feedback-categories {
    display: flex; flex-wrap: wrap; gap: var(--space-sm);
}

.feedback-cat-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-md);
    background: var(--bg-primary); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 0.9rem;
    cursor: pointer; transition: all 0.2s ease;
}
.feedback-cat-btn:hover {
    border-color: var(--accent); color: var(--text-primary);
    background: rgba(45, 212, 191, 0.05);
}
.feedback-cat-btn.active {
    border-color: var(--accent); color: var(--accent);
    background: var(--accent-glow); font-weight: 600;
}
.feedback-cat-icon { font-size: 1.1rem; }

.feedback-stars {
    display: flex; align-items: center; gap: 6px;
}
.feedback-star {
    background: none; border: none; padding: 4px;
    cursor: pointer; transition: transform 0.2s ease;
}
.feedback-star:hover { transform: scale(1.2); }
.feedback-star.active svg,
.feedback-star.hover svg { filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.4)); }
.feedback-rating-label {
    margin-left: 12px; font-size: 0.9rem;
    color: var(--accent); font-weight: 600;
}

.feedback-textarea {
    resize: vertical; min-height: 120px;
    font-family: 'DM Sans', sans-serif;
}
.feedback-char-count {
    text-align: right; font-size: 0.8rem;
    color: var(--text-muted); margin-top: 4px;
}

.feedback-submit-btn {
    width: 100%; max-width: 320px;
}

.feedback-image-previews {
    margin-top: 0.75rem;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.feedback-image-preview-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.4rem 0.7rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.85rem; color: var(--text-secondary);
    overflow: hidden;
}
.feedback-image-preview-item span:nth-child(2) {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.feedback-success-card { overflow: hidden; position: relative; }
.feedback-success-icon {
    width: 88px; height: 88px; border-radius: 50%;
    background: var(--accent-glow);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .feedback-categories { gap: var(--space-xs); }
    .feedback-cat-btn { padding: 8px 14px; font-size: 0.85rem; }
    .feedback-submit-btn { max-width: 100%; }
}

/* Selection & focus */
::selection { background: rgba(45, 212, 191, 0.3); color: var(--text-primary); }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ═══════════════════════════════════════════════════
   LANGUAGE SWITCHER
   ═══════════════════════════════════════════════════ */

.lang-switcher {
    position: relative;
    z-index: 1000;
}

.lang-switcher-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: var(--radius-sm, 8px);
    color: var(--text-secondary, rgba(255,255,255,0.7));
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
}
.lang-switcher-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary, #fff);
    border-color: var(--accent, #2dd4bf);
}

.lang-switcher-label {
    font-weight: 600;
    letter-spacing: 0.5px;
}

.lang-switcher-chevron {
    transition: transform 0.2s ease;
    opacity: 0.6;
}
.lang-switcher-chevron.open {
    transform: rotate(180deg);
}

.lang-switcher-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.lang-switcher-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    overflow: hidden;
    z-index: 1001;
    animation: langDropIn 0.15s ease;
}

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

.lang-switcher-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-secondary, rgba(255,255,255,0.7));
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
    text-align: left;
}
.lang-switcher-option:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary, #fff);
}
.lang-switcher-option.active {
    color: var(--accent, #2dd4bf);
    background: rgba(45,212,191,0.08);
}
.lang-switcher-option + .lang-switcher-option {
    border-top: 1px solid var(--border, rgba(255,255,255,0.06));
}

.lang-option-name { flex: 1; }
.lang-option-code {
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    opacity: 0.6;
}
.lang-option-check {
    color: var(--accent, #2dd4bf);
    flex-shrink: 0;
}

/* Landing page: position language switcher in nav */
.landing-nav { position: relative; }
.landing-nav .lang-switcher { margin-left: auto; }
.landing-nav-links { display: flex; align-items: center; gap: 0.5rem; }

/* Mobile header: language switcher positioning */
.mobile-header .lang-switcher-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════
   TUTORIAL OVERLAY
   ═══════════════════════════════════════════════════ */

.tutorial-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}

.tutorial-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl, 20px);
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
    padding: 2.5rem 2rem 2rem;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    position: relative;
}

/* Subtle glow border */
.tutorial-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(var(--accent-rgb, 99, 102, 241), 0.4), transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.tutorial-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-lg);
}

.tutorial-step-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: var(--space-sm);
}

.tutorial-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    line-height: 1.3;
}

.tutorial-body {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: var(--space-xl);
}

.tutorial-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: var(--space-xl);
}

.tutorial-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.25s, transform 0.25s;
}

.tutorial-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

/* X close button */
.tutorial-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    flex-shrink: 0;
}
.tutorial-close-btn:hover {
    background: var(--bg-tertiary, var(--bg-primary));
    color: var(--text-primary);
    border-color: var(--accent);
}

/* Nav row: Back (left) + Continue (right) */
.tutorial-nav-btns {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-top: var(--space-xs);
}

.tutorial-continue-btn {
    min-width: 130px;
}

/* Back button hidden on step 0 but still occupies space so Continue stays right */
.tutorial-btn-invisible {
    visibility: hidden;
    pointer-events: none;
}

@media (max-width: 480px) {
    .tutorial-card {
        padding: 2rem 1.25rem 1.5rem;
    }
    .tutorial-title {
        font-size: 1.2rem;
    }
    .tutorial-nav-btns {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .tutorial-continue-btn { width: 100%; justify-content: center; }
    .tutorial-back-btn { width: 100%; justify-content: center; }
    .tutorial-btn-invisible { display: none; }
}

/* ─── Glucose Trend Arrow ─────────────────────────────────── */
.glucose-trend-arrow {
    display: inline-block;
    font-size: 1.1rem;
    line-height: 1;
    transition: color 0.3s ease;
}

/* ─── Time In Range Widget ────────────────────────────────── */
.tir-bar-wrap {
    margin: 0.75rem 0 1rem;
}
.tir-bar {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
    gap: 2px;
}
.tir-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    min-width: 2px;
    transition: width 0.4s ease;
    border-radius: 3px;
}
.tir-verylow  { background: #7c3aed; }
.tir-low      { background: #f59e0b; }
.tir-inrange  { background: #22c55e; }
.tir-high     { background: #f97316; }
.tir-veryhigh { background: #ef4444; }

.tir-legend {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.tir-legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.tir-inrange-row { font-weight: 600; }
.tir-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tir-verylow-dot  { background: #7c3aed; }
.tir-low-dot      { background: #f59e0b; }
.tir-inrange-dot  { background: #22c55e; }
.tir-high-dot     { background: #f97316; }
.tir-veryhigh-dot { background: #ef4444; }

.tir-legend-label { flex: 1; color: var(--text-primary); }
.tir-range-hint   { color: var(--text-muted); font-size: 0.78rem; font-weight: 400; }
.tir-legend-pct   { font-weight: 700; min-width: 44px; text-align: right; }
.tir-legend-count { color: var(--text-muted); font-size: 0.78rem; min-width: 80px; text-align: right; }

/* ─── Admin Setup Completeness ────────────────────────────── */
.admin-completeness-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border-subtle, #334155);
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 1.25rem;
}
.admin-completeness-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.admin-completeness-score { text-align: right; }
.admin-completeness-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-primary, #0f172a);
    gap: 2px;
    margin-bottom: 0.75rem;
}
.admin-comp-seg { height: 100%; min-width: 2px; transition: width 0.4s ease; border-radius: 3px; }
.admin-comp-full    { background: #22c55e; }
.admin-comp-partial { background: #eab308; }
.admin-comp-none    { background: #475569; }
.admin-completeness-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.admin-comp-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.admin-comp-dot-full    { background: #22c55e; }
.admin-comp-dot-partial { background: #eab308; }
.admin-comp-dot-none    { background: #475569; }

/* ─── Admin Feedback Sentiment Tag ───────────────────────── */
.admin-fb-tag-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.admin-fb-tag-btns {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
}
.admin-tag-btn {
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    border: 1.5px solid var(--tag-color, #64748b);
    background: transparent;
    color: var(--tag-color, #64748b);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}
.admin-tag-btn:hover {
    background: var(--tag-color, #64748b);
    color: #fff;
}
.admin-tag-btn.active {
    background: var(--tag-color, #64748b);
    color: #fff;
}
.admin-tag-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-tag-clear {
    --tag-color: #64748b;
    font-size: 0.7rem;
}

/* Tag badge in collapsed card header */
.admin-tag-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.admin-tag-bug     { background: rgba(239,68,68,0.15); color: #ef4444; }
.admin-tag-feature { background: rgba(96,165,250,0.15); color: #60a5fa; }
.admin-tag-praise  { background: rgba(34,197,94,0.15); color: #22c55e; }
