/* =========================================================
 C ALCIUM — RedLine Education Design System v1.1                       *
 Light-first · Mobile-first · Premium · Distinctive
 ========================================================= */

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

/* ---------- THEME TOKENS ---------- */
:root {
    /* Brand */
    --blue: #2563EB;
    --blue-hover: #1D4ED8;
    --blue-soft: #EFF6FF;
    --blue-deep: #1E3A8A;
    --blue-ink: #0C1E4A;
    --red: #DC2626;
    --red-soft: #FEF2F2;
    --red-deep: #991B1B;
    --gold: #F59E0B;
    --gold-soft: #FFFBEB;
    --gold-deep: #B45309;
    --green: #10B981;
    --green-soft: #ECFDF5;
    --purple: #8B5CF6;
    --purple-soft: #F5F3FF;

    /* Surfaces */
    --bg: #F6F8FC;
    --bg-2: #EEF2F9;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --border: #E2E8F0;
    --border-2: #CBD5E1;

    /* Text */
    --text: #0B1220;
    --text-2: #475569;
    --text-3: #94A3B8;
    --text-inv: #FFFFFF;

    /* Shadows — multi-layer for depth */
    --sh-1: 0 1px 2px rgba(11, 18, 32, 0.05);
    --sh-2: 0 2px 4px rgba(11, 18, 32, 0.04), 0 4px 12px rgba(11, 18, 32, 0.06);
    --sh-3: 0 4px 8px rgba(11, 18, 32, 0.04), 0 12px 32px rgba(11, 18, 32, 0.10);
    --sh-glow-blue: 0 8px 24px rgba(37, 99, 235, 0.20);
    --sh-glow-gold: 0 8px 24px rgba(245, 158, 11, 0.20);

    /* Radii */
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 24px;
    --r-2xl: 32px;
    --r-full: 9999px;

    /* Layout */
    --nav-h: 62px;
    --tab-h: 64px;
    --max-w: 1200px;
    --pad: 16px;

    /* Gradients — the signature RedLine trio */
    --grad-brand: linear-gradient(135deg, var(--red) 0%, var(--red) 35%, var(--blue) 65%, var(--blue) 100%);
    --grad-blue: linear-gradient(135deg, #3B82F6 0%, #2563EB 50%, #1E40AF 100%);
    --grad-gold: linear-gradient(135deg, #FBBF24 0%, #F59E0B 50%, #D97706 100%);
    --grad-blue-soft: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    --grad-surface: linear-gradient(135deg, #FFFFFF 0%, #F6F8FC 100%);
    --grad-header: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(255,255,255,0) 100%);
}

html.dark {
    --blue: #3B82F6;
    --blue-hover: #60A5FA;
    --blue-soft: rgba(59, 130, 246, 0.14);
    --blue-deep: #93C5FD;
    --blue-ink: #DBEAFE;
    --red: #EF4444;
    --red-soft: rgba(239, 68, 68, 0.14);
    --red-deep: #FCA5A5;
    --gold: #FBBF24;
    --gold-soft: rgba(251, 191, 36, 0.14);
    --gold-deep: #FCD34D;
    --green: #34D399;
    --green-soft: rgba(52, 211, 153, 0.14);
    --purple: #A78BFA;
    --purple-soft: rgba(167, 139, 250, 0.14);

    --bg: #0A0F1C;
    --bg-2: #0F172A;
    --surface: #141B2D;
    --surface-2: #1E293B;
    --border: #1E2A44;
    --border-2: #334155;

    --text: #F1F5F9;
    --text-2: #CBD5E1;
    --text-3: #64748B;

    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sh-2: 0 2px 4px rgba(0, 0, 0, 0.30), 0 4px 12px rgba(0, 0, 0, 0.35);
    --sh-3: 0 4px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.45);
    --sh-glow-blue: 0 8px 24px rgba(59, 130, 246, 0.30);
    --sh-glow-gold: 0 8px 24px rgba(251, 191, 36, 0.25);
    --grad-surface: linear-gradient(135deg, #141B2D 0%, #0F172A 100%);
}

/* ---------- BASE ---------- */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
body.no-scroll { overflow: hidden; }

/* Soft dot texture for depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, var(--border-2) 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.35;
    pointer-events: none;
    z-index: -1;
    mask-image: linear-gradient(180deg, black, transparent 60%);
    -webkit-mask-image: linear-gradient(180deg, black, transparent 60%);
}
html.dark body::before { opacity: 0.15; }

/* ---------- TYPOGRAPHY ---------- */
h1 { font-size: 1.75rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.025em; }
h2 { font-size: 1.375rem; font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; }
h3 { font-size: 1.125rem; font-weight: 700; line-height: 1.35; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-2); }
small, .text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-3); }
.text-strong { color: var(--text); font-weight: 600; }

