:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef0ff;
  --accent: #06b6d4;
  --danger: #dc2626;
  --danger-light: #fdecec;
  --success: #16a34a;
  --success-light: #e8f8ee;
  --warning: #d97706;
  --warning-light: #fff4e0;
  --border: #e6e8f0;
  --input-border: #c7cbe0;
  --shadow: 0 4px 20px rgba(30, 41, 89, 0.06);
  --shadow-lg: 0 20px 50px rgba(30, 41, 89, 0.15);
  --radius: 16px;
  --sky-light: #e0f2fe;
  --sky-card: #bfe6fb;
  --sky-text: #0c4a6e;
  --watermark: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MjAiIGhlaWdodD0iNDIwIj4KPHRleHQgeD0iMjAiIHk9IjYwIiBmb250LXNpemU9IjQ2IiBvcGFjaXR5PSIwLjEwIiB0cmFuc2Zvcm09InJvdGF0ZSgtOCAyMCA2MCkiPvCfjpM8L3RleHQ+Cjx0ZXh0IHg9IjIxMCIgeT0iNDAiIGZvbnQtc2l6ZT0iMzgiIG9wYWNpdHk9IjAuMDkiIHRyYW5zZm9ybT0icm90YXRlKDEwIDIxMCA0MCkiPvCfk4g8L3RleHQ+Cjx0ZXh0IHg9IjMyMCIgeT0iMTIwIiBmb250LXNpemU9IjQyIiBvcGFjaXR5PSIwLjEwIiB0cmFuc2Zvcm09InJvdGF0ZSgtNiAzMjAgMTIwKSI+8J+SuzwvdGV4dD4KPHRleHQgeD0iNzAiIHk9IjE3MCIgZm9udC1zaXplPSIzNiIgb3BhY2l0eT0iMC4wOSIgdHJhbnNmb3JtPSJyb3RhdGUoNiA3MCAxNzApIj7wn5K8PC90ZXh0Pgo8dGV4dCB4PSIyNTAiIHk9IjIwMCIgZm9udC1zaXplPSIzNCIgb3BhY2l0eT0iMC4wOCIgdHJhbnNmb3JtPSJyb3RhdGUoLTEwIDI1MCAyMDApIj7wn5OxPC90ZXh0Pgo8dGV4dCB4PSIxMCIgeT0iMjcwIiBmb250LXNpemU9IjM2IiBvcGFjaXR5PSIwLjA5IiB0cmFuc2Zvcm09InJvdGF0ZSg4IDEwIDI3MCkiPvCfk4o8L3RleHQ+Cjx0ZXh0IHg9IjE4MCIgeT0iMzAwIiBmb250LXNpemU9IjQwIiBvcGFjaXR5PSIwLjEwIiB0cmFuc2Zvcm09InJvdGF0ZSgtNSAxODAgMzAwKSI+8J+knTwvdGV4dD4KPHRleHQgeD0iMzMwIiB5PSIyOTAiIGZvbnQtc2l6ZT0iMzIiIG9wYWNpdHk9IjAuMDgiIHRyYW5zZm9ybT0icm90YXRlKDEyIDMzMCAyOTApIj7wn5KhPC90ZXh0Pgo8dGV4dCB4PSI5MCIgeT0iMzkwIiBmb250LXNpemU9IjM4IiBvcGFjaXR5PSIwLjA5IiB0cmFuc2Zvcm09InJvdGF0ZSgtOSA5MCAzOTApIj7wn46TPC90ZXh0Pgo8dGV4dCB4PSIyNzAiIHk9IjM4MCIgZm9udC1zaXplPSIzNCIgb3BhY2l0eT0iMC4wOCIgdHJhbnNmb3JtPSJyb3RhdGUoNyAyNzAgMzgwKSI+8J+TojwvdGV4dD4KPC9zdmc+");
  font-family: 'Nirmala UI', 'Vrinda', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--primary); }

/* ---------- Hero / landing layout ---------- */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
  background-color: #ffffff;
  background-image: var(--watermark);
  background-repeat: repeat;
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
}

