:root {
  color-scheme: light;
  --bg: #f7f8ff; --card: #fdfdff; --ink: #27263c; --ink2: #404055; --muted: #616174; --faint: #6e6e82;
  --line: #dcdcee;
  --sub: color-mix(in oklab, var(--ink) 4%, var(--card)); --sub2: color-mix(in oklab, var(--ink) 8%, var(--card));
  --brand: #c13c3b; --accent: #535eb8;
  --ok: #0b7643; --warn: #a56d00; --bad: #c13c3b;
  --radius: 12px; --radius-md: 8px; --radius-sm: 6px;
  --shadow-sm: 0 1px 2px #27263c0d; --shadow-hover: 0 1px 2px #27263c0d, 0 8px 20px -10px #27263c33;
  --nav: #1a1d34; --nav-line: #2b2e44; --nav-mut: #a1a4b1; --nav-ink: #f0f1f7;
  --font: "Geist", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e0e1b; --card: #1b1b2c; --ink: #eaeaf3; --ink2: #c3c3ce; --muted: #90919e; --faint: #9a9aa8; --line: #2d2d42;
    --sub: color-mix(in oklab, var(--ink) 6%, var(--card)); --sub2: color-mix(in oklab, var(--ink) 11%, var(--card));
    --brand: #dd766f; --accent: #94a0dd; --ok: #4cc38a; --warn: #e0b04a; --bad: #ff7a72;
    --shadow-sm: 0 1px 2px #0006; --shadow-hover: 0 1px 2px #0006, 0 10px 24px -10px #000a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e1b; --card: #1b1b2c; --ink: #eaeaf3; --ink2: #c3c3ce; --muted: #90919e; --faint: #9a9aa8; --line: #2d2d42;
  --sub: color-mix(in oklab, var(--ink) 6%, var(--card)); --sub2: color-mix(in oklab, var(--ink) 11%, var(--card));
  --brand: #dd766f; --accent: #94a0dd; --ok: #4cc38a; --warn: #e0b04a; --bad: #ff7a72;
  --shadow-sm: 0 1px 2px #0006; --shadow-hover: 0 1px 2px #0006, 0 10px 24px -10px #000a;
}