/* Gradient text — signature */
.text-gradient-blue {
    background: linear-gradient(135deg, #1E3A8A 0%, #2563EB 60%, #3B82F6 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
html.dark .text-gradient-blue {
    background: linear-gradient(135deg, #BFDBFE 0%, #3B82F6 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.text-gradient-gold {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.text-gradient-brand {
    background: var(--grad-brand);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---------- CONTAINER ---------- */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--pad); }

/* ---------- TOP NAV ---------- */
.c-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--nav-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    transition: box-shadow 0.2s ease;
}
html.dark .c-nav { background: rgba(20, 27, 45, 0.92); }
.c-nav.scrolled { box-shadow: var(--sh-2); }
.c-nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--pad);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.c-logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.c-logo .r { color: var(--red); }
.c-logo .l { color: var(--blue); }
.c-logo-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--grad-brand);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 900; font-size: 0.75rem;
    box-shadow: var(--sh-glow-blue);
    letter-spacing: -0.5px;
}
.c-nav-links { display: none; align-items: center; gap: 4px; }
.c-nav-link {
    padding: 8px 14px;
    border-radius: var(--r);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-2);
    transition: all 0.15s;
    position: relative;
}
.c-nav-link:hover { background: var(--bg-2); color: var(--text); }
.c-nav-link.active { color: var(--blue); background: var(--blue-soft); }
.c-nav-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- ICON BUTTON ---------- */
.c-icon-btn {
    width: 40px; height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.c-icon-btn:hover { background: var(--bg-2); color: var(--text); transform: translateY(-1px); }
.c-icon-btn .dot {
    position: absolute; top: 8px; right: 8px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid var(--surface);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ---------- BUTTONS ---------- */
.c-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--r);
    font-weight: 700;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.2, 0.9, 0.3, 1);
    text-align: center;
    white-space: nowrap;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.c-btn-primary {
    background: var(--grad-blue);
    color: white;
    box-shadow: var(--sh-glow-blue);
}
.c-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.30);
    filter: brightness(1.06);
}
.c-btn-primary:active { transform: translateY(0); }
.c-btn-primary::after {
    content: '';
    position: absolute; top: 0; left: -120%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    transform: skewX(-25deg);
    transition: left 0.6s ease;
}
.c-btn-primary:hover::after { left: 130%; }
.c-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.c-btn-primary:disabled::after { display: none; }

.c-btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.c-btn-secondary:hover { background: var(--bg-2); border-color: var(--blue); color: var(--blue); transform: translateY(-2px); }

.c-btn-ghost { background: transparent; color: var(--text-2); }
.c-btn-ghost:hover { background: var(--bg-2); color: var(--text); }

.c-btn-danger { background: var(--red); color: white; box-shadow: 0 8px 24px rgba(220, 38, 38, 0.20); }
.c-btn-danger:hover { background: var(--red-deep); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(220, 38, 38, 0.30); }

.c-btn-gold { background: var(--grad-gold); color: white; box-shadow: var(--sh-glow-gold); }
.c-btn-gold:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(245, 158, 11, 0.30); filter: brightness(1.06); }

