:root {
  --paper: #F3F5F4;
  --surface: #FFFFFF;
  --sunken: #E8ECEC;
  --ink: #1B2733;
  --muted: #5B6A76;
  --rule: #D6DDE0;
  --primary: #1F4E79;
  --primary-ink: #FFFFFF;
  --debit: #1D6B52;
  --credit: #9E2F25;
  --warn: #8A5A00;
  --warn-bg: #FBF1DC;
  --error-bg: #FBE9E6;
  --ok-bg: #E3F1EB;
  --focus: #3B7BC0;
  --radius-s: 4px;
  --radius-m: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12191F;
    --surface: #1A232B;
    --sunken: #222D36;
    --ink: #E4EAEE;
    --muted: #96A4AF;
    --rule: #2F3B45;
    --primary: #6FA3D6;
    --primary-ink: #0E1A26;
    --debit: #5FC29C;
    --credit: #EE8A7E;
    --warn: #E8B85A;
    --warn-bg: #3A2F17;
    --error-bg: #3D211D;
    --ok-bg: #18332A;
    --focus: #8DBDF0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.num { text-align: right; white-space: nowrap; }
.debit { color: var(--debit); }
.credit { color: var(--credit); }

/* ---------- Buttons & inputs ---------- */
.btn {
  border: 1px solid var(--rule); background: var(--surface); border-radius: var(--radius-s);
  padding: 7px 14px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--credit); }
.btn.link { border: 0; background: none; padding: 4px 6px; color: var(--primary); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .cell-input {
  border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface);
  padding: 7px 9px; color: var(--ink); min-width: 0;
}
.field input:focus, .cell-input:focus, .field select:focus { border-color: var(--focus); outline: none; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}
.login-side {
  background: var(--primary); color: var(--primary-ink); padding: 56px; display: flex;
  flex-direction: column; justify-content: flex-end; gap: 16px;
}
.login-side p { max-width: 34ch; font-size: 17px; margin: 0; opacity: .9; }
.ledger-lines {
  flex: 1; background-image: repeating-linear-gradient(to bottom, transparent 0 35px, rgba(255,255,255,.14) 35px 36px);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40%); mask-image: linear-gradient(to bottom, transparent, #000 40%);
}
.login-form { padding: 56px 40px; display: flex; flex-direction: column; justify-content: center; gap: 16px; background: var(--surface); }
.login-form .hint { font-size: 13px; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; } .login-side { display: none; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100%; }
.sidebar {
  background: var(--sunken); border-right: 1px solid var(--rule); display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
}
.brand { padding: 18px 18px 12px; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--primary); display: grid; place-items: center; }
.brand-mark span { width: 14px; height: 2px; background: var(--primary-ink); box-shadow: 0 5px 0 var(--primary-ink), 0 -5px 0 var(--primary-ink); }
.sidebar .search { margin: 0 14px 10px; }
.client-list { list-style: none; margin: 0; padding: 0 8px; overflow: auto; flex: 1; }
.client {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px;
  border-radius: var(--radius-s); cursor: pointer;
}
.client:hover { background: var(--surface); }
.client.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--primary); }
.client .name { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client .meta { font-size: 12px; color: var(--muted); }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid var(--rule); font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 20px 28px 0; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.period { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; }
.period select { padding: 6px 8px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--surface); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--ok-bg); color: var(--debit); font-weight: 500; }
.badge.locked { background: var(--warn-bg); color: var(--warn); }
.tabs { display: flex; gap: 2px; width: 100%; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--ink); border-bottom-color: var(--primary); }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--sunken); }
tfoot td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; }
tr.void td { color: var(--muted); text-decoration: line-through; }
.group-head th { text-align: center; border-bottom: 1px solid var(--rule); }

/* ---------- Overview ---------- */
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; }
.figure { background: var(--surface); padding: 16px 18px; }
.figure .label { font-size: 13px; color: var(--muted); }
.figure .value { font-size: 21px; font-weight: 600; margin-top: 4px; }
.figure .note { font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.notice { padding: 10px 14px; border-radius: var(--radius-s); background: var(--warn-bg); color: var(--warn); }
.notice.error { background: var(--error-bg); color: var(--credit); }
.notice.ok { background: var(--ok-bg); color: var(--debit); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Voucher slip (phần nhập chứng từ) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 25, 35, .45); display: flex; justify-content: flex-end; z-index: 10; }
.slip {
  width: min(980px, 100%); height: 100%; overflow: auto; background: var(--paper);
  display: flex; flex-direction: column; animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .slip { animation: none; } }
