/* UI thẩm định v2. Màu, bo góc, cỡ chữ lấy từ bản thiết kế (Main/Queue/Stats.dc.html). Không tải font ngoài. */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #FCFCFD;
  --subtle: #F2F4F7;
  --stage: #EEF0F3;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --row-line: #F2F4F7;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #475467;
  --muted-2: #667085;
  --faint: #98A2B3;
  --accent: #1D4ED8;
  --accent-hover: #1E3A8A;
  --accent-bg: #EFF8FF;
  --accent-ink: #175CD3;
  --accent-tint: rgba(29, 78, 216, .10);

  --ok: #067647;    --ok-bg: #ECFDF3;    --ok-line: #ABEFC6;
  --part: #175CD3;  --part-bg: #EFF8FF;  --part-line: #B2DDFF;
  --warn: #B54708;  --warn-bg: #FFF4E5;  --warn-line: #FEDF89;  --warn-dot: #DC6803;
  --warn-btn: #93370D; --warn-btn-bg: #FFFAEB; --warn-btn-line: #FEC84B;
  --mute: #344054;  --mute-bg: #F9FAFB;  --mute-line: #D0D5DD;
  --bad: #B42318;   --bad-bg: #FEF3F2;   --bad-line: #FECDCA;

  --r-lg: 12px;
  --r-md: 10px;
  --r-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .08);
  --shadow-page: 0 1px 3px rgba(16, 24, 40, .12);
  --tap: 44px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; font-weight: 700; line-height: 1.3; }
h2 { font-size: 15px; font-weight: 600; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted-2); }
.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(--accent); outline-offset: 2px; }

/* ---- khung chung: menu bên trái (sidenav.js) + thanh trên chỉ còn nút của trang ------------------------- */
:root { --side-w: 248px; --side-w-mini: 64px; }
.has-side { padding-left: var(--side-w); }
html.nav-collapsed .has-side { padding-left: var(--side-w-mini); }
.skip-link { position: absolute; left: 8px; top: -200px; z-index: 100; padding: 8px 12px; background: var(--surface);
             border: 1px solid var(--border-strong); border-radius: var(--r-sm); }
.skip-link:focus { top: 8px; }
#main:focus { outline: none; }                                  /* đích của "Bỏ qua menu", không cần vòng focus */
.sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 30; width: var(--side-w); display: flex;
           flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); }
.side-head { flex: none; display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px 8px 6px 16px;
             border-bottom: 1px solid var(--border); }
.side-head .brand { flex: 1 1 auto; min-width: 0; gap: 8px; font-size: 14px; }
.brand-text { min-width: 0; line-height: 1.25; }
.side-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
            padding: 0; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
            color: var(--muted); cursor: pointer; }
.side-btn:hover { background: var(--subtle); color: var(--ink); }
.side-close { display: none; }
.nav { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 24px; display: flex;
       flex-direction: column; gap: 12px; font-size: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { margin: 0; padding: 8px 12px 4px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
.nav-group-current .nav-group-title { color: var(--ink-2); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 12px; border-radius: var(--r-sm);
         color: var(--ink-2); text-decoration: none; line-height: 1.3; }
.nav a:hover { background: var(--subtle); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600;
                              box-shadow: inset 3px 0 0 var(--accent); }
.nav-ic { flex: none; color: var(--muted-2); }
.nav a:hover .nav-ic, .nav a[aria-current="page"] .nav-ic { color: currentColor; }
.top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; min-height: 56px;
       display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ink);
         text-decoration: none; min-height: var(--tap); }
.brand:hover { color: var(--ink); }
.brand svg { flex: none; }
.brand-mark { color: var(--accent); }
.brand-sub { display: block; font-size: 11px; font-weight: 500; color: var(--muted-2); letter-spacing: .02em; }
.app-foot { max-width: 1440px; margin: 0 auto; padding: 16px 24px 24px; display: flex; flex-wrap: wrap;
            justify-content: space-between; gap: 4px 16px; font-size: 12px; color: var(--muted-2);
            border-top: 1px solid var(--border); }
.top .menu-btn, .has-side .top-brand { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
/* Thu gọn (màn rộng): chỉ còn biểu tượng; tên mục vẫn đọc được bằng trình đọc màn hình và hiện khi rê chuột (title). */
@media (min-width: 901px) {
  html.nav-collapsed .sidebar { width: var(--side-w-mini); }
  html.nav-collapsed .side-head { flex-direction: column; padding: 8px; }
  html.nav-collapsed .side-head .brand { flex: none; }
  html.nav-collapsed .brand-text, html.nav-collapsed .nav-label, html.nav-collapsed .nav-group-title {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html.nav-collapsed .nav { padding: 8px; }
  html.nav-collapsed .nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 12px; }
  html.nav-collapsed .nav a { justify-content: center; padding: 0; }
  html.nav-collapsed .side-collapse svg { transform: rotate(180deg); }
}
.local-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border);
              border-radius: 999px; }
.local-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

.page { max-width: 1440px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.page-head .lead { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap;
             align-items: center; gap: 8px; }
.card-head .hint { margin-left: auto; font-size: 12px; color: var(--muted-2); }
.card-body { padding: 16px 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap);
       padding: 0 16px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r-sm);
       color: var(--ink-2); font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--mute-bg); color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 600; padding: 0 20px; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #FFFFFF; }
.btn-warn { background: var(--warn-btn-bg); border-color: var(--warn-btn-line); color: var(--warn-btn); font-weight: 600; }
.btn-warn:hover { background: var(--warn-bg); color: var(--warn-btn); }
.btn[aria-disabled="true"] { color: var(--faint); pointer-events: none; }
.input, .select { min-height: var(--tap); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
                  padding: 0 12px; font-size: 14px; background: var(--surface); min-width: 0; }
.select { padding: 0 10px; }
textarea.input { padding: 10px 12px; min-height: 64px; resize: vertical; }

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 10px;
        border-radius: 999px; border: 1px solid transparent; white-space: nowrap; line-height: 1.4; }
.chip-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.chip-part { color: var(--part); background: var(--part-bg); border-color: var(--part-line); }
.chip-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.chip-muted { color: var(--mute); background: var(--mute-bg); border-color: var(--mute-line); }
.chip-bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.chip-outline { color: var(--muted); background: transparent; border-color: var(--border); font-weight: 400; }
.chip-soft { border: 0; font-weight: 400; padding: 2px 8px; }
.count { font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 2px 8px;
         border-radius: 999px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi-note { font-size: 12px; color: var(--muted-2); }
.kpi-warn { border-color: var(--warn-line); }
.kpi-warn .kpi-label { color: var(--warn); font-weight: 600; }
.kpi-good .kpi-value { color: var(--ok); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- hàng đợi ---------------------------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px;
           border-bottom: 1px solid var(--border); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--subtle); padding: 4px; border-radius: var(--r-md); }
.seg a { min-height: 36px; padding: 0 12px; border-radius: var(--r-sm); font-size: 13px; color: var(--muted);
         text-decoration: none; display: inline-flex; align-items: center; }
.seg a:hover { color: var(--ink); }
.seg a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.search { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; flex: 0 1 560px; min-width: 0; }
.search .input { flex: 1 1 240px; }
.q-table { min-width: 980px; }
.q-head, .q-row { display: grid; grid-template-columns: 2.2fr 2fr 1.4fr 3fr 1.3fr 1fr; gap: 12px; padding: 0 16px; }
.q-head { padding-top: 10px; padding-bottom: 10px; font-size: 12px; font-weight: 600; color: var(--muted);
          background: var(--surface-2); border-bottom: 1px solid var(--border); }
.q-row { align-items: center; padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--row-line);
         color: var(--ink); text-decoration: none; font-size: 14px; min-height: 64px; }
a.q-row:hover { background: var(--accent-bg); color: var(--ink); }
.q-row .sub { display: block; font-size: 12px; color: var(--muted-2); }
.q-row .name { font-weight: 600; }
.q-row .kind { color: var(--muted); }
.q-row .todo { color: var(--ink-2); }
.q-row .pay { font-weight: 600; }
.q-error { color: var(--bad); }
.q-empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.q-foot { padding: 12px 16px; font-size: 13px; color: var(--muted); }