.c-btn-block { width: 100%; }
.c-btn-sm { min-height: 36px; padding: 0 14px; font-size: 0.8125rem; }
.c-btn-lg { min-height: 52px; padding: 0 28px; font-size: 1rem; }

/* ---------- CARDS ---------- */
.c-card {
    background: var(--grad-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: var(--sh-1);
    position: relative;
}
.c-card-hover:hover {
    border-color: var(--blue);
    box-shadow: var(--sh-3), 0 0 0 1px rgba(37, 99, 235, 0.08);
    transform: translateY(-3px);
}
.c-card-flat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }

/* ---------- STAT CARD (with decorative orb) ---------- */
.stat-card-v2 {
    position: relative;
    overflow: hidden;
    padding: 20px;
    background: var(--grad-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-1);
}
.stat-card-v2::before {
    content: '';
    position: absolute;
    top: -60px; right: -60px;
    width: 140px; height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--blue-soft) 0%, transparent 70%);
    pointer-events: none;
}
.stat-card-v2.gold::before { background: radial-gradient(circle, var(--gold-soft) 0%, transparent 70%); }
.stat-card-v2.green::before { background: radial-gradient(circle, var(--green-soft) 0%, transparent 70%); }
.stat-card-v2.red::before { background: radial-gradient(circle, var(--red-soft) 0%, transparent 70%); }
.stat-card-v2 .lbl { position: relative; font-size: 0.7rem; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card-v2 .num { position: relative; font-size: 1.85rem; font-weight: 800; color: var(--text); margin-top: 4px; line-height: 1.1; }
.stat-card-v2.blue .num { color: var(--blue); }
.stat-card-v2.gold .num { color: var(--gold); }
.stat-card-v2.green .num { color: var(--green); }
.stat-card-v2.red .num { color: var(--red); }
.stat-card-v2 .ic {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--r);
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 0.9rem;
    margin-bottom: 8px;
}
.stat-card-v2.gold .ic { background: var(--gold-soft); color: var(--gold); }
.stat-card-v2.green .ic { background: var(--green-soft); color: var(--green); }
.stat-card-v2.red .ic { background: var(--red-soft); color: var(--red); }

/* ---------- INPUTS ---------- */
.c-input, .c-select, .c-textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    color: var(--text);
    font-size: 0.9375rem;
    transition: all 0.15s;
    outline: none;
    font-family: inherit;
}
.c-input::placeholder, .c-textarea::placeholder { color: var(--text-3); }
.c-input:focus, .c-select:focus, .c-textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
    background: var(--surface);
}
.c-textarea { min-height: 90px; resize: vertical; padding: 12px 14px; line-height: 1.5; }
.c-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

/* ---------- CHIPS / BADGES ---------- */
.c-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-full);
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--bg-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.c-chip-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.c-chip-gold { background: var(--gold-soft); color: var(--gold-deep); border-color: transparent; }
html.dark .c-chip-gold { color: var(--gold); }
.c-chip-red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.c-chip-green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.c-chip-purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }

/* ---------- SECTION HEADERS (with accent bar) ---------- */
.c-section { margin-bottom: 32px; }
.c-section-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.c-section-title {
    display: flex; align-items: center; gap: 10px;
    font-size: 1.125rem; font-weight: 800;
    color: var(--text);
    position: relative;
    padding-left: 14px;
}
.c-section-title::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 20px;
    border-radius: 4px;
    background: var(--grad-brand);
}
.c-section-title i { color: var(--blue); font-size: 1rem; }

