/* ============================================================
   Tin học THPT — Design System
   Desktop-first, responsive EdTech UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Brand */
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
    --primary-softer: color-mix(in srgb, var(--primary) 5%, white);

    --accent: #7c3aed;
    --accent-soft: color-mix(in srgb, var(--accent) 12%, white);

    /* Neutrals */
    --bg: #f5f7fb;
    --bg-alt: #eef2f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e5e9f2;
    --border-strong: #d3dae6;
    --text: #0f172a;
    --text-soft: #334155;
    --text-muted: #64748b;
    --text-faint: #94a3b8;

    /* Semantic */
    --success: #16a34a;
    --success-soft: #dcfce7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --info: #0891b2;
    --info-soft: #cffafe;

    /* Metrics */
    --radius-xs: 6px;
    --radius-sm: 9px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 10px 24px -8px rgba(15, 23, 42, .12);
    --shadow-lg: 0 10px 30px -8px rgba(15, 23, 42, .16), 0 24px 50px -20px rgba(15, 23, 42, .22);
    --shadow-xl: 0 30px 60px -20px rgba(15, 23, 42, .28);

    --sidebar-w: 268px;
    --topbar-h: 68px;
    --content-max: 1400px;

    --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

    --ease: cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
    --primary-soft: color-mix(in srgb, var(--primary) 22%, #0b1120);
    --primary-softer: color-mix(in srgb, var(--primary) 12%, #0b1120);
    --accent-soft: color-mix(in srgb, var(--accent) 22%, #0b1120);

    --bg: #070b14;
    --bg-alt: #0b1120;
    --surface: #111827;
    --surface-2: #161f32;
    --surface-3: #1c2740;
    --border: #26304a;
    --border-strong: #374151;
    --text: #f1f5f9;
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --success-soft: color-mix(in srgb, var(--success) 22%, #0b1120);
    --danger-soft: color-mix(in srgb, var(--danger) 22%, #0b1120);
    --warning-soft: color-mix(in srgb, var(--warning) 22%, #0b1120);
    --info-soft: color-mix(in srgb, var(--info) 22%, #0b1120);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow: 0 4px 12px -2px rgba(0, 0, 0, .5);
    --shadow-lg: 0 14px 40px -12px rgba(0, 0, 0, .7);
    --shadow-xl: 0 30px 60px -20px rgba(0, 0, 0, .8);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}
img, svg, video { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-700); }
ul, ol { list-style: none; }
h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); }
h3 { font-size: clamp(1.1rem, 1rem + .4vw, 1.35rem); }
h4 { font-size: 1.05rem; }
::selection { background: var(--primary); color: #fff; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 70;
    transition: transform .28s var(--ease);
}
.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    min-height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--text); font-size: 1.05rem; letter-spacing: -.02em; }
.brand:hover { color: var(--text); }
.brand__logo {
    display: grid; place-items: center;
    width: 38px; height: 38px; flex-shrink: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-size: .82rem; font-weight: 800; letter-spacing: .5px;
    box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--primary) 55%, transparent);
}
.sidebar__close { display: none; font-size: 1.8rem; color: var(--text-muted); line-height: 1; padding: 0 4px; }

.sidebar__nav { padding: 14px 12px 32px; overflow-y: auto; flex: 1; }
.sidebar__section {
    font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
    color: var(--text-faint); padding: 20px 12px 8px;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 11px;
    color: var(--text-soft); font-size: .93rem; font-weight: 500;
    margin-bottom: 3px; position: relative;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.nav-link.is-active::before {
    content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
    width: 4px; height: 22px; background: var(--primary); border-radius: 0 4px 4px 0;
}
.nav-link__icon { font-size: 1.15rem; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); z-index: 65;
}
.sidebar-backdrop.is-open { display: block; animation: fadeIn .2s; }

