/* Phòng thi trắc nghiệm: giao diện dùng chung cho cổng sinh viên và cổng giảng viên. */
:root {
  /* Bảng màu Mù Cang Chải: rơm và sương sớm, xanh lúa, vàng lúa chín, nâu đất. */
  --bg: #F4EDD8;
  --surface: #FFFCF2;
  --ink: #2B2A1A;
  --muted: #6A6549;
  --line: #E0D4AE;
  --accent: #2E6B37;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EBC8;
  --gold: #C98A0A;
  --gold-soft: #F6E3AA;
  --ok: #2E7A43;
  --ok-soft: #DCEBCB;
  --warn: #9A5A00;
  --warn-soft: #F8E6BE;
  --bad: #B3261E;
  --bad-soft: #F6DBD0;
  --side: #26351F;
  --side-ink: #F0EACB;
  --font-ui: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-text: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --veil: 234, 244, 236;
  --veil-a: 0.4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131A0F;
    --surface: #1C2617;
    --ink: #F0ECD6;
    --muted: #ABA98B;
    --line: #36412B;
    --accent: #A8D063;
    --accent-ink: #15200A;
    --accent-soft: #2A3820;
    --gold: #E5B43C;
    --gold-soft: #3F3413;
    --ok: #9BD17A;
    --ok-soft: #22331B;
    --warn: #E8B04A;
    --warn-soft: #3A2E12;
    --veil: 14, 26, 19;
    --bad: #F2857D;
    --bad-soft: #3B1F1B;
    --side: #0D120A;
    --side-ink: #D5D3B5;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3 { margin: 0; font-family: var(--font-text); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.3rem); line-height: 1.15; }
h2 { font-size: 1.3rem; line-height: 1.25; }
h3 { font-size: 1.1rem; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.eyebrow { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Nút và ô nhập ---------- */
.btn {
  font: 600 0.92rem var(--font-ui);
  min-height: 42px;
  padding: 0.55rem 1.05rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { min-height: 32px; padding: 0.25rem 0.7rem; font-size: 0.82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.link { border: 0; background: none; min-height: 0; padding: 0.2rem 0; color: var(--accent); font-weight: 500; text-decoration: underline; }

.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 500; font-size: 0.9rem; }
.field .hint { font-size: 0.8rem; color: var(--muted); }
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 42px;
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:disabled, select:disabled { opacity: 0.7; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.card.flat { padding: 0; overflow: hidden; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 0.9rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.id-ok { padding: 10px 12px; border-radius: 8px; background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: 0.92rem; overflow-wrap: anywhere; }
.form-error { color: var(--bad); font-size: 0.9rem; }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Hộp thoại và thông báo ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(8, 14, 20, 0.55); overflow-y: auto; }
.modal { width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.modal.wide { max-width: 760px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.toasts { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 480px; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25); }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); white-space: nowrap; background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }

/* =====================================================================
   CỔNG SINH VIÊN
   ===================================================================== */
.page { max-width: none; margin-inline: 0; padding-inline: clamp(16px, 3vw, 48px); padding-block: 28px 56px; }
/* Các màn hình làm bài, chờ và kết quả giữ bề rộng đọc thoải mái ở giữa; trang chủ dàn rộng, cột thông tin sát trái. */
.page > section:not(#screen-home) { max-width: 1080px; margin-inline: auto; }
.home-head { display: grid; gap: 8px; max-width: 46rem; margin-bottom: 26px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); grid-template-areas: "id exams"; gap: 20px 28px; align-items: start; }
.home-id { grid-area: id; }
.home-main { grid-area: exams; display: grid; gap: 28px; align-content: start; min-width: 0; }
@media (max-width: 860px) { .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "exams"; } }
.exam-section + .exam-section { margin-top: 28px; }
.exam-section > h2 { margin-bottom: 12px; }
.exam-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.exam-card { display: grid; gap: 10px; align-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.exam-card h3 { font-size: 1.02rem; }
.exam-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.resume { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 22px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); }
.rules { display: grid; gap: 8px; padding: 0; margin: 12px 0 0; list-style: none; }
.rules li { position: relative; padding-left: 20px; max-width: 62ch; font-size: 0.92rem; }
.rules li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }

.wait { max-width: 560px; margin: 8vh auto 0; text-align: left; }
.wait .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); display: inline-block; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .wait .dot { animation: none; } }