/* ---------- MODAL ---------- */
.c-modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: flex-end; justify-content: center; padding: 0; }
.c-modal.open { display: flex; }
.c-modal-bg {
    position: absolute; inset: 0;
    background: rgba(11, 18, 32, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.c-modal-panel {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90dvh;
    background: var(--surface);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding: 20px;
    overflow-y: auto;
    animation: sheetUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: 0 -20px 60px rgba(11, 18, 32, 0.25);
}
.c-modal-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--grad-brand);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
}
@keyframes sheetUp {
    from { transform: translateY(24px); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}
.c-modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.c-modal-title { font-size: 1.125rem; font-weight: 800; }
@media (min-width: 640px) {
    .c-modal { align-items: center; padding: 20px; }
    .c-modal-panel { border-radius: var(--r-2xl); animation: modalPop 0.2s ease; }
    .c-modal-panel::before { border-radius: var(--r-2xl); }
    @keyframes modalPop {
        from { transform: scale(0.96); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }
}

/* ---------- TOAST ---------- */
.c-toasts {
    position: fixed;
    bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
    left: 50%; transform: translateX(-50%);
    z-index: 300;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
    width: calc(100% - 32px);
    max-width: 400px;
}
.c-toast {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 12px 16px;
    box-shadow: var(--sh-3);
    font-size: 0.875rem;
    font-weight: 600;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
    position: relative;
    overflow: hidden;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.c-toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.c-toast.success::before { background: var(--green); }
.c-toast.error::before { background: var(--red); }
.c-toast.info::before { background: var(--blue); }
.c-toast i { font-size: 1.1rem; }
.c-toast.success i { color: var(--green); }
.c-toast.error i { color: var(--red); }
.c-toast.info i { color: var(--blue); }

/* ---------- BOTTOM TAB BAR ---------- */
.c-tabs {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 45;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
}
html.dark .c-tabs { background: rgba(20, 27, 45, 0.95); }
.c-tab {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    transition: color 0.15s;
    position: relative;
}
.c-tab i { font-size: 1.15rem; transition: transform 0.15s; }
.c-tab.active { color: var(--blue); }
.c-tab.active i { transform: translateY(-1px); }
.c-tab.active::before {
    content: '';
    position: absolute; top: 0;
    width: 36px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--grad-blue);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* ---------- FOOTER ---------- */
.c-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 40px 0 24px;
    margin-top: 48px;
    padding-bottom: calc(24px + var(--tab-h) + env(safe-area-inset-bottom));
    position: relative;
}
.c-footer::before {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 120px; height: 3px;
    background: var(--grad-brand);
    border-radius: 0 0 4px 4px;
}
.c-footer-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 640px) { .c-footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; } }
.c-footer h4 {
    font-size: 0.7rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-3); margin-bottom: 12px;
}
.c-footer ul { display: flex; flex-direction: column; gap: 8px; }
.c-footer a { font-size: 0.8125rem; color: var(--text-2); transition: color 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.c-footer a:hover { color: var(--blue); }
.c-footer-bottom {
    margin-top: 32px; padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-3);
}

/* ---------- EMPTY STATE ---------- */
.c-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
}
.c-empty .icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px;
    border-radius: var(--r-2xl);
    background: var(--grad-blue-soft);
    color: var(--blue);
    font-size: 1.6rem;
    margin-bottom: 14px;
    box-shadow: var(--sh-1);
}
html.dark .c-empty .icon { background: var(--blue-soft); }
.c-empty h3 { color: var(--text); font-size: 1rem; margin-bottom: 6px; }
.c-empty p { font-size: 0.8125rem; max-width: 320px; margin: 0 auto; }