.main {
    margin-left: var(--sidebar-w);
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar__burger { display: none; font-size: 1.5rem; color: var(--text); padding: 6px; border-radius: 8px; }
.topbar__burger:hover { background: var(--surface-3); }
.topbar__title { font-size: 1.15rem; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; font-size: 1.05rem;
    background: var(--surface-2); border: 1px solid var(--border);
    color: var(--text-soft);
    transition: all .16s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }

.user-menu { position: relative; }
.user-menu__trigger {
    display: flex; align-items: center; gap: 9px;
    padding: 5px 10px 5px 5px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--surface);
    transition: all .16s var(--ease);
}
.user-menu__trigger:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; display: grid; place-items: center;
    font-weight: 800; font-size: .82rem;
}
.user-menu__name { font-size: .89rem; font-weight: 600; }
.user-menu__dropdown {
    display: none; position: absolute; right: 0; top: calc(100% + 10px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 220px; padding: 7px; z-index: 60;
    animation: slideDown .18s var(--ease);
}
.user-menu__dropdown.is-open { display: block; }
.user-menu__dropdown a, .user-menu__dropdown button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left; padding: 10px 12px;
    border-radius: 9px; color: var(--text-soft); font-size: .9rem; font-weight: 500;
    transition: background .14s;
}
.user-menu__dropdown a:hover, .user-menu__dropdown button:hover { background: var(--surface-3); color: var(--text); }
.link-danger { color: var(--danger) !important; }

.content {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 28px;
    flex: 1;
}
.footer {
    padding: 22px 28px; text-align: center;
    color: var(--text-faint); font-size: .83rem;
    border-top: 1px solid var(--border);
}

/* ============================================================
   CARDS & SURFACES
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease);
}
.card__title { font-size: 1.06rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 9px; }
.card--hover:hover { box-shadow: var(--shadow); transform: translateY(-3px); border-color: var(--border-strong); }
.card--flat { box-shadow: none; }
.card--gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; border: none;
    box-shadow: 0 12px 32px -10px color-mix(in srgb, var(--primary) 60%, transparent);
}

/* Panels with header */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.panel__head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); }
.panel__title { font-size: 1.02rem; font-weight: 700; }
.panel__body { padding: 22px; }

/* ============================================================
   GRID SYSTEM
   ============================================================ */
