/* ===================================================================
   Website trắc nghiệm An toàn thông tin — giao diện chung
   Phong cách: nền sáng, màu phẳng (không gradient), tông đỏ – vàng
   =================================================================== */
:root {
  /* Màu chủ đạo: đỏ cờ, vàng đồng */
  --red: #b3141b;
  --red-dark: #8c0f14;
  --red-50: #fcefef;
  --red-100: #f6d5d6;
  --gold: #c8960c;
  --gold-dark: #8a6508;
  --gold-50: #fbf5e3;

  /* Màu cho biểu đồ (tách khỏi màu thương hiệu) */
  --data: #1f4e8c;
  --data-50: #e9f0f9;

  --ink: #1c1f26;
  --ink-2: #3e4451;
  --muted: #6b7280;
  --line: #e6e2da;
  --line-2: #d4cfc4;
  --bg: #f7f5f1;
  --card: #ffffff;
  --soft: #faf8f4;

  --good: #15803d;
  --good-bg: #e5f4ea;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --warn: #92600a;
  --warn-bg: #fdf3dc;
  --info: #1f4e8c;
  --info-bg: #e9f0f9;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(28, 31, 38, .05);
  --shadow: 0 2px 10px rgba(28, 31, 38, .06);
  --shadow-lg: 0 16px 40px rgba(28, 31, 38, .16);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
svg.i { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }
::selection { background: var(--red-100); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  height: 42px; padding: 0 18px;
  border: 1px solid var(--red); border-radius: var(--radius-sm);
  font: 600 14.5px/1 var(--font);
  cursor: pointer; white-space: nowrap;
  background: var(--red); color: #fff;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); text-decoration: none; }
.btn:focus-visible { outline: 3px solid var(--red-100); outline-offset: 1px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-light { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-light:hover { background: var(--soft); color: var(--red); border-color: var(--red); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-ghost:hover { background: rgba(28, 31, 38, .05); color: var(--ink); border-color: transparent; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: #8f1c13; border-color: #8f1c13; }
.btn-good { background: var(--good); border-color: var(--good); }
.btn-good:hover { background: #166534; border-color: #166534; }
.btn-gold { background: var(--red); border-color: var(--red); color: #fff; }
.btn-gold:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-block { width: 100%; }
.icon-btn { width: 34px; padding: 0; }

/* ---------- Ô nhập ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--muted); }
.req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
  font: 400 15px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.input::placeholder { color: #9aa0aa; }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px var(--red-50); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > .input { padding-left: 40px; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 44px; height: 24px; border-radius: 12px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 9px; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--red-100); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; background: #fff; }
.seg button { border: 0; border-right: 1px solid var(--line-2); background: #fff; padding: 8px 14px; font: 600 13.5px var(--font); color: var(--muted); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--red); color: #fff; }

/* ---------- Thẻ, nhãn ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-head h3 { font-size: 16.5px; font-weight: 700; }
.card-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge svg.i { display: none; }
.badge-good { background: var(--good-bg); color: var(--good); border-color: #c4e5cf; }
.badge-bad { background: var(--bad-bg); color: var(--bad); border-color: #f5c9c4; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca8; }
.badge-blue { background: var(--info-bg); color: var(--info); border-color: #cbdaee; }
.badge-gray { background: #f1efea; color: var(--muted); border-color: var(--line); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: Consolas, "Cascadia Mono", "Courier New", monospace; }
.nowrap { white-space: nowrap; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 20px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.ta-r { text-align: right; }
.big { font-size: 16px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid transparent; }
.alert svg.i { display: none; }
.alert-bad { background: var(--bad-bg); color: var(--bad); border-color: #f5c9c4; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca8; }
.alert-info { background: var(--gold-50); color: var(--gold-dark); border-color: #ecd9a2; }

.avatar { width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center; font-weight: 700; font-size: 13.5px; background: var(--red); color: #fff; flex: none; }
.avatar.soft { background: var(--red-50); color: var(--red-dark); }

kbd { font: 600 11.5px var(--font); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: #fff; color: var(--ink-2); }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); background: var(--soft); padding: 11px 14px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #fdfcfa; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .chk { width: 40px; }
.table input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--red); cursor: pointer; }
.cell-name { font-weight: 600; white-space: nowrap; }
.cell-sub { color: var(--muted); font-size: 13px; }
.cell-sub.ellipsis { max-width: 260px; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty svg.i { display: none; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.attempt-count { display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 4px; background: #f1efea; font-weight: 700; }
.td-actions .btn + .btn { margin-left: 4px; }
.cv { min-width: 0; }

/* ---------- Thông báo nổi, hộp thoại ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px; padding: 13px 16px; background: var(--ink); color: #fff; border-radius: var(--radius-sm); border-left: 4px solid var(--good); box-shadow: var(--shadow-lg); font-size: 14px; animation: toastIn .25s ease; }
.toast svg.i { display: none; }
.toast.bad { border-left-color: #f87171; }
.toast.info { border-left-color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

.modal-back { position: fixed; inset: 0; z-index: 900; background: rgba(28, 31, 38, .45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn .15s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: var(--radius); border-top: 4px solid var(--red); box-shadow: var(--shadow-lg); animation: popIn .2s ease; }
.modal.wide { max-width: 860px; }
.modal-head { padding: 20px 24px 6px; display: flex; gap: 14px; align-items: flex-start; }
.modal-head h3 { font-size: 18px; }
.modal-head .btn-ghost { flex: none; }
.modal-icon { display: none; }
.modal-body { padding: 10px 24px 4px; color: var(--ink-2); }
.modal-foot { padding: 18px 24px 22px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal-foot svg.i { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px); } }

.tip { position: fixed; z-index: 1100; pointer-events: none; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; box-shadow: var(--shadow-lg); max-width: 320px; }

/* ---------- Logo ---------- */
.logos { display: inline-flex; align-items: center; gap: 14px; }
.logos img { display: block; height: 56px; width: auto; }
.logos .sep { width: 1px; height: 36px; background: var(--line-2); }
.logos-sm { gap: 10px; }
.logos-sm img { height: 40px; }
.logos-sm .sep { height: 26px; }
.logos-side img { height: 44px; }
.logos-lg { margin: 0 auto 18px; }
.brand { display: flex; align-items: center; gap: 14px; color: inherit; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-text { min-width: 0; }
.brand-text b { display: block; font-size: 15px; line-height: 1.25; color: var(--ink); }
.brand-text span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; }

/* Dải đỏ – vàng trên cùng (nhận diện cổng thông tin cơ quan nhà nước) */
.gov-strip { height: 5px; background: var(--red); border-bottom: 2px solid var(--gold); box-sizing: content-box; }

/* ===================================================================
   TRANG CHỦ (nhập thông tin)
   =================================================================== */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 92px; padding-top: 14px; padding-bottom: 12px; }
.header-text { border-left: 1px solid var(--line-2); padding-left: 20px; min-width: 0; }
.header-text .ht-top { display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-dark); }
.header-text .ht-main { display: block; font-size: 18px; font-weight: 800; color: var(--red); text-transform: uppercase; letter-spacing: .01em; line-height: 1.3; }

.hero-photo { position: relative; height: 440px; background: #cfe0ef url("/img/dat-mui-1920.jpg") center 70% / cover no-repeat; }
.hero-photo .wrap { position: relative; height: 100%; display: flex; align-items: flex-end; padding-bottom: 36px; }
.hero-panel { max-width: 640px; background: #fff; padding: 26px 30px 28px; border-radius: var(--radius); border-left: 5px solid var(--red); box-shadow: var(--shadow-lg); }
.kicker { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-dark); padding-bottom: 6px; border-bottom: 2px solid var(--gold); }
.kicker svg.i { display: none; }
.hero-panel h1 { margin: 14px 0 10px; font-size: clamp(24px, 2.6vw, 34px); font-weight: 800; color: var(--red-dark); line-height: 1.22; }
.hero-panel p { color: var(--ink-2); font-size: 15.5px; }
.photo-credit { position: absolute; right: 10px; bottom: 6px; font-size: 11px; color: rgba(255, 255, 255, .92); text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.photo-credit a { color: inherit; text-decoration: underline; }

.home-main { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 40px; padding-top: 40px; padding-bottom: 56px; align-items: start; }
.section-title { font-size: 20px; font-weight: 800; color: var(--ink); padding-bottom: 10px; margin-bottom: 18px; border-bottom: 2px solid var(--line); position: relative; }
.section-title::after { content: ""; position: absolute; left: 0; bottom: -2px; width: 64px; height: 2px; background: var(--red); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.facts > div { padding: 18px 20px; border-right: 1px solid var(--line); }
.facts > div:last-child { border-right: 0; }
.facts b { display: block; font-size: 30px; font-weight: 800; color: var(--red); line-height: 1.1; font-variant-numeric: tabular-nums; }
.facts span { font-size: 13.5px; color: var(--muted); }
.steps-list { list-style: none; counter-reset: s; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.steps-list li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: start; color: var(--ink-2); }
.steps-list li::before { content: counter(s); width: 34px; height: 34px; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 700; border-radius: 6px; }
.steps-list b { display: block; color: var(--ink); }
.note-box { margin-top: 24px; padding: 14px 16px; background: var(--gold-50); border: 1px solid #ecd9a2; border-left: 4px solid var(--gold); border-radius: var(--radius-sm); color: var(--gold-dark); font-size: 14px; }
.note-box b { color: #6b4e05; }

.form-card { padding: 28px 28px 26px; border-top: 4px solid var(--red); box-shadow: var(--shadow); }
.form-card h2 { font-size: 21px; font-weight: 800; }
.form-card .lead { color: var(--muted); margin: 4px 0 22px; font-size: 14.5px; }
.form-card form { display: flex; flex-direction: column; gap: 16px; }
.who-card { display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); }
.who-card .avatar { width: 48px; height: 48px; font-size: 16px; }
.who-card b { display: block; font-size: 16.5px; }
.who-card span { display: block; font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; }
.who-card + .alert { margin-top: 14px; }

.site-footer { background: #fff; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 18px; }
.site-footer a { color: var(--ink-2); }

/* ===================================================================
   KHUNG TRANG HỌC VIÊN
   =================================================================== */
.topbar { position: sticky; top: 0; z-index: 50; background: #fff; border-top: 4px solid var(--red); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 20px; height: 68px; display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-chip .n { font-size: 13.5px; font-weight: 600; line-height: 1.2; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .u { font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .btn-ghost { color: var(--ink-2); border: 1px solid var(--line-2); }
.topbar .btn-ghost svg.i { display: none; }
.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

/* Lời chào */
.welcome { display: grid; grid-template-columns: minmax(0, 1fr) 260px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.welcome-body { padding: 28px 32px; }
.welcome-photo { background: #cfe0ef url("/img/dat-mui-square.jpg") center / cover no-repeat; min-height: 220px; }
.welcome h1 { font-size: clamp(21px, 2.3vw, 28px); font-weight: 800; color: var(--red-dark); margin: 12px 0 8px; }
.welcome p { color: var(--ink-2); max-width: 640px; }
.welcome p b { color: var(--ink); }
.welcome .row { margin-top: 22px; }
.welcome .btn svg.i { display: none; }
.welcome .badge { white-space: normal; }

.dash-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; margin-top: 22px; }
.info-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.info-item { padding: 16px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.info-item:nth-child(2n) { border-right: 0; }
.info-item:nth-last-child(-n+2) { border-bottom: 0; }
.info-item .ic { display: none; }
.info-item b { display: block; font-size: 19px; font-weight: 800; color: var(--red); line-height: 1.2; }
.info-item span { font-size: 13px; color: var(--muted); }
.rules { margin: 20px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rules li { position: relative; padding-left: 18px; color: var(--ink-2); font-size: 14.5px; }
.rules li::before { content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; background: var(--red); }
.rules li svg.i { display: none; }

.history-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.score-pill { width: 52px; height: 52px; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none; background: #f1efea; color: var(--ink-2); border: 1px solid var(--line); }
.score-pill svg.i { width: 20px; height: 20px; }
.score-pill.good { background: var(--good-bg); color: var(--good); border-color: #c4e5cf; }
.score-pill.bad { background: var(--bad-bg); color: var(--bad); border-color: #f5c9c4; }

/* ===================================================================
   LÀM BÀI
   =================================================================== */
.quizbar { position: sticky; top: 0; z-index: 60; background: #fff; border-top: 4px solid var(--red); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.quizbar-in { max-width: 1180px; margin: 0 auto; padding: 0 20px; height: 66px; display: flex; align-items: center; gap: 16px; }
.quiz-logo { width: 42px; height: 42px; flex: none; }
.quizbar .title { font-weight: 700; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quizbar .title small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.quizbar .btn svg.i { display: none; }
.timer { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: #fff; color: var(--ink); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.timer svg.i { display: none; }
.timer::before { content: "Còn lại"; font-size: 12px; font-weight: 600; color: var(--muted); }
.timer.warn { background: var(--warn-bg); border-color: #f0dca8; color: var(--warn); }
.timer.danger { background: var(--bad-bg); border-color: #f5c9c4; color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.progress { height: 4px; background: var(--line); }
.progress > i { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.save-state { font-size: 12.5px; color: var(--muted); }
.save-state svg.i { display: none; }

.quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
.q-card { padding: 30px 32px; }
.q-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.q-no { font-size: 13px; font-weight: 800; color: var(--red); letter-spacing: .06em; text-transform: uppercase; }
.q-text { font-size: 20px; font-weight: 700; line-height: 1.5; color: var(--ink); }
.options { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.option {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff;
  font: 400 16px/1.5 var(--font); color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: var(--red); background: var(--soft); }
.option:focus-visible { outline: 3px solid var(--red-100); }
.option .key { width: 32px; height: 32px; border-radius: 4px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 14px; background: #f1efea; color: var(--ink-2); transition: background .15s, color .15s; }
.option .txt { padding-top: 4px; }
.option.selected { border-color: var(--red); background: var(--red-50); box-shadow: inset 4px 0 0 var(--red); }
.option.selected .key { background: var(--red); color: #fff; }
.q-actions { display: flex; align-items: center; gap: 10px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.q-actions svg.i { display: none; }
.flag-btn.on { background: var(--gold-50); color: var(--gold-dark); border-color: var(--gold); }
.kbd-hint { font-size: 12.5px; color: var(--muted); margin-top: 14px; }

.nav-card { position: sticky; top: 92px; padding: 20px; }
.nav-card h4 { font-size: 14.5px; margin-bottom: 4px; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 16px 0; }
.nav-grid button {
  position: relative; height: 40px; border-radius: 4px; border: 1px solid var(--line-2); background: #fff;
  font: 600 14px var(--font); color: var(--ink-2); cursor: pointer; transition: all .12s;
}
.nav-grid button:hover { border-color: var(--red); }
.nav-grid button.done { background: var(--red); border-color: var(--red); color: #fff; }
.nav-grid button.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.nav-grid button.flag::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; background: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border: 1px solid var(--line-2); display: inline-block; }
.legend i.done { background: var(--red); border-color: var(--red); }
.legend i.flag { background: var(--gold); border-color: var(--gold); width: 8px; height: 8px; }
.nav-stats { display: flex; justify-content: space-between; padding: 12px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.nav-stats b { font-size: 16px; }

/* ===================================================================
   KẾT QUẢ
   =================================================================== */
.result-hero { display: grid; grid-template-columns: auto 1fr; gap: 36px; align-items: center; padding: 32px 36px; border-top: 4px solid var(--red); }
.result-hero .btn svg.i { display: none; }
.ring { position: relative; width: 190px; height: 190px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .bg { stroke: #ece8e0; }
.ring .fg { transition: stroke-dashoffset 1.2s cubic-bezier(.2,.8,.2,1); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .val b { font-size: 46px; font-weight: 800; line-height: 1; color: var(--ink); }
.ring .val span { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.result-hero h2 { font-size: 25px; font-weight: 800; margin: 10px 0 6px; }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 22px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.result-stats div { padding: 14px 16px; border-right: 1px solid var(--line); background: #fff; }
.result-stats div:last-child { border-right: 0; }
.result-stats b { display: block; font-size: 22px; font-weight: 800; }
.result-stats span { font-size: 13px; color: var(--muted); }
.review-item { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; }
.review-q { display: flex; gap: 12px; font-weight: 600; font-size: 15.5px; }
.review-q .num { width: 30px; height: 30px; border-radius: 4px; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 700; }
.review-q .num.good { background: var(--good-bg); color: var(--good); }
.review-q .num.bad { background: var(--bad-bg); color: var(--bad); }
.review-q .num.none { background: #f1efea; color: var(--muted); }
.review-opts { margin: 12px 0 0 42px; display: flex; flex-direction: column; gap: 6px; }
.review-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14.5px; color: var(--ink-2); border: 1px solid transparent; }
.review-opt .k { font-weight: 700; width: 18px; flex: none; }
.review-opt.correct { background: var(--good-bg); color: #14532d; border-color: #c4e5cf; }
.review-opt.wrong { background: var(--bad-bg); color: #7f1d1d; border-color: #f5c9c4; }
.review-opt .tag { margin-left: auto; font-size: 12px; font-weight: 700; white-space: nowrap; }
.review-opt .tag svg.i { display: none; }

/* ===================================================================
   QUẢN TRỊ
   =================================================================== */
.admin-login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); border-top: 5px solid var(--red); }
.admin-login-card { width: 100%; max-width: 420px; padding: 32px 28px; text-align: center; box-shadow: var(--shadow); }
.admin-login-card form { text-align: left; }
.admin-login-card h2 { font-size: 22px; font-weight: 800; color: var(--red-dark); }
.admin-login-card .input-icon > svg { display: none; }
.admin-login-card .input-icon > .input { padding-left: 14px; }

.admin-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; border-top: 4px solid var(--red); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; overflow-y: auto; }
.side-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 4px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--ink); }
.side-brand:hover { text-decoration: none; }
.side-brand .brand-text b { color: var(--red); text-transform: uppercase; font-size: 14px; letter-spacing: .02em; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-dark); padding: 14px 12px 6px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; font-size: 14.5px; margin-bottom: 2px; border-left: 3px solid transparent; }
.side-nav a svg.i { color: var(--muted); }
.side-nav a:hover { background: var(--soft); color: var(--ink); text-decoration: none; }
.side-nav a.on { background: var(--red-50); color: var(--red-dark); font-weight: 700; border-left-color: var(--red); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.side-nav a.on svg.i { color: var(--red); }
.side-nav a .count { margin-left: auto; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: #f1efea; color: var(--ink-2); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.side-foot .user-chip { padding: 6px; }
.side-foot .btn-ghost { justify-content: flex-start; width: 100%; }

.main { min-width: 0; }
.main-head { position: sticky; top: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--line); }
.main-head-in { padding: 16px 32px; display: flex; align-items: center; gap: 16px; }
.head-title { flex: 1; min-width: 0; }
.head-title .crumb { font-size: 12.5px; color: var(--gold-dark); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main-head h1 { font-size: 22px; font-weight: 800; }
.head-actions { flex-wrap: nowrap; }
.main-body { padding: 26px 32px 60px; max-width: 1400px; }
.menu-btn { display: none; }

.class-banner { display: flex; align-items: center; gap: 18px; padding: 20px 24px; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--red); border-radius: var(--radius); margin-bottom: 20px; flex-wrap: wrap; }
.class-banner .ic { display: none; }
.class-banner small { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-dark); font-weight: 700; }
.class-banner h2 { font-size: 19px; font-weight: 800; color: var(--red-dark); margin-top: 2px; }
.class-banner > div > div { color: var(--muted); opacity: 1 !important; }
.banner-switch { padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); }
.banner-switch span[style] { opacity: 1 !important; color: var(--muted); }

.share { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 20px; flex-wrap: wrap; }
.share .ic { display: none; }
.share-link { font-size: 15px; color: var(--red); font-weight: 700; overflow-wrap: anywhere; }
.share .btn svg.i { display: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; border-top: 3px solid var(--red); }
.stat:nth-child(2) { border-top-color: var(--gold); }
.stat:nth-child(3) { border-top-color: var(--good); }
.stat:nth-child(4) { border-top-color: var(--data); }
.stat .ic { display: none; }
.stat .v { font-size: 30px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-top: 20px; align-items: start; }

.histo { display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; align-items: end; height: 200px; margin-top: 26px; border-bottom: 1px solid var(--line-2); position: relative; }
.histo .col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; }
.histo .bar { width: 70%; max-width: 34px; background: var(--data); border-radius: 3px 3px 0 0; transition: height .6s cubic-bezier(.2,.8,.2,1), opacity .15s; }
.histo .bar.zero { background: transparent; }
.histo .col:hover .bar { opacity: .8; }
.histo .num { position: absolute; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.histo-x { display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed #ece8e0; pointer-events: none; }
.thr-line { position: absolute; top: -6px; bottom: 0; border-left: 2px dashed var(--red); pointer-events: none; }
.thr-key { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.thr-key i { width: 0; height: 16px; border-left: 2px dashed var(--red); }

.qbar { display: grid; grid-template-columns: 58px minmax(0, 1fr) 54px; gap: 12px; align-items: center; padding: 9px 0; cursor: default; }
.qbar + .qbar { border-top: 1px solid #f1eee8; }
.qbar .qn { font-weight: 700; font-size: 13px; color: var(--muted); }
.qbar .qt { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.qbar .track { height: 8px; background: #efece6; border-radius: 2px; overflow: hidden; }
.qbar .track > i { display: block; height: 100%; background: var(--data); border-radius: 2px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.qbar .pv { font-weight: 700; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .input { height: 38px; font-size: 14px; }
.toolbar .search { flex: 1 1 240px; max-width: 360px; }
.toolbar .search > svg { display: none; }
.toolbar .search > .input { padding-left: 12px; }
.toolbar select.input { width: auto; padding-right: 30px; }
.selbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--red-50); border-bottom: 1px solid var(--red-100); font-size: 14px; color: var(--red-dark); flex-wrap: wrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.hist-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

.setting-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row b { display: block; font-size: 15px; }
.setting-row span { font-size: 13.5px; color: var(--muted); }
.setting-row .input { width: 120px; }

.qbank-item { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.qbank-item:last-child { border-bottom: 0; }
.qbank-item .opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.qbank-item .o { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--soft); font-size: 14px; color: var(--ink-2); border: 1px solid var(--line); display: flex; gap: 8px; }
.qbank-item .o.ok { background: var(--good-bg); border-color: #c4e5cf; color: #14532d; font-weight: 600; }
.qbank-item .o svg.i { display: none; }

/* Bảng tự chuyển thành dạng thẻ khi khung hẹp */
.cq { container-type: inline-size; }
@container (min-width: 761px) and (max-width: 1040px) {
  .rtable .opt { display: none; }
  .rtable th, .rtable td { padding-left: 10px; padding-right: 10px; }
  .rtable .td-actions .btn span { display: none; }
  .rtable .td-actions .btn { width: 34px; padding: 0; }
  .rtable .td-unit { min-width: 150px; }
}
@container (max-width: 760px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { position: relative; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .rtable tbody tr:hover td { background: transparent; }
  .rtable td { border: 0; padding: 4px 0; text-align: left; white-space: normal; }
  .rtable td[data-label] { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: baseline; }
  .rtable td[data-label]::before { content: attr(data-label); font-size: 12.5px; color: var(--muted); font-weight: 600; }
  .rtable td.td-main { padding: 0 40px 8px 0; }
  .rtable td.chk { position: absolute; top: 14px; right: 12px; width: auto; padding: 0; }
  .rtable td.td-actions { padding-top: 10px; }
  .rtable .cell-sub.ellipsis { max-width: 100%; }
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1280px) {
  .main-body { padding: 24px 24px 56px; }
  .main-head-in { padding: 14px 24px; }
}
@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
/* Máy tính bảng ngang, laptop nhỏ */
@media (max-width: 1100px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 200; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .home-main { grid-template-columns: minmax(0, 1fr) 420px; gap: 28px; }
}
/* Máy tính bảng dọc */
@media (max-width: 960px) {
  .home-main { grid-template-columns: minmax(0, 1fr); }
  .form-card { order: -1; }
  .hero-photo { height: 380px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .quiz-layout { grid-template-columns: minmax(0, 1fr); }
  .nav-card { position: static; }
  .nav-grid { grid-template-columns: repeat(10, 1fr); }
  .q-card { padding: 24px 20px; }
  .q-text { font-size: 18px; }
  .quizbar .title small { display: none; }
  .welcome { grid-template-columns: minmax(0, 1fr) 200px; }
}
@media (max-width: 900px) {
  .head-actions .btn span { display: none; }
  .head-actions .btn { padding: 0 12px; }
  .main-head-in { padding: 12px 16px; }
  .main-body { padding: 18px 16px 50px; }
  .qbank-item .opts { grid-template-columns: 1fr; }
  .setting-row { grid-template-columns: 1fr; gap: 10px; padding: 16px; }
}
/* Điện thoại */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 16px; }
  .site-header .wrap { min-height: 0; gap: 14px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
  .site-header .logos img { height: 44px; }
  .header-text { border-left: 0; padding-left: 0; flex-basis: 100%; }
  .header-text .ht-main { font-size: 15px; }
  .hero-photo { height: auto; background: none; }
  .hero-photo::before { content: ""; display: block; height: 200px; background: #cfe0ef url("/img/dat-mui-960.jpg") center 60% / cover no-repeat; }
  .hero-photo .wrap { height: auto; padding-bottom: 0; margin-top: -40px; }
  .hero-panel { padding: 20px 18px; box-shadow: var(--shadow); }
  .hero-panel p { font-size: 14.5px; }
  .photo-credit { display: none; }
  .home-main { padding-top: 24px; gap: 28px; }
  .form-card { padding: 22px 18px; }
  .form-2col { grid-template-columns: 1fr; gap: 16px; }
  .facts > div { padding: 14px 12px; }
  .facts b { font-size: 24px; }
  .facts span { font-size: 12.5px; }

  .container { padding: 18px 14px 48px; }
  .topbar-in, .quizbar-in { padding: 0 12px; gap: 10px; height: 60px; }
  .topbar .brand-text, .user-chip .n, .user-chip .u { display: none; }
  .hide-sm { display: none; }
  .welcome { grid-template-columns: minmax(0, 1fr); }
  .welcome-photo { min-height: 130px; order: -1; }
  .welcome-body { padding: 20px 18px; }
  .welcome .row .btn-lg { width: 100%; }
  .info-list { grid-template-columns: 1fr; }
  .info-item { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .info-item:last-child { border-bottom: 0 !important; }
  .card-head { padding: 16px; }
  .card-pad { padding: 16px; }
  .history-item { padding: 12px 14px; gap: 10px; }
  .score-pill { width: 46px; height: 46px; font-size: 15px; }

  .quizbar .title, .save-state, .quiz-logo { display: none; }
  .quizbar .timer { margin-left: auto; }
  .q-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .q-actions .spacer { display: none; }
  .q-actions .flag-btn { grid-column: 1 / -1; order: -1; }
  .nav-grid { grid-template-columns: repeat(6, 1fr); }
  .option { padding: 12px 14px; font-size: 15px; }
  .kbd-hint { display: none; }

  .result-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 24px 18px; gap: 16px; }
  .result-hero .row { justify-content: center; }
  .result-hero h2 { font-size: 20px; }
  .ring { width: 160px; height: 160px; }
  .ring .val b { font-size: 38px; }
  .result-stats b { font-size: 18px; }
  .review-item { padding: 16px 14px; }
  .review-q { font-size: 14.5px; }
  .review-opts { margin-left: 0; }

  .modal-head { padding: 18px 16px 4px; }
  .modal-body { padding: 8px 16px 4px; }
  .modal-foot { padding: 14px 16px 18px; }
  .modal-foot .btn { flex: 1; }
  .toolbar { padding: 12px; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .toolbar select.input { flex: 1 1 140px; }
  .class-banner { padding: 16px; }
  .banner-switch { width: 100%; }
  .main-head h1 { font-size: 19px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .v { font-size: 24px; }
  .histo { height: 160px; }
  .histo .num, .histo-x { font-size: 11px; }
  .thr-key { font-size: 12px; }
  .qbar { grid-template-columns: 50px minmax(0, 1fr) 48px; gap: 8px; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
}
/* Điện thoại nhỏ (iPhone SE, Android màn hình nhỏ) */
@media (max-width: 380px) {
  body { font-size: 14px; }
  .wrap { padding: 0 12px; }
  .site-header .logos img { height: 38px; }
  .hero-panel h1 { font-size: 21px; }
  .facts { grid-template-columns: 1fr; }
  .facts > div { border-right: 0; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 10px; }
  .facts > div:last-child { border-bottom: 0; }
  .facts b { font-size: 22px; }
  .timer { font-size: 16px; padding: 6px 10px; }
  .timer::before { display: none; }
  .quizbar .btn { padding: 0 12px; }
  .q-card { padding: 18px 14px; }
  .q-text { font-size: 16.5px; }
  .option { padding: 11px 12px; gap: 10px; font-size: 14.5px; }
  .option .key { width: 28px; height: 28px; }
  .nav-grid { grid-template-columns: repeat(5, 1fr); }
  .result-stats { grid-template-columns: 1fr; }
  .result-stats div { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-stats div:last-child { border-bottom: 0; }
  .stats { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .topbar, .quizbar, .sidebar, .main-head, .btn, #toasts, .gov-strip { display: none !important; }
  body { background: #fff; }
  .admin-shell { display: block; border: 0; }
}