/* ---------- PROGRESS BAR ---------- */
.c-progress {
    width: 100%; height: 8px;
    background: var(--bg-2);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
}
.c-progress-bar {
    height: 100%;
    background: var(--grad-blue);
    border-radius: 99px;
    transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.4);
}
.c-progress.gold .c-progress-bar {
    background: var(--grad-gold);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* ---------- RANK BADGES (for leaderboards) ---------- */
.rank-medal {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--r-full);
    font-weight: 800; font-size: 0.875rem;
    background: var(--bg-2);
    color: var(--text-2);
    flex-shrink: 0;
    box-shadow: var(--sh-1);
}
.rank-medal.r1 {
    background: var(--grad-gold);
    color: white;
    box-shadow: var(--sh-glow-gold);
}
.rank-medal.r2 {
    background: linear-gradient(135deg, #E5E7EB, #9CA3AF);
    color: #1F2937;
}
.rank-medal.r3 {
    background: linear-gradient(135deg, #FED7AA, #C2410C);
    color: white;
}
.rank-medal.r4plus { background: var(--bg-2); color: var(--text-3); }

/* ---------- HELPERS ---------- */
.stack { display: flex; flex-direction: column; }
.stack-2 { gap: 8px; }
.stack-3 { gap: 12px; }
.stack-4 { gap: 16px; }
.stack-6 { gap: 24px; }
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid-sm-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid-md-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid-md-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- DESKTOP BREAKPOINT ---------- */
@media (min-width: 768px) {
    body { padding-bottom: 0; }
    .c-tabs { display: none; }
    .c-nav-links { display: flex; }
    .c-footer { padding-bottom: 24px; }
    .c-toasts { bottom: 16px; }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- MINIMAL MODE (perf) ---------- */
html.minimal-mode body::before { display: none !important; }
html.minimal-mode .c-nav, html.minimal-mode .c-tabs { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
html.minimal-mode .c-card, html.minimal-mode .stat-card-v2 { box-shadow: none !important; }
html.minimal-mode .c-btn-primary::after { display: none !important; }

/* ---------- ADMIN EXTENSIONS ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.admin-tabs {
    display: flex; gap: 6px; overflow-x: auto;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    scrollbar-width: none;
    position: sticky;
    top: 62px;
    background: var(--bg);
    z-index: 30;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
    flex-shrink: 0;
    padding: 10px 18px;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.admin-tab:hover { border-color: var(--blue); color: var(--blue); }
.admin-tab.active { background: var(--grad-blue); border-color: transparent; color: white; box-shadow: var(--sh-glow-blue); }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s; }

/* Quick nav cards */
.quick-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.quick-card {
    display: flex; align-items: center; gap: 12px;
    padding: 14px;
    background: var(--grad-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.quick-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--sh-2);
}
.quick-card .qi {
    width: 40px; height: 40px;
    border-radius: var(--r);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.quick-card .qt { font-weight: 700; font-size: 0.875rem; color: var(--text); }
.quick-card .qd { font-size: 0.7rem; color: var(--text-3); }

/* Tables */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.admin-table th {
    text-align: left; padding: 12px;
    font-size: 0.7rem; font-weight: 800;
    color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
}
.admin-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--bg-2); }

/* Exam list grid */
.exam-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.exam-list-row {
    padding: 14px;
    background: var(--grad-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex; gap: 12px; align-items: center;
    transition: all 0.15s;
    box-shadow: var(--sh-1);
}
.exam-list-row:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: var(--sh-2); }
.exam-list-row .icon { width: 42px; height: 42px; border-radius: var(--r); display: flex; align-items: center; justify-content: center; color: white; font-size: 1rem; flex-shrink: 0; }
.exam-list-row .info { flex: 1; min-width: 0; }
.exam-list-row .info h4 { font-size: 0.875rem; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.exam-list-row .info p { font-size: 0.7rem; color: var(--text-3); }
.exam-list-row .actions { display: flex; gap: 4px; }

/* Editor sections */
.editor-section {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--surface);
}
.editor-section-head {
    padding: 14px 16px;
    background: var(--bg-2);
    font-weight: 700;
    font-size: 0.8125rem;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer;
    list-style: none;
}
.editor-section-head::-webkit-details-marker { display: none; }
.editor-section-head::after { content: '▾'; color: var(--text-3); transition: transform 0.2s; }
.editor-section[open] .editor-section-head::after { transform: rotate(180deg); }
.editor-section-body { padding: 16px; }

.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* =========================================================
 *  AUTH MODAL — modern two-column redesign
 *  Keeps all existing IDs so auth.js works unchanged.
 *  ========================================================= */
#authModal .c-modal-panel {
padding: 0;
max-width: 900px;
width: 100%;
overflow: hidden;
background: var(--surface);
}
@media (max-width: 899px) {
    #authModal .c-modal-panel { max-width: 520px; }
}
@media (max-width: 640px) {
    #authModal .c-modal-panel { max-width: 100%; }
}

.auth-shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 520px;
}
@media (min-width: 900px) {
    .auth-shell { grid-template-columns: 380px 1fr; }
}

/* ---------- Left branding panel ---------- */
.auth-side {
    display: none;
    background:
    radial-gradient(circle at 20% 20%, rgba(239,68,68,0.18), transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(59,130,246,0.22), transparent 55%),
    linear-gradient(135deg, #0c1445 0%, #0a0f2a 100%);
    color: #f1f5f9;
    padding: 32px 28px;
    position: relative;
    overflow: hidden;
}
@media (min-width: 900px) { .auth-side { display: flex; } }
.auth-side::before {
    content: '';
    position: absolute; inset: 0;
    background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    mask-image: radial-gradient(ellipse at center, black 0%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 72%);
    pointer-events: none;
}
.auth-side-inner {
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: relative;
    z-index: 1;
    width: 100%;
}
.auth-logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 900; font-size: 1.05rem; letter-spacing: -0.02em;
}
.auth-logo-mark {
    width: 36px; height: 36px; border-radius: 11px;
    background: linear-gradient(135deg, #EF4444 0%, #FBBF24 50%, #3B82F6 100%);
    color: #fff; font-size: 0.72rem; font-weight: 900;
    display: inline-flex; align-items: center; justify-content: center;
    letter-spacing: -0.5px;
    box-shadow: 0 6px 16px rgba(239,68,68,0.28);
}
.auth-logo .r { color: #dc2626; }
.auth-logo .b { color: #3b82f6; }
.auth-side h2 {
    font-size: 1.75rem; font-weight: 900; line-height: 1.15;
    letter-spacing: -0.02em; color: #fff; margin: 0;
}
.auth-side p {
    font-size: 0.875rem; color: rgba(203,213,225,0.85);
    line-height: 1.55; margin: 0;
}
.auth-features {
    list-style: none; padding: 0; margin: 4px 0 0;
    display: flex; flex-direction: column; gap: 12px;
}
.auth-features li {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.8125rem; color: rgba(226,232,240,0.95); font-weight: 500;
}
.auth-features li i {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.72rem;
    background: rgba(251,191,36,0.14); color: var(--gold);
    flex-shrink: 0;
}
.auth-side-foot {
    margin-top: auto; font-size: 0.72rem;
    color: rgba(148,163,184,0.9);
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---------- Right form panel ---------- */
.auth-form-panel {
    padding: 32px 28px;
    position: relative;
    display: flex; flex-direction: column; gap: 20px;
    overflow-y: auto;
    max-height: 90dvh;
}
@media (max-width: 640px) {
    .auth-form-panel { padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); max-height: 95dvh; }
}

.auth-close {
    position: absolute; top: 14px; right: 14px;
    width: 34px; height: 34px; border-radius: 50%;
    border: none; background: rgba(255,255,255,0.05);
    color: var(--text-3); font-size: 0.9rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.auth-close:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Tabs ---------- */
.auth-tabs {
    display: inline-flex;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    padding: 4px; gap: 2px;
    align-self: flex-start;
    max-width: 100%;
}
.auth-tab {
    padding: 8px 20px; border-radius: var(--r-full);
    border: none; background: transparent;
    color: var(--text-3);
    font-family: inherit; font-size: 0.8125rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s;
    white-space: nowrap;
}
.auth-tab.active {
    background: var(--surface); color: var(--text);
    box-shadow: var(--sh-1);
}
.auth-tab:not(.active):hover { color: var(--text-2); }
@media (max-width: 420px) {
    .auth-tab { padding: 7px 14px; font-size: 0.75rem; }
}

/* ---------- Titles ---------- */
.auth-title {
    font-size: 1.35rem; font-weight: 800;
    letter-spacing: -0.02em; color: var(--text); margin: 0;
}
.auth-sub {
    font-size: 0.8125rem; color: var(--text-3);
    margin: -12px 0 0; line-height: 1.5;
}

/* ---------- Form ---------- */
.auth-form {
    display: flex; flex-direction: column; gap: 14px;
}
.auth-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 560px) { .auth-grid { grid-template-columns: 1fr; } }

.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > label {
    font-size: 0.68rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-3);
}

.auth-input-wrap {
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px; min-height: 46px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r);
    transition: all 0.15s;
}
.auth-input-wrap:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-soft);
}
.auth-input-wrap > i {
    color: var(--text-3); font-size: 0.85rem;
    width: 16px; text-align: center; flex-shrink: 0;
}
.auth-input-wrap > input,
.auth-input-wrap > select {
    flex: 1; min-width: 0;
    background: transparent; border: none; outline: none;
    color: var(--text); font-size: 0.9rem;
    padding: 10px 0; font-family: inherit;
}
.auth-input-wrap > select { cursor: pointer; padding-right: 4px; }
.auth-input-wrap > select option { background: var(--surface-solid); color: var(--text); }
.auth-input-wrap > input::placeholder { color: var(--text-3); }

