:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --text: #182230;
  --muted: #5c6b7f;
  --border: #dce3ee;
  --primary: #1a66d9;
  --primary-hover: #1453b5;
  --primary-soft: #eaf2ff;
  --success: #138a4c;
  --success-soft: #e6f7ee;
  --warning: #b86e00;
  --warning-soft: #fff5e0;
  --danger: #c92a2a;
  --danger-soft: #ffeaea;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(17, 34, 68, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-chip {
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 5px 10px;
  border-radius: 999px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-version {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.badge-neutral {
  background: #edf2f7;
  color: #4a5568;
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Main & Footer */
.main-content {
  flex: 1;
  padding-top: 20px;
  padding-bottom: 36px;
}

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
  padding: 12px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.center-box {
  max-width: 460px;
  margin: 28px auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #b8d3ff;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
  font-family: inherit;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-warning {
  background: #d97706;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: #f8fafc;
}

.btn-link {
  background: transparent;
  color: var(--primary);
  padding: 4px 6px;
}

/* Alerts */
.alert {
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: #f5d08a;
  color: #7c4a00;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #f5b5b5;
  color: #8b1a1a;
}

.alert-info {
  background: var(--primary-soft);
  border-color: #bfd6ff;
  color: #14438a;
}

/* Exam Sticky Bar & Progress */
.exam-sticky {
  position: sticky;
  top: 58px;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.exam-sticky-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.timer-pill {
  font-size: 1.1rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.timer-pill.timer-low {
  background: var(--danger-soft);
  color: var(--danger);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e5ecf6;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1a66d9, #138a4c);
  width: 0%;
  transition: width 0.25s ease;
}

.q-nav-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.q-pill {
  width: 30px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.q-pill.answered {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Question Cards */
.question-card {
  scroll-margin-top: 195px;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.question-card.highlight-unanswered {
  border: 2px solid var(--danger);
  box-shadow: 0 0 0 4px rgba(201, 42, 42, 0.16);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.question-stem {
  font-size: 1.02rem;
  margin-bottom: 12px;
}

.options-list {
  display: grid;
  gap: 8px;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
}

.option-item:hover {
  background: #f8fbff;
  border-color: #aac6f3;
}

.option-item.selected {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.option-item.review-correct {
  background: var(--success-soft);
  border-color: var(--success);
}

.option-item.review-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.option-item input[type="radio"] {
  margin-top: 4px;
}

/* Tabs & Tables */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f9fd;
  font-weight: 700;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.toast.toast-error {
  background: var(--danger);
}

.toast.toast-success {
  background: var(--success);
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.flex-gap {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
