:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --text: #111c33;
  --muted: #5d6a82;
  --border: #dbe2ee;
  --primary: #1d4ed8;
  --primary-2: #163fae;
  --on-primary: #ffffff;
  --accent: #0e9f84;
  --ok: #0f7a45;
  --ok-bg: #e2f5ea;
  --warn: #8a5600;
  --warn-bg: #fff2d6;
  --bad: #b42323;
  --bad-bg: #fde6e6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1424;
    --surface: #152038;
    --surface-2: #1c2a47;
    --text: #e8eefb;
    --muted: #9aa8c3;
    --border: #2a3a5c;
    --primary: #4c7dff;
    --primary-2: #3b6af0;
    --accent: #2fc7a6;
    --ok: #4fd18b;
    --ok-bg: #12341f;
    --warn: #f3c157;
    --warn-bg: #3a2c0b;
    --bad: #ff8080;
    --bad-bg: #3d1515;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
p { margin: .4rem 0; }
a { color: var(--primary); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.1rem; font-weight: 600; }
.center { text-align: center; }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-bad { color: var(--bad); }

/* ---------- Khung trang ---------- */
.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 16px;
  background: linear-gradient(120deg, #13286b, #1d4ed8 60%, #0e9f84);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 28px; height: 28px; }
.topbar-sub { opacity: .85; font-size: .9rem; }
.topbar .spacer { flex: 1; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .4); background: transparent; }

.container { max-width: 1180px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 480px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 940px) {
  .layout { grid-template-columns: 400px 1fr; align-items: start; }
}

/* ---------- Nút & ô nhập ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-2); }
.btn-danger { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: .35rem .8rem; font-size: .9rem; }
.btn-xs { min-height: 30px; padding: .2rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.actions .btn { flex: 1 1 auto; }

.stack > * + * { margin-top: .9rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem .75rem; min-height: 44px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.field.inline select { width: auto; min-width: 180px; }
input.big { font-size: 1.4rem; letter-spacing: .25em; text-align: center; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; align-items: end; }
.choice { display: flex; gap: .55rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.choice input { width: auto; min-height: 0; margin-top: .25rem; }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.choice.disabled { opacity: .5; cursor: not-allowed; }
.choices { display: grid; gap: .5rem; }
.check { display: flex; gap: .5rem; align-items: center; font-size: .9rem; }
.check input { width: auto; min-height: 0; }

.note { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .7rem .85rem; font-size: .9rem; }
.error { color: var(--bad); font-size: .9rem; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: .75rem 1rem; margin-bottom: 16px; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.pill { display: inline-block; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--muted); }
.count { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; align-items: center; justify-content: center; }

/* ---------- Trạng thái kết quả (SV) ---------- */
.result { text-align: center; padding: 28px 18px; }
.result-icon {
  width: 84px; height: 84px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.6rem; font-weight: 700;
}
.result h2 { font-size: 1.7rem; letter-spacing: .02em; }
.result.ok .result-icon { background: var(--ok-bg); color: var(--ok); }
.result.ok h2 { color: var(--ok); }
.result.warn .result-icon { background: var(--warn-bg); color: var(--warn); }
.result.warn h2 { color: var(--warn); }
.result.bad .result-icon { background: var(--bad-bg); color: var(--bad); }
.result.bad h2 { color: var(--bad); font-size: 1.3rem; }

.spinner {
  width: 44px; height: 44px; margin: 8px auto 14px;
  border: 4px solid var(--surface-2); border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 8px; border-radius: 8px; font-weight: 700; font-size: .85rem; background: var(--surface-2); color: var(--muted); }
.badge.P { background: var(--ok-bg); color: var(--ok); }
.badge.L { background: var(--warn-bg); color: var(--warn); }
.badge.A { background: var(--bad-bg); color: var(--bad); }

.history { list-style: none; padding: 0; margin: .5rem 0 0; }
.history li { display: flex; justify-content: space-between; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: 0; }

/* ---------- Trang giảng viên ---------- */
.toolbar { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }

.clock { text-align: center; padding: .5rem 0 1rem; }
.phase { font-weight: 700; font-size: 1rem; }
.phase.ok { color: var(--ok); }
.phase.warn { color: var(--warn); }
.phase.bad { color: var(--bad); }
.countdown { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s linear; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; }
.stat { background: var(--surface-2); border-radius: 12px; padding: .6rem .3rem; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--warn); }

