/* ACDI-ITS Check — giao diện chung */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #5b6474;
  --line: #e2e7f0;
  --brand: #1d4ed8;
  --brand-2: #0f766e;
  --brand-soft: #e8efff;
  --acdi: #dc2626;
  --its: #16a34a;
  --warn-bg: #fff7e6;
  --warn-line: #f5c26b;
  --err: #b91c1c;
  --ok: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px; line-height: 1.6;
}
a { color: var(--brand); }
img, canvas { max-width: 100%; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
main { padding: 24px 0 48px; min-height: 70vh; }
h1 { font-size: clamp(1.45rem, 3.6vw, 2.1rem); line-height: 1.25; margin: .2em 0 .4em; }
h2 { font-size: 1.25rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Header / footer */
#site-header { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand small { display: block; color: var(--muted); font-size: .78rem; line-height: 1.2; }
.brand b { display: block; line-height: 1.2; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; font-weight: 500; font-size: .95rem; }
.nav a.on, .nav a:hover { background: var(--brand-soft); color: var(--brand); }
#site-footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: .88rem; background: #fff; }

/* Thẻ, lưới */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .card { padding: 16px; } }

.hero { background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%); color: #fff; border-radius: 18px; padding: 28px 24px; margin-bottom: 20px; }
.hero p { opacity: .95; max-width: 720px; }
.hero .btn { background: #fff; color: var(--brand); }
.hero .btn.ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .7); }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px;
  border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.green { background: var(--brand-2); border-color: var(--brand-2); }
.btn.red { background: #fff; color: var(--err); border-color: #f1b4b4; }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.btn-row.between { justify-content: space-between; }

/* Form */
label { font-weight: 500; }
.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=number], input[type=email], input[type=date], input[type=password], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cdd5e1; border-radius: 10px; background: #fff; color: var(--ink); min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .opt:focus-within { outline: 3px solid #bcd0ff; outline-offset: 1px; }
.req { color: var(--err); }
.hint { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.locked { background: #f1f5f9 !important; }

/* Lựa chọn dạng thẻ */
.opts { display: grid; gap: 8px; }
.opts.row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid #cdd5e1; border-radius: 10px; cursor: pointer; background: #fff; font-weight: 400;
}
.opt input { margin-top: 4px; width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.opt .letter { font-weight: 700; color: var(--brand); min-width: 1.2em; }

/* Likert */
.q { padding: 14px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q-text { font-weight: 500; margin-bottom: 8px; }
.q-text .qid { display: inline-block; font-size: .78rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 6px; padding: 0 6px; margin-right: 6px; }
.likert { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.likert label {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 8px 4px; border: 1px solid #cdd5e1;
  border-radius: 10px; cursor: pointer; font-size: .8rem; font-weight: 400; line-height: 1.25; background: #fff; min-height: 64px; justify-content: center;
}
.likert label b { font-size: 1.05rem; }
.likert input { position: absolute; opacity: 0; pointer-events: none; }
.likert label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.likert label:has(input:focus-visible) { outline: 3px solid #bcd0ff; }
.q.missing .q-text { color: var(--err); }
@media (max-width: 480px) { .likert label span { display: none; } .likert label { min-height: 48px; } }

/* Tiến độ */
.progress { height: 10px; background: #e5eaf3; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); width: 0; transition: width .25s; }
.steps-note { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); }

/* Hộp thông báo */
.note { border: 1px solid var(--warn-line); background: var(--warn-bg); padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.note.ok { border-color: #9ad8b0; background: #ecfbf1; }
.note.err { border-color: #f1b4b4; background: #fdf0f0; color: var(--err); }
.note.info { border-color: #b8ccf5; background: #eef3ff; }
.code-big { font-family: ui-monospace, Consolas, monospace; font-size: 1.8rem; letter-spacing: .18em; font-weight: 800; color: var(--brand); }
.tag { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; background: #eef2f7; color: var(--muted); font-weight: 600; }
.tag.ok { background: #e3f6ea; color: var(--ok); }
.tag.warn { background: #fff1d6; color: #9a6400; }
.tag.err { background: #fde3e3; color: var(--err); }

/* Kết quả */
.score-big { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }
.level-pill { display: inline-block; padding: 4px 14px; border-radius: 999px; color: #fff; font-weight: 700; }
.kpi { text-align: center; }
.kpi .v { font-size: 1.7rem; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: .88rem; }
.bar-row { display: grid; grid-template-columns: 210px 1fr 48px; gap: 8px; align-items: center; margin: 6px 0; font-size: .92rem; }
.bar-row .bar { height: 12px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 1fr 44px; } .bar-row .bar { grid-column: 1 / -1; grid-row: 2; } }
.feedback { white-space: pre-line; }
.rules { counter-reset: r; list-style: none; padding: 0; margin: 0; }
.rules li { counter-increment: r; position: relative; padding: 10px 0 10px 44px; border-top: 1px solid var(--line); }
.rules li:first-child { border-top: 0; }
.rules li::before {
  content: counter(r); position: absolute; left: 0; top: 10px; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-weight: 800;
}
.chart-box { position: relative; width: 100%; height: 320px; }
.chart-box.tall { height: 380px; }

/* Bảng */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; background: #fff; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f6f8fc; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Tab */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { font: inherit; border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* Toast */
#toast-box { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(92vw, 460px); }
.toast { padding: 12px 16px; border-radius: 10px; background: #1f2937; color: #fff; box-shadow: var(--shadow); font-size: .95rem; }
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }

.log { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; background: #0f172a; color: #d1e0ff; padding: 10px; border-radius: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
.qr-box { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.scenario-edit { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }

@media print {
  #site-header, #site-footer, .no-print, .btn, .btn-row { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