/* ---- trang hồ sơ ------------------------------------------------------------------------------- */
.case-page { padding-top: 20px; padding-bottom: 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.crumbs a { text-decoration: none; }
.crumbs .actions { margin-left: auto; display: flex; gap: 8px; }

.summary { padding: 20px 24px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.summary-main { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.summary-line { color: var(--muted); }
.summary-line b { color: var(--ink); font-weight: 600; }
.summary-sub { font-size: 13px; color: var(--muted-2); }
.summary-note { font-size: 13px; color: var(--ink-2); font-style: italic; }
.figures { flex: 1 1 560px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
           border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.fig { padding: 12px 16px; border-right: 1px solid var(--border); min-width: 0; }
.fig:last-child { border-right: 0; }
.fig-label { font-size: 12px; color: var(--muted); }
.fig-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fig-accent { background: var(--accent-bg); }
.fig-accent .fig-label { color: var(--accent-ink); font-weight: 600; }
.fig-accent .fig-value { font-size: 24px; font-weight: 700; color: var(--accent); }

.hl-status { margin: 0; font-size: 13px; color: var(--warn); min-height: 0; }
.hl-status:empty { display: none; }

.case-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.viewer { flex: 1 1 440px; min-width: 0; overflow: hidden; position: sticky; top: 16px;
          display: flex; flex-direction: column; max-height: calc(100vh - 120px); }
.case-side { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.doc-tabs { flex: none; display: flex; flex-wrap: nowrap; align-items: center; overflow-x: auto; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border);
            background: var(--surface-2); }
.doc-tab { flex: none; white-space: nowrap; min-height: 36px; padding: 0 12px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
           border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 500; }
.doc-tab:hover { color: var(--ink); }
.doc-tab[aria-selected="true"] { border-color: var(--border-strong); background: var(--surface); color: var(--ink);
                                 font-weight: 600; }
.doc-tab .doc-count { margin-left: 6px; font-size: 11px; color: var(--muted-2); font-weight: 400; }
.stage { background: var(--stage); padding: 16px; overflow: auto; flex: 1 1 auto; min-height: 240px; }
.zoom-box { width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.page-wrap { position: relative; margin: 0; background: var(--surface); box-shadow: var(--shadow-page); }
.page-wrap[hidden] { display: none; }
.page-wrap img { display: block; width: 100%; height: auto; }
.page-wrap figcaption { font-size: 12px; color: var(--muted-2); padding: 4px 8px; border-top: 1px solid var(--border); }
.page-missing { padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong);
                background: var(--surface); border-radius: var(--r-sm); }
.viewer-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border);
               font-size: 13px; color: var(--muted); }
.zoom { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.zoom button { width: var(--tap); height: var(--tap); border: 1px solid var(--border-strong); background: var(--surface);
               border-radius: var(--r-sm); cursor: pointer; font-size: 16px; }
.zoom-level { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

.hl { position: absolute; border: 2px solid var(--accent); background: var(--accent-tint); border-radius: 3px;
      pointer-events: none; }
.hl-label { position: absolute; top: -22px; left: -2px; background: var(--accent); color: #FFFFFF; font-size: 11px;
            font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; max-width: 360px;
            overflow: hidden; text-overflow: ellipsis; }
.hl-label.inside { top: 2px; left: 2px; }

.src { cursor: pointer; }

/* "Cần bạn xem": mỗi việc = ở đâu, có chuyện gì, cần làm gì, vì sao */
.ri-summary { padding: 12px 20px 4px; }
.ri-head { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.ri-progress { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.ri-tier { margin: 0; padding: 14px 20px 6px; font-size: 12px; font-weight: 600; letter-spacing: .02em;
           text-transform: uppercase; color: var(--muted-2); }
.ri-list { list-style: none; margin: 0; padding: 0 12px 4px; display: flex; flex-direction: column; gap: 4px; }
.ri { border: 1px solid var(--border); border-left: 4px solid var(--warn-dot); border-radius: var(--r-md);
      padding: 6px 10px; background: var(--surface); }
/* Danh sách gọn: mỗi việc một dòng (số, chấm mức độ, chỗ: việc, số dòng, mở, đã kiểm tra); chi tiết gập bên dưới */
.ri-view { padding: 8px 20px 0; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px;
           align-items: center; }
.ri-view a { color: var(--accent); min-height: var(--tap); display: inline-flex; align-items: center; }
.ri-view a[aria-current="true"] { color: var(--ink); font-weight: 600; text-decoration: none; }
.ri-group { margin: 0; padding: 12px 20px 4px; font-size: 13px; font-weight: 600; color: var(--ink-2);
            display: flex; justify-content: space-between; gap: 8px; }
.ri-group-count { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Nhóm việc thu gọn được (mặc định đóng), mũi tên giống details.adjust / details.trace */
details.ri-group-box > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center;
                                 padding: 4px 20px 0; list-style: none; }
details.ri-group-box > summary > .ri-group { flex: 1; padding: 0; }
details.ri-group-box[open] > summary { margin-bottom: 4px; }
.ri-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ri-num { min-width: 1.6em; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ri-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--warn-dot); }
.ri-dot.dot-1 { background: var(--accent); }
.ri-dot.dot-2 { background: var(--faint); }
.ri-line .ri-text { flex: 1 1 14em; min-width: 0; overflow-wrap: anywhere; }
.ri-count { margin-left: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ri-also { margin-left: 4px; font-size: 11px; }
.ri-line .ri-actions { margin-top: 0; margin-left: auto; gap: 4px 12px; }
.ri-more { margin: 2px 0 0 calc(1.6em + 16px); }
.ri-more > summary { cursor: pointer; font-size: 12px; color: var(--muted-2); min-height: 28px; display: flex;
                     align-items: center; }
.ri-more[open] > summary { margin-bottom: 4px; }
.ri-msg { margin: 4px 0 0; font-size: 13px; color: var(--warn); }
.ri-msg:empty { display: none; }
@media (max-width: 480px) { .ri-more { margin-left: 0; } .ri-line .ri-actions { margin-left: 0; } }
.ri.tier-1 { border-left-color: var(--accent); }
.ri.tier-2 { border-left-color: var(--faint); }
.ri.is-done { background: var(--surface-2); border-left-color: var(--ok); }
.ri.is-done .ri-text, .ri.is-done .ri-do { color: var(--muted-2); }
.ri p { margin: 0 0 4px; overflow-wrap: anywhere; }
.ri-text { font-size: 14px; color: var(--ink); }
.ri-where { font-weight: 600; }
.ri-now { font-size: 13px; color: var(--warn); }
.ri-do { font-size: 14px; color: var(--ink-2); }
.ri-why { font-size: 13px; color: var(--muted); }
.ri-tag { display: inline-block; min-width: 58px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
.ri-one { font-size: 13px; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--row-line); }
.ri-rows { margin: 4px 0; }
.ri-rows summary, .ri-notes summary, .ri-tech summary { cursor: pointer; min-height: var(--tap); display: flex;
                                                       align-items: center; color: var(--accent); font-size: 13px; }
.ri-rows ul { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--row-line); }
.ri-row { display: block; width: 100%; text-align: left; padding: 8px 6px; border: 0; background: none;
          font-size: 13px; color: var(--ink-2); min-height: var(--tap); overflow-wrap: anywhere; }
button.ri-row { cursor: pointer; }
button.ri-row:hover, button.ri-row.active { background: var(--accent-bg); }
.ri-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 8px; }
.ri-open.active { border-color: var(--accent); background: var(--accent-bg); }
.ri-check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: 13px;
            color: var(--ink-2); cursor: pointer; }
.ri-check input { width: 18px; height: 18px; margin: 0; }
.ri-notes, .ri-tech { padding: 4px 20px 8px; }
.ri-notes > .ri-list { padding: 0 0 4px; }
.ri-tech summary { color: var(--muted-2); font-size: 12px; }
.ri-tech td { font-size: 12px; overflow-wrap: anywhere; }
.issue-code { font-size: 11px; color: var(--muted-2); }
.issues-empty { padding: 16px 20px; color: var(--muted); }
.term { position: relative; border-bottom: 1px dotted var(--muted-2); cursor: help; }
.term-tip { position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: max-content; max-width: min(280px, 70vw);
            padding: 8px 10px; border-radius: var(--r-sm); background: var(--ink); color: #FFFFFF; font-size: 12px;
            font-weight: 400; line-height: 1.45; box-shadow: var(--shadow-sm); display: none; }
.term:hover .term-tip, .term:focus .term-tip { display: block; }
.term.tip-off .term-tip { display: none; }
@media (max-width: 720px) { .term-tip { max-width: 220px; } }

/* thẻ quyền lợi */
.benefits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 16px 20px; }
.benefit-card { border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; display: flex;
                flex-direction: column; gap: 8px; background: var(--surface); text-align: left; }
.benefit-card:hover, .benefit-card.active { border-color: var(--accent); }
.benefit-card.active { box-shadow: inset 0 0 0 1px var(--accent); }
.benefit-head { display: flex; justify-content: space-between; gap: 8px; }
.benefit-name { font-weight: 600; font-size: 14px; }
.benefit-pay { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.benefit-limits { font-size: 12px; color: var(--muted); }
.benefit-foot { font-size: 12px; color: var(--muted-2); }
.meter { height: 6px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; width: var(--w, 0%); min-width: 2px; background: var(--accent);
                border-radius: 999px; }
.benefit-nums { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; font-size: 12px; color: var(--muted); }
.benefit-nums div { display: flex; gap: 4px; }
.benefit-nums dt { margin: 0; }
.benefit-nums dd { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.benefits-empty { padding: 16px 20px; color: var(--muted); }
.benefit-total { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 20px 16px; font-size: 13px; color: var(--muted); }

/* dòng chi phí */
table.lines { width: 100%; min-width: 640px; border-collapse: collapse; }
table.lines th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2);
                 padding: 10px 8px; border-bottom: 1px solid var(--border); }
table.lines td { padding: 12px 8px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }
table.lines th:first-child, table.lines td:first-child { padding-left: 20px; }
table.lines th:last-child, table.lines td:last-child { padding-right: 20px; }
table.lines th.num { text-align: right; }
tr.line-row { cursor: pointer; }
tr.line-row:hover td { background: var(--mute-bg); }
tr.line-row.active td, tr.line-row:has(.active) td { background: var(--accent-bg); }
tr.line-row.active td:first-child, tr.line-row:has(.active) td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.amt.active { outline: 2px solid var(--accent); outline-offset: -2px; }
.line-sub { display: block; font-size: 12px; color: var(--muted-2); }
.line-reason { display: block; font-size: 12px; color: var(--bad); }
/* Dòng thuốc: chip danh mục BHYT + gợi ý K5 (Đồng ý / Không đồng ý đi qua form sửa nhãn lâm sàng có sẵn). */
.chip-bhyt { margin-left: 4px; cursor: help; }
.drug-ai { margin-top: 4px; font-size: 12px; max-width: 34ch; }
.drug-ai > summary { cursor: pointer; color: var(--muted); }
.drug-ai-why { margin: 4px 0; }
.drug-ai-src { margin: 2px 0; color: var(--muted); }
.drug-ai-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.drug-ai-act { margin: 0; }
.doctor-act label { display: block; margin-bottom: 4px; }
.doctor-act textarea { width: 100%; }
/* Trợ lý AI cho việc cần làm: đề xuất + căn cứ + "Áp dụng đề xuất" (không tự áp). */
.ri-ai-suggest { margin: 6px 0 4px; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--accent-bg); font-size: 13px; }
.ri-ai-suggest p { margin: 2px 0; }
.ri-ai-apply { margin: 4px 0 0; }
.ri-ai-bulk { margin: 8px 0; }
.ri-ai-bulk > summary { cursor: pointer; }
.ri-ai-bulk ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.doctor-case h2 { font-size: 16px; }
.doctor-lines td { vertical-align: top; }

.strong { font-weight: 600; }

details.adjust { border-top: 1px solid var(--border); }
details.adjust > summary, details.history > summary, details.trace > summary {
  cursor: pointer; min-height: var(--tap); display: flex; align-items: center; padding: 0 20px; font-weight: 600;
  font-size: 14px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; margin-right: 8px; color: var(--muted-2); }
details[open] > summary::before { content: "▾"; }
.adjust-forms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 20px 16px; }
.adjust-form { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border);
               border-radius: var(--r-md); padding: 12px; }
