:root {
  --primary: #2563EB;
  --accent: #14B8A6;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10B981;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(37, 99, 235, .10), transparent 35%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 16px; }
.splash { min-height: 80vh; display: grid; place-items: center; text-align: center; gap: 8px; }
.logo-badge {
  width: 58px; height: 58px; border-radius: 18px;
  display: grid; place-items: center;
  color: white; font-weight: 900; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: var(--shadow);
}
.auth-wrap { min-height: 92vh; display: grid; place-items: center; }
.auth-card {
  width: min(100%, 440px); background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 30px; padding: 24px; box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-row h1 { font-size: 22px; margin: 0; }
.brand-row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: #EEF2FF; padding: 5px; border-radius: 16px; margin: 18px 0; }
.tab { border: 0; padding: 12px 14px; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 700; }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 8px 20px rgba(37,99,235,.08); }
.form-grid { display: grid; gap: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; background: #fff; outline: 0;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.10); }
.btn {
  border: 0; background: var(--primary); color: #fff; padding: 13px 16px; border-radius: 16px;
  font-weight: 800; box-shadow: 0 10px 24px rgba(37,99,235,.22);
}
.btn:hover { transform: translateY(-1px); }
.btn.secondary { background: #E2E8F0; color: var(--text); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--primary); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 11px; border-radius: 12px; font-size: 13px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 16px; background: #FEF3C7; color: #92400E; margin: 12px 0; font-size: 14px; }
.alert.info { background: #DBEAFE; color: #1E40AF; }
.alert.danger { background: #FEE2E2; color: #991B1B; }
.main-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; min-height: calc(100vh - 32px); }
.sidebar {
  position: sticky; top: 16px; height: calc(100vh - 32px); border: 1px solid var(--line); background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px); border-radius: 28px; padding: 16px; box-shadow: var(--shadow);
}
.side-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.side-brand h2 { font-size: 16px; margin: 0; }
.side-nav { display: grid; gap: 8px; margin-top: 16px; }
.nav-btn {
  border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border-radius: 16px; text-align: left; font-weight: 800;
}
.nav-btn.active, .nav-btn:hover { background: #EFF6FF; color: var(--primary); }
.nav-icon { width: 22px; text-align: center; }
.content { padding-bottom: 86px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px;
}
.topbar h1 { font-size: clamp(24px, 4vw, 36px); margin: 0; letter-spacing: -.7px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,var(--primary),var(--accent)); color:#fff; display:grid; place-items:center; font-weight: 900; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.kpi { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kpi .num { font-size: 34px; font-weight: 900; letter-spacing: -1px; }
.kpi .label { color: var(--muted); font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 999px; background: #EFF6FF; color: #1D4ED8; font-size: 12px; font-weight: 800; }
.pill.green { background: #D1FAE5; color: #047857; }
.pill.red { background: #FEE2E2; color: #B91C1C; }
.pill.gray { background: #F1F5F9; color: #475569; }
.test-card { display: grid; gap: 10px; }
.test-card h3 { margin: 0; }
.progress-line { height: 9px; background: #E2E8F0; border-radius: 999px; overflow: hidden; }
.progress-line span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); width: 0; transition: width .25s; }
.exam-wrap { max-width: 760px; margin: 0 auto; }
.exam-head { position: sticky; top: 8px; z-index: 20; background: rgba(248,250,252,.84); backdrop-filter: blur(14px); padding: 10px 0; }
.exam-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.timer { font-size: 16px; font-weight: 900; color: var(--primary); background: #EFF6FF; padding: 9px 12px; border-radius: 14px; }
.q-card { margin-top: 12px; }
.q-instruction { color: var(--muted); font-weight: 700; font-size: 14px; white-space: pre-line; }
.q-text { white-space: pre-line; line-height: 1.7; font-size: 17px; }
.media-box { margin: 12px 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #F8FAFC; }
.media-box img { width: 100%; display: block; }
.audio-box { margin: 12px 0; }
.audio-box audio { width: 100%; }
.options { display: grid; gap: 10px; margin-top: 14px; }
.option-btn {
  width: 100%; text-align: left; border: 1px solid var(--line); background: #fff; padding: 14px; border-radius: 18px;
  display: flex; gap: 12px; align-items: flex-start; min-height: 54px;
}
.option-btn.selected { border-color: var(--primary); background: #EFF6FF; box-shadow: 0 0 0 4px rgba(37,99,235,.08); }
.option-key { flex: 0 0 30px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; background: #F1F5F9; font-weight: 900; }
.option-btn.selected .option-key { background: var(--primary); color: white; }
.exam-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 16px; }
.note-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; background: #F8FAFC; }
.review-item { border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; background: #fff; }
.review-item.correct { border-color: rgba(16,185,129,.35); }
.review-item.wrong { border-color: rgba(239,68,68,.35); }
.flashcard { min-height: 210px; display: grid; place-items: center; text-align: center; font-size: 24px; font-weight: 900; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(135deg, #fff, #F8FAFC); padding: 20px; }
.flashcard.back { background: linear-gradient(135deg, #EFF6FF, #ECFDF5); }
.admin-section { display: grid; gap: 16px; }
.code-block { background: #0F172A; color: #E2E8F0; padding: 14px; border-radius: 16px; overflow-x: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.bottom-nav { display: none; }
.hidden { display: none !important; }
@media (max-width: 860px) {
  .app-shell { padding: 12px; }
  .main-layout { display: block; }
  .sidebar { display: none; }
  .content { padding-bottom: 88px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .user-chip { display: none; }
  .bottom-nav {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 50;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
    background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 24px; padding: 7px; box-shadow: var(--shadow); backdrop-filter: blur(14px);
  }
  .bottom-nav .nav-btn { padding: 8px 4px; justify-content: center; flex-direction: column; gap: 2px; font-size: 10px; border-radius: 17px; }
  .bottom-nav .nav-icon { width: auto; }
  .auth-card { border-radius: 24px; padding: 18px; }
  .exam-actions { position: sticky; bottom: 84px; background: rgba(248,250,252,.88); backdrop-filter: blur(12px); padding: 10px 0; }
}