.auth-eye {
    background: none; border: none;
    padding: 6px; margin-right: -8px;
    color: var(--text-3); cursor: pointer;
    border-radius: var(--r-sm);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.auth-eye:hover { color: var(--text); }

.auth-forgot {
    align-self: flex-end;
    background: none; border: none;
    color: var(--blue); font-family: inherit;
    font-size: 0.75rem; font-weight: 700;
    cursor: pointer; padding: 2px 0; margin-top: -6px;
}
.auth-forgot:hover { text-decoration: underline; }

.auth-submit {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 50px; padding: 0 24px;
    border-radius: var(--r); border: none;
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: #fff; font-family: inherit;
    font-size: 0.9375rem; font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(37,99,235,0.28);
    transition: all 0.15s; margin-top: 4px;
}
.auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(37,99,235,0.4);
    filter: brightness(1.05);
}
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.auth-foot {
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center; font-size: 0.75rem;
    color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    gap: 6px;
}

/* Hide old toggle texts — tabs replace them */
.auth-shell #toggleText,
.auth-shell #toggleBtn { display: none !important; }

/* Mobile: nicer bottom-sheet behaviour for this specific modal */
@media (max-width: 640px) {
    #authModal .auth-shell { min-height: 0; }
    .auth-title { font-size: 1.2rem; }
}