.grid { display: grid; gap: 20px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ============================================================
   STATS
   ============================================================ */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    position: relative; overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat__icon {
    width: 46px; height: 46px; border-radius: 13px;
    display: grid; place-items: center; font-size: 1.35rem;
    background: var(--primary-soft); margin-bottom: 14px;
}
.stat__label { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.stat__value { font-size: 1.85rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat__meta { font-size: .78rem; color: var(--text-faint); margin-top: 6px; }
.stat--success .stat__icon { background: var(--success-soft); }
.stat--warning .stat__icon { background: var(--warning-soft); }
.stat--danger .stat__icon { background: var(--danger-soft); }
.stat--accent .stat__icon { background: var(--accent-soft); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: 11px;
    font-size: .92rem; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
    transition: all .16s var(--ease);
    text-decoration: none; line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn--primary {
    background: var(--primary); color: #fff;
    box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--primary) 60%, transparent);
}
.btn--primary:hover { background: var(--primary-600); color: #fff; box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--primary) 65%, transparent); }

.btn--accent {
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
    box-shadow: 0 4px 14px -3px color-mix(in srgb, var(--primary) 55%, transparent);
}
.btn--accent:hover { color: #fff; filter: brightness(1.06); }

.btn--outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--outline:hover { background: var(--surface-3); border-color: var(--text-faint); color: var(--text); }

.btn--ghost { background: var(--surface-3); color: var(--text-soft); }
.btn--ghost:hover { background: var(--border); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; color: #fff; }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: #15803d; color: #fff; }

.btn--white { background: #fff; color: var(--primary-700); }
.btn--white:hover { color: var(--primary-700); box-shadow: var(--shadow-lg); }

.btn--sm { padding: 7px 14px; font-size: .83rem; border-radius: 9px; }
.btn--lg { padding: 14px 30px; font-size: 1rem; border-radius: 13px; }
.btn--block { width: 100%; }
.btn--icon { padding: 10px; width: 40px; height: 40px; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 11px; padding: 4px; gap: 3px; }
.segmented__item {
    padding: 8px 16px; border-radius: 8px; font-size: .86rem; font-weight: 600;
    color: var(--text-muted); transition: all .16s var(--ease);
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-xs); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 7px; color: var(--text-soft); }
.form-control {
    width: 100%; padding: 11px 15px;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface);
    font-size: .93rem;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}
textarea.form-control { resize: vertical; min-height: 110px; line-height: 1.65; }
select.form-control { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px;
}
.form-hint { font-size: .8rem; color: var(--text-faint); margin-top: 6px; line-height: 1.5; }
.form-error { font-size: .82rem; color: var(--danger); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { display: none; }
.toggle__track {
    width: 46px; height: 26px; border-radius: 99px; background: var(--border-strong);
    position: relative; transition: background .2s var(--ease); flex-shrink: 0;
}
.toggle__track::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%; background: #fff;
    transition: transform .2s var(--ease); box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle__track { background: var(--primary); }
.toggle input:checked + .toggle__track::after { transform: translateX(20px); }
.toggle__label { font-size: .9rem; font-weight: 500; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 14px 18px; border-radius: var(--radius-sm);
    font-size: .9rem; border: 1px solid;
    display: flex; gap: 11px; align-items: flex-start;
    animation: slideDown .25s var(--ease);
}
.alert__icon { font-size: 1.1rem; line-height: 1.5; }
.alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, transparent); color: color-mix(in srgb, var(--success) 80%, #000); }
.alert--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: color-mix(in srgb, var(--danger) 80%, #000); }
.alert--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 40%, transparent); color: color-mix(in srgb, var(--info) 80%, #000); }
.alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); color: color-mix(in srgb, var(--warning) 80%, #000); }
[data-theme="dark"] .alert--success, [data-theme="dark"] .alert--error,
[data-theme="dark"] .alert--info, [data-theme="dark"] .alert--warning { color: var(--text); }

.page-alerts { padding: 0 28px; max-width: var(--content-max); margin: 16px auto 0; width: 100%; }
.page-alerts .alert { margin-bottom: 10px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .89rem; min-width: 620px; }
.table th, .table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
    font-weight: 700; color: var(--text-muted); font-size: .75rem;
    text-transform: uppercase; letter-spacing: .05em;
    background: var(--surface-2); position: sticky; top: 0;
}
.table tbody tr { transition: background .14s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px; border-radius: 99px;
    font-size: .74rem; font-weight: 700; line-height: 1.6;
    white-space: nowrap;
}
.badge--easy, .badge--success { background: var(--success-soft); color: var(--success); }
.badge--medium, .badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--hard, .badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--muted { background: var(--surface-3); color: var(--text-muted); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--info { background: var(--info-soft); color: var(--info); }

/* ============================================================
   PROGRESS
   ============================================================ */
.progress { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress__bar { height: 100%; border-radius: 99px; background: var(--primary); transition: width .6s var(--ease); }
.progress--lg { height: 13px; }

/* Ring progress */
.ring { --pct: 0; width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; position: relative;
    background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--surface-3) 0);
}
.ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring__value { position: relative; font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }

/* ============================================================
   HERO (landing + dashboard)
   ============================================================ */
.hero {
    border-radius: var(--radius-lg); padding: 52px 48px;
    background: linear-gradient(130deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff; position: relative; overflow: hidden; margin-bottom: 24px;
    box-shadow: 0 24px 60px -24px color-mix(in srgb, var(--primary) 70%, transparent);
}
.hero::before {
    content: ''; position: absolute; top: -50%; right: -10%;
    width: 500px; height: 500px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.hero::after {
    content: ''; position: absolute; bottom: -40%; left: -5%;
    width: 360px; height: 360px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.1), transparent 70%);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; margin-bottom: 14px; max-width: 780px; }
.hero p { color: rgba(255,255,255,.9); font-size: 1.05rem; max-width: 640px; margin-bottom: 26px; }
.hero--compact { padding: 34px 32px; }
.hero--compact p { margin-bottom: 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
    text-align: center; padding: 56px 24px; color: var(--text-muted);
}
.empty__icon {
    width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 18px;
    display: grid; place-items: center; font-size: 2rem;
    background: var(--surface-3);
}
.empty__title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty__text { font-size: .9rem; max-width: 420px; margin: 0 auto 20px; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-brand {
    background: linear-gradient(150deg, var(--primary), var(--accent));
    color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-brand::before {
    content: ''; position: absolute; top: -20%; right: -20%;
    width: 620px; height: 620px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.16), transparent 70%);
}
.auth-brand__inner { position: relative; z-index: 1; }
.auth-brand h1 { color: #fff; font-size: 2.4rem; margin: 28px 0 16px; }
.auth-brand p { color: rgba(255,255,255,.9); font-size: 1.02rem; max-width: 460px; }
.auth-features { margin-top: 36px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.auth-feature { display: flex; align-items: center; gap: 13px; font-size: .95rem; color: rgba(255,255,255,.95); }
.auth-feature__icon {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: grid; place-items: center; background: rgba(255,255,255,.18); font-size: 1.1rem;
}
.auth-form-side { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 430px; }
.auth-card__title { font-size: 1.7rem; margin-bottom: 8px; }
.auth-card__sub { color: var(--text-muted); font-size: .94rem; margin-bottom: 30px; }
.auth-footer { text-align: center; margin-top: 22px; font-size: .9rem; color: var(--text-muted); }

/* ============================================================
   CODE LAB
   ============================================================ */
.lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; height: calc(100vh - var(--topbar-h) - 56px); min-height: 520px; }
.lab__pane { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.lab__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-shrink: 0; }
.lab__body { flex: 1; position: relative; overflow: hidden; }
.lab__tabs { display: flex; gap: 3px; }
.lab__tab {
    padding: 6px 13px; border-radius: 8px; font-size: .81rem; font-weight: 600;
    color: var(--text-muted); font-family: var(--font-mono);
}
.lab__tab:hover { background: var(--surface-3); color: var(--text); }
.lab__tab.is-active { background: var(--primary); color: #fff; }
.lab__editor {
    width: 100%; height: 100%; border: none; resize: none; padding: 18px;
    font-family: var(--font-mono); font-size: .85rem; line-height: 1.7;
    background: var(--surface); color: var(--text); tab-size: 4;
    position: absolute; inset: 0;
}
.lab__editor:focus { outline: none; }
.lab__preview { width: 100%; height: 100%; border: none; background: #fff; position: absolute; inset: 0; }
.lab__actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---------- Code editor with autocomplete ---------- */
.ce-wrap { position: absolute; inset: 0; }
.ce { position: relative; width: 100%; height: 100%; }
.ce__highlight {
    position: absolute; inset: 0; margin: 0; padding: 18px;
    font-family: var(--font-mono); font-size: .85rem; line-height: 1.7;
    white-space: pre-wrap; word-wrap: break-word; overflow: hidden;
    pointer-events: none; color: var(--text); tab-size: 4;
    background: transparent; border: none; z-index: 0;
}
.ce__highlight code { font-family: inherit; font-size: inherit; line-height: inherit; background: none; padding: 0; }
.ce .lab__editor {
    position: relative; z-index: 1; background: transparent !important;
    color: transparent !important;
    caret-color: var(--primary) !important;
}
.ce .lab__editor::selection { background: color-mix(in srgb, var(--primary) 30%, transparent); }
.ce .lab__editor::placeholder { color: var(--text-faint) !important; }

/* Syntax tokens */
.tok-tag { color: #e06c75; }
.tok-attr { color: #d19a66; }
.tok-str { color: #98c379; }
.tok-punc { color: #abb2bf; }
.tok-com { color: #5c6370; font-style: italic; }
.tok-sel { color: #e06c75; }
.tok-prop { color: #61afef; }
.tok-val { color: #98c379; }
.tok-kw { color: #c678dd; }
.tok-num { color: #d19a66; }
[data-theme="dark"] .ce { --ce-bg: #0f172a; }
.ce .lab__editor { color: transparent !important; }

/* Autocomplete popup */
.ce__popup {
    position: absolute; z-index: 30; min-width: 260px; max-width: 380px;
    max-height: 240px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 10px; box-shadow: var(--shadow-lg);
    padding: 5px; animation: slideDown .12s var(--ease);
}
.ce__item {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px; border-radius: 7px; cursor: pointer;
    font-size: .84rem; white-space: nowrap;
}
.ce__item.is-active { background: var(--primary-soft); }
.ce__kind {
    width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
    display: grid; place-items: center; font-size: .68rem; font-weight: 800;
    color: #fff;
}
.ce__kind--tag { background: #e06c75; }
.ce__kind--attr { background: #d19a66; }
.ce__kind--prop { background: #61afef; }
.ce__kind--value { background: #98c379; }
.ce__kind--js { background: #c678dd; }
.ce__label { font-family: var(--font-mono); font-weight: 600; color: var(--text); flex-shrink: 0; }
.ce__desc { color: var(--text-faint); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; margin-left: auto; padding-left: 12px; }
.ce__item.is-active .ce__desc { color: var(--text-muted); }
.ce__hint {
    position: sticky; bottom: -5px;
    margin-top: 4px; padding: 6px 10px 7px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    font-size: .7rem; color: var(--text-faint);
    display: flex; gap: 8px; flex-wrap: wrap;
}
.ce__hint kbd {
    font-family: var(--font-mono); font-size: .68rem;
    background: var(--surface-3); border: 1px solid var(--border);
    border-bottom-width: 2px; border-radius: 4px;
    padding: 1px 5px; color: var(--text-soft);
}

@media (max-width: 768px) {
    .ce__popup { min-width: 200px; max-width: 80vw; }
    .ce__desc { display: none; }
}


/* ============================================================
   CHATBOT
   ============================================================ */
.chat-fab {
    position: fixed; right: 26px; bottom: 26px; z-index: 90;
    width: 62px; height: 62px; border-radius: 20px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-size: 1.6rem;
    display: grid; place-items: center;
    box-shadow: 0 12px 32px -8px color-mix(in srgb, var(--primary) 70%, transparent);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.chat-fab:hover { transform: scale(1.06) translateY(-2px); box-shadow: 0 18px 40px -10px color-mix(in srgb, var(--primary) 75%, transparent); }
.chat-fab__dot { position: absolute; top: 12px; right: 12px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }

.chat-panel {
    position: fixed; right: 26px; bottom: 100px; z-index: 95;
    width: min(420px, calc(100vw - 40px));
    height: min(620px, calc(100vh - 140px));
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
    display: none; flex-direction: column; overflow: hidden;
    animation: slideUp .26s var(--ease);
}
.chat-panel.is-open { display: flex; }
.chat-panel__header {
    display: flex; align-items: center; gap: 12px; padding: 16px 18px;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}
.chat-panel__avatar { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 1.2rem; }
.chat-panel__title { font-weight: 700; font-size: .96rem; flex: 1; }
.chat-panel__status { font-size: .75rem; opacity: .85; font-weight: 400; display: flex; align-items: center; gap: 5px; }
.chat-panel__body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--bg-alt); }
.chat-msg { max-width: 86%; padding: 12px 16px; border-radius: 16px; font-size: .9rem; line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg--user {
    align-self: flex-end; background: var(--primary); color: #fff;
    border-bottom-right-radius: 5px; box-shadow: var(--shadow-sm);
}
.chat-msg--ai {
    align-self: flex-start; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-bottom-left-radius: 5px; box-shadow: var(--shadow-xs);
}
.chat-msg pre {
    background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 9px;
    overflow-x: auto; font-size: .81rem; margin: 9px 0; font-family: var(--font-mono);
}
.chat-msg code { font-family: var(--font-mono); font-size: .85em; }
.chat-msg--ai code { background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }
.chat-panel__footer { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-panel__input-wrap { display: flex; gap: 9px; align-items: flex-end; }
.chat-panel__input {
    flex: 1; border: 1px solid var(--border-strong); border-radius: 13px;
    padding: 11px 15px; font-size: .9rem; background: var(--surface);
    resize: none; max-height: 120px; line-height: 1.5;
    transition: border-color .16s;
}
.chat-panel__input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.chat-panel__send { width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.chat-panel__send:hover { background: var(--primary-600); }
.chat-suggestions { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; }
.chat-chip {
    padding: 7px 13px; border-radius: 99px; font-size: .79rem; font-weight: 500;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
    transition: all .15s;
}
.chat-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); animation: bounce 1.3s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }

/* Blinking stream cursor (ChatGPT-like) */
.chat-cursor {
    display: inline-block; width: 8px; height: 1.05em; vertical-align: text-bottom;
    background: var(--primary); margin-left: 2px; border-radius: 2px;
    animation: caret .9s steps(1) infinite;
}
@keyframes caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

.chat-msg--error { border-color: color-mix(in srgb, var(--danger) 40%, transparent) !important; color: var(--danger); }
.chat-retry {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 10px; padding: 6px 13px; border-radius: 8px;
    background: var(--danger); color: #fff; font-size: .8rem; font-weight: 600;
    transition: background .15s;
}
.chat-retry:hover { background: #b91c1c; }

/* Markdown content inside chat */
.md-content { word-wrap: break-word; overflow-wrap: anywhere; }
.md-content > *:first-child { margin-top: 0; }
.md-content > *:last-child { margin-bottom: 0; }
.md-content p { margin: 0 0 10px; line-height: 1.65; }
.md-content h3, .md-content h4, .md-content h5 { margin: 14px 0 8px; font-size: 1rem; }
.md-content ul, .md-content ol { padding-left: 22px; margin: 0 0 10px; }
.md-content ul { list-style: disc; }
.md-content ol { list-style: decimal; }
.md-content li { margin-bottom: 5px; line-height: 1.6; }
.md-content strong { font-weight: 700; color: var(--text); }
.md-content code {
    font-family: var(--font-mono); font-size: .85em;
    background: var(--surface-3); padding: 2px 6px; border-radius: 5px;
    color: var(--primary-700);
}
[data-theme="dark"] .md-content code { color: var(--primary); }
.md-content a { text-decoration: underline; }

/* Code block with header + copy */
.md-code {
    margin: 12px 0; border-radius: 11px; overflow: hidden;
    background: #0f172a; border: 1px solid #1e293b;
}
.md-code__bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 12px; background: #1e293b;
    font-size: .72rem; color: #94a3b8; font-weight: 600;
}
.md-code__lang { text-transform: uppercase; letter-spacing: .06em; }
.md-code__copy {
    color: #cbd5e1; font-size: .72rem; font-weight: 600;
    padding: 3px 10px; border-radius: 6px; transition: all .15s;
}
.md-code__copy:hover { background: rgba(255,255,255,.12); color: #fff; }
.md-code pre { margin: 0; padding: 13px; overflow-x: auto; }
.md-code code {
    background: none !important; color: #e2e8f0 !important; padding: 0 !important;
    font-family: var(--font-mono); font-size: .82rem; line-height: 1.65;
}

/* Stop button */
.chat-panel__send.is-stop { background: var(--danger); }
.chat-panel__send.is-stop:hover { background: #b91c1c; }
.stop-square {
    display: block; width: 13px; height: 13px; border-radius: 3px; background: #fff;
}

/* ============================================================
   EXAM
   ============================================================ */
.exam-bar {
    position: sticky; top: 0; z-index: 45;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; gap: 16px;
}
.exam-bar__title { font-weight: 700; flex: 1; font-size: 1rem; }
.exam-timer {
    font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem;
    padding: 8px 18px; border-radius: 11px; background: var(--primary-soft); color: var(--primary);
    letter-spacing: .02em;
}
.exam-timer.is-warning { background: var(--danger-soft); color: var(--danger); animation: pulse 1.4s infinite; }

.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.question-card { scroll-margin-top: 90px; }
.question-card.is-current { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
.question-block-num {
    display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 10px;
    border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; font-size: .92rem; margin-right: 10px;
}
.option {
    display: flex; align-items: flex-start; gap: 13px;
    padding: 14px 17px; border: 1.5px solid var(--border); border-radius: 12px;
    margin-bottom: 10px; cursor: pointer; transition: all .16s var(--ease);
    background: var(--surface);
}
.option:hover { border-color: var(--primary); background: var(--primary-softer); }
.option input { margin-top: 3px; accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; }
.option.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.option__key { font-weight: 800; color: var(--primary); }

.question-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; }
.qchip {
    aspect-ratio: 1; border-radius: 10px; border: 1.5px solid var(--border);
    background: var(--surface); color: var(--text-soft); font-weight: 700; font-size: .86rem;
    display: grid; place-items: center; transition: all .16s var(--ease);
}
.qchip:hover { border-color: var(--primary); transform: scale(1.06); }
.qchip.is-done { background: var(--success); color: #fff; border-color: var(--success); }
.qchip.is-current { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.qchip.is-flagged { background: var(--warning); color: #fff; border-color: var(--warning); }
.qchip.is-done.is-flagged { background: linear-gradient(135deg, var(--success) 50%, var(--warning) 50%); }

.exam-legend { display: flex; flex-direction: column; gap: 9px; font-size: .82rem; color: var(--text-muted); }
.exam-legend__item { display: flex; align-items: center; gap: 9px; }
.exam-legend__swatch { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border); flex-shrink: 0; }

/* TF table */
.tf-table { width: 100%; border-collapse: collapse; }
.tf-table td, .tf-table th { padding: 13px 14px; border-bottom: 1px solid var(--border); }
.tf-table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--surface-2); }
.tf-table td:nth-child(2), .tf-table td:nth-child(3) { text-align: center; width: 90px; }
.tf-table input[type=radio] { width: 19px; height: 19px; accent-color: var(--primary); }

/* ============================================================
   RESULT
   ============================================================ */
.result-score {
    font-size: 4rem; font-weight: 800; letter-spacing: -.04em; line-height: 1;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* ============================================================
   LESSON
   ============================================================ */
.lesson-content { font-size: 1rem; line-height: 1.8; color: var(--text-soft); }
.lesson-content p { margin-bottom: 16px; }
.lesson-content h2, .lesson-content h3 { margin: 26px 0 13px; color: var(--text); }
.lesson-content ul, .lesson-content ol { padding-left: 24px; margin-bottom: 16px; }
.lesson-content ul { list-style: disc; }
.lesson-content ol { list-style: decimal; }
.lesson-content li { margin-bottom: 7px; }
.lesson-content code {
    font-family: var(--font-mono); font-size: .87em;
    background: var(--surface-3); padding: 3px 7px; border-radius: 6px;
    color: var(--primary-700);
}
[data-theme="dark"] .lesson-content code { color: var(--primary); }
.lesson-content pre {
    background: #0f172a; color: #e2e8f0; padding: 18px; border-radius: 12px;
    overflow-x: auto; margin-bottom: 18px; font-family: var(--font-mono); font-size: .85rem; line-height: 1.7;
}
.lesson-content pre code { background: none; color: inherit; padding: 0; }
.lesson-content img { border-radius: 12px; margin: 16px 0; }
.lesson-content blockquote {
    border-left: 4px solid var(--primary); padding: 10px 18px; margin: 18px 0;
    background: var(--primary-softer); border-radius: 0 10px 10px 0; color: var(--text-soft);
}
.lesson-content table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.lesson-content th, .lesson-content td { border: 1px solid var(--border); padding: 10px 13px; text-align: left; }
.lesson-content th { background: var(--surface-2); }

/* Practice explanation (revealed after checking) */
.practice-explain {
    margin-top: 12px; padding: 14px 16px; border-radius: 11px;
    background: var(--surface-2); border-left: 3px solid var(--primary);
    font-size: .88rem; line-height: 1.7;
}
.practice-explain > *:first-child { margin-top: 0; }
.practice-explain > *:last-child { margin-bottom: 0; }
.practice-explain::before {
    content: '💡 Giải thích';
    display: block; font-weight: 700; font-size: .82rem;
    color: var(--primary); margin-bottom: 8px;
}

/* Code block with copy */
.code-block { position: relative; }
.code-block__copy {
    position: absolute; top: 10px; right: 10px; padding: 5px 11px;
    border-radius: 7px; background: rgba(255,255,255,.12); color: #cbd5e1;
    font-size: .75rem; font-weight: 600; opacity: 0; transition: opacity .2s;
}
.code-block:hover .code-block__copy { opacity: 1; }
.code-block__copy:hover { background: rgba(255,255,255,.22); color: #fff; }

/* ============================================================
   TABS / CHIPS
   ============================================================ */
.chips { display: flex; gap: 9px; flex-wrap: wrap; }
.chip {
    padding: 8px 16px; border-radius: 99px; font-size: .86rem; font-weight: 600;
    background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
    transition: all .16s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
    padding: 12px 18px; font-size: .9rem; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================================
   TOPIC / LESSON CARDS
   ============================================================ */
.topic-card {
    display: flex; flex-direction: column; gap: 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px;
    transition: all .2s var(--ease); color: var(--text);
    position: relative; overflow: hidden;
}
.topic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); color: var(--text); }
.topic-card__icon {
    width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
    font-size: 1.6rem; background: var(--primary-soft);
}
.topic-card__name { font-weight: 700; font-size: 1.05rem; }
.topic-card__desc { font-size: .86rem; color: var(--text-muted); line-height: 1.55; flex: 1; }
.topic-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.lesson-row {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 13px;
    transition: all .18s var(--ease); color: var(--text);
}
.lesson-row:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateX(4px); color: var(--text); }
.lesson-row__num {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 800;
    background: var(--surface-3); color: var(--text-muted); font-size: .9rem;
}
.lesson-row.is-done .lesson-row__num { background: var(--success-soft); color: var(--success); }

/* Strengths/weakness bars */
.skillbar { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.skillbar__label { flex: 1; font-size: .87rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skillbar__track { width: 130px; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; flex-shrink: 0; }
.skillbar__fill { height: 100%; border-radius: 99px; }
.skillbar__value { width: 42px; text-align: right; font-size: .82rem; font-weight: 700; flex-shrink: 0; }

/* ============================================================
   ADMIN
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 70;
    transition: transform .28s var(--ease);
}
.admin-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.admin-main .content { max-width: var(--content-max); }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 18px; } .mt-3 { margin-top: 28px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 18px; } .mb-3 { margin-bottom: 28px; }
.muted { color: var(--text-muted); font-size: .88rem; }
.strong { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.section-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 22px; }
.divider { height: 1px; background: var(--border); margin: 22px 0; }
.mono { font-family: var(--font-mono); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .65; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 18px; height: 18px; border: 2.5px solid var(--border-strong);
    border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) {
    :root { --content-max: 1100px; }
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 1024px) {
    .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid--sidebar { grid-template-columns: 1fr; }
    .exam-layout { grid-template-columns: 1fr; }
    .auth-split { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .lab { grid-template-columns: 1fr; height: auto; }
    .lab__pane { height: 440px; }
}

@media (max-width: 768px) {
    :root { --topbar-h: 60px; }
    body { font-size: 14.5px; }
    .sidebar, .admin-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-xl); }
    .sidebar.is-open, .admin-sidebar.is-open { transform: translateX(0); }
    .sidebar__close { display: block; }
    .main, .admin-main { margin-left: 0; }
    .topbar__burger { display: grid; place-items: center; }
    .topbar { padding: 0 16px; gap: 10px; }
    .topbar__title { font-size: 1rem; }
    .content { padding: 18px 16px; }
    .page-alerts { padding: 0 16px; }
    .grid--2, .grid--3, .grid--4, .grid--auto { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .hero { padding: 32px 22px; border-radius: var(--radius); }
    .hero p { font-size: .95rem; }
    .card { padding: 18px; }
    .user-menu__name { display: none; }
    .exam-bar { padding: 12px 16px; gap: 10px; }
    .exam-bar__title { font-size: .9rem; }
    .exam-timer { font-size: .92rem; padding: 7px 13px; }
    .auth-brand { padding: 32px 22px; }
    .chat-panel {
        right: 0; bottom: 0; width: 100vw; height: 100dvh;
        border-radius: 0; border: none; max-width: none;
    }
    .chat-fab { right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 17px; }
    .alert { font-size: .86rem; padding: 12px 14px; }
    .question-nav { grid-template-columns: repeat(6, 1fr); }
    .table { min-width: 520px; }
}

@media (max-width: 480px) {
    .content { padding: 14px 12px; }
    .stat__value { font-size: 1.55rem; }
    .stat { padding: 16px; }
    .btn { padding: 10px 16px; }
    .btn--lg { padding: 13px 22px; }
    .result-score { font-size: 3rem; }
    .question-nav { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 1536px) {
    :root { --content-max: 1500px; }
}

@media print {
    .sidebar, .topbar, .chat-fab, .chat-panel, .footer { display: none !important; }
    .main { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
