*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222636;
  --border: #2e3347;
  --accent: #4f8ef7;
  --accent2: #38d9a9;
  --danger: #f76f6f;
  --warning: #f7934f;
  --text: #e8ecf5;
  --text2: #8892a4;
  --text3: #4f5a6e;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

/* ── HEADER ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #4f8ef7, #7b6ef7);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff; flex-shrink: 0;
}
.header-title { font-weight: 700; font-size: 15px; flex: 1; }
.header-user {
  font-size: 13px; color: var(--text2);
  display: flex; align-items: center; gap: 8px;
}
.avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #4f8ef7, #7b6ef7);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; cursor: pointer;
}
.back-btn {
  width: 34px; height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; flex-shrink: 0;
}

/* ── TABS ── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky; top: 57px; z-index: 90;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 13px 18px;
  font-size: 13px; font-weight: 600;
  color: var(--text2); cursor: pointer;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  transition: .2s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── PAGE ── */
.page { padding: 20px; max-width: 700px; margin: 0 auto; }

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}
.card-head {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 15px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: .2s; text-decoration: none;
  font-family: inherit;
}
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, #4f8ef7, #6b7ef7); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(79,142,247,.35); }
.btn-success { background: linear-gradient(135deg, #38d9a9, #2dc4a0); color: #000; }
.btn-danger { background: rgba(247,111,111,.15); color: var(--danger); border: 1px solid rgba(247,111,111,.3); }
.btn-ghost { background: var(--surface2); border: 1.5px solid var(--border); color: var(--text2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }

/* ── FORM ── */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 16px; color: var(--text);
  outline: none; transition: .2s;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,.15);
}
.field textarea { resize: vertical; min-height: 100px; }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 30% 20%, #1a2540 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 28px;
}
.login-logo {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #4f8ef7, #7b6ef7);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
  margin-bottom: 24px;
}
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--text2); font-size: 14px; margin-bottom: 28px; }
.login-error {
  background: rgba(247,111,111,.1);
  border: 1px solid rgba(247,111,111,.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px; margin-bottom: 16px;
  display: none;
}

/* ── PENDING BANNER ── */
.pending-banner {
  background: rgba(247,147,79,.1);
  border: 1.5px solid rgba(247,147,79,.3);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 12px;
}
.pending-icon { font-size: 22px; flex-shrink: 0; }
.pending-text { flex: 1; }
.pending-title { font-weight: 700; font-size: 15px; color: var(--warning); margin-bottom: 4px; }
.pending-sub { font-size: 13px; color: var(--text2); }

/* ── TEST CARD ── */
.test-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: .2s;
  display: flex; align-items: center; gap: 14px;
}
.test-item:hover { border-color: var(--accent); transform: translateY(-1px); }
.test-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.icon-blue { background: rgba(79,142,247,.15); }
.icon-green { background: rgba(56,217,169,.15); }
.icon-orange { background: rgba(247,147,79,.15); }
.test-info { flex: 1; }
.test-name { font-weight: 600; font-size: 15px; margin-bottom: 5px; }
.test-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.meta-tag { font-size: 12px; color: var(--text2); }
.test-badge {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.badge-pass { background: rgba(56,217,169,.2); color: var(--accent2); }
.badge-fail { background: rgba(247,111,111,.2); color: var(--danger); }
.badge-new { background: var(--surface2); color: var(--text3); border: 1.5px solid var(--border); }

/* ── QUESTION ── */
.q-progress {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}
.q-progress-top {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--text2);
  margin-bottom: 8px;
}
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f8ef7, #7b6ef7);
  border-radius: 2px; transition: .4s;
}
.q-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 16px;
}
.q-type {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(79,142,247,.12);
  border: 1px solid rgba(79,142,247,.25);
  color: var(--accent);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; margin-bottom: 12px;
}
.q-text { font-size: 17px; font-weight: 500; line-height: 1.6; margin-bottom: 16px; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.answer-opt {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px; cursor: pointer; transition: .2s;
}
.answer-opt:hover { border-color: var(--accent); }
.answer-opt.selected { border-color: var(--accent); background: rgba(79,142,247,.1); }
.answer-opt.correct { border-color: var(--accent2); background: rgba(56,217,169,.1); }
.answer-opt.wrong { border-color: var(--danger); background: rgba(247,111,111,.1); }
.opt-circle {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: .2s;
}
.opt-square {
  width: 24px; height: 24px; border-radius: 6px;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; transition: .2s;
}
.answer-opt.selected .opt-circle,
.answer-opt.selected .opt-square {
  border-color: var(--accent); background: var(--accent); color: #fff;
}
.answer-opt.correct .opt-circle,
.answer-opt.correct .opt-square {
  border-color: var(--accent2); background: var(--accent2); color: #000;
}
.answer-opt.wrong .opt-circle,
.answer-opt.wrong .opt-square {
  border-color: var(--danger); background: var(--danger); color: #fff;
}
.opt-text { font-size: 15px; font-weight: 500; flex: 1; line-height: 1.4; }
.nav-btns { display: flex; gap: 10px; }
.nav-btns .btn { flex: 1; }

/* ── RESULT ── */
.result-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center; margin-bottom: 16px;
}
.result-ring { position: relative; width: 120px; height: 120px; margin: 0 auto 20px; }
.result-ring svg { transform: rotate(-90deg); }
.ring-bg { stroke: var(--border); stroke-width: 8; fill: none; }
.ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring-pct {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px; font-weight: 700;
}
.result-verdict { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.result-sub { color: var(--text2); font-size: 14px; }
.result-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.r-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px; text-align: center;
}
.r-stat-val { font-size: 22px; font-weight: 700; margin-bottom: 3px; }
.r-stat-label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; }