.adjust-form h3 { font-size: 13px; font-weight: 600; }
.adjust-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* vì sao ra số này */
.why { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.why ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.why-foot { font-size: 12px; color: var(--muted-2); }
details.trace { border: 1px solid var(--border); border-radius: var(--r-md); }
details.trace > summary { font-size: 13px; padding: 0 12px; }
.calc-h { font-size: 13px; font-weight: 600; padding: 8px 12px 0; }
.why ol.calc-steps { padding: 4px 12px 8px 32px; gap: 4px; line-height: 1.5; }
.calc-steps li.src { border-radius: var(--r-sm, 4px); padding: 2px 4px; }
.calc-steps li.src:hover, .calc-steps li.src:focus-visible { background: var(--accent-bg); }
details.trace-tech { margin: 4px 12px 12px; border-top: 1px solid var(--border); }
details.trace-tech > summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 8px 0; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--row-line); vertical-align: top; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid tr.src:hover td { background: var(--accent-bg); }

details.history { overflow: hidden; }
.history-body { padding: 0 0 12px; display: flex; flex-direction: column; gap: 12px; }
.history-body h3 { font-size: 13px; font-weight: 600; padding: 8px 20px 0; }

.decide-bar { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--r-lg); padding: 14px 20px; display: flex; flex-wrap: wrap; align-items: center;
              gap: 12px; box-shadow: 0 -4px 12px rgba(16, 24, 40, .06); margin-bottom: 16px; }
.decide-bar label { font-size: 13px; font-weight: 600; }
.decide-bar .input { flex: 1 1 200px; }
.decided-note { flex-basis: 100%; font-size: 13px; color: var(--muted); }

/* ---- thống kê ---------------------------------------------------------------------------------- */
.stat-cols { display: flex; flex-wrap: wrap; gap: 16px; }
.stat-cols > .stat-card { flex: 1 1 520px; }
.stat-card { min-width: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 220px minmax(0, 1fr) 120px; gap: 12px; align-items: center; }
.bar-row .sub { display: block; font-size: 12px; color: var(--muted-2); }
.bar { height: 10px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: var(--w, 0%); min-width: 2%; background: var(--accent); border-radius: 999px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.status-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-card { border: 1px solid; border-radius: var(--r-md); padding: 14px; }
.status-card .s-label { font-size: 13px; font-weight: 600; }
.status-card .s-n { font-size: 22px; font-weight: 700; }
.status-card .s-pay { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tone-ok { border-color: var(--ok-line); background: var(--ok-bg); } .tone-ok .s-label { color: var(--ok); }
.tone-part { border-color: var(--part-line); background: var(--part-bg); } .tone-part .s-label { color: var(--part); }
.tone-warn { border-color: var(--warn-line); background: var(--warn-bg); } .tone-warn .s-label { color: var(--warn); }
.tone-muted { border-color: var(--mute-line); background: var(--mute-bg); } .tone-muted .s-label { color: var(--mute); }
.empty { color: var(--muted); }

/* ---- màn hẹp ----------------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .viewer { position: static; max-height: none; }
}
/* ---- menu màn hẹp (≤ 900px): menu bên trái thành ngăn kéo, "☰ Menu" mở; bảng lưới tự cuộn ngang trong khung ---- */
@media (max-width: 900px) {
  .has-side, html.nav-collapsed .has-side { padding-left: 0; }
  .side-collapse { display: none; }
  .nav a { min-height: var(--tap); }
  html:not(.js) .sidebar { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  html.js .sidebar { z-index: 60; width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden;
                     transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
                     box-shadow: 0 8px 32px rgba(16, 24, 40, .24); }
  html.js.nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur) var(--ease); }
  html.js.nav-open, html.js.nav-open body { overflow: hidden; }
  html.js .side-close, html.js .menu-btn { display: inline-flex; }
  .has-side .top-brand { display: flex; }
  .side-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(16, 24, 40, .45); }
  .side-scrim[hidden] { display: none; }
  .top-right { flex-wrap: wrap; margin-left: 0; }
  table.grid { display: block; overflow-x: auto; }
}
@media (max-width: 720px) {
  .top { padding: 8px 16px; }
  .top-right { margin-left: 0; }
  .page { padding: 16px; }
  .kpis, .status-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-value { font-size: 22px; }
  .search { margin-left: 0; flex-basis: 100%; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fig:nth-child(2) { border-right: 0; }
  .fig:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .summary { padding: 16px; }
  .benefits, .adjust-forms { grid-template-columns: minmax(0, 1fr); }
  .bar-row { grid-template-columns: minmax(0, 1fr) 96px; }
  .bar-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .decide-bar { position: static; padding: 12px 16px; box-shadow: none; }
  .decide-bar .btn { flex: 1 1 auto; }
  .crumbs .actions { margin-left: 0; }
}

/* ---- phụ ----------------------------------------------------------------------------------------- */
h1 .sub, .q-row .name .sub { display: inline; font-size: 12px; font-weight: 400; color: var(--muted-2); }
.kpi-bad { border-color: var(--bad-line); }
.kpi-bad .kpi-label { color: var(--bad); font-weight: 600; }
[role="button"][tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- dòng hồ sơ đang xử lý trên hàng đợi, hộp thoại dùng chung, ô form --------------------------- */
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.q-inbox { background: var(--surface-2); }
.q-inbox .name { color: var(--ink-2); }
.q-inbox .inbox-state { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.q-inbox .inbox-reason { color: var(--bad); }
.q-inbox .inbox-state .sub { display: block; }
.inbox-bar { display: block; width: 100%; max-width: min(280px, 70vw); height: 6px; border-radius: 999px; background: var(--subtle);
             overflow: hidden; }
.inbox-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit;
                    transition: width .4s ease; }

.modal { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border);
         border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: 0 20px 48px rgba(16, 24, 40, .18); }
.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal[open] { display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.icon-btn { margin-left: auto; width: var(--tap); height: var(--tap); display: inline-flex; align-items: center;
            justify-content: center; border: 0; background: transparent; border-radius: var(--r-sm); color: var(--muted);
            cursor: pointer; }
.icon-btn:hover { background: var(--subtle); color: var(--ink); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border);
              background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.field-label .req { font-weight: 400; font-size: 12px; color: var(--muted-2); margin-left: 4px; }
.field .help { font-size: 12px; color: var(--muted-2); margin: 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field .select, .field .input { width: 100%; }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
            gap: 6px; min-height: 120px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
            background: var(--surface-2); color: var(--muted); text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone svg { color: var(--accent); }
.dz-main u { color: var(--accent); text-decoration-thickness: 1px; }
.form-error { margin: 0; padding: 10px 12px; border: 1px solid var(--bad-line); background: var(--bad-bg); color: var(--bad);
              border-radius: var(--r-sm); }

@media (max-width: 720px) {
  .head-actions { margin-left: 0; width: 100%; }
  .head-actions .btn-primary { flex: 1 1 100%; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .modal-foot .btn { flex: 1 1 0; }
}
.banner { padding: 12px 16px; border-radius: var(--r-md); border: 1px solid var(--border); }
.banner[hidden] { display: none; }
.banner-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.banner-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.guide-steps li { margin-bottom: 6px; }
.guide-section { margin-top: 20px; }
.feedback-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- trang tiếp nhận hồ sơ (/tiep-nhan) và trang theo dõi --------------------------------------- */
.intake-page { max-width: 1200px; }
.intake { display: flex; flex-direction: column; gap: 16px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--subtle); }
.btn-lg { min-height: 52px; padding: 0 28px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.req-chip, .opt-chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 1px 8px;
                       border-radius: 999px; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.req-chip { color: var(--accent-ink); background: var(--accent-bg); border: 1px solid var(--part-line); }
.opt-chip { color: var(--muted); background: var(--mute-bg); border: 1px solid var(--border); font-weight: 500; }

.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
           gap: 8px; counter-reset: none; }
.stepper-item { position: relative; }
.stepper-btn { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 8px 12px;
               border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--muted);
               text-align: left; cursor: pointer; }
.stepper-btn:disabled { cursor: default; opacity: 1; }
.stepper-num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center;
               justify-content: center; font-weight: 700; font-size: 13px; background: var(--subtle); color: var(--muted); }
.stepper-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.stepper-item[data-state="current"] .stepper-btn { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink);
                                                   box-shadow: inset 0 0 0 1px var(--accent); }