/* =========================================================
 *  PHONE FIT — perfect margins & spacing on small screens
 *  ========================================================= */

/* ---------- Standard phones (up to 640px) ---------- */
@media (max-width: 640px) {
    :root {
        --pad: 14px;
        --tab-h: 60px;
        --nav-h: 58px;
    }

    /* Kill horizontal scroll caused by gradient text or wide elements */
    html, body { overflow-x: hidden; max-width: 100vw; }

    /* Slightly tighter base font for phones */
    body { font-size: 14.5px; }

    /* Nav is a bit shorter */
    .c-nav { height: var(--nav-h); }

    /* Hero: less top/bottom air */
    .hero { padding: 28px 0 24px; }
    .hero h1 { font-size: 1.85rem; line-height: 1.2; }
    .hero p { font-size: 0.9375rem; margin-bottom: 20px; }
    .hero-actions { gap: 8px; margin-top: 22px; }
    .hero-actions .c-btn-lg { min-height: 46px; padding: 0 22px; font-size: 0.9375rem; }

    /* Sections: tighter vertical rhythm */
    .c-section { margin-bottom: 24px; }
    .c-section-head { margin-bottom: 12px; }
    .c-section-title { font-size: 1rem; padding-left: 12px; }
    .c-section-title::before { width: 3px; height: 18px; }
    .c-section-title i { font-size: 0.9rem; }

    /* Cards: less padding so content breathes wider */
    .c-card { padding: 16px; }
    .c-card-flat { padding: 16px; }

    /* Feature grid */
    .feature-grid { gap: 10px; }
    .feature { padding: 14px 12px; }
    .feature i { width: 36px; height: 36px; font-size: 1rem; margin-bottom: 8px; }
    .feature h3 { font-size: 0.875rem; }
    .feature p { font-size: 0.7rem; line-height: 1.45; }

    /* Programme cards */
    .prog-grid { gap: 10px; }
    .prog-card { padding: 16px; }
    .prog-card .icon { width: 40px; height: 40px; font-size: 1.05rem; margin-bottom: 10px; }

    /* CTA band */
    .cta-band {
        padding: 26px 18px;
        border-radius: var(--r-lg);
    }
    .cta-band h2 { font-size: 1.2rem; margin-bottom: 6px; }
    .cta-band p { font-size: 0.875rem; margin-bottom: 16px; }
    .cta-band .c-btn-lg { min-height: 46px; font-size: 0.9375rem; }

    /* ====================================================
     *      LEADERBOARD — reduce padding so it fits on phones
     *      ==================================================== */
    #leaderboard table th,
    #leaderboard table td {
    padding: 10px 10px !important;
    font-size: 0.8125rem;
    }
    #leaderboard table th { font-size: 0.625rem !important; }
    #leaderboard td:first-child { font-size: 0.875rem !important; }
    #leaderboard td a,
    #leaderboard td div { word-break: break-word; overflow-wrap: anywhere; }

    /* ====================================================
     *      FOOTER — kill the double bottom-padding bug
     *      Previously: body padding-bottom + footer padding-bottom
     *      both added the tab-bar height → huge empty space.
     *      Now: body padding handles the tab bar, footer just
     *      adds a small breathing room.
     *      ==================================================== */
    .c-footer {
        margin-top: 32px;
        padding: 28px 0 20px;
        padding-bottom: 20px;                 /* ← no more tab-h double-count */
    }
    .c-footer-grid { gap: 20px; }
    .c-footer-bottom { margin-top: 24px; padding-top: 16px; font-size: 0.7rem; }

    /* Toast placement above tab bar */
    .c-toasts {
        bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
        width: calc(100% - 24px);
    }

    /* Modals fill the bottom nicely */
    .c-modal-panel { padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); }

    /* Auth modal tweaks */
    .auth-form-panel { padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); }
    .auth-title { font-size: 1.15rem; }
    .auth-sub { font-size: 0.78rem; }
    .auth-input-wrap { min-height: 44px; padding: 0 12px; }
    .auth-input-wrap > input,
    .auth-input-wrap > select { font-size: 0.875rem; }
    .auth-submit { min-height: 48px; font-size: 0.9rem; }
    .auth-tab { padding: 7px 14px; font-size: 0.75rem; }
    .auth-grid { gap: 10px; }
}

/* ---------- Very narrow phones (≤ 380px, e.g. iPhone SE) ---------- */
@media (max-width: 380px) {
    :root { --pad: 12px; }

    .hero { padding: 22px 0 18px; }
    .hero h1 { font-size: 1.6rem; }
    .hero p { font-size: 0.875rem; }

    .c-section { margin-bottom: 20px; }
    .c-section-title { font-size: 0.9375rem; }

    .feature-grid { gap: 8px; }
    .feature { padding: 12px 10px; }
    .feature p { font-size: 0.68rem; }

    #leaderboard table th,
    #leaderboard table td { padding: 8px 8px !important; font-size: 0.75rem; }
    #leaderboard td:first-child { font-size: 0.8125rem !important; }

    .cta-band { padding: 22px 14px; }
    .cta-band h2 { font-size: 1.1rem; }
}

/* ---------- Landscape phones (short height) ---------- */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .hero { padding: 20px 0 16px; }
    .hero h1 { font-size: 1.6rem; }
    .c-section { margin-bottom: 20px; }
}