.slip-head { padding: 20px 28px; background: var(--surface); border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.slip-body { padding: 20px 28px; display: flex; flex-direction: column; gap: 18px; }
.slip-grid { display: grid; grid-template-columns: 170px 150px 150px minmax(0, 1fr); gap: 12px; }
.slip-grid .wide { grid-column: 1 / -1; }
@media (max-width: 720px) { .slip-grid { grid-template-columns: 1fr 1fr; } }

.entries { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: auto; }
.entries table { min-width: 760px; }
.entries th.side-debit { color: var(--debit); }
.entries th.side-credit { color: var(--credit); }
.entries td { padding: 6px 8px; vertical-align: middle; }
.entries td.split { border-left: 2px solid var(--rule); }
.entries .cell-input { width: 100%; }
.entries .acc { width: 92px; }
.entries .amount { text-align: right; font-weight: 500; }
.entries .acc-name { font-size: 12px; color: var(--muted); display: block; margin-top: 2px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entries .kind { font-size: 12px; color: var(--muted); }
.entries-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-top: 1px solid var(--rule); }
.total-line { font-size: 15px; font-weight: 600; }
.invoice-box { background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--radius-m); padding: 14px 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.invoice-box .wide { grid-column: span 2; }
@media (max-width: 720px) { .invoice-box { grid-template-columns: 1fr 1fr; } }
.slip-foot { margin-top: auto; padding: 14px 28px; background: var(--surface); border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 10px; position: sticky; bottom: 0; }

.empty { padding: 32px; text-align: center; color: var(--muted); }
.history { font-size: 13px; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; max-height: 40vh; }
}