#screen-exam { position: relative; z-index: 2; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.watermark { position: fixed; inset: 0; z-index: 1; pointer-events: none; background-repeat: repeat; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.tb-title { min-width: 0; display: grid; }
.tb-title strong { font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title span { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-right { display: flex; align-items: center; gap: 10px; flex: none; }
.pill { font-size: 0.78rem; font-weight: 600; padding: 0.25rem 0.65rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); white-space: nowrap; }
.pill.has { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.pill.off { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.timer { font: 600 1.3rem var(--font-mono); font-variant-numeric: tabular-nums; padding: 0.1rem 0.6rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.timer.low { color: var(--warn); border-color: var(--warn); }
.timer.crit { color: var(--bad); border-color: var(--bad); }
@media (max-width: 480px) { .pill.hide-sm:not(.has):not(.off) { display: none; } }

.exam-body { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 28px; margin-top: 20px; align-items: start; }
@media (max-width: 899px) { .exam-body { grid-template-columns: minmax(0, 1fr); } }
.q-card { scroll-margin-top: 80px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.q-num { font: 600 0.8rem var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.q-tools { display: flex; gap: 8px; align-items: center; }
.flag-btn { font: 500 0.82rem var(--font-ui); padding: 0.3rem 0.7rem; min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.flag-btn[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.q-text { font-family: var(--font-text); font-weight: 400; font-size: clamp(1.1rem, 2.6vw, 1.3rem); line-height: 1.5; margin-bottom: 18px; text-wrap: pretty; letter-spacing: 0; white-space: pre-line; }
.opts { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 10px; }
.opt { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.opt:hover { border-color: var(--muted); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.bubble { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font: 600 0.8rem var(--font-ui); color: var(--muted); transition: background 0.12s, color 0.12s, border-color 0.12s; }
.opt-text { padding-top: 3px; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input:checked + .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.q-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }

.palette { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
@media (max-width: 899px) { .palette { position: static; } }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 8px; margin: 12px 0; }
.pal-btn { position: relative; overflow: hidden; min-height: 42px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 600 0.9rem var(--font-mono); cursor: pointer; }
.pal-btn.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pal-btn.cur { outline: 2px solid var(--ink); outline-offset: 2px; }
.pal-btn.flag::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 14px 14px 0; border-color: transparent var(--warn) transparent transparent; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 16px; padding: 0; font-size: 0.78rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { position: relative; overflow: hidden; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); display: inline-block; }
.sw.done { background: var(--accent); border-color: var(--accent); }
.sw.flag::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 8px 8px 0; border-color: transparent var(--warn) transparent transparent; }

.score-row { display: flex; flex-wrap: wrap; gap: 20px 48px; align-items: flex-end; margin-top: 22px; }
.score { font-family: var(--font-text); font-weight: 600; font-size: clamp(3.4rem, 12vw, 5.5rem); line-height: 1; font-variant-numeric: tabular-nums; }
.score .of { font-size: 1.4rem; color: var(--muted); margin-left: 0.4rem; font-weight: 400; }
.stats { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; }
.stats dt { font-size: 0.75rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font: 600 1.15rem var(--font-mono); font-variant-numeric: tabular-nums; }
.section { margin-top: 34px; }
.log { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.log li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.log time { font: 500 0.82rem var(--font-mono); color: var(--muted); }
.rv-item { padding: 18px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.rv-item:first-child { border-top: 1px solid var(--line); margin-top: 12px; }
.rv-top { display: flex; align-items: center; gap: 10px; }
.rv-q { font-family: var(--font-text); font-size: 1.05rem; line-height: 1.5; white-space: pre-line; }
.rv-opts { display: grid; gap: 4px; font-size: 0.92rem; }
.rv-opt { display: flex; gap: 8px; padding: 4px 8px; border-radius: 6px; }
.rv-opt b { flex: none; width: 1.4em; }
.rv-opt.right { background: var(--ok-soft); color: var(--ok); }
.rv-opt.wrong { background: var(--bad-soft); color: var(--bad); }
.rv-opt span { min-width: 0; overflow-wrap: anywhere; }
.rv-explain { font-size: 0.9rem; color: var(--muted); max-width: 70ch; white-space: pre-line; }

/* =====================================================================
   CỔNG GIẢNG VIÊN
   ===================================================================== */
.login { max-width: 400px; margin: 12vh auto 0; padding-inline: 16px; }
.admin { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink); padding: 22px 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.side .brand { padding: 0 12px 18px; font-family: var(--font-text); font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.side .brand small { display: block; margin-top: 4px; font: 500 0.75rem var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; }
.side a.nav { display: block; padding: 10px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; font-size: 0.93rem; }
.side a.nav:hover { background: rgba(255, 255, 255, 0.08); }
.side a.nav[aria-current="page"] { background: rgba(255, 255, 255, 0.16); }
.side .course-pick-wrap { display: grid; gap: 4px; padding: 0 4px 12px; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.95; }
.side .course-pick-wrap select { font: 600 0.9rem var(--font-ui); letter-spacing: 0; text-transform: none; padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.12); color: inherit; width: 100%; }
.side .course-pick-wrap select option { color: #111; }
.side .spacer { flex: 1; }
.side .btn { background: transparent; color: inherit; border-color: rgba(255, 255, 255, 0.3); }
.admin-main { min-width: 0; padding: 28px clamp(16px, 3vw, 36px) 64px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-head p { margin-top: 4px; }
@media (max-width: 860px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 12px; }
  .side .brand { display: none; }
  .side a.nav { white-space: nowrap; }
  .side .spacer { display: none; }
}
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile .k { font-size: 0.78rem; color: var(--muted); }
.tile .v { font: 600 1.7rem var(--font-mono); font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li.active { background: var(--accent-soft); }
.list .pick { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; overflow-wrap: anywhere; }
.list .count { font: 500 0.8rem var(--font-mono); color: var(--muted); }
.q-row { display: grid; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.q-row:last-child { border-bottom: 0; }
.q-row .q-t { white-space: pre-line; }
.q-row ol { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 2px; font-size: 0.9rem; color: var(--muted); }
.q-row li.right { color: var(--ok); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.ratio-table input { width: 84px; text-align: right; }
.ratio-sum.bad { color: var(--bad); font-weight: 600; }
.ratio-sum.ok { color: var(--ok); font-weight: 600; }
.opt-edit { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.opt-edit .letter { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font-weight: 600; font-size: 0.8rem; color: var(--muted); }
.opt-edit input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ok); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: 600 0.9rem var(--font-ui); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.live-board { text-align: center; padding: 28px 16px; }
.live-board .state { font-family: var(--font-text); font-weight: 600; font-size: clamp(1.4rem, 4vw, 2rem); }
.live-board .clock { font: 600 clamp(2.6rem, 9vw, 4.2rem) var(--font-mono); font-variant-numeric: tabular-nums; color: var(--accent); line-height: 1.2; }
.import-preview { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.import-preview .item { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 0.86rem; }
.import-preview .item:last-child { border-bottom: 0; }
.import-preview .item.err { background: var(--bad-soft); }
.import-preview .item .errs { color: var(--bad); }

/* ---------- Bổ sung cho màn hình điều khiển, kết quả, danh sách ---------- */
.row.center { justify-content: center; }
.live-board > * + * { margin-top: 12px; }
.card + .card, .card + .tiles, .tiles + .card, .card + .tabs, .card + .two-col, .tiles + .two-col { margin-top: 16px; }
.btn.big { padding: 14px 28px; font-size: 1.1rem; }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline select { min-width: 220px; }
.log { margin: 8px 0 16px; padding-left: 18px; font-size: 0.9rem; }
.review { padding-left: 20px; }
.review > li { margin-bottom: 18px; }
.review .opts { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; }
.review .opts li { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.review .opts li.good { background: var(--ok-soft); border-color: var(--ok); }
.review .opts li.bad { background: var(--bad-soft); border-color: var(--bad); }

.qr-box { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.qr-box img { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.qr-big { display: block; margin: 0 auto; width: min(80vw, 70vh); height: min(80vw, 70vh); image-rendering: pixelated; background: #fff; padding: 14px; border-radius: 12px; }

/* Danh sách sinh viên: thanh công cụ lọc và chuyển lớp */
.tools { gap: .6rem; align-items: end; margin: .4rem 0 .6rem; }
.tools .field.grow { flex: 1 1 14rem; margin: 0; }
table.roster th, table.roster td { white-space: nowrap; padding: .4rem .6rem; }
table.roster td:first-child, table.roster th:first-child { width: 2rem; }

/* ---------- Quản trị website ---------- */
.side .nav-label { margin: 14px 12px 2px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; opacity: 0.6; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.two-col.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.md-editor { font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.6; min-height: 320px; }
.md-preview { min-height: 320px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.md-guide summary { cursor: pointer; font-weight: 500; }
.md-guide pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
@media (max-width: 720px) { .two-col.even { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .side .nav-label { display: none; } }

/* ---------- Nền ảnh Mù Cang Chải tự đổi (chỉ dùng CSS, không cần JavaScript) ---------- */
.banner { position: relative; width: 100vw; margin-inline: calc(50% - 50vw); height: clamp(120px, 17vw, 230px); overflow: hidden; background: var(--bg); box-shadow: 0 10px 28px -18px rgba(60, 45, 10, 0.6); }
.banner.banner-sm { height: clamp(90px, 11vw, 150px); margin-bottom: 20px; }
html, body { overflow-x: clip; }
.banner i { position: absolute; inset: 0; opacity: 0; background-position: center; background-size: cover; background-repeat: no-repeat; animation: bgfade 132s linear infinite; }
.banner i:nth-child(1) { background-image: url('/img/nen-1.webp'); animation-delay: 0s; }
.banner i:nth-child(2) { background-image: url('/img/nen-2.webp'); animation-delay: 12s; }
.banner i:nth-child(3) { background-image: url('/img/nen-3.webp'); animation-delay: 24s; }
.banner i:nth-child(4) { background-image: url('/img/nen-4.webp'); animation-delay: 36s; }
.banner i:nth-child(5) { background-image: url('/img/nen-5.webp'); animation-delay: 48s; }
.banner i:nth-child(6) { background-image: url('/img/nen-6.webp'); animation-delay: 60s; }
.banner i:nth-child(7) { background-image: url('/img/nen-7.webp'); animation-delay: 72s; }
.banner i:nth-child(8) { background-image: url('/img/nen-8.webp'); animation-delay: 84s; }
.banner i:nth-child(9) { background-image: url('/img/nen-9.webp'); animation-delay: 96s; }
.banner i:nth-child(10) { background-image: url('/img/nen-10.webp'); animation-delay: 108s; }
.banner i:nth-child(11) { background-image: url('/img/nen-11.webp'); animation-delay: 120s; }
@keyframes bgfade { 0% { opacity: 0; } 1.894% { opacity: 1; } 9.091% { opacity: 1; } 10.985% { opacity: 0; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .banner i { animation: none; }
  .banner i:nth-child(1) { opacity: 1; }
}

/* ---------- Chọn môn học trong phòng thi ---------- */
.subjects { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.subject-label { font-weight: 500; color: var(--muted); margin-right: 4px; }
.subject-tab { font: inherit; font-weight: 500; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.subject-tab:hover { border-color: var(--accent); }
.subject-tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ai-box > summary { cursor: pointer; }
.ai-box[open] > summary { margin-bottom: 8px; }

/* Tiến độ của sinh viên */
.prog-num { font-size: 2rem; line-height: 1; color: var(--accent, #1b7f3b); }
.bar { height: .7rem; border-radius: 99px; background: rgba(0,0,0,.08); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: #1f8a3f; border-radius: 99px; }
#btn-progress { align-self: flex-start; }

/* Trạng thái bài thi ở trang chủ: đang mở = xanh, chưa mở / đã đóng / hết lượt = đen */
.exam-card.on { border-color: var(--accent); }
.exam-card.off { border-color: var(--ink); }
.btn.dark, .btn.dark:disabled { background: var(--ink); border-color: var(--ink); color: var(--bg); opacity: 1; cursor: not-allowed; }
.badge.dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Thống kê điểm ở trang Bài thi */
.stats-area { margin-top: 28px; display: grid; gap: 14px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.stat-card { display: grid; gap: 12px; align-content: start; }
.stat-card h3 { font-size: 1.05rem; }
.stat-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.stat-grid dt { font-size: 0.74rem; color: var(--muted); }
.stat-grid dd { margin: 2px 0 0; font: 600 1.15rem var(--font-mono); font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .col { fill: var(--accent); }
.chart .col.low { fill: var(--warn); }
.chart .val { font: 600 10px var(--font-mono); fill: var(--ink); }
.chart .tick, .chart .cap { font: 500 10px var(--font-ui); fill: var(--muted); }
.chart-empty { padding: 28px 0; text-align: center; }
.q-thumb { display: block; max-width: min(100%, 420px); max-height: 240px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; object-fit: contain; }

/* Đăng nhập, xác nhận, chọn môn */
.login-grid { display: grid; grid-template-columns: minmax(0, 440px); }
.login-card { max-width: 520px; }
#screen-confirm { display: grid; gap: 16px; align-content: start; }
#screen-confirm[hidden] { display: none; }
.who-name { font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
.id-ok { color: var(--ok, #1b7a46); font-weight: 600; }
.q-img { display: block; max-width: 100%; max-height: 360px; margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.q-img[hidden] { display: none; }

.prog-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.prog-10 { display: flex; align-items: baseline; gap: 8px; margin-left: auto; text-align: right; }

/* ---------- Nhóm học tập và điểm danh ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.group-card h3 { font-size: 1rem; margin: 0; }
.group-card.warnbox { border-color: var(--warn); }
.members { display: grid; gap: 2px; margin-top: 8px; }
.member { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; padding: 3px 0; cursor: pointer; }
.plan { max-height: 260px; overflow: auto; display: grid; gap: 6px; font-size: 0.88rem; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 0.35rem 0.9rem; font: inherit; font-weight: 500; cursor: pointer; min-height: 36px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.att-table input.big { width: 1.35rem; height: 1.35rem; }
.att-table tr.is-absent td { background: var(--bad-soft); }
.att-table td, .att-table th { text-align: left; }
.code-box { font-size: 2.4rem; font-weight: 600; letter-spacing: 0.12em; padding: 0.2rem 1rem; border: 2px dashed var(--accent); border-radius: 12px; color: var(--accent); }
.class-card h2 { font-size: 1.1rem; margin: 0; }
.class-card h3 { font-size: 0.95rem; margin: 0 0 6px; }
.class-card .class-part + .class-part { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.class-card .mini-list { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 4px; font-size: 0.9rem; }
.class-card .mini-list li { display: flex; justify-content: space-between; gap: 10px; }
.join-code { font: 600 1.3rem var(--font-mono); letter-spacing: 0.15em; }
.class-card input[type="text"] { max-width: 16rem; }
.field.inline > label { white-space: nowrap; }
input[type="date"], input[type="datetime-local"], input[type="number"] { font: inherit; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); min-height: 40px; }
.class-card .mini-list + .join-code, .class-card [data-act="leave"] { margin-top: 4px; }
.class-card .member-list li { flex-wrap: wrap; align-items: baseline; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.class-card .mem-mail { color: var(--accent); overflow-wrap: anywhere; }
.member-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 0; }
.member-row .member { flex: 1 1 14rem; }
.member-row .btn.sm { min-height: 28px; padding: 0.1rem 0.55rem; font-size: 0.78rem; }
select[data-class-leader] { min-width: 16rem; max-width: 100%; }

.star-red { color: var(--bad); font-weight: 700; letter-spacing: -0.05em; }
