/* ==========================================================================
   voicoi · Bảng lương mockups — stylesheet
   Sections 1–4 are verbatim copies of the live tenant CSS (only the Tailwind
   @import/@source lines and the Thủ kho phone section were left out):
     1. app/tenants/voicoi/tenant.css (tokens, components, admin shell, workbook rules)
     2. app/tenants/voicoi/quan-ly/cong-trinh/[id]/doi-tac/doi-tac.css (A4 + ledger drawer)
     3. app/tenants/voicoi/quan-ly/_tong-quan/tong-quan.css (KPI row)
     4. app/tenants/voicoi/quan-ly/bao-cao/bao-cao.css (A4 preview)
   Section 5 is NEW (Bảng lương only), scoped under .pg-bang-luong / .bl-*.
   Section 6 is a mockup-only proposal for the admin shell under 760px.
   ========================================================================== */

/* next/font variables, resolved here to the Google Fonts families */
:root { --font-be-vietnam-pro: "Be Vietnam Pro"; --font-jetbrains-mono: "JetBrains Mono"; }

/* ---------- 1. tenant.css ---------- */
:root {
  /* Canonical tokens, one custom property per DESIGN_SYSTEM.json key */
  --paper: #f4f3ef;
  --surface: #ffffff;
  --surface2: #f9f8f5;
  --surfaceSunk: #eeede8;
  --ink: #131d27;
  --ink2: #394551;
  --ink3: #5f6a75;
  --inkInv: #ffffff;
  --line: #dcdcd6;
  --lineStrong: #b9bbb4;
  --grid: rgba(31, 58, 82, 0.05);
  --steel: #1f3a52;
  --steel600: #294b69;
  --steel100: #e6ecf1;
  --steel50: #f1f4f7;
  --amber: #e8a317;
  --amber100: #fdf1d6;
  --amberInk: #7a4e00;
  --ok: #1d6f42;
  --okBg: #e5f2ea;
  --warn: #8f5200;
  --warnBg: #fdf0da;
  --danger: #b3261e;
  --dangerBg: #fbe7e5;
  --info: #1f4f7a;
  --infoBg: #e7eef6;
  --lock: #474d55;
  --lockBg: #eceae6;
  --groupVatLieu: #2f5d8a;
  --groupNhanCong: #b8691f;
  --groupMayMoc: #56682f;
  --groupChung: #7a6552;
  --groupPhatSinh: #a23b3b;
  --groupKhac: #7d848c;

  --font: var(--font-be-vietnam-pro), system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: var(--font-jetbrains-mono), ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;

  --space-unit: 4px;
  --space-1: 4px;
  --space-2: 6px;
  --space-3: 8px;
  --space-4: 10px;
  --space-5: 12px;
  --space-6: 14px;
  --space-7: 16px;
  --space-8: 20px;
  --space-9: 24px;
  --space-10: 32px;

  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-pill: 999px;
  --shadow-1: 0 1px 0 rgba(19, 29, 39, 0.04), 0 1px 2px rgba(19, 29, 39, 0.06);
  --shadow-2: 0 8px 28px rgba(19, 29, 39, 0.16), 0 2px 6px rgba(19, 29, 39, 0.08);
  --focus: 0 0 0 3px rgba(232, 163, 23, 0.55);

  /* Aliases used by the ported mockup component CSS below */
  --ink-2: var(--ink2);
  --ink-3: var(--ink3);
  --ink-inv: var(--inkInv);
  --surface-2: var(--surface2);
  --surface-sunk: var(--surfaceSunk);
  --line-strong: var(--lineStrong);
  --steel-600: var(--steel600);
  --steel-100: var(--steel100);
  --steel-50: var(--steel50);
  --amber-100: var(--amber100);
  --amber-ink: var(--amberInk);
  --ok-bg: var(--okBg);
  --warn-bg: var(--warnBg);
  --danger-bg: var(--dangerBg);
  --info-bg: var(--infoBg);
  --lock-bg: var(--lockBg);
  --g-vl: var(--groupVatLieu);
  --g-nc: var(--groupNhanCong);
  --g-mm: var(--groupMayMoc);
  --g-chung: var(--groupChung);
  --g-ps: var(--groupPhatSinh);
  --g-khac: var(--groupKhac);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "tnum" 1;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--steel-600); text-underline-offset: 2px; }