.stepper-item[data-state="current"] .stepper-num { background: var(--accent); color: #FFFFFF; }
.stepper-item[data-state="done"] .stepper-btn { color: var(--ink-2); }
.stepper-item[data-state="done"] .stepper-num { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.stepper-item[data-state="done"] .stepper-btn:hover { border-color: var(--border-strong); }
.stepper-item[data-state="todo"] .stepper-btn:not(:disabled):hover { border-color: var(--border-strong); color: var(--ink); }

.step[hidden] { display: none; }
.step .card-head h2 { font-size: 17px; }
.step .card-head h2:focus { outline: none; }
.step .card-head h2:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.step-body { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.step-lead { margin: 0; color: var(--ink-2); }
.step-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
             padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
             border-radius: 0 0 var(--r-lg) var(--r-lg); }
.step-foot-note { margin-left: auto; font-size: 13px; color: var(--muted); }
.step-foot .btn-primary { margin-left: 0; }

.dropzone-lg { min-height: 240px; gap: 10px; border-width: 2px; }
.dropzone-lg .dz-main { font-size: 17px; font-weight: 600; color: var(--ink-2); }
.dropzone-lg .dz-or { font-size: 13px; }
.dropzone-lg .dz-btn { pointer-events: none; }
.help { font-size: 13px; color: var(--muted-2); margin: 0; }
.up-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.up-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--border);
           border-radius: var(--r-sm); background: var(--surface); }
.up-icon { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.up-ok .up-icon { background: var(--ok); }
.up-err { border-color: var(--bad-line); background: var(--bad-bg); }
.up-err .up-icon { background: var(--bad); }
.up-up .up-icon, .up-render .up-icon { background: var(--accent); }
.up-text { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-meta { font-size: 13px; color: var(--muted); }
.up-err .up-meta { color: var(--bad); }
.up-bar { flex: 1 1 100%; max-width: none; }

.thumbs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
          gap: 16px; }
.thumb { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md);
         background: var(--surface); overflow: hidden; }
.thumb-warn { border-color: var(--warn-line); }
.thumb.dragging { opacity: .4; }
.thumb.drop-before { box-shadow: -4px 0 0 var(--accent); }
.thumb.drop-after { box-shadow: 4px 0 0 var(--accent); }
.thumb-img { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; width: 100%;
             padding: 8px; border: 0; border-bottom: 1px solid var(--border); background: var(--stage); cursor: zoom-in; }
.thumb-img img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: var(--shadow-page); background: #FFFFFF; }
.thumb-img:focus-visible { outline-offset: -3px; }
.thumb-num { position: absolute; top: 8px; left: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
             background: var(--ink); color: #FFFFFF; font-weight: 700; font-size: 13px; display: inline-flex;
             align-items: center; justify-content: center; }