/* Nhóm chất lượng QA · QC · QI · PS: --pt = màu ô/huy hiệu (đặc, icon trắng), --pc = màu chữ nhãn */
.g-QA { --pt: #12915b; --pc: #0e8a55; }
.g-QC { --pt: #c27c00; --pc: #a56d00; }
.g-QI { --pt: #5563de; --pc: #4f5bd5; }
.g-PS { --pt: #d6453f; --pc: #c13c3b; }
.g-NS { --pt: #9b4d96; --pc: #94468f; }
:root[data-theme="dark"] .g-QI { --pc: #8f9cff; } :root[data-theme="dark"] .g-QA { --pc: #3fd29a; }
:root[data-theme="dark"] .g-QC { --pc: #f5bd3d; } :root[data-theme="dark"] .g-PS { --pc: #ff7a72; } :root[data-theme="dark"] .g-NS { --pc: #e08fda; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .g-QI { --pc: #8f9cff; } :root:not([data-theme="light"]) .g-QA { --pc: #3fd29a; }
  :root:not([data-theme="light"]) .g-QC { --pc: #f5bd3d; } :root:not([data-theme="light"]) .g-PS { --pc: #ff7a72; } :root:not([data-theme="light"]) .g-NS { --pc: #e08fda; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1180px; }
.muted { color: var(--muted); }

/* thanh trên */
.top { position: sticky; top: 0; z-index: 20; background: var(--nav); color: var(--nav-ink); border-bottom: 1px solid var(--nav-line); }
.top .wrap { display: flex; align-items: center; gap: 10px; height: 56px; }
.top img { height: 34px; width: auto; filter: saturate(1.15) drop-shadow(0 0 6px #8ee0a755); }
.top b { font-weight: 700; font-size: 14px; letter-spacing: .01em; }
.top small { display: block; color: var(--nav-mut); font-size: 11px; line-height: 1.2; margin-top: 1px; }
.top .sp { flex: 1; }
.top .prog { font-size: 12px; color: var(--nav-mut); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 3px; background: var(--nav-line); }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .25s; }

/* banner */
.hero { margin: 16px 0; border-radius: var(--radius); padding: 22px 20px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, #c13c3b66 0, transparent 55%), linear-gradient(135deg, #1a1d34 0%, #3a2a55 100%); }
.hero::after { content: ""; position: absolute; right: -50px; bottom: -70px; width: 190px; height: 190px; border-radius: 50%; border: 28px solid #ffffff10; }
.hero .eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #ffffffb3; font-weight: 600; }
.hero h1 { margin: 6px 0 4px; font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; }
.hero p { margin: 0; color: #ffffffd9; font-size: 14px; max-width: 560px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; background: #ffffff1f; font-size: 12px; font-weight: 600; margin-top: 12px; margin-right: 6px; }
.pill.code { background: var(--brand); }

/* thẻ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 12px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }
.sec { margin: 22px 2px 8px; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.sub { margin: 14px 2px 6px; font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }

/* trường thông tin */
.fld { margin-bottom: 14px; }
.fld:last-child { margin-bottom: 0; }
.fld > label, .fld > .lb { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.req { color: var(--bad); }
input[type=text], input[type=date], input[type=password], textarea, select {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; font-size: 16px; min-height: 42px; }
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts label { position: relative; }
.opts input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.opts span { display: inline-block; padding: 8px 13px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); font-size: 13.5px; }
.opts input:checked + span { background: var(--nav); color: #fff; border-color: var(--nav); }
.opts input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.invalid > .lb, .invalid > label { color: var(--bad); }
.invalid .opts span, .invalid input[type=text] { border-color: var(--bad); }
.q.invalid { border-color: var(--bad); }

/* câu hỏi chấm điểm */
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 0 2px 10px; }
.legend b { color: var(--ink); font-weight: 700; margin-right: 3px; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px; margin-bottom: 8px; }
.q .t { display: flex; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.q .n { flex: none; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--sub2); font-size: 12px; font-weight: 700; display: grid; place-items: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale.ten { grid-template-columns: repeat(10, 1fr); gap: 4px; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.scale span { display: grid; place-items: center; height: 42px; border: 1px solid var(--line); border-radius: 8px; font-weight: 700; font-size: 15px; background: var(--sub); font-variant-numeric: tabular-nums; transition: background .12s, color .12s; }
.scale.ten span { height: 38px; font-size: 13px; }
.scale input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }
.skill { display: grid; grid-template-columns: 1fr 78px 78px; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.skill.h { border-top: 0; padding: 0 0 4px; }
.skill .hd { font-size: 11px; color: var(--muted); text-align: center; }
.skill select { padding: 6px 8px; min-height: 38px; }

/* nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius-md); padding: 9px 14px; font-weight: 600; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--sub); }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { filter: brightness(1.06); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.bad { color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: default; }
.submit { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.submit .btn { width: 100%; min-height: 48px; font-size: 16px; }
.err { color: var(--bad); font-weight: 600; margin: 8px 2px; }
.done { text-align: center; padding: 48px 16px; }
.done .ok { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; font-size: 32px; }
.done h2 { font-size: 22px; font-weight: 800; margin: 0 0 6px; }

/* trang chủ */
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: 1fr 1fr; } }
.tile { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; border-top: 3px solid var(--pt); }
.tile:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.tile .c { font-size: 12px; font-weight: 700; color: var(--pc); letter-spacing: .04em; }
.tile h3 { margin: 4px 0 4px; font-size: 16px; font-weight: 700; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }
.tile .m { margin-top: 10px; font-size: 12px; color: var(--faint); }

/* admin */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--brand); }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; border-top: 3px solid var(--pt); }
.stat .v { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--sub); position: sticky; top: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow: auto; max-height: 62vh; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.row select { width: auto; min-width: 180px; }
.heat { display: inline-block; min-width: 38px; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.qrgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.qrc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; border-top: 3px solid var(--pt, var(--brand)); }
.qrc .qr { background: #fff; display: inline-block; padding: 10px; border-radius: 8px; line-height: 0; }
.qrc .qr svg, .qrc .qr img { width: 180px; height: 180px; }
.qrc h4 { margin: 10px 0 2px; font-size: 14px; }
.qrc .u { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 8px; }
.qrc .a { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.login { max-width: 360px; margin: 18vh auto 0; }
@media print {
  body { background: #fff; color: #000; }
  .top, .tabs, .noprint, .qrc .a { display: none !important; }
  .qrgrid { grid-template-columns: repeat(2, 1fr); }
  .qrc { break-inside: avoid; border: 1px solid #999; }
}
.g-QA { --pt: #12915b; --pc: #0e8a55; }
.g-QC { --pt: #c27c00; --pc: #a56d00; }
.g-QI { --pt: #5563de; --pc: #4f5bd5; }
.g-PS { --pt: #d6453f; --pc: #c13c3b; }
:root[data-theme="dark"] .g-QI { --pc: #8f9cff; } :root[data-theme="dark"] .g-QA { --pc: #3fd29a; }
:root[data-theme="dark"] .g-QC { --pc: #f5bd3d; } :root[data-theme="dark"] .g-PS { --pc: #ff7a72; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .g-QI { --pc: #8f9cff; } :root:not([data-theme="light"]) .g-QA { --pc: #3fd29a; }
  :root:not([data-theme="light"]) .g-QC { --pc: #f5bd3d; } :root:not([data-theme="light"]) .g-PS { --pc: #ff7a72; }
}
