:root {
  --brand: #1be4d0;
  --brand-dark: #0fb8a7;
  --brand-soft: rgba(27, 228, 208, 0.14);
  --navy: #0f172a;
  --navy-light: #1e293b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #cbd5e1;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --success: #059669;
  --radius: 14px;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: "Cairo", "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

[dir="ltr"] {
  font-family: "Inter", "Cairo", sans-serif;
}

.hidden {
  display: none !important;
}

/* Screens */
.screen {
  min-height: 100vh;
}

#screen-login,
#screen-receipt {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}

/* Auth & Receipt Cards */
.auth-card,
.receipt-card {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  display: inline-block;
  background: var(--navy);
  color: var(--brand);
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.brand-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--navy);
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.instructions-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.instructions-box h3 {
  font-size: 0.92rem;
  color: var(--navy);
  margin-bottom: 6px;
}

.instructions-box ul {
  padding-right: 18px;
}

/* Alerts */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  font-weight: 600;
}

.alert-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--warning-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: var(--navy);
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--navy);
}

.btn-secondary:hover:not(:disabled) {
  background: #cbd5e1;
}

.btn-danger-outline {
  background: transparent;
  color: #fca5a5;
  border: 1.5px solid #ef4444;
  padding: 8px 14px;
  font-size: 0.86rem;
}

.btn-danger-outline:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Exam Topbar */
.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--navy);
  color: #ffffff;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.topbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-pill {
  background: var(--brand);
  color: var(--navy);
  font-family: "Inter", sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 6px;
}

.topbar-info h2 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.student-meta {
  font-size: 0.8rem;
  color: #94a3b8;
}

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

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.sync-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.sync-badge.saving .dot {
  background: #f59e0b;
}

.sync-badge.offline .dot {
  background: #ef4444;
}

.timer-box {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timer-box.warning {
  color: #fbbf24;
  border-color: #fbbf24;
}

.timer-box.critical {
  background: #7f1d1d;
  color: #fecaca;
  border-color: #ef4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% { opacity: 0.75; }
}

/* Main Exam Layout */
.exam-layout {
  max-width: 1120px;
  margin: 22px auto;
  padding: 0 16px 40px;
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
}

/* Navigator Panel */
.navigator-panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid #e2e8f0;
}

.nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.progress-pill {
  background: var(--brand-soft);
  color: var(--navy);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.q-nav-btn {
  height: 38px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.q-nav-btn.answered {
  background: #ecfdf5;
  border-color: var(--success);
  color: var(--success);
}

.q-nav-btn.current {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--brand);
}

.q-nav-btn.flagged::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
}

.nav-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.leg {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-left: 4px;
}
.leg.current { background: var(--navy); }
.leg.answered { background: var(--success); }
.leg.flagged { background: var(--warning); }

/* Question Stage & Deterrents (SEC-03) */
.question-stage {
  user-select: none;
  -webkit-user-select: none;
}

.passage-card,
.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid #e2e8f0;
  margin-bottom: 18px;
}

.passage-card {
  border-right: 4px solid var(--brand-dark);
  background: #f8fafc;
}

.section-badge {
  display: inline-block;
  background: var(--navy);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.passage-body {
  font-size: 1.02rem;
  line-height: 1.75;
  color: #1e293b;
  white-space: pre-line;
}

.q-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.q-badge {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  color: var(--navy);
  font-size: 0.95rem;
}

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

.points-badge {
  font-family: "Inter", sans-serif;
  font-size: 0.8rem;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.btn-flag {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-flag.active {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: #92400e;
}

.q-text {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 20px;
}

/* MCQ Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  background: #ffffff;
}

.option-item:hover {
  border-color: var(--brand-dark);
  background: #f8fafc;
}

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

.option-key {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--navy);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.option-item.selected .option-key {
  background: var(--navy);
  color: var(--brand);
}

.essay-input {
  width: 100%;
  min-height: 160px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: "Inter", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  user-select: text;
  -webkit-user-select: text;
}

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

/* Receipt */
.receipt-card {
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.receipt-box {
  background: var(--navy);
  color: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
}

.receipt-label {
  display: block;
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.receipt-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.receipt-code-row strong {
  font-family: "Inter", sans-serif;
  font-size: 1.35rem;
  color: var(--brand);
  letter-spacing: 1px;
}

.btn-small {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
}

.receipt-details {
  text-align: right;
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.92rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #e2e8f0;
}

.detail-row:last-child {
  border-bottom: none;
}

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

.modal-box {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-box h3 {
  margin-bottom: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.text-danger {
  color: var(--danger);
}