.thumb[draggable="true"] .thumb-img { cursor: grab; }
.thumb-meta { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 4px; min-width: 0; }
.thumb-title { font-weight: 600; }
.thumb-src { font-size: 12px; color: var(--muted-2); overflow-wrap: anywhere; }
.thumb-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.thumb-badges .chip { white-space: normal; font-size: 12px; font-weight: 600; }
.thumb-actions { display: flex; flex-wrap: nowrap; gap: 0; padding: 4px 8px 8px; margin-top: auto; }
.thumb-act { flex: none; margin-left: 0; width: 38px; height: 40px; color: var(--ink-2); }
.thumb-act:disabled { color: var(--faint); cursor: default; background: transparent; }
.thumb-del { margin-left: auto; color: var(--bad); }
.thumb-del:hover { background: var(--bad-bg); color: var(--bad); }
.toast { position: sticky; bottom: 16px; align-self: center; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px;
         background: var(--ink); color: #FFFFFF; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(16, 24, 40, .25); }
.toast[hidden] { display: none; }
.toast .btn { background: transparent; color: #FFFFFF; border-color: rgba(255, 255, 255, .5); }
.toast .btn:hover { background: rgba(255, 255, 255, .12); color: #FFFFFF; }

.info-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 20px; align-items: start; }
.info-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fs { margin: 0; border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 16px 16px; display: flex;
      flex-direction: column; gap: 16px; min-width: 0; }
.fs legend { padding: 0 6px; font-weight: 700; font-size: 14px; color: var(--ink); }
.fs-collapse { padding: 0 16px; display: block; }
.fs-inner { display: flex; flex-direction: column; gap: 16px; }
.fs-collapse[open] { padding-bottom: 16px; }
.fs-collapse > summary { min-height: var(--tap); display: flex; align-items: center; flex-wrap: wrap; gap: 4px; cursor: pointer;
                         font-weight: 700; font-size: 14px; list-style: none; }
.field-error { font-size: 13px; color: var(--bad); font-weight: 600; }
.field-error[hidden] { display: none; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.ai-reads { border: 1px solid var(--part-line); background: var(--part-bg); border-radius: var(--r-md); padding: 16px;
            color: var(--ink-2); position: sticky; top: 16px; }
.ai-reads h3 { font-size: 14px; color: var(--accent-ink); }
.ai-reads p { margin: 8px 0; font-size: 13px; }
.ai-reads ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

.confirm { margin: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-md); }
.confirm-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 12px; padding: 10px 16px;
               border-bottom: 1px solid var(--row-line); align-items: center; }
.confirm-row:last-child { border-bottom: 0; }
.confirm dt { color: var(--muted); font-size: 13px; }
.confirm dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-weight: 600; }
.confirm dd .btn { margin-left: auto; font-weight: 400; min-height: 36px; }
.confirm-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; align-items: center; }
.confirm-strip img { height: 88px; width: auto; border: 1px solid var(--border); background: #FFFFFF; }
.confirm-more { font-size: 13px; color: var(--muted); padding: 0 8px; }

.viewer-modal { width: min(980px, calc(100vw - 32px)); }
.viewer-body { overflow: auto; background: var(--stage); padding: 16px; display: flex; justify-content: center; flex: 1 1 auto; }
.viewer-body img { max-width: 100%; max-height: calc(100vh - 220px); object-fit: contain; background: #FFFFFF;
                   box-shadow: var(--shadow-page); }

.track { display: flex; flex-wrap: wrap; gap: 24px; padding: 24px; }
.track-main { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.track-label { margin: 0; font-size: 18px; font-weight: 700; }
.track-eta { margin: 4px 0 0; color: var(--muted); }
.track-eta[hidden] { display: none; }
.track-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.track-step { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.track-step:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px;
                                       background: var(--border); }
.track-step[data-state="done"]:not(:last-child)::before { background: var(--ok-line); }
.track-icon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center;
              justify-content: center; font-weight: 700; font-size: 13px; background: var(--subtle); color: var(--muted);
              border: 2px solid var(--border); }
.track-icon .i-done { display: none; }
.track-step[data-state="done"] .track-icon { background: var(--ok); border-color: var(--ok); color: #FFFFFF; }
.track-step[data-state="done"] .i-done { display: block; }
.track-step[data-state="done"] .i-num { display: none; }
.track-step[data-state="active"] .track-icon { border-color: var(--accent); color: var(--accent); background: var(--accent-bg);
                                               border-top-color: transparent; animation: spin 1s linear infinite; }
.track-step[data-state="active"] .i-num { animation: spin 1s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .track-step[data-state="active"] .track-icon, .track-step[data-state="active"] .i-num { animation: none; }
  .track-step[data-state="active"] .track-icon { border-top-color: var(--accent); }
}
.track-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 4px; }
.track-name { font-weight: 600; }
.track-step[data-state="todo"] .track-name { color: var(--muted); font-weight: 500; }
.track-step[data-state="active"] .track-name { color: var(--accent-ink); }
.track-detail { font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.track-detail:empty { display: none; }
.track-help { font-size: 13px; color: var(--muted-2); }
.track-error { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.track-error[hidden], .track-done[hidden], .track-page[hidden] { display: none; }
.track-error p { margin: 0; flex: 1 1 240px; }
.track-done { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px; border: 1px solid var(--ok-line);
              background: var(--ok-bg); border-radius: var(--r-md); }
.track-page { flex: 0 1 240px; margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center;
              background: var(--stage); border-radius: var(--r-md); padding: 16px; align-self: flex-start; }
.track-page img { width: 100%; max-width: 208px; height: auto; background: #FFFFFF; box-shadow: var(--shadow-page); }
.track-page figcaption { font-size: 13px; color: var(--muted); }
.track-links { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 900px) {
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-reads { position: static; order: -1; }
  .confirm-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-width: 720px) {
  .stepper { gap: 4px; }
  .stepper-btn { flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; padding: 8px 4px;
                 text-align: center; min-height: 72px; }
  .stepper-name { font-size: 12px; }
  .step-body { padding: 16px; }
  .step-foot { padding: 12px 16px; }
  .step-foot .btn-primary { flex: 1 1 100%; order: 3; }
  .step-foot-note { flex: 1 1 auto; text-align: right; }
  .dropzone-lg { min-height: 200px; }
  .thumbs { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .thumb { display: grid; grid-template-columns: 88px minmax(0, 1fr); grid-template-areas: "img meta" "img actions"; }
  .thumb-img { grid-area: img; border-bottom: 0; border-right: 1px solid var(--border); height: 100%; aspect-ratio: auto;
               min-height: 140px; }
  .thumb-meta { grid-area: meta; }
  .thumb-actions { grid-area: actions; padding: 0 4px 4px 4px; gap: 0; }
  .thumb-act { width: 44px; height: 44px; }
  .thumb-del { margin-left: 0; }
  .track { padding: 16px; }
  .track-page { flex: 1 1 100%; }
  .btn-lg { width: 100%; }
}

/* Đăng nhập (Plan 7) */
.login-box { max-width: 420px; margin: 48px auto; padding: 24px; border: 1px solid var(--border);
             border-radius: var(--r-sm); background: var(--surface, #fff); }
.login-product { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--accent-ink); }
.login-form { display: grid; gap: 12px; margin-top: 16px; }
.login-form label { display: grid; gap: 4px; font-size: 14px; }
.login-error { color: var(--bad, #b42318); font-weight: 600; }
.user-chip { font-size: 13px; color: var(--ink); }
.logout-form { margin: 0; }
.decide-who { font-size: 13px; color: var(--muted); flex-basis: 100%; }   /* dòng riêng: vùng nội dung hẹp hơn vì menu bên trái, nút Duyệt không bị đẩy xuống */

/* ---- quy tắc nghiệp vụ (Plan 7) ---- */
.rule-tabs { display: flex; gap: .25rem; margin: 1rem 0 .5rem; border-bottom: 1px solid var(--line, #d6d9de); }
.rule-tab { border: 0; background: none; padding: .5rem .9rem; cursor: pointer; font: inherit; border-bottom: 3px solid transparent; }
.rule-tab[aria-selected="true"] { border-bottom-color: currentColor; font-weight: 600; }
.rule-panel { padding: 1rem; }
.rule-safety { margin-top: .25rem; }
.rule-filter { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.rule-sentence { font-weight: 600; margin: .75rem 0; }
.rb-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.rb-if { font-weight: 700; }
.rb-rows { list-style: none; padding-left: 0; margin: .25rem 0; }
.rb-nested { padding-left: 1.25rem; border-left: 2px solid var(--line, #d6d9de); }
.rb-row { display: flex; gap: .5rem; align-items: flex-start; margin: .35rem 0; }
.rb-cond, .rb-val { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rb-wide { min-width: 18rem; }
.rb-raw { font-style: italic; }
.rb-add { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.rb-action { margin-top: 1rem; display: grid; gap: .5rem; border: 1px solid var(--line, #d6d9de); padding: .75rem; }
.rb-chips { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.rb-chip { font-size: .8rem; }
.rb-errors li { margin: .2rem 0; }
.ri-rule { margin: .25rem 0; }
.ri-why-rule summary { cursor: pointer; }
.ri-why-rule ul, .try-trace { margin: .25rem 0 .25rem 1.25rem; }
.try-results { list-style: none; padding-left: 0; }
.try-ok { color: var(--ok, #1a7f37); }
.try-bad { color: var(--bad, #b42318); }
.tc-facts, .tc-docs { display: grid; gap: .35rem; margin: .5rem 0; }
.tc-fact { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rule-action { display: flex; gap: .5rem; align-items: center; margin: .4rem 0; }
.rule-texts dt { font-weight: 600; }
.rule-texts dd { margin: 0 0 .4rem; }
.vl-version { border-top: 1px solid var(--line, #d6d9de); padding-top: .5rem; margin-top: .5rem; }

.rule-prose textarea { width: 100%; }
.rule-prose .prose-actions { display: flex; gap: .5rem; align-items: center; margin: .5rem 0; }
.rule-prose .prose-sentence { font-weight: 600; }
.engine-badge { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid currentColor; }

/* Plan 8: thanh người nhận/hạn xử lý trên trang hồ sơ */
.ops-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 8px 0 12px; font-size: 14px; }
.ops-bar form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.ops-complete form { margin-top: 6px; }
.q-row .chip.sla { margin-left: 4px; }
.inline-form { display: inline-flex; gap: 8px; align-items: end; margin-right: 12px; }

.hl-amber { border-color: #B45309; background: rgba(245, 158, 11, .15); }
.hl-amber .hl-label { background: #B45309; }
.hl-approx { border-style: dashed; }
.uf-card { border-left: 4px solid #F59E0B; }
.uf-note { margin: 0 0 8px; font-size: 13px; color: var(--muted, #555); }
.uf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.uf-item { display: grid; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line, #E5E7EB); }
.uf-why { font-size: 13px; color: #92400E; }
.uf-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; }

/* Kết quả thử tham số sản phẩm (Plan 9a) */
.whatif-figs { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 12px; }
.whatif-figs .fig { min-width: 180px; }
.issue { border-left: 4px solid var(--line, #d0d5dd); padding: .5rem .75rem; margin: .5rem 0; }
.issue-mau_thuan, .issue-nhieu { border-left-color: #b54708; }
.issue h3 { margin: .25rem 0; font-size: 1rem; }

/* Luyện tập (Plan 9a) */
.practice-banner { background: var(--mute-bg); border-left: 4px solid var(--accent); }
.practice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.practice-form fieldset label { display: block; margin: 4px 0; }
.practice-feedback { margin: 8px 0 16px; padding-left: 20px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 0; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; }
.row-warn td { background: var(--mute-bg); }
.checklist { list-style: none; padding-left: 0; } .checklist li { margin: 4px 0; }
/* Từ điển "?" (Plan 9a) */
.help-tip { display: inline-block; position: relative; margin-left: 6px; vertical-align: middle; }
.help-tip > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  min-height: 24px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--border); font-size: 12px;
  font-weight: 500; white-space: nowrap; }
.help-tip > summary::marker { content: ""; }
.help-tip > summary::-webkit-details-marker { display: none; }
.help-tip .help-q { font-weight: 700; }
.help-tip[open] > .help-body { position: absolute; z-index: 20; top: 28px; left: 0; width: min(360px, 80vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; font-weight: 400; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); }
.help-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.glossary dt { font-weight: 600; margin-top: 12px; }
.glossary dd { margin: 2px 0 0; }
/* Hướng dẫn lần đầu (Plan 9a) */
.tour-target { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.tour-box { position: fixed; left: 16px; bottom: 16px; z-index: 50; width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18); }
.tour-box h2 { font-size: 16px; margin: 4px 0 6px; }
.tour-count { font-size: 12px; color: var(--muted-2); margin: 0; }
.tour-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.has-side .tour-box { left: calc(var(--side-w) + 16px); }
html.nav-collapsed .has-side .tour-box { left: calc(var(--side-w-mini) + 16px); }
@media (max-width: 900px) { .has-side .tour-box, html.nav-collapsed .has-side .tour-box { left: 16px; } }
/* Thư đã lưu (Plan 10 B2): khung thư trong trang ứng dụng; khi in chỉ còn thư */
.letter-frame { width: 100%; min-height: 60rem; border: 1px solid var(--border); background: #FFFFFF; border-radius: var(--r-md); }
@media print { .top, .sidebar, .skip-link, .side-scrim, .no-print, .crumbs { display: none !important; } .has-side { padding-left: 0 !important; } .page { padding: 0; } .letter-frame { border: 0; min-height: 100vh; } }
.eyebrow { margin: 0; font-size: 12px; color: var(--muted); }
.form-error:empty { display: none; }

/* Duyệt nhanh: Đúng / Sửa ngay trên từng việc cần làm */
.ri-ok { display: inline; margin: 0; }
.ri-edit { margin: 4px 0 0 28px; }
.ri-edit > summary { display: inline-block; list-style: none; cursor: pointer; }
.ri-edit > summary::-webkit-details-marker { display: none; }
.ri-editor { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 6px; }
.ri-chooser fieldset { flex: 1 1 100%; border: 0; margin: 0; padding: 0; display: grid; gap: 4px; }
.ri-chooser legend { font-weight: 600; margin-bottom: 2px; }
.ri-chooser .ri-option { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ri-chooser .ri-option .input { max-width: 14rem; }
.ri-chooser > .hint { flex: 1 1 100%; margin: 0; }
.ri-chooser + .ri-chooser { border-top: 1px solid var(--border); padding-top: 8px; }
.ri-keys { font-size: 0.85em; margin: 2px 0; }
li.ri:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.decide-main { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; flex: 1 1 520px; }
.decide-more { display: inline-block; }
.decide-more .chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
/* ---- soạn quy tắc nhanh: ô gõ bằng lời, mảnh bấm sửa, từ mới -------------------------------------------- */
.onebox h2 { margin: 0 0 .25rem; }
.onebox textarea { width: 100%; font-size: 15px; }
.onebox-template { font-size: 12px; }
.onebox-check { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .2rem; }
.onebox-part.ok .onebox-mark { color: var(--ok); }
.onebox-part.todo .onebox-mark { color: var(--mute); }
.onebox-snippet { margin: .1rem 0; }
.onebox-progress { font-weight: 600; }
.onebox-guide details { margin-top: .5rem; }
.field-dict { max-height: 320px; overflow: auto; padding-left: 1rem; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }
mark.term-unknown { background: var(--warn-bg); color: inherit; border-bottom: 2px dotted var(--warn); padding: 0 .15rem; }
.fast-name { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: .5rem; }
.fast-name .input { min-width: 16rem; }
.chip-row { margin: .3rem 0; line-height: 2.1; }
.chip-btn { border: 1px solid var(--accent); background: var(--accent-bg); color: var(--accent-ink); border-radius: 999px;
  padding: 2px 10px; cursor: pointer; font: inherit; }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-btn.chip-level { border-style: dashed; }
.chip-pop { position: absolute; z-index: 20; background: var(--card, #fff); border: 1px solid var(--line, #d6d9de);
  border-radius: 8px; padding: .5rem; box-shadow: 0 6px 24px rgba(0,0,0,.12); min-width: 16rem; max-width: 28rem; }
.chip-options { list-style: none; margin: .4rem 0 0; padding: 0; max-height: 240px; overflow: auto; }
.chip-option { padding: .25rem .4rem; cursor: pointer; border-radius: 4px; }
.chip-option[aria-selected="true"], .chip-option:hover { background: var(--accent-bg); }
.chip-option.current { font-weight: 600; }
.term-list { list-style: none; padding: 0; }
.term-row { margin: .3rem 0; }
.term-panel { border: 1px solid var(--line, #d6d9de); border-radius: 8px; padding: .75rem; margin-top: .5rem; }
.term-panel textarea, .term-panel .input { width: 100%; margin: .25rem 0; }
.term-items { max-height: 260px; overflow: auto; margin: .25rem 0; }
.term-items .check { display: block; }
.fast-alts .fast-alt { display: block; margin: .3rem 0; text-align: left; }
@media (max-width: 640px) { .fast-name .input { min-width: 0; width: 100%; } .chip-pop { max-width: calc(100vw - 32px); } }

/* ---- trang quy tắc 4 tab ------------------------------------------------------------------------------- */
a.rule-tab { text-decoration: none; color: inherit; display: inline-block; }
.overlap-list { list-style: disc; padding-left: 1.5rem; }
.trial-steps { list-style: none; padding: 0; }
.trial-mark { display: inline-block; width: 1.2rem; font-weight: 700; }
.version-diff { list-style: none; padding: 0; font-family: inherit; }
.version-diff li { padding: 2px 6px; border-radius: 4px; margin: 2px 0; }
.version-diff .diff-del { background: var(--warn-bg); }
.version-diff .diff-add { background: var(--ok-bg); }
.version-diff .diff-same { color: var(--mute); }
.diff-sign { display: inline-block; width: 1rem; font-weight: 700; }
.timeline { padding-left: 1rem; }
.backtest-compare { font-weight: 600; }

/* ---- tinh chỉnh giao diện 2026-11-23 (docs/design/ux-audit-2026-11-23.md) --------------------------------------
   Chỉ CSS, không đổi chữ hay logic. Thang khoảng cách 4/8/12/16/24/32, chữ phụ tối thiểu 13px, một vòng focus,
   chuyển động 180ms và tắt khi người dùng chọn giảm chuyển động. Đặt cuối tệp để đè lên quy tắc cũ. */
:root {
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
  --t-caption: 13px;                       /* chữ phụ: không nhỏ hơn 13px cho người đọc không chuyên */
  --focus: var(--accent);
  --ease: cubic-bezier(.2, 0, 0, 1);
  --dur: 180ms;
  --line: var(--border);                   /* một số trang quy tắc dùng var(--line) chưa khai báo */
  --card: var(--surface);
}

/* Chữ: tiêu đề trang đậm vừa, đoạn dẫn không chạy hết chiều ngang màn hình, đoạn dẫn thứ hai là phụ */
h1 { font-size: 22px; line-height: 28px; font-weight: 650; letter-spacing: -.005em; }
h2 { line-height: 24px; }
.page-head .lead { max-width: 80ch; line-height: 1.55; }
.page-head .lead + .lead { color: var(--muted-2); }
.page-head > div > .muted { max-width: 80ch; }

/* Chữ phụ 12px nâng lên 13px (dễ đọc hơn trên màn hình văn phòng) */
.q-row .sub, .line-sub, .bar-row .sub, .kpi-note, .benefit-limits, .benefit-foot, .benefit-nums, .card-head .hint,
.field .help, .why-foot, .thumb-src, .q-head, table.lines th, table.grid th { font-size: var(--t-caption); }

/* Thẻ: thẻ thường không có card-head/card-body thì nội dung không dính sát viền */
.card:is([class="card"], .onebox, .rule-step, .fast-rule, .rule-new, .value-list, .ai-judge, .whatif, .practice-form, .rule-message):not(:has(> .card-head, > .card-body, > .table-scroll, > .q-table, > .toolbar, > .ri-summary)) {
  padding: var(--s-4) 20px; display: flex; flex-direction: column; gap: var(--s-3); }
.card:is([class="card"], .onebox):not(:has(> .card-head, > .card-body, > .table-scroll, > .q-table, > .toolbar, > .ri-summary)) > :is(p, h2, h3, ul, ol, form) { margin-top: 0; margin-bottom: 0; }
.card > table.grid { border: 1px solid var(--border); border-radius: var(--r-md); border-collapse: separate; border-spacing: 0;
                     overflow: hidden; }
.card > table.grid > thead th { border-top: 0; }
.card ul:has(> li.muted:only-child) { list-style: none; padding-left: 0; }
.ri-legend { margin: 0; padding: var(--s-3) 20px 0; font-size: var(--t-caption); color: var(--muted); }

/* Bảng: tên hàng (th trong thân bảng) là chữ thường đậm, hàng cao hơn, số căn phải dạng bảng, rê chuột tô nền */
table.grid th, table.grid td { padding: 10px var(--s-3); vertical-align: middle; }
table.grid tbody th { font-size: 14px; font-weight: 600; color: var(--ink); background: transparent; }
table.grid thead th { white-space: nowrap; }
table.grid td { font-variant-numeric: tabular-nums; }
table.grid tbody tr { transition: background-color var(--dur) var(--ease); }
table.grid tbody tr:hover > :is(td, th) { background: var(--mute-bg); }
table.grid ul { margin: 0; padding-left: 18px; }
.q-row { transition: background-color var(--dur) var(--ease); }
.q-row .pay { font-variant-numeric: tabular-nums; }

/* Chip trạng thái: hạn xử lý còn xa là thông tin trung tính, chỉ tô màu khi sắp/quá hạn */
.q-row .chip.sla.chip-ok { color: var(--ink-2); background: var(--surface); border-color: var(--border); font-weight: 500; }

/* Nút: phân cấp rõ (chính đặc, phụ viền, ghost không viền), chuyển màu mượt */
.btn { transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease),
                   box-shadow var(--dur) var(--ease); font-weight: 500; }
.btn:hover { border-color: var(--muted-2); }
.btn-primary { font-weight: 600; box-shadow: var(--shadow-sm); }
.btn-primary:hover { border-color: var(--accent-hover); }
.btn-ghost:hover { border-color: transparent; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 1; background: var(--subtle); border-color: var(--border); color: var(--muted-2);
                                             box-shadow: none; }

/* Ô nhập: viền xanh và quầng nhạt khi đang gõ, nền mờ khi khoá */
.input, .select { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.input:hover, .select:hover { border-color: var(--muted-2); }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.input:focus:not(:focus-visible), .select:focus:not(:focus-visible) { outline: none; }
.input:disabled, .select:disabled { background: var(--subtle); color: var(--muted-2); }
.input::placeholder { color: var(--muted-2); }

/* Focus: một vòng rõ, khác với trạng thái đang chọn */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a.q-row:focus-visible { outline-offset: -2px; }

/* Menu bên trái: đổi nền/màu mượt */
.nav a { transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }

/* Ô "?" giải thích thuật ngữ và mục gập: bỏ dấu tam giác thừa (trước đây hiện "▸ ?" hoặc "▶ ▸") */
details > summary { list-style: none; }
details > summary::marker { content: ""; }
.help-tip > summary::before { content: none; }
.help-tip > summary { color: var(--ink-2); background: var(--surface); transition: border-color var(--dur) var(--ease); }
.help-tip > summary:hover { border-color: var(--muted-2); }
.help-tip .help-q { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
                    border-radius: 50%; background: var(--subtle); color: var(--accent-ink); font-size: 11px; }

/* Thanh quyết định: nổi rõ ở chân trang hồ sơ, nút to hơn */
.decide-bar { border-color: var(--border-strong); box-shadow: 0 -8px 24px -8px rgba(16, 24, 40, .16); padding: var(--s-4) 20px; }
.decide-bar .btn, .decide-bar .input { min-height: 48px; }
.decide-bar .btn-primary { font-size: 15px; padding: 0 24px; }

/* Thẻ số liệu: nhãn và số tách bậc rõ, thẻ cần chú ý có vạch màu bên trái */
.kpi { padding: var(--s-4) 20px; display: flex; flex-direction: column; gap: var(--s-1); }
.kpi-label { color: var(--muted); font-weight: 500; }
.kpi-warn { box-shadow: inset 3px 0 0 var(--warn-dot); }
.kpi-bad { box-shadow: inset 3px 0 0 var(--bad); }

/* Trạng thái trống */
.q-empty { padding: var(--s-6) var(--s-4); font-size: 15px; }

/* Hướng dẫn lần đầu: khung nhấn không đè lên chữ */
.tour-target { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: var(--r-sm);
               box-shadow: 0 0 0 8px var(--accent-tint); }
.tour-box { border-radius: var(--r-lg); padding: var(--s-4) 20px; }

/* Giảm chuyển động: giữ trạng thái cuối, bỏ chuyển cảnh */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important;
                            animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
/* Hộp "So sánh" (việc cần làm): các chỗ nguồn cạnh nhau, ảnh cắt bằng CSS, nút Đúng/Sửa ngay trong hộp */
.cmp { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: 0 12px 40px rgba(16, 24, 40, .25); }
.cmp::backdrop { background: rgba(16, 24, 40, .45); }
.cmp-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2; }
.cmp-head h2 { margin: 0; font-size: 16px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.cmp-help { margin: 8px 20px 0; }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; padding: 12px 20px; }
.cmp-panel { margin: 0; border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cmp-cap { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.cmp-page { color: var(--muted-2); font-size: 12px; }
.cmp-value { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.cmp-value-label { color: var(--muted); font-size: 12px; }
.cmp-text { align-self: start; justify-content: flex-start; background: var(--accent-bg); border-color: var(--part-line); }
.cmp-text .cmp-value b { font-size: 18px; }
.cmp-view { position: relative; overflow: hidden; background: var(--stage); border-radius: var(--r-sm); min-height: 80px; }
.cmp-view img { position: absolute; max-width: none; height: auto; user-select: none; }
.cmp-box { position: absolute; border: 3px solid var(--warn-dot); border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(16, 24, 40, .12); pointer-events: none; }
.cmp-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.cmp-tools .cmp-whole { margin-left: auto; }
.cmp-actions { padding: 4px 20px 8px; border-top: 1px solid var(--border); }
.cmp-actions:empty { display: none; }
.cmp-actions .ri-ok { display: inline-block; margin: 8px 8px 0 0; }
.cmp-actions details.ri-edit { display: inline-block; vertical-align: top; margin-top: 8px; max-width: 100%; }
.cmp-actions details.ri-edit[open] { display: block; }
.cmp-msg { margin: 0 20px; }
.cmp-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px 20px 14px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .cmp { width: calc(100vw - 16px); }
  .cmp-grid { grid-template-columns: 1fr; padding: 12px; }
}

/* Khiếu nại của khách (trang hồ sơ) */
.complaint { margin-bottom: 16px; }
.complaint .card-head h2 { margin: 0; font-size: 15px; }
.complaint .card-head .kn-state { margin-left: auto; }
.kn-body { padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.kn-facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; }
.kn-facts div { min-width: 0; }
.kn-facts dt { font-size: 12px; color: var(--muted-2); }
.kn-facts dd { margin: 2px 0 0; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.kn-summary { border-left: 3px solid var(--warn-dot); background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 12px; }
.kn-summary p { margin: 2px 0 0; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }
.kn-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kn-note { margin: 0; background: var(--accent-bg); border-color: var(--part-line); color: var(--ink-2); font-size: 13px; }
.kn-body > .banner { margin: 0; font-size: 13px; }
.kn-hint { margin: 0; font-size: 13px; }
.kn-events > summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.kn-events ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.kn-when { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.kn-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.kn-form { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: var(--r-md);
           padding: 12px 14px; background: var(--surface); min-width: 0; }
.kn-form h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.kn-form-quiet { background: var(--surface-2); }
.kn-choices { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.kn-choices label { display: flex; gap: 8px; align-items: flex-start; }
.kn-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.kn-row { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kn-record > summary { list-style: none; }
.kn-record > summary::-webkit-details-marker { display: none; }
.kn-record[open] > summary { margin-bottom: 10px; }
.kn-record .kn-form { border-style: dashed; }

/* ---- khung khoanh nhiều dòng (fix/highlight-boxes): bấm quyền lợi -> các hàng liền nhau gộp một khung (hlbox.js);
   viền mảnh 2px, nền nhạt trong suốt để vẫn đọc được chữ bên dưới, nhãn chỉ một lần ---- */
.hl.hl-multi { border-width: 2px; background: rgba(29, 78, 216, .06); box-shadow: none; }
.hl.hl-multi.hl-amber { background: rgba(245, 158, 11, .08); }
.hl.hl-multi.hl-approx { border-style: dashed; }
/* ---- bảng dòng chi phí dài: nhóm theo mục, tìm, lọc (lines_table.js) ---- */
.lt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 0 20px 12px; }
.lt-tools[hidden] { display: none; }
.lt-search { flex: 1 1 240px; }
.lt-search .input { width: 100%; }
.lt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lt-chip { cursor: pointer; background: var(--surface); }
.lt-chip[aria-pressed="true"] { color: #FFFFFF; background: var(--accent); border-color: var(--accent); }
.lt-count { font-size: 13px; color: var(--muted); }
.lt-group { border-top: 1px solid var(--border); }
.lt-group[hidden] { display: none; }
.lt-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 20px; cursor: pointer;
           background: var(--surface-2); position: sticky; top: 0; z-index: 2; }
.lt-name { font-weight: 600; }
.lt-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lt-group .table-scroll { max-height: 70vh; overflow: auto; }
.lt-group table.lines thead th { position: sticky; top: 0; z-index: 1; }
tr.line-row[hidden] { display: none; }

/* Phân trang danh sách dài (_pager.html) */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pager-link { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--ink-2); text-decoration: none; }
a.pager-link:hover { border-color: var(--border-strong); background: var(--subtle); }
a.pager-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pager-link.is-current { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.pager-link.is-disabled { color: var(--faint); background: var(--surface-2); }
.pager-gap { padding: 0 4px; color: var(--faint); }

/* Tra cứu người được bảo hiểm (trang tiếp nhận, bước 3) */
.info-form-wrap { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.lookup { border: 1px solid var(--part-line); border-radius: var(--r-md); padding: 16px; }
.lookup-title { font-size: 15px; margin: 0 0 4px; }
.lookup-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.lookup-kind { flex: 0 0 auto; width: auto; }
.lookup-value { flex: 1 1 180px; min-width: 0; }
.lookup-results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.lookup-card { border: 1px solid var(--part-line); border-radius: var(--r-md); padding: 12px; display: flex;
  flex-direction: column; gap: 4px; align-items: flex-start; }
.lookup-card-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lookup-card-expired { opacity: .65; }
.lookup-line { font-size: 13px; overflow-wrap: anywhere; }
.lookup-warn { margin: 4px 0; font-size: 13px; color: var(--warn-ink, #8a5a00); }
.lookup-benefits { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.lookup-more summary { font-size: 13px; cursor: pointer; }
.lookup-dep-group { margin-left: 16px; }
.lookup-dep-title { margin: 0; font-size: 13px; font-weight: 600; }
.lookup-notfound { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lookup-chosen { margin-top: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lookup-chosen-line { margin: 0; font-size: 13px; }
.lookup-chosen[hidden] { display: none; }
input[readonly].input { background: var(--part-bg); }

/* Người được bảo hiểm đọc từ chứng từ (trang tiếp nhận, bước 3; static/intake_identity.js) */
.idread { border: 1px solid var(--part-line); border-radius: var(--r-md); padding: 16px; display: flex;
  flex-direction: column; gap: 10px; min-width: 0; }
.idread-status { margin: 0; font-size: 13px; }
.idread-status[data-state="ok"] { border-color: var(--ok-line, var(--part-line)); }
.idread-missing { margin: 0; padding-left: 18px; font-size: 13px; color: var(--warn); }
.idread-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.idread-field { min-width: 0; }
.idread-src { font-size: 12px; color: var(--mute); overflow-wrap: anywhere; }
.idread-src[data-edited="1"] { color: var(--warn); font-weight: 600; }
.idread-alt { font-size: 12px; color: var(--warn); overflow-wrap: anywhere; }
.idread-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.idread-result { margin: 0; font-size: 13px; }
.idread-result[hidden], .idread-missing[hidden], .idread-alt[hidden] { display: none; }
.lookup-agree { font-size: 12px; color: var(--ok, inherit); }
details.lookup > summary { cursor: pointer; }

/* ---- rà soát UX 2026-11-26 (trước buổi khách dùng thử) ---------------------------------------------------------
   Sửa bố cục chung cho trang không dùng page-head/card-head; không đổi logic. */
/* Thuộc tính hidden luôn ẩn, kể cả khi lớp (.btn, .chip...) đặt display: nút "Hủy hồ sơ này" từng hiện khi chưa có nháp. */
[hidden] { display: none !important; }
/* Trang xếp dọc bằng gap của .page: đoạn văn trực tiếp không cộng thêm lề mặc định (khoảng trắng to giữa tiêu đề và
   đoạn dẫn). */
.page > :is(p, ul, h1) { margin-top: 0; margin-bottom: 0; }
.page > h1 + .lead { margin-top: -8px; }
.page > .lead, .page > p.muted { max-width: 80ch; line-height: 1.55; }
.page > .lead + .muted { margin-top: -8px; }
/* Thanh lọc dạng "tabs" (khiếu nại, cơ sở khám): giống thanh lọc ở hàng đợi thay vì các liên kết dính liền nhau. */
nav.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
nav.tabs > a:not(.btn) { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--r-sm);
                         color: var(--muted); text-decoration: none; background: var(--subtle); font-size: 13px; }
nav.tabs > a:not(.btn):hover { color: var(--ink); }
nav.tabs > a[aria-current="page"]:not(.btn) { background: var(--surface); color: var(--ink); font-weight: 600;
                                              box-shadow: inset 0 0 0 1px var(--border-strong); }
nav.tabs > .btn { margin-left: auto; }
/* Bảng lớp "table" (trước đây không có kiểu): giống bảng lưới, nền trắng, tự cuộn ngang ở màn hẹp. */
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; background: var(--surface);
              border: 1px solid var(--border); border-radius: var(--r-md); }
table.table th, table.table td { text-align: left; padding: 10px var(--s-3); border-top: 1px solid var(--row-line);
                                 vertical-align: top; }
table.table thead th { border-top: 0; font-size: var(--t-caption); color: var(--muted); font-weight: 600;
                       background: var(--surface-2); white-space: nowrap; }
@media (max-width: 900px) { table.table { display: block; overflow-x: auto; } }
/* Biểu mẫu xếp dọc: nhãn ở trên ô nhập, ô nhập không kéo dài hết màn hình, nút cùng một hàng. */
.form-stack { display: flex; flex-direction: column; gap: var(--s-3); align-items: stretch; }
.card.form-stack { padding: var(--s-4) 20px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; max-width: 480px; font-weight: 500; color: var(--ink-2); }
.form-stack label :is(.input, .select) { width: 100%; font-weight: 400; }
.form-stack label:has(> input[type="checkbox"], > input[type="radio"]) { flex-direction: row; align-items: center; gap: 8px;
                                                                        max-width: none; font-weight: 400; }
.form-stack fieldset { margin: 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md);
                       display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.form-stack legend { padding: 0 4px; font-weight: 600; color: var(--ink); }
.form-stack table label, .form-stack table :is(.input, .select) { max-width: none; }
.form-stack table .input { min-width: 120px; }
.form-stack > p, .form-stack fieldset > p, .form-stack > h2 { margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
/* Ô kết luận trong bảng (kiểm tra mẫu, thu hồi khóa): xếp dọc trong ô, không chen ngang. */
td .form-stack { min-width: 240px; gap: var(--s-2); display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
                 align-items: end; }
td .form-stack > .form-actions { grid-column: 1 / -1; }
table.grid tr:has(td .form-stack) > td { vertical-align: top; }
/* Trang bác sĩ: tiêu đề và dòng tóm tắt hồ sơ không dính sát viền thẻ. */
.doctor-case > :is(h2, p) { margin: 0; padding: var(--s-4) 20px 0; }
.doctor-case > p.hint { padding-top: 4px; padding-bottom: var(--s-3); }
/* Ô số tiền ở tóm tắt hồ sơ: cột đủ rộng cho số lớn (65.000.000) thay vì tràn sang cột bên. */
@media (min-width: 721px) { .figures { grid-template-columns: repeat(4, minmax(max-content, 1fr)); } }
.summary-line .chip, .title-row .chip { white-space: normal; }
/* Màn hẹp: phím tắt bàn phím không dùng trên điện thoại; tên người dùng bỏ khỏi thanh trên để thanh còn một hàng. */
@media (max-width: 720px) {
  .ri-keys { display: none; }
  .top-right .user-chip { display: none; }
  .top-right { margin-left: auto; }
}
/* Hồ sơ không có ảnh chứng từ: khung xem gọn, không hiện nút phóng to/thu nhỏ vô dụng. */
.viewer.viewer-empty .stage { min-height: 0; }
.viewer.viewer-empty .page-missing { padding: 20px 16px; }
.viewer.viewer-empty .viewer-foot { display: none; }
/* Trang lỗi: câu hướng dẫn việc nên làm. */
.error-help { color: var(--muted); max-width: 70ch; }
.error-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* ---- quy tắc: luồng 4 bước cho người không rành kỹ thuật, mọi thứ kỹ thuật trong một mục "Nâng cao" ---- */
.rule-steps { display: flex; flex-direction: column; gap: var(--s-4); }
.rule-step h2 { display: flex; align-items: center; gap: .5rem; margin: 0; }
.step-no { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
           background: var(--accent, #1d4ed8); color: #fff; font-size: 14px; flex: none; }
.rule-step textarea { width: 100%; font-size: 15px; }
.rule-plain { font-size: 16px; font-weight: 600; line-height: 1.5; margin: 0; padding: .75rem 1rem;
              border-left: 4px solid var(--ok); background: var(--ok-bg); border-radius: var(--r-md); }
.rule-step .fast-name { display: flex; gap: .75rem; align-items: end; flex-wrap: wrap; }
.rule-step .fast-name input { min-width: min(28rem, 100%); }
.fast-alts { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.fast-alt { text-align: left; white-space: normal; }
.try-summary { font-size: 15px; margin: 0; }
.try-examples { margin: 0; padding-left: 1.2rem; }
.try-examples .try-trace { color: var(--muted); font-size: var(--t-caption); }
.rule-advanced { padding: var(--s-3) 20px; }
.rule-advanced > summary { cursor: pointer; font-weight: 600; font-size: inherit; color: var(--ink, inherit); min-height: var(--tap); display: flex; align-items: center; }
.rule-advanced .adv-block { border-top: 1px solid var(--border); padding-top: var(--s-3); margin-top: var(--s-3); }
.rule-admin-links { margin: .5rem 0 0; }
.onebox-title-field input { width: 100%; }
@media (max-width: 600px) {
  .rule-step .fast-name { flex-direction: column; align-items: stretch; }
  .rule-step .fast-name input, .rule-step .fast-name select { min-width: 0; width: 100%; }
  .rule-advanced { padding: var(--s-3) 12px; }
  /* bộ dựng điều kiện trong "Nâng cao": ô chọn co theo màn hẹp, không tràn ngang */
  .rule-advanced .rb-row, .rule-advanced .rb-cond, .rule-advanced .rb-val { flex-wrap: wrap; min-width: 0; }
  .rule-advanced .rb-cond { flex: 1 1 100%; }
  .rule-advanced :is(select, input, textarea, fieldset, .rb-action) { min-width: 0; max-width: 100%; }
  .rule-advanced .rb-wide { min-width: 0; }
  .rule-advanced .rb-action { grid-template-columns: minmax(0, 1fr); }
  .rule-advanced .rb-chip { white-space: normal; max-width: 100%; text-align: left; }
  .rule-advanced .tc-fact { display: flex; flex-wrap: wrap; gap: .4rem; }
  .rule-advanced .rb-labeled select, .rule-advanced .rb-labeled input { width: 100%; }
}
/* đổi người nhận tiền sau khi nộp (trang hồ sơ) */
.payee-change { margin-top: 6px; font-size: 13px; }
.payee-change > summary { cursor: pointer; }
.payee-history { margin: 6px 0; padding-left: 18px; }
.payee-history li { margin: 4px 0; }
.payee-confirm, .payee-form { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: end; margin-top: 4px; }
.payee-form .hint { flex-basis: 100%; margin: 0; }

/* Chân trang luôn ở đáy màn hình: trang ngắn (đăng nhập, lỗi) không để chân trang lơ lửng giữa màn hình. */
@media screen {
  body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  body > main.page { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
  body > .app-foot { width: 100%; box-sizing: border-box; margin-top: 0; }
}
/* Trang đăng nhập: khung đăng nhập nằm giữa màn hình theo chiều dọc (main giãn hết chiều cao còn lại). */
@media screen and (min-height: 640px) { .page > .login-box { margin: auto; width: 100%; } }

/* ---- Sửa kết quả chi trên dòng chi phí (line_override.js) ---------------------------------------------------------- */
.chip-info { color: var(--accent-ink); background: var(--accent-bg); border-color: var(--accent-tint); }
.ovr-intro { margin: 0; padding: 0 20px 12px; }
.ovr-notice { margin: 0 20px 12px; padding: 8px 12px; border-radius: 8px; background: var(--accent-bg); color: var(--accent-ink); }
.ovr-notice[hidden] { display: none; }
tr.line-row[data-override] > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ovr-why { color: var(--accent-ink); }
.ovr-cell .ovr-chip { display: inline-flex; margin-top: 4px; }
.ovr-cmp { display: block; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.ovr-cmp-sm { display: none; }
.ovr { margin-top: 6px; font-size: 13px; }
.ovr > summary { list-style: none; display: inline-flex; }
.ovr > summary::-webkit-details-marker { display: none; }
.ovr-form { display: grid; gap: 8px; margin-top: 8px; padding: 10px 12px; width: 300px; max-width: 80vw;
  box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ovr-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ovr-form legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.ovr-form label { display: grid; gap: 4px; }
.ovr-form fieldset label { display: inline-flex; align-items: center; gap: 6px; }
.ovr-form [hidden] { display: none; }
.ovr-form .hint { margin: 0; }
.ovr-undo { background: transparent; border-style: dashed; }
.ovr-msg { font-size: 12px; color: var(--muted); }
@media (max-width: 640px) { .ovr-form { width: min(300px, calc(100vw - 64px)); } .ovr-cmp { white-space: normal; }
  .ovr-cmp-sm { display: block; } }
