/* Hệ thống giám sát hồ sơ & đánh giá hài lòng – giao diện
   Không dùng thư viện ngoài, không tải font từ internet. Hỗ trợ chế độ tối theo hệ điều hành. */

:root {
  color-scheme: light;
  --page: #f6f2ea;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #161615;
  --ink-2: #52514e;
  --muted: #6b6a65;
  --line: #e4e3dc;
  --line-2: #c9c8be;
  --brand: #b3141b;
  --brand-hover: #94100f;
  --brand-ink: #ffffff;
  --brand-soft: #fdeceb;
  --brand-deep: #8a0e13;
  --gold: #f2b705; --gold-ink: #7a5000; --gold-bg: #fff4cf; --gold-line: #e9c55a;
  --info: #2a78d6; --info-ink: #1d5aa3; --info-bg: #e7f0fc;
  --violet: #6250d6; --violet-ink: #4a3bb0; --violet-bg: #eeebfc;
  --focus: #3987e5;
  --good: #0ca30c;  --good-ink: #006300;  --good-bg: #e6f5e6;
  --warn: #fab219;  --warn-ink: #7a5300;  --warn-bg: #fff3d4;
  --serious: #ec835a; --serious-ink: #8f3a17; --serious-bg: #fde9e0;
  --crit: #d03b3b;  --crit-ink: #a12424;  --crit-bg: #fbe5e5;
  --neutral: #898781; --neutral-bg: #efeee9;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .05);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #9d9b94;
    --line: #2c2c2a; --line-2: #45443f;
    --brand: #ef6461; --brand-hover: #f47f7c; --brand-ink: #160404; --brand-soft: #3a1516; --brand-deep: #5c0a0e;
    --gold: #e0a800; --gold-ink: #f2c94c; --gold-bg: #3a2c08; --gold-line: #7a5d10;
    --info: #3987e5; --info-ink: #7fb2f0; --info-bg: #15263c;
    --violet: #9085e9; --violet-ink: #b3abf2; --violet-bg: #241f45;
    --good-ink: #3fcf3f; --good-bg: #13301a; --warn-ink: #fab219; --warn-bg: #3a2c08;
    --serious-ink: #f2a07f; --serious-bg: #3a2016; --crit-ink: #ef7d7d; --crit-bg: #3d1717;
    --neutral-bg: #2a2a28;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --grid: #2c2c2a; --axis: #383835;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--page); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.1rem; } h3 { font-size: .98rem; }
p { margin: 0 0 .75rem; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
.empty svg.ic { width: 1.4em; height: 1.4em; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, monospace; font-size: .9em; }

/* ---------------------------------------------------------------- khung trang */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh;
  background: linear-gradient(to right, var(--surface) 247px, var(--line) 247px, var(--line) 248px, transparent 248px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.brand svg { flex: none; }
.brand b { display: block; font-size: .95rem; line-height: 1.2; }
.brand span { display: block; font-size: .78rem; color: var(--muted); line-height: 1.25; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav a .count { margin-left: auto; font-size: .75rem; background: var(--crit); color: #fff; border-radius: 99px; padding: 0 7px; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .foot { margin-top: auto; padding: 14px 18px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 24px; }
.topbar form.find { flex: 1; max-width: 420px; position: relative; }
.topbar form.find input { padding-left: 34px; }
.topbar form.find svg { position: absolute; left: 10px; top: 9px; width: 18px; height: 18px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px;
  color: var(--ink-2); border: 1px solid transparent; background: none; cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; }
.iconbtn .dot { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; border-radius: 99px; background: var(--crit);
  color: #fff; font-size: .68rem; display: grid; place-items: center; padding: 0 4px; font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; }
.user .who { text-align: right; line-height: 1.2; }
.user .who b { display: block; font-size: .88rem; }
.user .who span { font-size: .75rem; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid;
  place-items: center; font-weight: 650; font-size: .85rem; }
.menu-toggle { display: none; }
.nav-backdrop { display: none; }
.content { padding: 22px 24px 48px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------------- thẻ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px 0; }
.card > .hd h2 { margin: 0; font-size: 1rem; }
.card > .hd .sub { color: var(--muted); font-size: .82rem; }
.card > .bd { padding: 14px 18px 18px; }
.card > .bd.flush { padding: 8px 0 4px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: block;
  color: inherit; position: relative; }
a.tile:hover { text-decoration: none; border-color: var(--line-2); }
.tile .label { color: var(--ink-2); font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 1.75rem; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.tile .note { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.tile.crit .value { color: var(--crit-ink); }
.tile.warn .value { color: var(--warn-ink); }
.tile.good .value { color: var(--good-ink); }
.tile .mark { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* -------------------------------------------------------------------- bảng */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr:last-child td { border-bottom: none; }
table.data .code { font-weight: 600; white-space: nowrap; }
table.data .sub { display: block; color: var(--muted); font-size: .8rem; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------- nhãn */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px 2px 7px; font-size: .78rem;
  font-weight: 550; white-space: nowrap; background: var(--neutral-bg); color: var(--ink-2); }
.badge svg { width: 13px; height: 13px; flex: none; }
.b-good { background: var(--good-bg); color: var(--good-ink); }
.b-warn { background: var(--warn-bg); color: var(--warn-ink); }
.b-serious { background: var(--serious-bg); color: var(--serious-ink); }
.b-crit { background: var(--crit-bg); color: var(--crit-ink); }
.b-info { background: var(--brand-soft); color: var(--brand); }
.b-neutral { background: var(--neutral-bg); color: var(--ink-2); }
.pill { display: inline-block; border: 1px solid var(--line-2); border-radius: 99px; padding: 1px 8px; font-size: .75rem; color: var(--ink-2); }

/* ----------------------------------------------------------- nút & biểu mẫu */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--crit-ink); border-color: var(--crit); }
.btn.danger:hover { background: var(--crit-bg); }
.btn.ghost { border-color: transparent; background: none; color: var(--brand); }
.btn.sm { height: 30px; padding: 0 10px; font-size: .85rem; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { font-weight: 550; font-size: .88rem; display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 3px; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], input[type=url], input[type=file], select, textarea {
  width: 100%; height: 36px; padding: 6px 10px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px; }
textarea { height: auto; min-height: 76px; resize: vertical; }
input[type=file] { height: auto; padding: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
.check input { margin-top: 3px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.filters-note { flex-basis: 100%; margin: 0; }
.filters .field.auto { max-width: none; flex: 0 0 auto; }
.filters .field.wide { max-width: 320px; flex-basis: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 7px 12px; color: var(--ink-2); border-right: 1px solid var(--line); font-size: .85rem; font-weight: 550; }
.seg a:last-child { border-right: none; }
.seg a:hover { background: var(--surface-2); text-decoration: none; }
.seg a.on { background: var(--brand-soft); color: var(--brand); }

details.inline { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
details.inline > summary { cursor: pointer; padding: 8px 12px; font-weight: 550; list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline[open] > summary { border-bottom: 1px solid var(--line); }
details.inline > div { padding: 12px; }
.transitions { display: grid; gap: 8px; }

/* ----------------------------------------------------------------- thông báo */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; border: 1px solid; display: flex; gap: 8px; }
.flash.success { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); color: var(--good-ink); }
.flash.error { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 35%, transparent); color: var(--crit-ink); }
.flash.warning { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn-ink); }
.flash.info { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand); }

/* ------------------------------------------------------------- dòng thời gian */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 2px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--brand); }
.timeline .dot.k-note { border-color: var(--neutral); }
.timeline .dot.k-extend, .timeline .dot.k-supplement { border-color: var(--warn); }
.timeline .dot.k-bad { border-color: var(--crit); }
.timeline .dot.k-done { border-color: var(--good); }
.timeline .when { font-size: .8rem; color: var(--muted); }
.timeline .what { font-weight: 600; }
.timeline .note { margin-top: 3px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: .88rem; white-space: pre-line; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ----------------------------------------------------------------- biểu đồ */
.chart { position: relative; width: 100%; min-height: 60px; }
.chart svg { display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart text { font: 11.5px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart text.lbl { fill: var(--ink-2); font-size: 12.5px; }
.chart text.val { fill: var(--ink); font-weight: 600; font-size: 12px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .s1 { stroke: var(--series-1); } .chart .f1 { fill: var(--series-1); }
.chart .s2 { stroke: var(--series-2); } .chart .f2 { fill: var(--series-2); }
.chart .st-ok { fill: var(--good); } .chart .st-near { fill: var(--warn); } .chart .st-overdue { fill: var(--crit); }
.chart .st-paused { fill: var(--neutral); }
.chart .dotm { stroke: var(--surface); stroke-width: 2; }
.chart .mark { transition: opacity .12s; }
.chart .mark:hover, .chart .mark:focus { opacity: .82; outline: none; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--ink-2); margin: 2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.legend i.c1 { background: var(--series-1); } .legend i.c2 { background: var(--series-2); }
.legend i.ok { background: var(--good); } .legend i.near { background: var(--warn); } .legend i.overdue { background: var(--crit); }
.legend i.paused { background: var(--neutral); }
.legend svg { width: 13px; height: 13px; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); min-width: 140px; max-width: 280px; }
.tooltip .t { color: var(--muted); font-size: .76rem; margin-bottom: 3px; }
.tooltip .r { display: flex; align-items: center; gap: 8px; }
.tooltip .r b { font-variant-numeric: tabular-nums; }
.tooltip .r i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
details.tableview { margin-top: 8px; max-width: 100%; overflow-x: auto; }
.card, .grid > * { min-width: 0; }
details.tableview summary { cursor: pointer; color: var(--brand); font-size: .82rem; }
details.tableview table { margin-top: 6px; font-size: .85rem; }

.bar-mini { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; margin-top: 4px; }
.bar-mini > span { display: block; height: 100%; width: 0; background: var(--series-1); border-radius: 0 3px 3px 0; }

/* ----------------------------------------------------------------- phân trang */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 14px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 6px;
  border: 1px solid var(--line); color: var(--ink-2); font-size: .85rem; }
.pager span.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pager .info { border: none; color: var(--muted); margin-right: auto; }

/* ----------------------------------------------------------------- đăng nhập */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1200px 500px at 10% -10%, var(--brand-soft), transparent), var(--page); }
.auth .box { width: 100%; max-width: 400px; }
.auth .box .card { padding: 26px; }
.auth h1 { font-size: 1.3rem; margin-top: 10px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle { position: absolute; top: 3px; right: 3px; height: 30px; min-width: 52px; padding: 0 10px; border: 0; border-radius: 6px;
  background: none; color: var(--brand); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.pw-toggle:hover { background: var(--brand-soft); }
.pw-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field .hint.caps-warn { color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 4px 8px; margin-top: 6px; }
.demo-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo-box h2 { font-size: .95rem; margin: 0 0 4px; }
.demo-box p { font-size: .85rem; color: var(--ink-2); margin: 0 0 10px; }
.demo-box code { font-size: .85rem; background: var(--neutral-bg); border-radius: 4px; padding: 1px 5px; color: var(--ink); }
.demo-users { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.demo-user { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px; text-align: left;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.demo-user b { font-size: .85rem; font-weight: 650; }
.demo-user span { font-size: .75rem; color: var(--muted); }
.demo-user:hover { border-color: var(--brand); background: var(--brand-soft); }
.demo-user:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.qrbox { background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--line); display: inline-block; }
.qrbox svg { display: block; width: 180px; height: 180px; }

/* ------------------------------------------------------ trang dành cho người dân */
.public { min-height: 100vh; }
.pub-head { background: var(--brand); color: #fff; padding: 18px 20px 22px; }
@media (prefers-color-scheme: dark) { .pub-head { background: var(--brand-deep); } }
.pub-head .in { max-width: 640px; margin: 0 auto; display: flex; gap: 12px; align-items: center; }
.pub-head b { display: block; font-size: 1.05rem; }
.pub-head span { opacity: .85; font-size: .88rem; }
.pub-body { max-width: 640px; margin: -10px auto 0; padding: 0 14px 40px; }
.pub-body .card { padding: 20px; }
.pub-body h1 { font-size: 1.25rem; }
.q { margin: 18px 0 6px; font-weight: 650; font-size: 1rem; }
.faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.faces > div { display: flex; }
.faces > div > label { flex: 1; }
.faces label { margin: 0; cursor: pointer; text-align: center; border: 2px solid var(--line); border-radius: 12px; padding: 10px 2px 8px;
  font-weight: 550; font-size: .76rem; line-height: 1.2; color: var(--ink-2); background: var(--surface); }
.faces input { position: absolute; opacity: 0; pointer-events: none; }
.faces svg { width: 40px; height: 40px; display: block; margin: 0 auto 6px; }
.faces input:checked + label, .faces label.on { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }
.faces input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.scale { display: grid; grid-template-columns: 1fr repeat(5, 46px); align-items: center; gap: 6px; padding: 8px 0;
  border-bottom: 1px solid var(--line); }
.scale .name { font-weight: 550; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale label { margin: 0; height: 40px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 8px;
  cursor: pointer; font-weight: 650; color: var(--ink-2); background: var(--surface); }
.scale input:checked + label { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.scale input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 2px; }
.scale-head { display: grid; grid-template-columns: 1fr repeat(5, 46px); gap: 6px; font-size: .7rem; color: var(--muted); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; font-weight: 500; border: 1px solid var(--line-2); border-radius: 99px; padding: 6px 12px; cursor: pointer;
  display: inline-flex; gap: 6px; align-items: center; background: var(--surface); }
.chips input:checked + span { font-weight: 650; color: var(--brand); }
.big-ok { text-align: center; padding: 26px 10px; }
.big-ok svg { width: 64px; height: 64px; }

/* -------------------------------------------------------------------- kiosk */
.kiosk { min-height: 100vh; display: flex; flex-direction: column; background: var(--page); user-select: none; }
.kiosk header { padding: 22px 32px; display: flex; justify-content: space-between; align-items: center; background: var(--brand); color: #fff; }
.kiosk header b { font-size: 1.4rem; }
.kiosk main { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; }
.kiosk h1 { font-size: 2.1rem; margin-bottom: 8px; }
.kiosk .pending { font-size: 1.1rem; color: var(--ink-2); min-height: 1.6em; margin-bottom: 18px; }
.kiosk .kfaces { display: grid; grid-template-columns: repeat(5, minmax(120px, 190px)); gap: 18px; justify-content: center; }
.kiosk .kfaces button { border: 3px solid var(--line); background: var(--surface); border-radius: 22px; padding: 22px 8px 16px;
  font: inherit; font-size: 1.05rem; font-weight: 650; color: var(--ink); cursor: pointer; }
.kiosk .kfaces button:active, .kiosk .kfaces button.on { border-color: var(--brand); background: var(--brand-soft); }
.kiosk .kfaces svg { width: 92px; height: 92px; display: block; margin: 0 auto 10px; }
.kiosk .kcrit { display: grid; gap: 14px; max-width: 760px; margin: 0 auto; }
.kiosk .krow { display: grid; grid-template-columns: 1fr repeat(5, 70px); gap: 10px; align-items: center; text-align: left;
  font-size: 1.15rem; font-weight: 600; }
.kiosk .krow button { height: 60px; border-radius: 14px; border: 2px solid var(--line-2); background: var(--surface); font: inherit;
  font-size: 1.3rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.kiosk .krow button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.kiosk footer { padding: 14px 32px; color: var(--muted); display: flex; justify-content: space-between; font-size: .95rem; }

/* ------------------------------------------------------------------ in ấn */
.print-page { max-width: 820px; margin: 0 auto; padding: 24px; background: #fff; color: #000; }
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 12.5px; }
  .sidebar, .topbar, .no-print, .flash, .page-head .actions { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; }
  .print-only { display: block; }
  a { color: #000; }
  .chart .s1 { stroke: #1c5cab; }
  table.data th { background: #f2f2f2 !important; }
}

/* --------------------------------------------------------------- màn hình TV */
body.tv .sidebar, body.tv .topbar { display: none; }
body.tv .shell { display: block; background: none; }
body.tv .content { max-width: none; padding: 24px 32px; font-size: 16px; }
body.tv .tile .value { font-size: 2.4rem; }

/* ------------------------------------------------------------------ đáp ứng */
@media (max-width: 1100px) {
  .g-main, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .menu-toggle { display: inline-grid; }
  .nav-backdrop.on { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .35); }
  .topbar { padding: 8px 12px; }
  .user .who { display: none; }
  .content { padding: 16px 12px 40px; }
  .g2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .kiosk .kfaces { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .kiosk .kfaces svg { width: 56px; height: 56px; }
}
@media (max-width: 420px) {
  .faces svg { width: 32px; height: 32px; }
  .scale, .scale-head { grid-template-columns: 1fr repeat(5, 38px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.hidden-empty:empty { display: none; }
.kiosk .actions { justify-content: center; }
.kiosk .big-ok svg { width: 120px; height: 120px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
.faces legend { grid-column: 1 / -1; }


/* ===================================================== CHỦ ĐỀ ĐỎ – VÀNG (từ bản 1.1.0) */
.shell { background: linear-gradient(to right, var(--surface) 255px, var(--line) 255px, var(--line) 256px, transparent 256px);
  grid-template-columns: 256px 1fr; }
.sidebar .brand { background: linear-gradient(150deg, var(--brand-deep), var(--brand) 70%); color: #fff; border-bottom: 3px solid var(--gold);
  padding: 16px 16px 14px; }
.sidebar .brand b { color: #fff; font-size: 1rem; letter-spacing: .01em; }
.sidebar .brand span { color: #ffe08a; }
.emblem { flex: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }
.nav .group { color: var(--brand); font-weight: 650; display: flex; align-items: center; gap: 8px; }
.nav .group::after { content: ""; flex: 1; height: 1px; background: var(--gold-line); opacity: .7; }
.nav a.active { background: var(--brand-soft); color: var(--brand); box-shadow: inset 3px 0 0 var(--gold); font-weight: 600; }
.nav a .count.info { background: var(--info); }
details.navgroup > summary { list-style: none; cursor: pointer; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand); font-weight: 650; padding: 12px 10px 4px; display: flex; align-items: center; gap: 6px; }
details.navgroup > summary::-webkit-details-marker { display: none; }
details.navgroup > summary svg { width: 13px; height: 13px; transition: transform .15s; }
details.navgroup[open] > summary svg { transform: rotate(90deg); }
details.navgroup > summary .tag { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
details.navgroup > div { display: flex; flex-direction: column; gap: 2px; }
.topbar { background: linear-gradient(90deg, var(--brand-deep), var(--brand)); border-bottom: 3px solid var(--gold); color: #fff; }
.topbar .iconbtn { color: #fff; }
.topbar .iconbtn:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); }
.topbar .iconbtn .dot { background: var(--gold); color: #3a2600; }
.topbar form.find input { background: #fff; border-color: transparent; color: #161615; }
.topbar .user .who b { color: #fff; }
.topbar .user .who span { color: #ffe08a; }
.topbar .avatar { background: var(--gold); color: var(--brand-deep); }
.topbar .ward { font-weight: 650; letter-spacing: .02em; white-space: nowrap; color: #ffe08a; font-size: .9rem; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #3a2600; font-weight: 600; }
.btn.gold:hover { filter: brightness(.95); }
.page-head h1 { color: var(--brand-deep); }
@media (prefers-color-scheme: dark) { .page-head h1 { color: var(--ink); } }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--gold-ink); background: var(--gold-bg); border-radius: 99px; padding: 2px 10px 2px 8px; margin-bottom: 6px; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 4px !important; }

/* thẻ chỉ số có màu */
.ktiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.ktiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ktile { --tc: var(--brand); --tb: var(--brand-soft); --tv: var(--brand);
  display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--tc); border-radius: var(--radius); padding: 14px 14px 12px; color: var(--ink); box-shadow: var(--shadow); }
a.ktile:hover { text-decoration: none; border-color: var(--tc); background: linear-gradient(var(--tb), var(--surface) 70%); }
.ktile .kic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--tb); color: var(--tc); flex: none; }
.ktile .kic svg { width: 20px; height: 20px; }
.ktile .label { font-size: .82rem; color: var(--ink-2); line-height: 1.3; }
.ktile .value { font-size: 1.75rem; font-weight: 700; color: var(--tv); letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.ktile .note { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.ktile.t-gold { --tc: var(--gold); --tb: var(--gold-bg); --tv: var(--gold-ink); }
.ktile.t-info { --tc: var(--info); --tb: var(--info-bg); --tv: var(--info-ink); }
.ktile.t-warn { --tc: var(--warn); --tb: var(--warn-bg); --tv: var(--warn-ink); }
.ktile.t-crit { --tc: var(--crit); --tb: var(--crit-bg); --tv: var(--crit-ink); }
.ktile.t-good { --tc: var(--good); --tb: var(--good-bg); --tv: var(--good-ink); }
/* thẻ cũ (tổng quan một cửa) cũng có viền màu theo sắc thái */
.tile { border-top: 4px solid var(--brand); }
.tile.good { border-top-color: var(--good); background: linear-gradient(var(--good-bg), var(--surface) 55%); }
.tile.warn { border-top-color: var(--warn); background: linear-gradient(var(--warn-bg), var(--surface) 55%); }
.tile.crit { border-top-color: var(--crit); background: linear-gradient(var(--crit-bg), var(--surface) 55%); }
.tile:nth-child(6n+2):not(.good):not(.warn):not(.crit) { border-top-color: var(--info); }
.tile:nth-child(6n+6):not(.good):not(.warn):not(.crit) { border-top-color: var(--gold); }

.urgency-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.urgency-strip .lbl { font-size: .82rem; color: var(--ink-2); margin-right: 4px; }
.uchip { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 4px 6px 4px 10px; font-size: .84rem;
  font-weight: 600; border: 1px solid transparent; }
.uchip:hover { text-decoration: none; filter: brightness(.96); }
.uchip svg { width: 15px; height: 15px; }
.uchip b { background: rgba(255,255,255,.85); color: #161615; border-radius: 99px; padding: 0 8px; min-width: 26px; text-align: center; }
.uchip.u-express { background: #8a0e13; color: #fff; }
.uchip.u-very_urgent { background: var(--crit); color: #fff; }
.uchip.u-urgent { background: var(--warn); color: #3a2600; }
.uchip.u-normal { background: var(--neutral-bg); color: var(--ink-2); border-color: var(--line); }
.badge.u-express { background: #8a0e13; color: #fff; }
.badge.u-very_urgent { background: var(--crit-bg); color: var(--crit-ink); }
.badge.u-urgent { background: var(--warn-bg); color: var(--warn-ink); }
.badge.b-gold { background: var(--gold-bg); color: var(--gold-ink); }
.badge.b-violet { background: var(--violet-bg); color: var(--violet-ink); }
.badge.b-info { background: var(--info-bg); color: var(--info-ink); }

/* nhãn loại văn bản và vai trò xử lý */
.type-tag { display: inline-block; font-size: .72rem; font-weight: 650; border-radius: 4px; padding: 1px 6px; vertical-align: 2px;
  color: #fff; background: var(--neutral); letter-spacing: .01em; }
h1 .type-tag { font-size: .8rem; vertical-align: 4px; }
.ty-cv { background: var(--series-1); } .ty-qd { background: var(--series-2); } .ty-kh { background: #128a60; }
.ty-tb { background: #b87d00; } .ty-gm { background: #c2477a; } .ty-bc { background: var(--series-6); }
.ty-ct { background: var(--series-7); } .ty-nq { background: #c43231; } .ty-tt { background: #3f5f86; } .ty-khac { background: #6b6a65; }
.role-tag { display: inline-block; font-size: .72rem; font-weight: 650; border-radius: 4px; padding: 1px 6px; border: 1px solid; }
.role-tag.r-lead { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.role-tag.r-support { color: var(--info-ink); border-color: var(--info); background: var(--info-bg); }
.role-tag.r-direct { color: var(--violet-ink); border-color: var(--violet); background: var(--violet-bg); }

/* thanh tiến độ */
.prog { display: inline-flex; align-items: center; gap: 8px; min-width: 120px; }
.prog .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; min-width: 70px; }
.prog .bar i { display: block; height: 100%; width: 0; background: var(--info); border-radius: 4px; }
.prog b { font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.prog.p-ok .bar i { background: var(--good); } .prog.p-near .bar i { background: var(--warn); } .prog.p-overdue .bar i { background: var(--crit); }
.big-progress .prog { width: 100%; margin-bottom: 12px; } .big-progress .bar { height: 12px; border-radius: 6px; }

/* dòng bảng tô màu theo hạn */
table.data tr.row-overdue td:first-child { box-shadow: inset 4px 0 0 var(--crit); }
table.data tr.row-near td:first-child, table.data tr.row-today td:first-child { box-shadow: inset 4px 0 0 var(--warn); }
table.data tr.row-overdue { background: color-mix(in srgb, var(--crit-bg) 45%, transparent); }
a.plain { color: inherit; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-weight: 550; font-size: .88rem; }
.tabs a:hover { text-decoration: none; border-color: var(--line-2); }
.tabs a b { background: var(--neutral-bg); border-radius: 99px; padding: 0 7px; font-size: .78rem; color: var(--ink); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a.on b { background: rgba(255,255,255,.9); color: var(--brand-deep); }
.tabs a.t-gold svg { color: var(--gold-ink); } .tabs a.t-info svg { color: var(--info); } .tabs a.t-good svg { color: var(--good-ink); }
.tabs a.on svg { color: #fff; }

.card.accent-top { border-top: 3px solid var(--brand); }
.card.highlight { border: 1px solid var(--gold-line); background: linear-gradient(var(--gold-bg), var(--surface) 140px); }
.card.directive blockquote { margin: 0 0 8px; padding: 10px 14px; border-left: 4px solid var(--gold); background: var(--gold-bg);
  border-radius: 0 8px 8px 0; font-size: 1rem; white-space: pre-line; }
.card .hd h2 svg { color: var(--brand); }
.subject { font-size: 1.05rem; font-weight: 550; line-height: 1.5; }
.pre { white-space: pre-line; }
.pre.result { background: var(--good-bg); border-radius: 8px; padding: 10px 12px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .span2 { grid-column: span 2; } .form-grid .span3 { grid-column: span 3; } .form-grid .span4 { grid-column: 1 / -1; }
.card > .ft { padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
fieldset.field { border: 0; padding: 0; margin: 0 0 12px; }
fieldset.field legend { font-weight: 550; margin-bottom: 6px; }
form.sep { border-top: 1px dashed var(--line-2); padding-top: 14px; }
ul.files { list-style: none; margin: 0; padding: 0; }
ul.files li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
ul.files li:last-child { border-bottom: none; }
ul.files .sub { width: 100%; color: var(--muted); font-size: .78rem; }
.timeline .ev-direct > b, .timeline .ev-approve > b, .timeline .ev-doc_done > b { color: var(--brand); }
.timeline .note { white-space: pre-line; }
.chart .f3 { fill: var(--series-3); } .chart .f4 { fill: var(--series-4); } .chart .f5 { fill: var(--series-5); }
.chart .f6 { fill: var(--series-6); } .chart .f7 { fill: var(--series-7); } .chart .f8 { fill: var(--series-8); }
.chart .tone-ok { fill: var(--good); } .chart .tone-near { fill: var(--warn); } .chart .tone-overdue { fill: var(--crit); }
.auth .brand-mark { display: flex; justify-content: center; }

@media (max-width: 1280px) { .ktiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .ktiles, .ktiles.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; } .form-grid .span2, .form-grid .span3 { grid-column: auto; }
  .topbar .ward { display: none; }
  .ktile .value { font-size: 1.45rem; }
}
@media (max-width: 420px) { .ktile { padding: 12px 10px; gap: 8px; } .ktile .kic { width: 32px; height: 32px; } }
@media print { .topbar, .sidebar { display: none !important; } .ktile { break-inside: avoid; } }
.auth { background: linear-gradient(160deg, var(--brand-deep), var(--brand)) top / 100% 260px no-repeat, var(--page); }
.auth .box .card { border-top: 4px solid var(--gold); }
.auth .box .card > p.muted { text-align: center; }

/* quét văn bản để vào sổ tự động (bản 1.2.0) */
.dropzone { position: relative; display: flex; gap: 14px; align-items: center; padding: 18px 20px; border: 2px dashed var(--gold-line);
  border-radius: 12px; background: var(--gold-bg); cursor: pointer; }
.dropzone:hover, .dropzone:focus-within, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--brand);
  color: #fff; flex: none; }
.dropzone .dz-icon svg { width: 24px; height: 24px; }
.dropzone .dz-text { display: flex; flex-direction: column; gap: 2px; }
.dropzone .dz-text b { font-size: 1.02rem; color: var(--brand-deep); }
.dropzone .dz-text span { color: var(--ink-2); font-size: .86rem; }
.dropzone .dz-busy { display: none; font-weight: 600; color: var(--brand) !important; }
.dropzone.busy .dz-busy { display: block; }
.dropzone.busy .dz-icon { animation: dzpulse 1s ease-in-out infinite alternate; }
@keyframes dzpulse { from { opacity: 1; } to { opacity: .45; } }
@media (prefers-color-scheme: dark) { .dropzone .dz-text b { color: var(--gold-ink); } }
.warn-text { color: var(--warn-ink); }
.draft-card { border: 1px solid var(--gold-line); border-left: 5px solid var(--gold); }
.draft-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 6px; }
.field.auto input, .field.auto select, .field.auto textarea { background: var(--gold-bg); border-color: var(--gold-line); }
.field.auto > label::after { content: "tự đọc"; margin-left: 6px; font-size: .68rem; font-weight: 650; color: var(--gold-ink);
  background: var(--gold-bg); border: 1px solid var(--gold-line); border-radius: 99px; padding: 0 6px; vertical-align: 1px; }
pre.ocr-text { white-space: pre-wrap; font-size: .8rem; max-height: 320px; overflow: auto; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
form.inline-form { display: inline; }
.draft-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.draft-layout .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.draft-layout .form-grid .span2, .draft-layout .form-grid .span3 { grid-column: 1 / -1; }
.preview-card { position: sticky; top: 80px; }
.preview-card .bd { max-height: calc(100vh - 170px); overflow: auto; }
img.doc-preview { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
pre.ocr-text.tall { max-height: none; }
@media (max-width: 1100px) { .draft-layout { grid-template-columns: 1fr; } .preview-card { position: static; } }

/* Mã liên kết Zalo Bot: to, dễ đọc, dễ gõ lại trên điện thoại */
.link-code { font-size: 2rem; font-weight: 700; letter-spacing: .3em; color: var(--brand); background: var(--surface-2);
  border: 1px dashed var(--line); border-radius: 10px; padding: 8px 16px; display: inline-block; margin: 4px 0 8px; }

/* Nhật ký kết nối Zalo Bot: JSON dài tự xuống dòng */
table.trace code { white-space: pre-wrap; word-break: break-all; }