.hero-brand {
  text-align: center;
  color: var(--text);
  margin-bottom: 22px;
}
.hero-brand .logo {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: var(--sky-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-brand h1 {
  font-size: 1.6rem;
  margin: 0 0 6px;
  font-weight: 700;
}
.hero-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.glass-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px 26px;
  box-shadow: var(--shadow-lg);
}
.glass-card.card-sky {
  background: var(--sky-card);
  border-color: #93cdf0;
}
.glass-card.card-sky p { color: var(--sky-text); }

/* ---------- Exam shell (full-bleed, post-login) ---------- */

.exam-shell {
  min-height: 100vh;
  position: relative;
  background-color: #ffffff;
  background-image: var(--watermark);
  background-repeat: repeat;
  padding: 0 0 60px;
}

.exam-shell-inner { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 0 20px; }

.exam-topbar {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 26px 60px 34px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.exam-topbar h1 { color: var(--text); margin: 0; font-size: 1.35rem; }
.exam-topbar .icon-btn {
  position: absolute;
  top: 26px;
  right: 24px;
  color: var(--muted);
}
.exam-topbar .icon-btn:hover { color: var(--danger); }

.state-icon {
  width: 76px; height: 76px; border-radius: 50%;
  background: #f3e8ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; margin: 4px auto 18px;
}
.state-icon.success { background: var(--success-light); }
.state-icon.warning { background: var(--warning-light); }
.state-icon.danger { background: var(--danger-light); }

/* Header band for the taking-state (question list) layout */
.exam-header-band {
  position: relative;
  background-color: #ffffff;
  background-image: var(--watermark);
  background-repeat: repeat;
  padding: 24px 24px 28px;
  border-bottom: 1px solid var(--border);
}
.exam-header-band .top-actions { display: block; text-align: center; margin-bottom: 0; }
.exam-header-band .top-actions h1 { color: var(--text); }
.exam-header-band .icon-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  color: var(--muted);
}
.exam-header-band .icon-btn:hover { color: var(--danger); }
.exam-header-band .exam-banner { margin: 14px auto 0; max-width: 720px; }

.exam-body-wide { max-width: 720px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- Generic layout ---------- */

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}
.wrap.wide { max-width: 1080px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

h1 { font-size: 1.55rem; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 14px; font-weight: 700; }
p.muted, .muted { color: var(--muted); font-size: 0.92rem; }

label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
}
label:first-of-type { margin-top: 0; }

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid var(--input-border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fbfcfe;
  color: var(--text);
  font-family: inherit;
  box-shadow: inset 0 1px 2px rgba(30, 41, 89, 0.05);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:hover, textarea:hover, select:hover { border-color: #a9aecf; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea { resize: vertical; min-height: 90px; }

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  display: inline-block;
  text-decoration: none;
  transition: transform .05s ease, background .15s ease, opacity .15s ease;
}
button:active, .btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: #fff; width: 100%; text-align: center; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #b7bdf5; cursor: not-allowed; }

.btn-secondary { background: var(--primary-light); color: var(--primary-dark); }
.btn-secondary:hover { background: #e0e3ff; }
.btn-danger { background: var(--danger-light); color: var(--danger); }
.btn-danger:hover { background: #fbdbda; }
.btn-small { padding: 7px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; text-align: center; }

.error {
  color: var(--danger);
  background: var(--danger-light);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-top: 12px;
}
.success {
  color: var(--success);
  background: var(--success-light);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-top: 12px;
}

.warning-note {
  color: var(--warning);
  background: var(--warning-light);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 0.85rem;
  margin-top: 14px;
  text-align: left;
}

.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: #f9faff; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge.ok { background: var(--success-light); color: var(--success); }
.badge.pending { background: var(--warning-light); color: var(--warning); }
.badge.suspended { background: var(--danger-light); color: var(--danger); }

.score-big { font-size: 2.6rem; font-weight: 800; color: var(--primary); text-align: center; margin: 10px 0; }

.top-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 10px; }
.top-actions h1 { margin: 0; }

.icon-btn { background: transparent; color: var(--muted); font-weight: 600; }
.icon-btn:hover { color: var(--danger); }

/* ---------- Countdown chips ---------- */

.timer-chips { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.timer-box {
  background: var(--primary-light);
  border-radius: 12px;
  padding: 12px 6px;
  min-width: 68px;
  text-align: center;
}
.timer-box span {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.timer-box label {
  margin: 4px 0 0;
  font-size: 0.72rem;
  color: var(--primary-dark);
  opacity: 0.75;
}

.exam-timer-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.exam-timer-bar.low { background: var(--danger); animation: pulse 1s infinite; }
.exam-timer-bar .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff; opacity: 0.85;
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%, 100% { opacity: .3 } 50% { opacity: 1 } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5) } 50% { box-shadow: 0 0 0 8px rgba(220,38,38,0) } }

/* ---------- Exam questions ---------- */

.progress-bar-track {
  height: 8px; border-radius: 999px; background: var(--primary-light); overflow: hidden; margin-bottom: 22px;
}
.progress-bar-fill {
  height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s ease; width: 0%;
}
.progress-label { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.q-block { padding: 20px 0; border-bottom: 1px solid var(--border); }
.q-block:last-child { border-bottom: none; }
.q-title { font-weight: 700; margin-bottom: 12px; font-size: 1.02rem; }
.q-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 0.8rem; font-weight: 800; margin-right: 8px; vertical-align: middle;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 9px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.option:hover { border-color: #c7cbf5; background: #fafaff; }
.option.selected { border-color: var(--primary); background: var(--primary-light); }
.option input { display: none; }
.opt-letter {
  width: 28px; height: 28px; border-radius: 50%; background: #eef0f5; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem;
  flex-shrink: 0; transition: background .12s ease, color .12s ease;
}
.option.selected .opt-letter { background: var(--primary); color: #fff; }

/* ---------- Admin dashboard layout ---------- */

.admin-shell { display: flex; min-height: 100vh; align-items: stretch; }

.admin-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-sidebar .brand {
  font-weight: 800;
  font-size: 1.15rem;
  padding: 4px 10px 20px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.94rem;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary-dark); }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .ic { font-size: 1.05rem; }
.admin-sidebar .logout-link {
  margin-top: auto;
  color: var(--muted);
  font-size: .88rem;
  padding: 11px 12px;
  text-decoration: none;
}
.admin-sidebar .logout-link:hover { color: var(--danger); }

.admin-main { flex: 1; padding: 30px 32px 60px; min-width: 0; }
.admin-topbar { display: none; }

.stat-row { display: flex; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 140px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); }
.stat-card .lbl { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { width: auto; min-width: 220px; }

.toggle-form-btn { margin-bottom: 4px; }

.exam-banner-thumb {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.exam-banner {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 16px;
  display: block;
}

.exam-meta-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}
.exam-meta-row .item { text-align: center; }
.exam-meta-row .item .v { font-size: 1.1rem; font-weight: 800; color: var(--primary-dark); }
.exam-meta-row .item .l { font-size: .78rem; color: var(--muted); }

.upload-hint {
  background: var(--primary-light); border-radius: 12px; padding: 14px 16px; font-size: .87rem; color: var(--primary-dark);
  margin-bottom: 16px;
}
.upload-hint a { font-weight: 700; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { display: none; }
  .admin-topbar {
    display: flex; gap: 6px; padding: 14px 16px; overflow-x: auto; background: #fff;
    border-bottom: 1px solid var(--border);
  }
  .admin-topbar .nav-link { white-space: nowrap; }
  .admin-main { padding: 22px 16px 50px; }
}

@media (max-width: 480px) {
  .wrap { padding: 22px 14px 40px; }
  .hero { padding: 24px 14px; }
  .timer-box { min-width: 58px; padding: 10px 4px; }
  .timer-box span { font-size: 1.4rem; }
  .exam-topbar { padding: 20px 16px 26px; }
  .exam-topbar h1 { font-size: 1.15rem; }
  .exam-shell-inner { padding: 0 14px; }
  .exam-header-band { padding: 18px 16px 22px; }
}
