/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242736;
  --border: #2e3347;
  --accent: #6c63ff;
  --accent-hover: #7c74ff;
  --accent-dim: rgba(108,99,255,0.15);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e8eaf0;
  --text-muted: #8b90a8;
  --text-dim: #5a6080;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== Layout ===== */
.container { max-width: 900px; margin: 0 auto; padding: 0 1.5rem; }
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* ===== Typography ===== */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }

.text-muted { color: var(--text-muted); font-size: 0.875rem; }
.text-center { text-align: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder { color: var(--text-dim); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }
.btn-full { width: 100%; }

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-info { background: var(--accent-dim); border: 1px solid rgba(108,99,255,0.3); color: #a5b4fc; }

/* ===== Navbar ===== */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar-brand .logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}
.navbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.navbar-user { color: var(--text-muted); font-size: 0.875rem; }

/* ===== Progress Bar ===== */
.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-accent { background: var(--accent-dim); color: #a5b4fc; }
.badge-green { background: rgba(34,197,94,0.12); color: #86efac; }
.badge-red { background: rgba(239,68,68,0.12); color: #fca5a5; }
.badge-yellow { background: rgba(245,158,11,0.12); color: #fcd34d; }

/* ===== Stat Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid rgba(46,51,71,0.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== Answer Options ===== */
.option-list { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.option-item:hover:not(.disabled) { border-color: var(--accent); background: var(--accent-dim); }
.option-item.selected { border-color: var(--accent); background: var(--accent-dim); }
.option-item.correct { border-color: var(--green); background: rgba(34,197,94,0.08); }
.option-item.incorrect { border-color: var(--red); background: rgba(239,68,68,0.08); }
.option-item.disabled { cursor: default; }
.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: background 0.15s;
}
.option-item.correct .option-letter { background: var(--green); color: #000; }
.option-item.incorrect .option-letter { background: var(--red); color: #fff; }
.option-item.selected:not(.correct):not(.incorrect) .option-letter { background: var(--accent); color: #fff; }

/* ===== Explanation Box ===== */
.explanation-box {
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: none;
}
.explanation-box.show { display: block; }
.explanation-box strong { color: var(--text); }

/* ===== Domain Filter ===== */
.domain-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.domain-pill {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.domain-pill:hover, .domain-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #a5b4fc;
}

/* ===== Spinner ===== */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tabs ===== */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .card { padding: 1.25rem; }
  h1 { font-size: 1.4rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
