/* Bookkeeping Auto - giao diện. Xem DESIGN.md. CSP: chỉ file này, không inline style, không font ngoài. */
:root {
  --ink: #0f172a; --ink-2: #334155; --muted: #566274;
  --bg: #f3f5f9; --card: #fff; --line: #d5dbe5; --line-soft: #e8ecf3;
  --pri: #1d4ed8; --pri-d: #1e40af; --pri-soft: #e8eefc;
  --ok: #047857; --ok-soft: #e6f5ef;
  --err: #b42318; --err-soft: #fdecea;
  --warn: #92400e; --warn-bg: #fef3c7; --warn-line: #e0a526;
  --info-soft: #eaf1fb;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --tabbar-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); color: var(--ink); background: var(--bg); overflow-x: hidden; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--pri); text-underline-offset: 2px; }
a:hover { color: var(--pri-d); }
code { font-family: var(--mono); font-size: .9em; background: #eef1f6; padding: .1em .35em; border-radius: 4px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.25rem 0; }
small, .small { font-size: .875rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; margin: .35rem 0 .75rem; }
.center { text-align: center; }
.r { text-align: right; }
.warn-text { color: var(--warn); }
.error-text { color: var(--err); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.show-sm { display: none; }
.ic { flex: none; vertical-align: -4px; }

/* Focus rõ ràng cho bàn phím */
:focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { top: 8px; }
main:focus { outline: none; }

/* ---- Thanh trên ---- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; padding: 0 24px; min-height: 60px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.nav-desktop { display: flex; gap: 4px; flex: 1; }
.nav-desktop a { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav-desktop a:hover { background: var(--bg); color: var(--ink); }
.nav-desktop a[aria-current] { background: var(--pri-soft); color: var(--pri-d); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.nav-desktop + .topbar-actions { margin-left: 0; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: .9rem; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--pri-soft); color: var(--pri-d); font-weight: 700; }
.lang-link { color: var(--ink-2); font-weight: 500; padding: 8px; }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 11px; background: var(--warn-bg); color: var(--warn); font-size: .8rem; font-weight: 700; text-align: center; line-height: 22px; border: 1px solid var(--warn-line); }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 0; }
.crumbs { margin-bottom: 8px; }
.crumbs a { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; font-size: .9rem; }
.crumbs .ic { transform: rotate(180deg); width: 16px; height: 16px; }

/* ---- Thẻ, lưới ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 0 0 16px; box-shadow: var(--shadow); }
.card.highlight { border-color: var(--warn-line); background: #fffdf5; }
.card.onboarding { border-color: var(--pri); background: var(--pri-soft); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin: 0; }
.grid-2 { margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; margin: 0; text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--pri); color: inherit; }
.stat-label { color: var(--muted); font-size: .9rem; font-weight: 500; }
.stat .num { font-size: 2.1rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .num.small { font-size: 1.2rem; line-height: 1.6; letter-spacing: 0; }
.stat-foot { color: var(--muted); font-size: .875rem; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.stat.attention { border-color: var(--warn-line); background: #fffdf5; }
.stat.attention .num { color: var(--warn); }
.stat.attention .stat-foot { color: var(--warn); font-weight: 600; }

/* ---- Auth ---- */
body.is-auth main { display: block; padding-top: 32px; }
.auth-card { max-width: 440px; margin: 24px auto; padding: 28px; }
.auth-card.wide { max-width: 720px; }
.auth-card h1 { font-size: 1.5rem; }
.lead { color: var(--ink-2); margin-bottom: 1rem; }
.card-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--pri-soft); color: var(--pri); margin-bottom: 8px; }
.card-icon .ic { width: 24px; height: 24px; }
.stepper { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; padding-bottom: 8px; border-bottom: 3px solid var(--line-soft); }
.stepper li[aria-current] { color: var(--pri-d); font-weight: 600; border-color: var(--pri); }
.stepper li.done { color: var(--ok); border-color: var(--ok); }
.stepper .dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--line-soft); font-weight: 700; font-size: .8rem; flex: none; }
.stepper li[aria-current] .dot { background: var(--pri); color: #fff; }
.stepper li.done .dot { background: var(--ok); color: #fff; }
.stepper .dot .ic { width: 14px; height: 14px; }
.twofa { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.qr-box { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; background: #fff; width: 220px; }
.qr svg { width: 100%; height: auto; display: block; }
.howto { padding-left: 1.2rem; margin: 0 0 .75rem; }
.howto li { margin-bottom: .35rem; }
.secret-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
code.secret, .secret-row code, .kv dd code, .highlight > code { font-size: 1rem; font-weight: 600; letter-spacing: .06em; padding: .25em .5em; }
.code-input { font-family: var(--mono); font-size: 1.25rem !important; letter-spacing: .12em; text-align: center; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; }
.codes li { border: 1px dashed var(--line); background: #fafbfd; border-radius: 8px; padding: 8px 10px; text-align: center; }
.codes code { background: none; font-size: 1rem; letter-spacing: .04em; word-break: normal; }
.ack { margin: 16px 0; padding: 12px; background: var(--bg); border-radius: 8px; }

/* ---- Form ---- */
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .95rem; }
.form > label:first-child { margin-top: 0; }
input, select, textarea { width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; min-height: 44px; padding: 9px 12px; border: 1px solid #8794a8; border-radius: var(--r-sm); font: inherit; background: #fff; color: var(--ink); }
input:hover, select:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible { outline: 3px solid rgba(29, 78, 216, .35); outline-offset: 0; border-color: var(--pri); border-radius: var(--r-sm); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; flex: none; accent-color: var(--pri); }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; margin: 12px 0; }
.pw { display: flex; gap: 8px; }
.pw input { flex: 1; min-width: 0; }
.pw-toggle { min-width: 64px; }
.row-form { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.row-form input, .row-form select { flex: 1 1 220px; width: auto; }
.row-form label { margin: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { min-width: 0; }
.field.uncertain input { background: var(--warn-bg); border-color: var(--warn-line); box-shadow: inset 4px 0 0 var(--warn-line); }
.tag-uncertain { white-space: nowrap; font-size: .75rem; font-weight: 700; color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 1px 8px; margin-left: 6px; }
.form.two-col { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.f label { margin-top: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0 16px; }
.filters .f { flex: 1 1 160px; min-width: 0; }
.filters .f-actions, .f-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
.rule-form { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 12px; align-items: end; margin-top: 12px; }

/* ---- Nút ---- */
.btn, button { font: inherit; }
.btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 16px; border: 1px solid #8794a8; border-radius: var(--r-sm); background: #fff; color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--bg); border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.primary:hover { background: var(--pri-d); border-color: var(--pri-d); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger-ghost { color: var(--err); border-color: #e4b4af; background: #fff; }
.btn.danger-ghost:hover { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled, .btn.disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; background: #eef1f6; border-color: var(--line); color: var(--muted); }
.btn.primary:disabled { background: #7f9bdc; border-color: #7f9bdc; color: #fff; }
button.pw-toggle { min-height: 44px; padding: 0 12px; border: 1px solid #8794a8; border-radius: var(--r-sm); background: #fff; font-weight: 600; cursor: pointer; color: var(--ink-2); }
button.pw-toggle:hover { background: var(--bg); }
button.sheet-link { font: inherit; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions.col { flex-direction: column; align-items: stretch; }
.actions.col form { display: block; }
.actions.col .btn { width: 100%; }
form.inline { display: inline; }
.auth-card .btn.block { margin-top: 16px; }

/* ---- Thông báo ---- */
.flash, .notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); margin: 0 0 16px; border: 1px solid var(--line); background: #fff; }
.flash .ic, .notice .ic { margin-top: 2px; }
.notice p { margin: 0 0 .35rem; }
.notice > div > :last-child, .notice > span:last-child { margin-bottom: 0; }
.flash-ok, .notice-ok { border-color: #8fd3b8; background: var(--ok-soft); color: #064e3b; }
.flash-err, .notice-err { border-color: #e9a8a1; background: var(--err-soft); color: #7a1a12; }
.flash-warn, .notice-warn { border-color: var(--warn-line); background: var(--warn-bg); color: #5c2a07; }
.notice-info { border-color: #b8cdee; background: var(--info-soft); color: #1e3a6b; }
.plain-list { margin: 0 0 .5rem; padding-left: 1.2rem; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 11px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); white-space: nowrap; }
.badge.ok { color: #065f46; background: var(--ok-soft); border-color: #8fd3b8; }
.badge.err { color: var(--err); background: var(--err-soft); border-color: #e9a8a1; }
.badge.warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; color: #94a3b8; }
.empty h3 { color: var(--ink); margin: 8px 0 4px; }
.empty p { max-width: 460px; margin: 0 auto 12px; }

/* ---- Bảng ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--line-soft); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table th.r, .table td.r { text-align: right; }
.table tbody tr:hover { background: #fafbfd; }
.table tr.flag td:first-child { box-shadow: inset 3px 0 0 var(--warn-line); }
.table td.strong { font-weight: 600; }
.table td.file, .table td.detail { word-break: break-word; max-width: 320px; }
.table td.act { text-align: right; white-space: nowrap; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; text-transform: none; font-size: .95rem; color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }
.cur { color: var(--muted); font-size: .85em; }
.conf { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
progress.bar { width: 56px; height: 8px; border-radius: 4px; overflow: hidden; border: 0; background: var(--line-soft); appearance: none; -webkit-appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--line-soft); }
progress.bar::-webkit-progress-value { background: var(--pri); }
progress.bar::-moz-progress-bar { background: var(--pri); }

/* ---- Tabs / segmented ---- */
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #e8ecf3; border-radius: 10px; margin: 4px 0 16px; max-width: 100%; overflow-x: auto; }
.seg button, .seg a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.seg [aria-selected="true"], .seg [aria-current] { background: #fff; color: var(--pri-d); box-shadow: var(--shadow); }
.seg button:hover:not([aria-selected="true"]), .seg a:hover:not([aria-current]) { background: rgba(255, 255, 255, .6); }
.seg [role="tablist"] { display: contents; }
html:not(.js) .seg[role="tablist"] { display: none; }
html.js .tab-panel > h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
.tab-panel[hidden] { display: none; }

/* ---- Duyệt 2 cột ---- */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 20px; align-items: start; }
.preview { position: sticky; top: 76px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.preview-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: #fafbfd; }
.preview-bar .file { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.preview iframe, .preview img { display: block; width: 100%; height: calc(100vh - 170px); min-height: 480px; border: 0; background: #e2e8f0; object-fit: contain; }
.form-col { margin: 0; }
.meta-box { margin-bottom: 14px; border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 12px; background: #fafbfd; }
.meta-box summary { cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 28px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); font-size: .9rem; }
.kv dd { margin: 0; word-break: break-word; }
.filename-preview { margin: 14px 0 4px; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); border: 1px solid #b8cdee; }
.filename-preview .label { display: block; font-size: .8rem; font-weight: 600; color: #1e3a6b; margin-bottom: 2px; }
.filename-preview code { background: none; padding: 0; font-size: .9rem; color: #12284f; }
.sticky-actions { margin-top: 16px; }
.sticky-actions .btn.primary { flex: 1 1 auto; }
.reject-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
code.final { display: block; margin-top: 4px; }
.preview-result { margin-top: 14px; padding: 12px; border-radius: 8px; background: var(--info-soft); border: 1px solid #b8cdee; }
.examples { list-style: none; margin: 8px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.examples li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.examples .old { background: var(--err-soft); color: #7a1a12; text-decoration: line-through; text-decoration-color: rgba(180, 35, 24, .5); }
.examples .new { background: var(--ok-soft); color: #064e3b; }
.examples .arrow { color: var(--muted); display: inline-flex; }
ul.plain { margin: 8px 0 0; padding-left: 1.2rem; word-break: break-word; }
.usage { display: flex; gap: 8px; align-items: center; color: var(--ink-2); background: var(--bg); padding: 8px 12px; border-radius: 8px; }

/* ---- Email + hướng dẫn ---- */
.mb-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.mb-layout > .card { margin: 0; }
.guide-card { background: #fafbfd; }
.guide h3 { margin-top: 0; }
.guide[hidden] { display: none; }

/* ---- Menu đáy (mobile) ---- */
.tabbar { display: none; }
.sheet-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 16px; color: var(--ink); text-decoration: none; background: none; border: 0; font-weight: 500; cursor: pointer; text-align: left; }
.sheet-link[aria-current] { color: var(--pri-d); font-weight: 700; background: var(--pri-soft); }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more-sheet { position: absolute; right: 0; bottom: calc(100% + 8px); width: 260px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(15, 23, 42, .18); padding: 6px 0; z-index: 40; }

@media (max-width: 1480px) { .user-name { display: none; } .topbar { gap: 12px; padding: 0 16px; } }
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .preview iframe, .preview img { height: 60vh; min-height: 360px; }
  .mb-layout { grid-template-columns: minmax(0, 1fr); }
  .nav-desktop a span { display: none; }
  .nav-desktop a[aria-current] span { display: inline; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 14px; min-height: 56px; gap: 8px; }
  .nav-desktop, .user-chip, .hide-sm { display: none; }
  .show-sm { display: inline; }
  main { padding: 16px 14px 32px; }
  h1 { font-size: 1.35rem; }
  .grid-2, .twofa, .two, .rule-form, .form.two-col { grid-template-columns: minmax(0, 1fr); }
  .grid-2 > .card { margin: 0; }
  .grid-2 { gap: 0; }
  .grid-2 > .card { margin-bottom: 16px; }
  .cards { gap: 10px; }
  .card { padding: 16px; }
  .stat .num { font-size: 1.7rem; }
  .qr-box { width: 200px; margin: 0 auto; }
  .stepper .step-label { display: none; }
  .stepper li[aria-current] .step-label { display: inline; }
  .auth-card { margin-top: 8px; padding: 20px; }
  .codes { grid-template-columns: 1fr 1fr; }
  .filters .f { flex: 1 1 100%; }
  .filters .f-actions .btn { flex: 1 1 auto; }
  .row-form > * { flex: 1 1 100%; }
  .row-form .btn { width: 100%; }
  .btn { min-height: 48px; }
  .btn.sm { min-height: 44px; }
  .page-head { align-items: flex-start; }
  .seg { display: flex; }
  .seg a, .seg button { flex: 1; justify-content: center; padding: 6px 8px; }

  /* Bảng -> thẻ */
  .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.stack, .table.stack tbody, .table.stack tfoot, .table.stack tr, .table.stack td, .table.stack th[scope] { display: block; width: 100%; }
  .table.stack tr { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; padding: 6px 12px; background: #fff; }
  .table.stack tr.flag { border-left: 4px solid var(--warn-line); }
  .table.stack tr.flag td:first-child { box-shadow: none; }
  .table.stack td { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--line-soft); text-align: right; max-width: none; }
  .table.stack td:last-child { border-bottom: 0; }
  .table.stack td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: .85rem; font-weight: 600; text-align: left; }
  .table.stack td[data-label=""]::before { display: none; }
  .table.stack td[data-label=""] { justify-content: flex-end; }
  .table.stack td > .cell-block { flex: 1; min-width: 0; text-align: right; }
  .table.stack td.strong { font-size: 1.02rem; }
  .table.stack td.act { white-space: normal; flex-wrap: wrap; }
  .table.stack td.file, .table.stack td.detail { max-width: none; }
  .table.stack tfoot tr { background: var(--bg); }
  .table.stack tfoot th { padding: 7px 0; border: 0; }
  .table.stack tbody tr:hover { background: #fff; }

  .tabbar { display: flex; position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
  .tabbar > a, .tabbar > .more { flex: 1; min-width: 0; }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; height: var(--tabbar-h); color: var(--ink-2); text-decoration: none; font-size: .75rem; font-weight: 600; position: relative; }
  .tab .ic { width: 24px; height: 24px; }
  .tab[aria-current] { color: var(--pri-d); }
  .tab[aria-current]::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--pri); border-radius: 0 0 3px 3px; }
  .tab .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 20px; line-height: 20px; padding: 0 5px; font-size: .72rem; }
  .more-sheet { right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); position: fixed; }
  .more[open] > summary { color: var(--pri-d); }
}

@media (max-width: 380px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  .topbar, .tabbar, .actions, .ack, .skip { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

/* Chống tràn với tên rất dài (NCC, email, tên công ty) */
main, .card, .page-head > div, .field, .f, .form, .row-form, .notice > div, .kv dd, .table td, .table th { min-width: 0; }
.card, .page-head h1, .table td, .kv dd, .notice, .examples code, .flash { overflow-wrap: anywhere; word-break: break-word; }
select { text-overflow: ellipsis; }
.row-form select, .row-form input { min-width: 0; max-width: 100%; }
.crumbs a span, .nav-desktop a span { overflow-wrap: normal; }
@media (max-width: 760px) { .row-form > select, .row-form > input { flex: 1 1 100%; width: 100%; } }