/* ---------- Bản in (A4) ---------- */
#print-root { display: none; }
@media print {
  #root { display: none !important; }
  #print-root { display: block; }
  html, body { height: auto; background: #fff; color: #000; }
}
.p-sheet {
  font: 12.5pt/1.45 "Times New Roman", Times, "Noto Serif", serif; color: #000; background: #fff;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.p-sheet h1 { font-size: 15pt; font-weight: 700; margin: 0 0 2px; letter-spacing: .02em; }
.p-sheet b { font-weight: 700; }
.p-small { font-size: 10.5pt; }
.p-center { text-align: center; }
.p-header { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.p-unit { max-width: 60%; }
.p-form { text-align: center; max-width: 38%; }
.p-title { margin: 6px 0 12px; }
.p-voucher-title { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; margin: 4px 0 14px; }
.p-accounts { justify-self: end; text-align: left; }
.p-lines > div { margin: 4px 0; }
.p-after { margin-top: 18px; }
.p-table { width: 100%; border-collapse: collapse; font-size: 10.5pt; }
.p-table th, .p-table td { border: 0.6pt solid #000; padding: 3px 5px; vertical-align: top; position: static; background: none; color: #000; }
.p-table th { text-align: center; font-weight: 700; }
.p-table thead { display: table-header-group; }      /* lặp tiêu đề cột trên mỗi trang */
.p-table tr { break-inside: avoid; }
.p-table tfoot td { font-weight: 700; border-top: 0.6pt solid #000; }
.p-table tfoot { display: table-row-group; }          /* dòng tổng chỉ in một lần ở cuối */
.p-table tr.b td { font-weight: 700; }
.p-table .r { text-align: right; white-space: nowrap; }
.p-table .c { text-align: center; white-space: nowrap; }
.p-sign { margin-top: 16px; break-inside: avoid; }
.p-sign-date { text-align: right; margin-bottom: 6px; padding-right: 2%; }
.p-sign-row { display: grid; text-align: center; gap: 8px; }
.p-sign-space { height: 22mm; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; max-width: 760px; }
.settings-grid .wide { grid-column: 1 / -1; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--sunken); border-radius: var(--radius-m); align-self: flex-start; flex-wrap: wrap; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: var(--radius-s); cursor: pointer; color: var(--muted); font-weight: 500; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--rule); }
.slip-grid.inv-grid { grid-template-columns: 260px minmax(0, 1fr) auto; align-items: start; }
.slip-grid.inv-grid .cell-input { width: 100%; }
@media (max-width: 720px) { .slip-grid.inv-grid { grid-template-columns: 1fr; } }
tr.strong-row td { font-weight: 600; background: var(--sunken); }
.p-right { text-align: right; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 16px; }
.login-form { overflow-y: auto; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; opacity: 0; }
.banner { padding: 10px 28px; background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.banner.danger { background: var(--error-bg); color: var(--credit); }
.content .banner { margin: -24px -28px 0; }
.perm-group { border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 10px 14px; display: grid; gap: 6px; background: var(--surface); }
.perm-group legend { font-weight: 600; padding: 0 6px; }
.perm-item { display: flex; gap: 8px; align-items: flex-start; }
.btn.link.danger { color: var(--credit); }
.acc-name { display: block; font-size: 12px; color: var(--muted); }
.badge { white-space: nowrap; display: inline-block; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0 4px; justify-content: flex-end; min-width: 180px; }

/* ---------- Hướng dẫn trong chương trình ---------- */
.help-btn { display: inline-flex; align-items: center; gap: 6px; }
.help-q { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.help-overlay { z-index: 20; }
.help-drawer { width: min(860px, 100%); }
.help-search { padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.help-search input { width: 100%; padding: 9px 12px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--paper); }
.help-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); flex: 1; min-height: 0; }
.help-toc { border-right: 1px solid var(--rule); padding: 10px 8px; overflow-y: auto; background: var(--sunken); }
.help-toc-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: var(--radius-s); cursor: pointer; color: var(--ink); font-size: 13.5px; }
.help-toc-item:hover { background: var(--surface); }
.help-toc-item.on { background: var(--surface); box-shadow: inset 3px 0 0 var(--primary); font-weight: 600; }
.help-body { padding: 18px 28px 32px; overflow-y: auto; line-height: 1.6; max-width: 70ch; }
.help-body h3 { font-size: 18px; margin-bottom: 10px; }
.help-body ol, .help-body ul { padding-left: 22px; }
.help-body li { margin: 4px 0; }
.help-link { padding: 0 2px; font-weight: 500; }
.help-back { padding-left: 0; margin-bottom: 6px; }
.help-foot { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; }
.help-results { padding-left: 18px; }
.help-hint { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rule); color: var(--ink); }
.getting-started { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--primary); border-radius: var(--radius-m); padding: 16px 20px; }
.getting-started .gs-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.getting-started ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
@media (max-width: 720px) { .help-layout { grid-template-columns: 1fr; } .help-toc { display: none; } }

/* ---------- Bản tin tài chính ---------- */
.bulletin-summary { background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--primary); border-radius: var(--radius-m); padding: 16px 20px; font-size: 16px; line-height: 1.6; }
.chart-card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 14px 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-card .grid { stroke: var(--rule); stroke-width: 1; }
.chart-card .axis0 { stroke: var(--muted); stroke-width: 1; }
.chart-card .tick { fill: var(--muted); font-size: 11px; }
.chart-card .bar { fill: var(--primary); opacity: .82; }
.chart-card .pline { fill: none; stroke: var(--debit); stroke-width: 2.5; }
.chart-card .pdot { fill: var(--debit); }
.chart-card .pdot.neg { fill: var(--credit); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-left: 10px; }
.legend .sw.bar { background: var(--primary); opacity: .82; }
.legend .sw.line { background: var(--debit); height: 3px; }
.bulletin-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.bulletin-box { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 14px 18px; }
.bulletin-box ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 6px; line-height: 1.5; }
@media (max-width: 900px) { .bulletin-cols { grid-template-columns: 1fr; } }
.fs-table td.c, .fs-table th.c { text-align: center; width: 70px; }
.fs-table tr.fs-head td { font-weight: 700; background: var(--sunken); letter-spacing: .02em; }
.fs-table tr.fs-l1 td { font-weight: 600; }
.fs-table tr.fs-l2 td:first-child { padding-left: 28px; }
.fs-table tr.fs-total td { font-weight: 700; border-top: 2px solid var(--ink); }
tbody tr.selected td { background: var(--ok-bg); }

