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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #fff;
  color: #000;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

/* ── Layout ─────────────────────────────────────────────────────── */
.page-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: #888;
  border-top: 1px solid #eee;
}
footer a { color: #888; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
}
.center-card { max-width: 400px; margin: auto; }
.wide-card   { max-width: 680px; margin: auto; }

/* ── Logo area ──────────────────────────────────────────────────── */
.logo-area { text-align: center; margin-bottom: 1.5rem; }
.logo-area h1 { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.accent { font-weight: 300; }
.subtitle { color: #666; font-size: 0.875rem; margin-top: 0.25rem; }

/* ── Forms ──────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.3rem; color: #333; }
.field input {
  width: 100%; padding: 0.55rem 0.75rem;
  border: 1px solid #ccc; border-radius: 6px;
  font-size: 0.95rem; background: #fff; color: #000;
  transition: border-color 0.15s;
}
.field input:focus { outline: none; border-color: #000; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.span-2 { grid-column: span 2; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.25rem; border-radius: 6px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.8; }
.btn-primary   { background: #000; color: #fff; }
.btn-secondary { background: #fff; color: #000; border-color: #000; }
.btn-outline   { background: transparent; color: #555; border-color: #ccc; }
.btn-full      { width: 100%; margin-top: 0.5rem; }
.btn-link      { background: none; border: none; cursor: pointer; font-size: 0.85rem; text-decoration: underline; padding: 0; color: #000; }
.btn-link.danger { color: #c00; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert { border-radius: 6px; padding: 0.65rem 0.9rem; margin-bottom: 1rem; font-size: 0.85rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Misc ────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid #eee; margin: 1rem 0; }
.small-link { text-align: center; font-size: 0.8rem; color: #888; }
.small-link a { color: #555; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.warn { color: #c00; }

/* ── Rules ───────────────────────────────────────────────────────── */
.rules-list { padding-left: 1.5rem; line-height: 2; font-size: 0.95rem; }
.info-box { background: #f5f5f5; border-radius: 6px; padding: 0.75rem 1rem; margin: 1rem 0; font-size: 0.875rem; }
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; margin-top: 1.25rem; }
.checkbox-row input { width: auto; }

/* ── Exam layout ─────────────────────────────────────────────────── */
.exam-layout { width: 100%; max-width: 780px; margin: 0 auto; }

.exam-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; background: #fff; border: 1px solid #e5e5e5;
  border-radius: 8px; margin-bottom: 1rem; gap: 1rem;
}
.exam-progress { flex: 1; }
.prog-label { font-size: 0.8rem; color: #555; display: block; margin-bottom: 4px; }
.progress-bar { height: 4px; background: #eee; border-radius: 2px; }
.progress-fill { height: 100%; background: #000; border-radius: 2px; transition: width 0.3s; }

.timer-box {
  display: flex; align-items: center; gap: 6px;
  background: #000; color: #fff; border-radius: 6px;
  padding: 0.4rem 0.85rem; font-size: 1rem; font-weight: 700;
  white-space: nowrap;
}
.timer-box.warning { background: #c00; }
.timer-icon { font-size: 0.9rem; }

/* ── Question card ───────────────────────────────────────────────── */
.question-card { max-width: 780px; }
.q-category { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.q-text { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.5rem; line-height: 1.5; }

.options-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.5rem; }
.option-label {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 1rem; border: 1px solid #ddd; border-radius: 6px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.option-label:hover { border-color: #000; }
.option-label:has(input:checked) { border-color: #000; background: #f9f9f9; }
.option-label input[type=radio] { display: none; }
.option-letter {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; min-width: 28px;
  border: 1.5px solid #ccc; border-radius: 50%;
  font-size: 0.8rem; font-weight: 700; color: #555;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.option-label:has(input:checked) .option-letter { border-color: #000; background: #000; color: #fff; }
.option-text { font-size: 0.95rem; padding-top: 2px; line-height: 1.4; }

.nav-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* ── Review grid ─────────────────────────────────────────────────── */
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 0.5rem; margin: 1rem 0; }
.review-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0.4rem; border-radius: 6px; border: 1px solid #ddd;
  text-decoration: none; color: #000; font-size: 0.8rem; font-weight: 600;
  transition: border-color 0.15s;
}
.review-item.answered  { border-color: #000; background: #f9f9f9; }
.review-item.unanswered { border-color: #ccc; background: #fff; color: #aaa; }
.q-num { font-size: 0.85rem; }
.q-status { font-size: 0.7rem; }

/* ── Thanks ──────────────────────────────────────────────────────── */
.thanks-icon {
  display: flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 50%; background: #000; color: #fff;
  font-size: 2rem; margin: 0 auto 1rem;
}

/* ── Admin layout ────────────────────────────────────────────────── */
.admin-layout { display: flex; width: 100%; max-width: 1200px; gap: 0; min-height: calc(100vh - 60px); }

.sidebar {
  width: 200px; min-width: 200px; background: #000; color: #fff;
  display: flex; flex-direction: column; padding: 1.5rem 0;
  border-radius: 8px 0 0 8px;
}
.sidebar-brand { padding: 0 1.25rem 1.5rem; font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand span { font-weight: 300; font-size: 0.85rem; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
  padding: 0.6rem 1.25rem; color: #ccc; text-decoration: none; font-size: 0.875rem;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-footer { padding: 1rem 1.25rem; font-size: 0.7rem; color: #666; border-top: 1px solid #222; margin-top: auto; word-break: break-all; }

.admin-main { flex: 1; padding: 1.5rem 2rem; border: 1px solid #e5e5e5; border-left: none; border-radius: 0 8px 8px 0; }
.admin-main h1 { font-size: 1.4rem; margin-bottom: 1.5rem; }

.section { margin-bottom: 2rem; }
.section h2 { font-size: 1rem; font-weight: 700; margin-bottom: 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid #eee; }

/* ── Token form ──────────────────────────────────────────────────── */
.token-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.field.inline { margin-bottom: 0; }
.field.inline label { font-size: 0.75rem; }
.field.inline input { padding: 0.45rem 0.65rem; font-size: 0.85rem; width: auto; }

/* ── Tables ──────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { text-align: left; padding: 0.5rem 0.75rem; background: #f5f5f5; font-weight: 600; font-size: 0.78rem; border-bottom: 1px solid #ddd; }
.data-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.data-table code { background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; letter-spacing: 0.05em; }
.empty-msg { color: #888; font-size: 0.875rem; padding: 0.5rem 0; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-dark    { background: #000; color: #fff; }

/* ── Chart ───────────────────────────────────────────────────────── */
.chart-container { max-height: 320px; background: #fafafa; border: 1px solid #eee; border-radius: 6px; padding: 1rem; }

/* ── Result page ─────────────────────────────────────────────────── */
.result-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.score-summary { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: 1rem; background: #f9f9f9; border-radius: 8px; }
.score-big { display: flex; align-items: baseline; gap: 4px; }
.score-num { font-size: 3rem; font-weight: 700; }
.score-max { font-size: 1.25rem; color: #666; }
.score-pct { font-size: 1.5rem; font-weight: 700; margin-left: 0.5rem; }
.level-badge { padding: 0.4rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 600; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-top: 0.5rem; }
.cat-card { border: 1px solid #eee; border-radius: 6px; padding: 0.75rem; }
.cat-card h4 { font-size: 0.78rem; color: #666; margin-bottom: 0.35rem; }
.cat-score { font-size: 1.4rem; font-weight: 700; }
.cat-bar { height: 4px; background: #eee; border-radius: 2px; margin: 6px 0; }
.cat-fill { height: 100%; background: #000; border-radius: 2px; }
.cat-pct { font-size: 0.75rem; color: #888; }

.q-detail { border: 1px solid #eee; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.q-detail.correct { border-left: 4px solid #166534; }
.q-detail.incorrect { border-left: 4px solid #991b1b; }
.q-detail-header { display: flex; justify-content: space-between; margin-bottom: 0.4rem; }
.q-indicator { font-weight: 700; }
.correct .q-indicator { color: #166534; }
.incorrect .q-indicator { color: #991b1b; }
.q-pts { font-size: 0.78rem; color: #666; }
.q-detail-text { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; }
.q-options-detail { list-style: none; font-size: 0.85rem; display: flex; flex-direction: column; gap: 2px; }
.q-options-detail li { padding: 2px 0; }
.correct-opt { color: #166534; font-weight: 600; }
.wrong-opt { color: #991b1b; }
.tag { font-size: 0.72rem; background: #dcfce7; color: #166534; padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.tag-wrong { background: #fee2e2; color: #991b1b; }