/* ── REVIEW ── */
.review-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px;
}
.review-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.review-num { font-size: 12px; color: var(--text3); font-weight: 600; }
.review-text { font-size: 14px; font-weight: 500; flex: 1; }
.review-ans {
  display: flex; gap: 8px;
  font-size: 13px; padding: 7px 10px;
  border-radius: 8px; margin-bottom: 4px; line-height: 1.4;
}
.ans-correct { background: rgba(56,217,169,.1); color: var(--accent2); }
.ans-wrong { background: rgba(247,111,111,.1); color: var(--danger); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px; font-size: 14px; border-bottom: 1px solid rgba(46,51,71,.5); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-green { background: rgba(56,217,169,.15); color: var(--accent2); }
.badge-red { background: rgba(247,111,111,.15); color: var(--danger); }
.badge-blue { background: rgba(79,142,247,.15); color: var(--accent); }
.badge-orange { background: rgba(247,147,79,.15); color: var(--warning); }

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-val { font-size: 30px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text2); }

/* ── SECTION TITLE ── */
.section-title {
  font-size: 12px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 12px;
}

/* ── INSTRUCTION ── */
.instruction-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
  font-size: 15px; line-height: 1.8;
  color: var(--text); white-space: pre-wrap;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: none; z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  width: 100%; max-height: 90vh;
  overflow-y: auto; padding: 24px;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-btns { display: flex; gap: 10px; margin-top: 20px; }
.modal-btns .btn { flex: 1; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 20px;
  font-size: 14px; font-weight: 500;
  z-index: 300; transition: .3s;
  white-space: nowrap; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(56,217,169,.4); color: var(--accent2); }
.toast.error { border-color: rgba(247,111,111,.4); color: var(--danger); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text2); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── CHART ── */
.chart-row { margin-bottom: 10px; }
.chart-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.chart-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.chart-fill { height: 100%; border-radius: 4px; transition: width .8s ease; }
.fill-blue { background: linear-gradient(90deg, #4f8ef7, #6b7ef7); }
.fill-green { background: linear-gradient(90deg, #38d9a9, #2dc4a0); }
.fill-orange { background: linear-gradient(90deg, #f7934f, #e87d3a); }
.fill-red { background: linear-gradient(90deg, #f76f6f, #e84f4f); }

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .result-stats { grid-template-columns: repeat(3, 1fr); }
  .r-stat-val { font-size: 18px; }
  .stat-val { font-size: 24px; }
}