/* Mẫu in song ngữ (chế độ English): tiếng Anh in nghiêng, nhỏ hơn, dưới tiếng Việt */
#print-root .p-en { display: block; font-style: italic; font-weight: 400; font-size: .82em; color: #444; text-transform: none; letter-spacing: 0; }
#print-root .p-en-inline { display: inline; }
#print-root h1 .p-en { font-size: .62em; margin-top: 2px; }
/* Logo CiDT */
.brand-logo { width: 30px; height: 30px; object-fit: contain; flex: none; }
.auth-logo { display: block; height: 116px; width: auto; margin: 0 auto 20px; }
/* Logo doanh nghiệp */
.logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 260px; height: 110px; border: 1px dashed var(--rule); border-radius: var(--radius-m); display: grid; place-items: center; padding: 10px;
  background: #fff conic-gradient(#eef1f1 25%, #fff 0 50%, #eef1f1 0 75%, #fff 0) 0 0 / 16px 16px; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: grid; gap: 8px; justify-items: start; }
#print-root .p-brand { display: flex; gap: 10px; align-items: flex-start; }
#print-root .p-logo { max-height: 17mm; max-width: 38mm; object-fit: contain; flex: none; }
#print-root .p-logo-corner { position: absolute; top: 0; left: 0; }
#print-root .p-sheet { position: relative; }
#print-root .p-brand { max-width: 66%; }
#print-root .p-brand .p-unit { max-width: none; }
.fx-rate-box { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
.fx-rate-box b { align-self: center; min-width: 36px; }
/* Logo trên nền tối: đặt trên ô nền sáng để chữ xanh đậm của logo không bị chìm */
@media (prefers-color-scheme: dark) {
  .auth-logo { background: #F3F5F4; border-radius: 12px; padding: 12px 18px; height: 140px; box-sizing: border-box; }
  .brand-logo { background: #F3F5F4; border-radius: 7px; padding: 3px; box-sizing: border-box; }
}
.import-steps { padding-left: 20px; display: grid; gap: 12px; margin: 0 0 8px; }
.import-steps li > div { margin-top: 6px; }

/* ---------- Trợ lý AI ---------- */
.assist-fab { position: fixed; right: 22px; bottom: 22px; z-index: 8; display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px;
  border: 0; background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 10px 28px -10px rgba(20, 40, 60, .55); }
.assist-fab:hover { filter: brightness(1.08); }
.assist-spark { font-size: 16px; }
.assist-panel { position: fixed; right: 22px; bottom: 22px; z-index: 8; width: min(420px, calc(100vw - 24px)); height: min(620px, calc(100vh - 40px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 24px 60px -20px rgba(20, 40, 60, .45); overflow: hidden; }
.assist-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--rule); background: var(--sunken); }
.assist-list { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 10px; align-content: start; }
.assist-msg { padding: 10px 12px; border-radius: 12px; line-height: 1.55; font-size: 14px; max-width: 92%; }
.assist-msg p { margin: 0 0 6px; } .assist-msg p:last-child { margin-bottom: 0; }
.assist-msg ul, .assist-msg ol { margin: 4px 0; padding-left: 18px; }
.assist-msg.bot { background: var(--paper); border: 1px solid var(--rule); justify-self: start; }
.assist-msg.me { background: var(--primary); color: var(--primary-ink); justify-self: end; white-space: pre-wrap; }
.assist-msg.err { border-color: var(--credit); color: var(--credit); }
.assist-note { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.assist-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.assist-suggest .btn { font-size: 13px; padding: 6px 10px; text-align: left; white-space: normal; }
.assist-foot { border-top: 1px solid var(--rule); padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.assist-foot textarea { resize: none; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; }
.assist-disclaimer { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }
@media print { .assist-fab, .assist-panel { display: none !important; } }
.payroll-table .cell-input { width: 96px; min-width: 0; padding-left: 5px; padding-right: 5px; }
.payroll-table { font-size: 13px; }
.payroll-table th, .payroll-table td { padding-left: 6px; padding-right: 6px; }
.payroll-table td:nth-child(2) { min-width: 118px; }
.payroll-table td { white-space: nowrap; }
.payroll-table th { white-space: normal; vertical-align: bottom; }
.payroll-table td:nth-child(2) { white-space: normal; }

/* ---------- Thanh menu hai tầng: nhóm chức năng, chức năng con ---------- */
.tab-groups { gap: 4px; }
.tab-group { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab-group:hover { color: var(--ink); }
.tab-group.active { color: var(--ink); border-bottom-color: var(--primary); }
.tab-count { font-size: 11px; font-weight: 600; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--sunken); color: var(--muted); line-height: 18px; text-align: center; }
.tab-group.active .tab-count { background: var(--primary); color: var(--primary-ink); }
.sub-tabs { background: var(--sunken); border-radius: var(--radius-m); padding: 4px; margin-top: 6px; gap: 2px; width: auto; align-self: flex-start; }
.sub-tabs .tab { border-bottom: 0; border-radius: var(--radius-s); padding: 6px 12px; font-size: 14px; }
.sub-tabs .tab.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.costing-table { font-size: 13px; }
.costing-table th, .costing-table td { padding-left: 6px; padding-right: 6px; }
.costing-table td { white-space: nowrap; }
.costing-table th { white-space: normal; vertical-align: bottom; }
.costing-table td:first-child { white-space: normal; min-width: 110px; }
.costing-table td:nth-child(2) { white-space: normal; min-width: 170px; max-width: 280px; }
.row-actions { display: flex; gap: 10px; margin-top: 2px; justify-content: flex-start; }
.row-actions .btn { margin: 0; }
.row-actions .btn.link { padding: 0; font-size: 12.5px; }
.stock-toggle { display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--ink); font-size: 13px; }
.stock-row > td { background: var(--sunken); }
.stock-box { padding: 6px 4px 10px; }
.stock-box table { width: 100%; font-size: 13px; background: var(--surface); }
.stock-box .new-item { display: inline-flex; gap: 6px; }
.cit-table td.c { width: 56px; color: var(--muted); font-weight: 600; }
.badge.ok { background: color-mix(in srgb, var(--debit) 15%, var(--surface)); color: var(--debit); }

/* Kiểm tra sổ sách */
.badge.sev-error { background: color-mix(in srgb, var(--credit) 15%, var(--surface)); color: var(--credit); }
.badge.sev-warn { background: color-mix(in srgb, #c68a00 18%, var(--surface)); color: #8a6100; }
.badge.sev-info { background: var(--sunken); color: var(--muted); }
.check-group { margin-top: 8px; }
.check-group h3 { display: flex; gap: 8px; align-items: center; }

/* Hộp hóa đơn chờ duyệt, tích hợp */
ul.reasons { margin: 4px 0 0; padding-left: 16px; font-size: 12.5px; color: var(--muted); }
code.secret { display: inline-block; padding: 4px 8px; background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; word-break: break-all; user-select: all; }

/* Chế độ kế toán */
.regime-card { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
.regime-questions { display: grid; gap: 8px; margin: 10px 0; }
.regime-questions label { display: flex; gap: 8px; align-items: flex-start; }
.regime-form, .regime-conv { margin-top: 10px; padding: 12px 14px; border: 1px dashed var(--rule); border-radius: var(--radius-m); }
td.warn { color: #8a6100; }

.fs-table tr.fs-l3 td:first-child { padding-left: 34px; color: var(--muted); }

ol.steps { margin: 0 0 8px; padding-left: 20px; display: grid; gap: 4px; }

/* Cổng khách hàng */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.portal-card { padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--surface); }
.portal-card h3 { margin-top: 0; }
ul.deadlines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
ul.deadlines li { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: start; }
ul.deadlines .due { font-weight: 600; display: grid; }
ul.deadlines .days { font-size: 12px; font-weight: 500; color: var(--muted); }
ul.deadlines li.soon .due, ul.deadlines li.soon .days { color: var(--credit); }
.small { font-size: 12.5px; }
.chat { display: grid; gap: 8px; max-height: 360px; overflow-y: auto; padding: 10px; border: 1px solid var(--rule); border-radius: var(--radius-m); background: var(--sunken); }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 12px; background: var(--surface); justify-self: start; }
.bubble.mine { justify-self: end; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.bubble .who { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }

.help-table { font-size: 13px; margin: 6px 0 10px; }
.help-table th, .help-table td { padding: 6px 8px; vertical-align: top; }