.filters { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .6rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: .3rem .75rem; font: inherit; font-size: .85rem; cursor: pointer; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.slist { display: flex; flex-direction: column; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem .2rem; border-bottom: 1px solid var(--border); }
.srow:last-child { border-bottom: 0; }
.sinfo { min-width: 0; }
.sname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smeta { font-size: .8rem; color: var(--muted); }
.dev-on { color: var(--ok); }
.dev-off { color: var(--warn); }
.sacts { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.mark { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.mk { border: 0; background: var(--surface); color: var(--muted); font: inherit; font-weight: 700; width: 38px; height: 34px; cursor: pointer; }
.mk + .mk { border-left: 1px solid var(--border); }
.mk.on.P { background: var(--ok-bg); color: var(--ok); }
.mk.on.L { background: var(--warn-bg); color: var(--warn); }
.mk.on.A { background: var(--bad-bg); color: var(--bad); }
.sum { font-size: .85rem; white-space: nowrap; }
.empty { padding: 1.2rem 0; text-align: center; color: var(--muted); }

.req { border: 1px solid var(--border); border-radius: 12px; padding: .7rem .8rem; margin-top: .6rem; }
.req .actions { margin-top: .5rem; }

.setrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; }
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; min-height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--border); cursor: pointer; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
details { border-top: 1px solid var(--border); padding-top: .6rem; margin-top: .6rem; }
summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%);
  max-width: min(92vw, 520px);
  background: #13203a; color: #fff; padding: .75rem 1rem; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 50;
  transition: transform .25s ease;
}
.toast.show { transform: translate(-50%, 0); }
.toast.bad { background: #8f1d1d; }

/* ---------- Màn chiếu ---------- */
.proj { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px; align-items: center; background: #f5f7fc; color: #111c33; }
@media (min-width: 900px) { .proj { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); padding: 40px; } }
.qr { background: #fff; border-radius: 20px; padding: 18px; box-shadow: 0 8px 30px rgba(16, 24, 40, .12); width: min(100%, 82vh); margin: 0 auto; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.qr svg { width: 100%; height: auto; display: block; }
.proj-info h1 { font-size: clamp(1.6rem, 3.2vw, 2.8rem); margin-bottom: .2rem; }
.proj-info .sub { font-size: clamp(1rem, 1.6vw, 1.4rem); color: #5d6a82; }
.proj .phase { font-size: clamp(1.3rem, 2.4vw, 2rem); margin-top: 1.5rem; }
.proj .countdown { font-size: clamp(3.5rem, 9vw, 7.5rem); line-height: 1.05; }
.proj .stats { margin-top: 1.5rem; }
.proj .stat { background: #fff; }
.proj .stat b { font-size: clamp(1.8rem, 3.5vw, 3rem); }
.proj .bar { background: #e3e8f3; margin-top: 1rem; }
.proj .hint { margin-top: 1.25rem; color: #5d6a82; font-size: clamp(.95rem, 1.4vw, 1.2rem); }
.closed-box { text-align: center; padding: 2rem; color: #b42323; font-size: 1.6rem; font-weight: 700; }

/* ---------- Trang in ---------- */
.print-toolbar { display: flex; gap: .75rem; justify-content: center; padding: 16px; flex-wrap: wrap; }
.poster { background: #fff; color: #111c33; max-width: 720px; margin: 0 auto 24px; padding: 32px; border: 1px solid #dbe2ee; border-radius: 16px; text-align: center; }
.poster h1 { font-size: 2rem; }
.poster .qr { box-shadow: none; width: 70%; border: 1px solid #dbe2ee; }
.poster ol { text-align: left; max-width: 520px; margin: 1rem auto 0; }
@media print {
  .print-toolbar, .topbar { display: none !important; }
  body { background: #fff; }
  .poster { border: 0; page-break-after: always; margin: 0 auto; }
}

/* ---------- Trang chủ ---------- */
.hero { background: linear-gradient(135deg, #13286b, #1d4ed8 55%, #0e9f84); color: #fff; border-radius: 20px; padding: 32px 24px; margin-bottom: 16px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hero p { opacity: .92; max-width: 640px; }
.hero .actions .btn { flex: 0 0 auto; }
.hero .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }
.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.features .card { margin: 0; }