a:hover { color: var(--steel); }
small { font-size: var(--fs-xs); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

[hidden] { display: none !important; }

.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono, .code { font-family: var(--mono); font-size: 0.92em; letter-spacing: 0; }
.muted { color: var(--ink-3); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Icons ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 24px; height: 24px; }
.i-xl { width: 30px; height: 30px; }

/* ---------- Layout helpers ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  font: inherit; font-weight: 600; font-size: var(--fs-md);
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--steel); border-color: var(--steel); color: var(--ink-inv); }
.btn-primary:hover { background: var(--steel-600); border-color: var(--steel-600); color: var(--ink-inv); }
.btn-accent { background: var(--amber); border-color: #c98a0c; color: var(--ink); }
.btn-accent:hover { background: #f0b232; border-color: #b57b06; }
.btn-danger { color: var(--danger); border-color: #e2b4b0; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #962019; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-sunk); border-color: transparent; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--steel-600); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { background: none; color: var(--steel); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-lg { min-height: 48px; padding: 0 20px; font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.req::after { content: " *"; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 10px;
  font: inherit; font-size: var(--fs-md); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.textarea { min-height: 72px; resize: vertical; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23394551' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--steel); box-shadow: var(--focus); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-sunk); color: var(--ink-2); cursor: not-allowed; }
.input.num, .input[data-money], .input[data-qty] { text-align: right; font-variant-numeric: tabular-nums; }
.is-invalid, .input.is-invalid { border-color: var(--danger) !important; background: #fffafa; }
.hint { font-size: var(--fs-xs); color: var(--ink-3); }
.error-text { font-size: var(--fs-sm); color: var(--danger); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-left: 0; background: var(--surface-sunk); color: var(--ink-2); font-size: var(--fs-sm); border-radius: 0 var(--r-md) var(--r-md) 0; white-space: nowrap; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-md); }
.checkbox input, .radio input { width: 18px; height: 18px; accent-color: var(--steel); margin: 0; }
.search-input { position: relative; }
.search-input .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search-input .input { padding-left: 34px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.seg button, .seg label { font: inherit; font-size: var(--fs-sm); font-weight: 600; padding: 6px 12px; border: 0; background: none; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg > :last-child { border-right: 0; }
.seg .is-active, .seg input:checked + span { background: var(--steel); color: #fff; }
.seg label { position: relative; padding: 0; }
.seg label span { display: block; padding: 6px 12px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.panel-head h2, .panel-head h3 { font-size: var(--fs-lg); }
#thu-block .panel-head h2, #chi-block .panel-head h2, #profit-block .panel-head h2 { font-size: 20px; font-weight: 700; }
.panel-body { padding: 16px; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); font-size: var(--fs-sm); color: var(--ink-3); }
.panel-flush .panel-body { padding: 0; }

.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- KPI / stat ---------- */
.kpi { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); position: relative; }
.kpi .eyebrow { display: block; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.15; }
.kpi-sub { margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-3); }
a.kpi { display: block; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--steel); }
.kpi-accent { border-top: 3px solid var(--steel); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--steel-50); }
.tbl tr.is-selected td { background: var(--amber-100); }
.tbl tr.group td { background: var(--surface-sunk); font-weight: 700; }
.tbl tr.subtotal td { font-weight: 700; background: var(--surface-2); }
.tbl tr.total td { font-weight: 700; font-size: var(--fs-lg); border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); background: var(--surface); }
.tbl td.indent-1 { padding-left: 32px; }
.tbl td.indent-2 { padding-left: 52px; }
.tbl .row-actions { display: flex; justify-content: flex-end; gap: 4px; opacity: .85; }
.tbl-compact th, .tbl-compact td { padding: 6px 10px; }
.tbl a.amount-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.tbl a.amount-link:hover { color: var(--steel); border-bottom-color: var(--steel); }
.clickable-row { cursor: pointer; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl th.center, .tbl td.center { text-align: center; }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 18px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge .i { width: 13px; height: 13px; vertical-align: 0; }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: #bcdcc8; }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: #efcf9a; }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: #efbdb8; }
.badge-lock { color: var(--lock); background: var(--lock-bg); border-color: #d5d2cb; }
.badge-info { color: var(--info); background: var(--info-bg); border-color: #c3d4e6; }
.badge-muted { color: var(--ink-3); background: var(--surface-sunk); border-color: var(--line); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); font-family: var(--mono); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border: 1px solid; border-left-width: 4px; border-radius: var(--r-md); font-size: var(--fs-md); }
.alert .i { margin-top: 2px; }
.alert strong { font-weight: 700; }
.alert-info { background: var(--info-bg); border-color: #c3d4e6; border-left-color: var(--info); color: #173c5e; }
.alert-warn { background: var(--warn-bg); border-color: #efcf9a; border-left-color: var(--amber); color: #5e3700; }
.alert-danger { background: var(--danger-bg); border-color: #efbdb8; border-left-color: var(--danger); color: #7d1a14; }
.alert-ok { background: var(--ok-bg); border-color: #bcdcc8; border-left-color: var(--ok); color: #154f30; }
.alert-lock { background: var(--lock-bg); border-color: #d5d2cb; border-left-color: var(--lock); color: var(--ink-2); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.tabs [role="tab"], .tabs a { font: inherit; font-weight: 600; font-size: var(--fs-md); padding: 10px 14px; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--ink-3); cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs [role="tab"]:hover, .tabs a:hover { color: var(--ink); }
.tabs [aria-selected="true"], .tabs a.is-active { color: var(--ink); border-bottom-color: var(--amber); }
.tabs .count { font-size: 11px; background: var(--surface-sunk); padding: 0 6px; border-radius: 999px; color: var(--ink-2); }

/* ---------- Filters + pinned total ---------- */
.filters-disclosure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 12px; }
.filters-disclosure-summary { list-style: none; cursor: pointer; padding: 10px 16px; font-weight: 600; font-size: 13px; color: var(--ink-2, #555); display: flex; align-items: center; gap: 6px; }
.filters-disclosure-summary::-webkit-details-marker { display: none; }
.filters-disclosure-summary::before { content: "▸"; display: inline-block; transition: transform 0.15s; }
.filters-disclosure[open] .filters-disclosure-summary::before { transform: rotate(90deg); }
.filters-disclosure[open] .filters-disclosure-summary { border-bottom: 1px solid var(--line); }
.filters-disclosure .filters { border: none; border-radius: 0; margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.filters .field { min-width: 150px; }
.filters .field.wide { min-width: 240px; flex: 1; }
.total-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: var(--steel); color: #fff; border-radius: var(--r-lg); }
.total-bar .eyebrow { color: rgba(255,255,255,.7); }
.total-bar .total-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-bar .muted { color: rgba(255,255,255,.75); }

/* ---------- Bars (cost breakdown) ---------- */
.hbar { height: 8px; background: var(--surface-sunk); border-radius: 1px; overflow: hidden; }
.hbar > span { display: block; height: 100%; }
.stackbar { display: flex; height: 14px; border-radius: 2px; overflow: hidden; gap: 1px; background: var(--surface); }
.stackbar > span { display: block; height: 100%; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .i { width: 36px; height: 36px; color: var(--line-strong); margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink-2); font-size: var(--fs-lg); margin-bottom: 4px; }
.skeleton { display: inline-block; height: 1em; min-width: 80px; border-radius: 2px; background: linear-gradient(90deg, #e9e8e3 0%, #f5f4f0 50%, #e9e8e3 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree-row { display: grid; grid-template-columns: 28px 90px 1fr auto auto; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); min-height: 44px; }
.tree-row:hover { background: var(--steel-50); }
.tree ul .tree-row { padding-left: 40px; background: var(--surface-2); }
.tree-toggle { width: 24px; height: 24px; border: 0; background: none; cursor: pointer; color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-sm); }
.tree-toggle:hover { background: var(--surface-sunk); }
li.is-collapsed > ul { display: none; }
li.is-collapsed > .tree-row .tree-toggle .i { transform: rotate(-90deg); }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(19, 29, 39, .42); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .15s; }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 90; box-shadow: var(--shadow-2); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s ease; border-left: 1px solid var(--line-strong); }
.drawer.is-open { transform: none; }
.drawer-wide { width: min(760px, 100vw); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: var(--fs-lg); }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -46%); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); z-index: 95; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.modal.is-open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.modal-head { padding: 18px 20px 6px; }
.modal-head h2 { font-size: var(--fs-lg); }
.modal-body { padding: 8px 20px 16px; color: var(--ink-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Toast ---------- */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ink); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-2); font-weight: 500; font-size: var(--fs-md); max-width: min(520px, calc(100vw - 32px)); animation: toastIn .18s ease; pointer-events: auto; }
.toast-ok .i { color: #7fd6a2; }
.toast-danger { background: #7d1a14; }
.toast-warn .i { color: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--ink-3); font-size: var(--fs-sm); }
.dl dd { margin: 0; font-weight: 500; }

/* ==========================================================================
   Admin workspace (desktop ≥1280px)
   ========================================================================== */
body.admin { min-width: 1024px; }

.a-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.a-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ink); color: #c9d2da; display: flex; flex-direction: column; }
.a-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; border-bottom: 1px solid #25313d; text-decoration: none; color: #fff; }
.a-brand-mark { width: 34px; height: 34px; flex: none; display: grid; place-items: center; background: var(--amber); color: var(--ink); border-radius: 3px; }
.a-brand-mark .i { width: 22px; height: 22px; stroke-width: 2.2; }
.a-brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: -0.01em; }
.a-brand small { display: block; color: #8d9aa6; font-size: 11.5px; line-height: 1.3; }
.a-nav { padding: 10px 10px 16px; flex: 1; }
.a-nav-group { margin-top: 14px; }
.a-nav-group:first-child { margin-top: 4px; }
.a-nav-label { padding: 0 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #6f7d8a; }
.a-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 1px 0; color: #c9d2da; text-decoration: none; border-radius: var(--r-md); font-weight: 500; font-size: 14px; border-left: 3px solid transparent; }
.a-nav a:hover { background: #1c2934; color: #fff; }
.a-nav a.is-active { background: #22313f; color: #fff; border-left-color: var(--amber); }
.a-nav a .i { color: #8d9aa6; }
.a-nav a.is-active .i { color: var(--amber); }
.a-nav .a-nav-sites a { padding-left: 38px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.a-nav .a-nav-sites .code { color: #8d9aa6; font-size: 11.5px; font-family: var(--mono); margin-right: 4px; }
.a-side-foot { padding: 12px 14px; border-top: 1px solid #25313d; display: flex; align-items: center; gap: 10px; }
.a-avatar { width: 32px; height: 32px; border-radius: 50%; background: #2d3e4e; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.a-side-foot .who { flex: 1; min-width: 0; line-height: 1.3; }
.a-side-foot .who strong { display: block; color: #fff; font-size: 13px; }
.a-side-foot .who small { color: #8d9aa6; }
.a-side-foot a { color: #8d9aa6; background: none; border: 0; cursor: pointer; padding: 0; }
.a-side-foot a:hover { color: #fff; }

.a-main { min-width: 0; display: flex; flex-direction: column; }
.a-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; height: 56px; background: rgba(244, 243, 239, 0.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .i { width: 14px; height: 14px; color: var(--line-strong); }
.crumbs span:last-child { color: var(--ink); font-weight: 600; }
.a-top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-3); }

.page { padding: 24px 28px 64px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.page-head .sub { margin-top: 4px; color: var(--ink-3); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.site-head { position: sticky; top: 56px; z-index: 25; background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 28px 0; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }
.site-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.site-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.site-title .chip { font-size: 13px; padding: 2px 8px; background: var(--ink); color: #fff; border-color: var(--ink); }
.site-title h1 { font-size: 24px; }
.site-meta { margin-top: 6px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.site-meta span { display: inline-flex; align-items: center; gap: 5px; }
.site-switch { min-width: 260px; }
.site-head .tabs { margin-top: 14px; border-bottom: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.lines-table .input, .lines-table .select { min-height: 32px; padding: 5px 8px; }

@media (max-width: 1180px) {
  .a-shell { grid-template-columns: 208px 1fr; }
  .page { padding: 20px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media print {
  .a-side, .a-top, .site-head, .page-actions, .no-print { display: none !important; }
  .a-shell { display: block; }
  body { background: #fff; }
}
/* ==========================================================================
   Workbook rebuild (2026-09-26) — shared admin rules
   (design/so-cong-truong-mockup/shared/admin.css, "Bản làm lại" section)
   ========================================================================== */

/* Tồn of a counterparty: dương thừa, âm thiếu (sign + word, never colour alone) */
.bal { display: inline-flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bal small { font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 0 5px; border-radius: 999px; }
.bal-thua { color: var(--ok); }
.bal-thua small { background: var(--ok-bg); color: var(--ok); }
.bal-thieu { color: var(--danger); }
.bal-thieu small { background: var(--danger-bg); color: var(--danger); }

/* Counterparty kind chip */
.kind { display: inline-flex; align-items: center; padding: 1px 8px; font-size: 12px; font-weight: 600; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.kind::before { content: ""; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--g-khac); }
.kind-supplier::before { background: var(--g-vl); }
.kind-machine::before { background: var(--g-mm); }
.kind-labor::before, .kind-staff::before { background: var(--g-nc); }
.kind-contractor { background: var(--steel-50); border-color: var(--steel-100); color: var(--steel); }
.kind-contractor::before { background: var(--steel); }

/* Formula hint under a figure */
.rb-hint { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); }
.rb-hint .i { width: 13px; height: 13px; }
.rb-formula { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r-sm); padding: 2px 6px; }

/* Period picker (seg + label) */
.rb-period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rb-period .muted { font-size: var(--fs-sm); }

/* Dark pinned total bar (A10 Tra cứu style) */
.total-bar-dark { position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 12px 18px; background: var(--ink); color: #fff; border-radius: var(--r-lg); box-shadow: 0 6px 18px rgba(19,29,39,.18); }
.total-bar-dark .eyebrow { color: #8d9aa6; }
.total-bar-dark .tb-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total-bar-dark .tb-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.total-bar-dark .tb-sub { color: #c9d2da; font-size: 13px; }
.total-bar-dark .tb-split { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.total-bar-dark .tb-chip { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: #c9d2da; background: #1f2b37; border: 1px solid #33424f; border-radius: var(--r-md); padding: 4px 10px; white-space: nowrap; }
.total-bar-dark .tb-chip strong { color: #fff; font-variant-numeric: tabular-nums; }

/* Drawer forms */
.rb-fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.rb-fs > legend { padding: 0; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.rb-impact { padding: 10px 12px; background: var(--steel-50); border: 1px solid var(--steel-100); border-left: 3px solid var(--steel); border-radius: var(--r-md); font-size: var(--fs-sm); }
.rb-impact ul { margin: 4px 0 0; padding-left: 18px; }
.rb-impact .num { font-weight: 600; }
.rb-computed { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 14px; background: var(--amber-100); border: 1px solid #efcf9a; border-radius: var(--r-md); }
.rb-computed strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.rb-att { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rb-att .att-thumb, .rb-att .att-add { width: 96px; height: 76px; border: 1px solid var(--line-strong); border-radius: var(--r-md); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface-sunk) 6px, var(--surface-sunk) 12px); color: var(--ink-3); font-size: 11px; }
.rb-att .att-add { border-style: dashed; background: var(--surface); cursor: pointer; font: inherit; font-size: 12px; }
.rb-att .att-add:hover { border-color: var(--steel); color: var(--steel); }
.rb-meta { padding-top: 12px; border-top: 1px solid var(--line); grid-template-columns: 130px 1fr; font-size: var(--fs-sm); }

/* Ledger tables (A4, A8): running balance column */
.tbl td.run { font-weight: 700; background: var(--surface-2); }
.tbl tr.opening td { font-style: italic; color: var(--ink-2); background: var(--surface-2); }
.tbl td.code-cell { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.tbl td.code-cell small { display: block; font-family: var(--font); color: var(--ink-3); }
.tbl .qty-line { display: block; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.row-flash td { animation: rbflash 2.4s ease-out; }
@keyframes rbflash { 0%, 40% { background: var(--amber-100); } 100% { background: transparent; } }

/* Loading skeleton rows */
.sk-rows { padding: 12px 16px; display: grid; gap: 10px; }
.sk-rows .skeleton { display: block; height: 14px; width: 100%; }
.sk-rows .skeleton:nth-child(3n) { width: 72%; }

/* ---------- 2. doi-tac.css ---------- */
/* A4 Công nợ đối tác (design/so-cong-truong-mockup/pages/34-rb-cong-no-doi-tac/style.css),
   scoped under .pg-doi-tac per the per-route CSS convention. */

.pg-doi-tac .rb-period { gap: 8px; }
.pg-doi-tac .group-seg button { white-space: nowrap; }

.pg-doi-tac .total-bar { flex-wrap: wrap; justify-content: flex-start; gap: 36px; }
.pg-doi-tac .total-bar .total-value { font-size: 21px; }
.pg-doi-tac .total-bar .muted { margin-left: auto; }

.pg-doi-tac .tbl td { vertical-align: middle; }
.pg-doi-tac .tbl thead th small { text-transform: none; letter-spacing: 0; }
.pg-doi-tac .tbl tr.group td { font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; }
.pg-doi-tac .tbl tr.group .dot { margin-right: 8px; vertical-align: 0; }
.pg-doi-tac .tbl tr.cp-row { cursor: pointer; }
.pg-doi-tac .tbl tr.cp-row td:first-child { padding-left: 28px; }
.pg-doi-tac .cp-name { font-weight: 600; }
.pg-doi-tac .cp-sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.pg-doi-tac .tbl tr.subtotal td { font-size: 13.5px; }
.pg-doi-tac .tbl tr.subtotal td:first-child,
.pg-doi-tac .tbl tr.total td:first-child { text-align: right; color: var(--ink-2); }
.pg-doi-tac .tbl tr.is-open td { background: var(--amber-100); }

.pg-doi-tac .drawer.drawer-wide { width: min(940px, 100vw); }
.pg-doi-tac .lg-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.pg-doi-tac .lg-sum { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.pg-doi-tac .lg-sum > div { padding: 10px 12px; border-right: 1px solid var(--line); }
.pg-doi-tac .lg-sum > div:last-child { border-right: 0; background: var(--surface-2); }
.pg-doi-tac .lg-sum .eyebrow { display: block; margin-bottom: 2px; }
.pg-doi-tac .lg-sum strong { font-size: 17px; font-variant-numeric: tabular-nums; }

.pg-doi-tac .ledger-table { font-size: 13px; }
.pg-doi-tac .ledger-table td { vertical-align: top; }
.pg-doi-tac .ledger-table td.who { font-size: 12.5px; white-space: nowrap; }
.pg-doi-tac .ledger-table td.who small { display: block; color: var(--ink-3); }
.pg-doi-tac .ledger-table tr.pay-row td:nth-child(2) { color: var(--ink-2); }
.pg-doi-tac .ledger-table tfoot td { font-weight: 700; background: var(--surface-2); }
.pg-doi-tac .tra-ho { font-size: 11px; font-weight: 700; color: var(--info); background: var(--info-bg); border-radius: 999px; padding: 0 6px; }

.pg-doi-tac .lg-invoices h4 { margin: 0; font-size: 14px; }
.pg-doi-tac .lg-invoices { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 3. tong-quan.css (KPI row only) ---------- */
.toggle-active { font-size: 14px; font-weight: 500; padding: 0 10px; min-height: 36px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.kpis .kpi-value { font-size: 22px; }

/* ---------- 4. bao-cao.css ---------- */
/* A11 — Báo cáo. Generic component classes (.panel, .field, .btn, .select,
   .alert, .chip, .row, .muted, .hint, .error-text, .page-head, ...) come
   from the tenant's global stylesheet (DESIGN_SYSTEM.json tokens); only the
   report-picker and A4-sheet markup that is unique to this screen lives
   here. Everything is scoped under `.pg-bao-cao` so it never leaks onto
   other pages after a client-side navigation away from this screen. */

.pg-bao-cao .report-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }

.pg-bao-cao .rp-list { padding: 6px; }
.pg-bao-cao .rp-item { display: grid; grid-template-columns: 16px 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-md); cursor: pointer; border: 1px solid transparent; }
.pg-bao-cao .rp-item:hover { background: var(--surface-2); }
.pg-bao-cao .rp-item:has(input:checked) { background: var(--steel-50); border-color: var(--steel); }
.pg-bao-cao .rp-item:has(input:focus-visible) { box-shadow: var(--focus); }
.pg-bao-cao .rp-item input { accent-color: var(--steel); width: 16px; height: 16px; margin: 0; }
.pg-bao-cao .rp-no { width: 24px; height: 24px; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; font-weight: 700; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.pg-bao-cao .rp-item:has(input:checked) .rp-no { background: var(--steel); color: #fff; border-color: var(--steel); }
.pg-bao-cao .rp-text strong { display: block; font-size: 13.5px; line-height: 1.3; }
.pg-bao-cao .rp-text small { display: block; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-bao-cao .chip-land { font-size: 10px; padding: 0 5px; }
.pg-bao-cao .btn-col { display: flex; flex-direction: column; gap: 8px; }
.pg-bao-cao .print-hint { display: flex; gap: 6px; align-items: center; }

/* Preview area */
.pg-bao-cao .pv-toolbar { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.pg-bao-cao .pv-stage { background: #d9d8d2; border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 24px; overflow: auto; background-image: linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px); background-size: 20px 20px; }

/* A4 sheet: 210 × 297 mm at 96dpi = 794 × 1123 px */
.pg-bao-cao .sheet { width: 794px; min-height: 1123px; margin: 0 auto; padding: 56px 60px 48px; background: #fff; color: #111; box-shadow: var(--shadow-2); font-size: 11.5px; line-height: 1.45; position: relative; font-feature-settings: "tnum" 1; page: a4p; }
.pg-bao-cao .sheet.is-land { width: 1123px; min-height: 794px; padding: 44px 48px; page: land; }
.pg-bao-cao .pv-stage.is-land .sheet { zoom: 0.74; }
.pg-bao-cao .sheet-empty { min-height: 500px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink-3); text-align: center; }
.pg-bao-cao .sheet-empty strong { font-size: 18px; color: var(--ink-2); }

.pg-bao-cao .rh { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding-bottom: 10px; border-bottom: 2px solid #111; }
.pg-bao-cao .rh-logo { width: 64px; height: 64px; display: grid; place-items: center; background: var(--amber); color: #111; border-radius: 3px; font-weight: 700; overflow: hidden; }
.pg-bao-cao .rh-logo img { width: 100%; height: 100%; object-fit: contain; }
.pg-bao-cao .rh-logo.is-empty { background: repeating-linear-gradient(45deg, #f3f3f0, #f3f3f0 5px, #e7e6e1 5px, #e7e6e1 10px); border: 1px dashed #999; font-size: 9px; color: #777; text-align: center; }
.pg-bao-cao .rh-name { font-size: 13.5px; font-weight: 700; letter-spacing: 0.01em; }
.pg-bao-cao .rh-name.is-missing { color: #a33; font-style: italic; font-weight: 600; }
.pg-bao-cao .rh-co { font-size: 10.5px; color: #333; }
.pg-bao-cao .rh-form { font-size: 9.5px; color: #555; text-align: right; align-self: start; }
.pg-bao-cao .rh-nation { text-align: right; font-size: 10px; }
.pg-bao-cao .rh-nation strong { display: block; font-size: 10.5px; }
.pg-bao-cao .rh-nation span { display: block; }
.pg-bao-cao .rt { text-align: center; margin: 18px 0 16px; }
.pg-bao-cao .rt h1 { font-size: 17px; letter-spacing: 0.03em; margin-bottom: 6px; }
.pg-bao-cao .rt-sub { color: #444; }
.pg-bao-cao .rt-period { font-weight: 600; margin-top: 4px; font-style: italic; }
.pg-bao-cao .rt-unit { text-align: right; font-size: 10px; font-style: italic; color: #555; margin-top: -4px; }
.pg-bao-cao .r-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; margin: 16px 0 6px; }

.pg-bao-cao .rtbl { width: 100%; border-collapse: collapse; font-size: 11px; }
.pg-bao-cao .rtbl th, .pg-bao-cao .rtbl td { border: 1px solid #9a9a95; padding: 4px 6px; vertical-align: top; }
.pg-bao-cao .rtbl thead th { background: #eeede8; font-weight: 700; text-align: center; font-size: 10.5px; }
.pg-bao-cao .rtbl thead { display: table-header-group; }
.pg-bao-cao .rtbl td.num, .pg-bao-cao .rtbl th.num { text-align: right; white-space: nowrap; }
.pg-bao-cao .rtbl .c-stt { width: 34px; text-align: center; }
.pg-bao-cao .rtbl .c-pct { width: 70px; }
.pg-bao-cao .rtbl .c-code { font-family: var(--mono); font-size: 10px; white-space: nowrap; }
.pg-bao-cao .rtbl .c-date { white-space: nowrap; }
.pg-bao-cao .rtbl tr.r-sub td { font-weight: 700; background: #f7f6f2; }
.pg-bao-cao .rtbl tr.r-child td.c-name { padding-left: 18px; }
.pg-bao-cao .rtbl tr.r-special td { font-style: italic; }
.pg-bao-cao .rtbl tr.r-total td { font-weight: 700; border-top: 2px solid #111; background: #fff; }
.pg-bao-cao .rtbl .r-muted { color: #666; font-style: italic; text-align: center; }
.pg-bao-cao .rtbl-grid { font-size: 9px; }
.pg-bao-cao .rtbl-grid th, .pg-bao-cao .rtbl-grid td { padding: 3px 3px; }
.pg-bao-cao .rtbl-grid .c-day { width: 20px; text-align: center; }
.pg-bao-cao .rtbl-grid .c-worker { white-space: nowrap; }
.pg-bao-cao .rtbl-nxt .c-grp { text-align: center; }
.pg-bao-cao .r-foot { font-size: 9.5px; color: #444; font-style: italic; margin-top: 6px; }
.pg-bao-cao .r-empty { margin-top: 6px; padding: 6px 10px; border: 1px dashed #999; font-style: italic; text-align: center; }
.pg-bao-cao .r-filters { display: grid; grid-template-columns: 110px 1fr; gap: 2px 10px; margin: 0 0 10px; font-size: 11px; }
.pg-bao-cao .r-filters dt { color: #555; }
.pg-bao-cao .r-filters dd { margin: 0; font-weight: 600; }
.pg-bao-cao .sign-date { text-align: right; font-style: italic; margin-top: 22px; font-size: 11px; }
.pg-bao-cao .signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 8px; text-align: center; page-break-inside: avoid; }
.pg-bao-cao .sig-role { font-weight: 700; text-transform: uppercase; font-size: 11px; }
.pg-bao-cao .sig-note { font-style: italic; font-size: 9.5px; color: #555; }
.pg-bao-cao .sig-name { margin-top: 64px; font-weight: 700; min-height: 16px; }
.pg-bao-cao .r-pageno { position: absolute; bottom: 18px; left: 60px; right: 60px; border-top: 1px solid #ccc; padding-top: 4px; font-size: 9px; color: #777; text-align: right; }
.pg-bao-cao .alert-inline { margin: 8px 0 0; }

@media (max-width: 1320px) {
  .pg-bao-cao .report-grid { grid-template-columns: 270px minmax(0, 1fr); }
  .pg-bao-cao .pv-stage .sheet:not(.is-land) { zoom: 0.9; }
}

@page a4p { size: A4 portrait; margin: 12mm; }
@page land { size: A4 landscape; margin: 10mm; }
@media print {
  body { background: #fff !important; }
  .pg-bao-cao .page-head, .pg-bao-cao .report-left, .pg-bao-cao .pv-toolbar, .pg-bao-cao .no-print { display: none !important; }
  .pg-bao-cao.page { padding: 0 !important; max-width: none; }
  .pg-bao-cao .report-grid { display: block; }
  .pg-bao-cao .pv-stage { background: none; border: 0; padding: 0; overflow: visible; }
  .pg-bao-cao .sheet, .pg-bao-cao .pv-stage.is-land .sheet { width: auto; min-height: 0; padding: 0; margin: 0; box-shadow: none; zoom: 1; }
  .pg-bao-cao .r-pageno { display: none; }
  .pg-bao-cao .rtbl tr { page-break-inside: avoid; }
}

/* ==========================================================================
   5. NEW — Bảng lương (/quan-ly/bang-luong, sổ lương drawer, nhập lương tháng)
   Built only from the tokens and patterns above: .tbl/.tbl-compact cells,
   .bal-thua/.bal-thieu balance chips, .kind chips, .lg-sum, .rb-computed.
   ========================================================================== */

.pg-bang-luong .kpis .kpi-value { font-size: 22px; }
.pg-bang-luong .kpi .kpi-value.neg { color: var(--danger); }
.pg-bang-luong .filters .field.narrow { min-width: 200px; width: 250px; flex: none; }
.pg-bang-luong .filters .field.mid { width: 270px; flex: none; }
.pg-bang-luong .page-head > div:first-child { flex: 1 1 420px; }
.pg-bang-luong .filters .field.wide { min-width: 180px; flex: 1; }

/* Grid: employees x months. Scrolls inside its panel; header and the name column stay put. */
.bl-scroll { overflow: auto; max-height: calc(100vh - 150px); overscroll-behavior: contain; }
table.tbl.bl-grid { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.bl-grid th, .bl-grid td { padding: 7px 10px; white-space: nowrap; }
.bl-grid thead th { top: 0; height: 30px; padding-top: 6px; padding-bottom: 6px; }
.bl-grid thead tr.bl-h2 th { top: 30px; font-size: 11px; letter-spacing: .04em; }
.bl-grid thead th.yr { text-align: center; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.bl-grid thead th small { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.bl-grid .sep { border-left: 1px solid var(--line-strong); }
.bl-grid .sep-soft { border-left: 1px solid var(--line); }
.bl-grid td.num, .bl-grid th.num { min-width: 92px; }

/* sticky first column */
.bl-grid .c-nv { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 196px; max-width: 220px; border-right: 1px solid var(--line-strong); }
.bl-grid thead th.c-nv { z-index: 4; background: var(--surface-2); vertical-align: bottom; }
.bl-grid tbody tr:hover td.c-nv { background: var(--steel-50); }
.bl-grid .nv-name { display: block; font-weight: 600; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.bl-grid .nv-role { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.bl-grid .nv-role .badge { font-size: 10.5px; line-height: 15px; padding: 0 6px; }
.bl-grid tbody tr { cursor: pointer; }
.bl-grid tbody tr.is-open td, .bl-grid tbody tr.is-open td.c-nv { background: var(--amber-100); }
.bl-grid tbody tr.is-left td:not(.c-nv) { color: var(--ink-2); }

/* month cells: clickable to enter/edit */
.bl-grid td.bl-m { position: relative; font-variant-numeric: tabular-nums; }
.bl-grid td.bl-m:hover { box-shadow: inset 0 0 0 1.5px var(--steel); background: var(--surface); cursor: cell; }
.bl-grid td.bl-pre { color: var(--ink-2); background: var(--surface-2); }
.bl-grid tbody tr:hover td.bl-pre { background: var(--steel-50); }
.bl-dash { color: var(--line-strong); }
.bl-grid td.bl-m.is-empty:hover .bl-dash { display: none; }
.bl-grid td.bl-m.is-empty:hover::after { content: "+ Nhập"; font-size: 11.5px; font-weight: 600; color: var(--steel-600); }
.bl-missing { display: inline-block; white-space: nowrap; padding: 0 6px; font-size: 11px; font-weight: 700; line-height: 18px; color: var(--amber-ink); border: 1px dashed #d9a441; border-radius: var(--r-sm); background: #fffaf0; }

/* multi-site split indicator ("2 CT") */
.bl-split { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; padding: 0 4px; font-family: var(--mono); font-size: 10px; font-weight: 500; line-height: 16px; color: var(--steel); background: var(--steel-50); border: 1px solid var(--steel-100); border-radius: var(--r-sm); vertical-align: 1px; }
.bl-split i { width: 6px; height: 6px; border-radius: 1px; background: var(--steel); }
.bl-split i + i { margin-left: -1px; background: var(--g-nc); }

/* lũy kế columns */
.bl-grid td.bl-tot { font-weight: 700; }
.bl-grid td.bl-rest .bal { font-weight: 700; }

/* total row pinned to the bottom of the scroll area */
.bl-grid tfoot td { position: sticky; bottom: 0; z-index: 1; background: var(--surface); font-weight: 700; font-size: 13.5px; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); padding-top: 9px; padding-bottom: 9px; }
.bl-grid tfoot td.c-nv { z-index: 3; text-align: left; }
.bl-grid tfoot td.c-nv small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }

.bl-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.bl-legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Sổ lương drawer ---------- */
.drawer.bl-drawer { width: min(1040px, 100vw); }
.bl-drawer .lg-sum strong { font-size: 17px; }
.bl-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.bl-col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bl-col-head h4 { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.bl-col-head h4 .dot { vertical-align: 0; }
.bl-col .tbl { font-size: 12.5px; }
.bl-col .tbl td { vertical-align: top; }
.bl-col .tbl tr.yr td { background: var(--surface-sunk); font-weight: 700; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding-top: 4px; padding-bottom: 4px; }
.bl-col .tbl td.ky { font-weight: 600; white-space: nowrap; }
.bl-col .tbl td.nd { min-width: 120px; }
.bl-col .tbl td.who { white-space: nowrap; }
.bl-col .tbl td.ky small, .bl-col .tbl td.who small { display: block; font-weight: 500; color: var(--ink-3); font-size: 11.5px; }
.bl-col .tbl tr.pc td.nd { color: var(--ink-2); }
.bl-col .tbl tr.pc td.nd { padding-left: 22px; }
.bl-col .tbl tr.cont td { border-top: 0; }
.bl-col .tbl tr.has-cont td { border-bottom-style: dotted; }
.bl-col .tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.bl-col .tbl td.ct { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.bl-type { display: inline-flex; padding: 0 7px; font-size: 11.5px; font-weight: 600; line-height: 18px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.bl-type.tu { color: var(--warn); background: var(--warn-bg); border-color: #efcf9a; }
.bl-type.tt { color: var(--info); background: var(--info-bg); border-color: #c3d4e6; }
.bl-du-no { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border: 2px solid var(--ink); border-radius: var(--r-lg); background: var(--surface); }
.bl-du-no .eyebrow { display: block; margin-bottom: 2px; }
.bl-du-no .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.bl-du-no.is-owed { border-color: var(--danger); }
.bl-du-no.is-owed .v { color: var(--danger); }
.bl-du-no.is-zero { border-color: var(--ok); }
.bl-du-no.is-zero .v { color: var(--ok); }
.bl-du-no .rb-formula { white-space: normal; }

/* ---------- Thêm lương tháng (drawer form) ---------- */
.drawer.bl-entry { width: min(1000px, 100vw); }
.bl-entry .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bl-lines { font-size: 13.5px; }
.bl-lines > thead th { position: static; }
.bl-lines td { vertical-align: middle; }
.bl-lines td.chk { width: 34px; padding-right: 0; }
.bl-lines .nv-name { font-weight: 600; display: block; white-space: nowrap; }
.bl-lines .nv-role { font-size: 12px; color: var(--ink-3); }
.bl-lines .input { min-height: 32px; padding: 5px 8px; }
.bl-lines .money { width: 132px; }
.bl-lines td.split-sum { font-size: 12.5px; color: var(--ink-2); }
.bl-lines tr.is-off td { color: var(--ink-3); background: var(--surface-2); }
.bl-lines tr.is-off .nv-name { color: var(--ink-3); }
.bl-lines tr.is-expanded > td { background: var(--steel-50); border-bottom-color: transparent; }
.bl-lines tr.bl-detail > td { padding: 0 12px 14px 46px; background: var(--steel-50); }
.bl-lines tr.bl-detail.has-error > td, .bl-lines tr.is-expanded.has-error > td { background: #fffafa; }
.bl-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.bl-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; min-width: 0; }
.bl-box h5 { margin: 0 0 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bl-box.is-invalid { border-color: var(--danger); }
.bl-pc { display: grid; grid-template-columns: 78px minmax(0, 1fr) 12px minmax(0, 1fr) 92px; gap: 6px; align-items: center; font-size: 12.5px; }
.bl-pc + .bl-pc { margin-top: 6px; }
.bl-pc .lbl { font-weight: 600; color: var(--ink-2); }
.bl-pc .op { text-align: center; color: var(--ink-3); }
.bl-pc .res { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bl-pc .input { min-height: 30px; padding: 4px 6px; font-size: 13px; min-width: 0; }
.bl-pc .input-addon { font-size: 11.5px; padding: 0 6px; }
.bl-pc .input-group { min-width: 0; }
.bl-pc .span-3 { grid-column: 2 / 5; }
.bl-split-row { display: grid; grid-template-columns: minmax(0, 1fr) 124px 46px 30px; gap: 6px; align-items: center; }
.bl-split-row + .bl-split-row { margin-top: 6px; }
.bl-split-row .select, .bl-split-row .input { min-height: 30px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.bl-split-row .pct { font-size: 12px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.bl-split-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-strong); font-size: 12.5px; }
.bl-check { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12.5px; }
.bl-check.ok { color: var(--ok); }
.bl-check.err { color: var(--danger); }
.bl-check .i { width: 15px; height: 15px; }
.bl-expand { width: 28px; height: 28px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: var(--r-sm); color: var(--ink-3); cursor: pointer; }
.bl-expand:hover { background: var(--surface-sunk); color: var(--ink); }
.bl-lines tr.is-expanded .bl-expand .i { transform: rotate(180deg); }
.bl-lines tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); }

/* ---------- Report 10 sheet ---------- */
.pg-bao-cao .rtbl-luong { font-size: 7.6px; letter-spacing: -0.01em; }
.pg-bao-cao .rtbl-luong thead small { font-size: 7px; font-weight: 500; }
.pg-bao-cao .rtbl-luong th, .pg-bao-cao .rtbl-luong td { padding: 3px 2px; }
.pg-bao-cao .rtbl-luong thead th { font-size: 7.6px; }
.pg-bao-cao .rtbl-luong .c-name { white-space: nowrap; }
.pg-bao-cao .rtbl-luong .c-role { display: block; font-size: 7.2px; color: #555; }
.pg-bao-cao .rtbl-luong td.num { vertical-align: middle; }
.pg-bao-cao .rtbl-luong td.num.is-split { background: #f3f2ed; }
.pg-bao-cao .rtbl-luong tr.r-total td { font-size: 7.8px; vertical-align: middle; }

/* ---------- Mockup-only annotation bar (not part of the product UI) ---------- */
.mk-states { position: fixed; left: 12px; bottom: 72px; z-index: 200; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: min(216px, calc(100vw - 24px)); padding: 6px 8px; background: #fffbea; border: 1.5px dashed var(--amber); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: 12px; color: var(--amber-ink); }
.mk-states strong { font-weight: 700; margin-right: 2px; }
.mk-states button, .mk-states a { font: inherit; font-weight: 600; padding: 2px 8px; border: 1px solid #e6c46f; border-radius: var(--r-sm); background: #fff; color: var(--amber-ink); cursor: pointer; text-decoration: none; }
.mk-states .is-active { background: var(--amber); border-color: #c98a0c; color: var(--ink); }
@media print { .mk-states { display: none !important; } }

/* ==========================================================================
   6. MOCKUP-ONLY PROPOSAL — admin shell below 760px.
   tenant.css has no phone layout for /quan-ly (the sidebar stays 208px wide).
   For "no horizontal page overflow at 375px" the sidebar collapses to a top
   strip with a Menu toggle; review before porting into tenant.css.
   ========================================================================== */
.a-menu-btn { display: none; }
@media (max-width: 900px) {
  .bl-cols { grid-template-columns: minmax(0, 1fr); }
  .bl-entry .form-grid { grid-template-columns: minmax(0, 1fr); }
  .bl-detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .a-shell { display: block; }
  .a-side { position: static; height: auto; overflow: visible; }
  .a-brand { padding: 10px 16px; border-bottom: 0; }
  .a-menu-btn { display: inline-flex; margin-left: auto; align-items: center; gap: 6px; padding: 6px 10px; font: inherit; font-size: 13px; font-weight: 600; color: #c9d2da; background: #1c2934; border: 1px solid #33424f; border-radius: var(--r-md); cursor: pointer; }
  .a-side .a-nav, .a-side .a-side-foot { display: none; }
  .a-side.is-menu-open .a-nav { display: block; border-top: 1px solid #25313d; }
  .a-side.is-menu-open .a-side-foot { display: flex; }
  .a-top { padding: 0 16px; height: 48px; position: static; }
  .a-top-right .muted { display: none; }
  .page { padding: 16px 16px 72px; }
  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 0; }
  .pg-bang-luong .kpis { gap: 10px; }
  .pg-bang-luong .kpi { padding: 10px 12px; }
  .pg-bang-luong .kpis .kpi-value { font-size: 16px; }
  .pg-bang-luong .kpi .kpi-sub { font-size: 12px; }
  .pg-bang-luong .filters { padding: 12px; }
  .pg-bang-luong .filters .field, .pg-bang-luong .filters .field.narrow, .pg-bang-luong .filters .field.mid, .pg-bang-luong .filters .field.wide { min-width: 0; width: auto; flex: 1 1 100%; }
  .bl-scroll { max-height: 70vh; }
  .bl-grid .c-nv { min-width: 138px; max-width: 138px; white-space: normal; }
  .bl-grid .nv-name { font-size: 13px; }
  .bl-grid .nv-role { flex-wrap: wrap; gap: 2px 6px; }
  .bl-drawer .lg-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bl-drawer .lg-sum > div:nth-child(2) { border-right: 0; }
  .bl-drawer .lg-sum > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .drawer-head, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .mk-states { left: 8px; right: 8px; bottom: 8px; max-width: none; }
}
