/* ==========================================================================
   Sổ Cái Việt (tenant misa-alternative) — shared mockup stylesheet
   Viewport: office desktop, designed at 1440x900, must hold at 1366x768
   and at 150 % Windows scaling / 200 % browser zoom (grids scroll inside,
   the page never scrolls sideways). Every S*.html links this file.
   No remote assets: IBM Plex Sans + IBM Plex Mono ship in ./fonts.

   Visual signature (own identity, PRODUCT.md):
   - Aubergine binding: one deep aubergine (hue 335) carries the brand mark,
     primary actions, the current module and keyboard focus. Everything
     else is a near-neutral grey tinted 0.004–0.012 toward that hue.
     No blue chrome, no orange selection bar, no ledger green, no seal.
   - The T-account: the logo is a chữ T (Nợ | Có) under a double rule.
     The same idea runs through every hạch toán grid: the Nợ column sits on
     a cool tint and the Có column on a warm tint, each labelled in text.
   - Double rule under totals, single rule above (bookkeeping convention).
   - Codes (accounts, voucher numbers, item codes) in Plex Mono; amounts in
     tabular Plex Sans, right-aligned, dot thousands, comma decimals.
   - Colour never carries meaning alone: every state has an icon and a word.
   ========================================================================== */

/* ---------- 0. Fonts ---------- */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap; src: url("fonts/plex-sans-vietnamese.woff2") format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap; src: url("fonts/plex-sans-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap; src: url("fonts/plex-sans-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/plex-mono-500-vietnamese.woff2") format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/plex-mono-500-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/plex-mono-500-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- 1. Tokens ---------- */
:root {
  /* Brand: aubergine binding (hue 335). White text on --brand is 7.6:1. */
  --brand: oklch(0.42 0.12 335);
  --brand-hover: oklch(0.37 0.11 335);
  --brand-press: oklch(0.33 0.10 335);
  --brand-ink: oklch(0.42 0.12 335);
  --brand-line: oklch(0.80 0.06 335);
  --brand-soft: oklch(0.955 0.018 335);
  --brand-soft-2: oklch(0.925 0.03 335);

  /* Neutrals tinted toward the brand hue */
  --ink: oklch(0.22 0.012 335);          /* body text, 15:1 on white */
  --ink-2: oklch(0.37 0.012 335);        /* secondary text, 10:1 */
  --ink-3: oklch(0.47 0.012 335);        /* muted text + placeholders, 5:1 on white, 4.6:1 on --surface-2 */
  --ink-4: oklch(0.63 0.010 335);        /* disabled text only */
  --ink-inv: oklch(0.985 0.003 335);
  --canvas: oklch(0.952 0.005 335);      /* app background behind panels */
  --surface: oklch(1 0 0);               /* grids, forms, documents */
  --surface-2: oklch(0.977 0.004 335);   /* sidebar, toolbars, grid header */
  --sunk: oklch(0.938 0.006 335);        /* read-only inputs, group bar, wells */
  --line: oklch(0.905 0.006 335);        /* grid rules, dividers */
  --line-2: oklch(0.85 0.008 335);       /* panel borders, stronger rules */
  --ctl-border: oklch(0.63 0.012 335);   /* form control boundary, 3:1 on white */
  --rule-ink: oklch(0.30 0.012 335);     /* bookkeeping total rules */

  /* Chrome: the top bar */
  --chrome: oklch(0.235 0.018 335);
  --chrome-2: oklch(0.30 0.022 335);
  --chrome-3: oklch(0.36 0.025 335);
  --chrome-ink: oklch(0.95 0.006 335);
  --chrome-ink-2: oklch(0.80 0.012 335);
  --chrome-line: oklch(0.33 0.02 335);

  /* Semantic states: ink (text/icon), bg (tint), line (border) */
  --ok: oklch(0.46 0.11 152);
  --ok-bg: oklch(0.958 0.03 152);
  --ok-line: oklch(0.80 0.07 152);
  --warn: oklch(0.46 0.10 65);
  --warn-bg: oklch(0.968 0.045 88);
  --warn-line: oklch(0.80 0.11 80);
  --warn-solid: oklch(0.78 0.15 78);
  --danger: oklch(0.50 0.19 27);
  --danger-bg: oklch(0.96 0.024 27);
  --danger-line: oklch(0.82 0.08 27);
  --info: oklch(0.45 0.11 250);
  --info-bg: oklch(0.96 0.018 250);
  --info-line: oklch(0.83 0.05 250);
  --lock: oklch(0.38 0.03 285);
  --lock-bg: oklch(0.952 0.01 285);
  --lock-line: oklch(0.82 0.03 285);

  /* Nợ / Có pairing (text label + tint, never tint alone) */
  --no: oklch(0.43 0.10 245);
  --no-bg: oklch(0.973 0.012 245);
  --no-head: oklch(0.945 0.022 245);
  --co: oklch(0.45 0.09 62);
  --co-bg: oklch(0.977 0.016 80);
  --co-head: oklch(0.952 0.03 80);

  /* Selection and hover in grids */
  --sel: oklch(0.925 0.032 320);
  --sel-line: oklch(0.72 0.08 330);
  --hover: oklch(0.968 0.01 320);

  /* Chart series (data viz only) */
  --c-1: oklch(0.42 0.12 335);
  --c-2: oklch(0.62 0.09 250);
  --c-3: oklch(0.70 0.11 75);
  --c-4: oklch(0.58 0.08 175);
  --c-5: oklch(0.55 0.02 335);

  /* Type */
  --f-ui: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", Consolas, "Cascadia Mono", monospace;
  --t-2xs: 11px;
  --t-xs: 12px;
  --t-sm: 13px;     /* grid cells, dense UI — never smaller for data */
  --t-md: 14px;     /* UI base, forms */
  --t-lg: 16px;     /* panel titles, cashier/storekeeper base */
  --t-xl: 18px;     /* page / voucher titles */
  --t-2xl: 22px;    /* dashboard figures */
  --t-3xl: 28px;    /* sign-in heading */
  --lh: 1.45;
  --lh-tight: 1.25;

  /* Space (4px grid) */
  --s-0: 2px; --s-1: 4px; --s-2: 6px; --s-3: 8px; --s-4: 12px; --s-5: 16px; --s-6: 20px; --s-7: 24px; --s-8: 32px; --s-9: 40px; --s-10: 56px;

  /* Sizes */
  --h-ctl: 30px;          /* form controls */
  --h-ctl-sm: 26px;       /* filter row, grid editors */
  --h-btn: 30px;
  --h-row: 28px;          /* grid body row */
  --h-head: 30px;         /* grid header row */
  --w-side: 216px;
  --h-top: 44px;
  --h-tabs: 34px;
  --h-band: 24px;
  --h-status: 26px;

  /* Shape */
  --r-1: 2px;
  --r-2: 4px;
  --r-3: 6px;
  --r-pill: 999px;

  /* Elevation (popovers and dialogs only; panels are flat with a border) */
  --sh-1: 0 1px 0 oklch(0.2 0.02 335 / 0.04), 0 1px 2px oklch(0.2 0.02 335 / 0.06);
  --sh-pop: 0 10px 30px oklch(0.2 0.03 335 / 0.18), 0 2px 6px oklch(0.2 0.03 335 / 0.10);
  --sh-dlg: 0 24px 64px oklch(0.18 0.03 335 / 0.28), 0 4px 12px oklch(0.18 0.03 335 / 0.12);
  --sh-paper: 0 1px 2px oklch(0.2 0.02 335 / 0.12), 0 10px 30px oklch(0.2 0.02 335 / 0.10);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  --focus-in: inset 0 0 0 2px var(--brand);

  /* Layers */
  --z-sticky: 10;
  --z-menu: 20;
  --z-band: 30;
  --z-scrim: 40;
  --z-dialog: 50;
  --z-toast: 60;
  --z-tip: 70;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --d-1: 120ms;
  --d-2: 180ms;
}

/* Thủ quỹ / Thủ kho screens: larger base, roomier rows (PRODUCT.md "Older eyes"). */
.is-large {
  --t-sm: 15px;
  --t-md: 16px;
  --t-lg: 18px;
  --t-xl: 22px;
  --h-ctl: 40px;
  --h-btn: 44px;
  --h-row: 44px;
  --h-head: 40px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-ui);
  font-size: var(--t-md);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--canvas);
  font-feature-settings: "tnum" 1, "lnum" 1;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 600; letter-spacing: -0.005em; text-wrap: balance; }
h1 { font-size: var(--t-xl); }
h2 { font-size: var(--t-lg); }
h3 { font-size: var(--t-md); }
h4 { font-size: var(--t-sm); }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--brand-ink); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--brand-hover); }
button { font: inherit; color: inherit; }
small { font-size: var(--t-xs); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-4) 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-2); }
[hidden] { display: none !important; }
::selection { background: var(--brand-soft-2); color: var(--ink); }

.skip { position: absolute; left: -9999px; top: 0; z-index: var(--z-tip); padding: 8px 12px; background: var(--brand); color: var(--ink-inv); font-weight: 600; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Text utilities */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.code { font-family: var(--f-mono); font-weight: 500; font-size: 0.93em; letter-spacing: 0; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.neg { color: var(--danger); }
.t-xs { font-size: var(--t-xs); }
.t-sm { font-size: var(--t-sm); }
.t-lg { font-size: var(--t-lg); }
.center { text-align: center; }
.right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout utilities */
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-top { display: flex; align-items: flex-start; gap: var(--s-3); }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.stack-lg > * + * { margin-top: var(--s-6); }
.gap-0 { gap: 0; }
.gap-1 { gap: var(--s-1); }
.gap-4 { gap: var(--s-4); }
.gap-5 { gap: var(--s-5); }
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-3); }
.mt-3 { margin-top: var(--s-4); }
.mt-4 { margin-top: var(--s-5); }
.mt-5 { margin-top: var(--s-6); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }

/* ---------- 3. Icons ---------- */
.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i-sm { width: 14px; height: 14px; vertical-align: -2px; }
.i-xs { width: 12px; height: 12px; vertical-align: -1px; }
.i-lg { width: 20px; height: 20px; }
.i-xl { width: 28px; height: 28px; }
.i-fill { fill: currentColor; stroke: none; }

/* ---------- 4. Keys ---------- */
kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 5px;
  font-family: var(--f-ui); font-size: 11px; font-weight: 600; line-height: 1;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: var(--r-1);
}

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--h-btn); padding: 0 12px;
  font-size: var(--t-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--ctl-border); border-radius: var(--r-2);
  cursor: pointer; text-decoration: none;
  transition: background var(--d-1), border-color var(--d-1), color var(--d-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn:active { background: var(--sunk); }
.btn[disabled], .btn.is-disabled { color: var(--ink-4); background: var(--surface); border-color: var(--line-2); cursor: not-allowed; }
.btn[disabled] .i, .btn.is-disabled .i { opacity: .55; }
.btn-primary { color: var(--ink-inv); background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { color: var(--ink-inv); background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:active { background: var(--brand-press); }
.btn-primary[disabled] { color: oklch(0.98 0 0 / 0.85); background: var(--ink-4); border-color: var(--ink-4); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger); }
.btn-danger-solid { color: var(--ink-inv); background: var(--danger); border-color: var(--danger); }
.btn-danger-solid:hover { color: var(--ink-inv); background: oklch(0.44 0.17 27); border-color: oklch(0.44 0.17 27); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunk); border-color: transparent; }
.btn-link { height: auto; padding: 0; background: none; border: 0; color: var(--brand-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { background: none; color: var(--brand-hover); }
.btn-sm { height: var(--h-ctl-sm); padding: 0 9px; font-size: var(--t-xs); }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--t-md); }
.btn-icon { width: var(--h-btn); padding: 0; }
.btn-icon.btn-sm { width: var(--h-ctl-sm); }
.btn .caret { margin-left: 2px; margin-right: -3px; color: var(--ink-3); }
.btn-primary .caret { color: oklch(0.98 0 0 / 0.8); }
.btn.is-busy { cursor: progress; }
.btn.is-busy .spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--r-2) 0 0 var(--r-2); }
.btn-group > .btn:last-child { border-radius: 0 var(--r-2) var(--r-2) 0; }

/* ---------- 6. Form controls ---------- */
.input, .select, .textarea {
  width: 100%; height: var(--h-ctl); padding: 0 8px;
  font: inherit; font-size: var(--t-sm); color: var(--ink);
  background: var(--surface); border: 1px solid var(--ctl-border); border-radius: var(--r-2);
  transition: border-color var(--d-1), box-shadow var(--d-1);
}
.textarea { height: auto; min-height: 60px; padding: 6px 8px; resize: vertical; line-height: var(--lh); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus, .input.is-focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.input[readonly], .input.is-ro, .select[disabled], .input[disabled] { background: var(--sunk); color: var(--ink-2); border-color: var(--line-2); }
.input[disabled] { color: var(--ink-4); cursor: not-allowed; }
.input.num, .input.money { text-align: right; font-variant-numeric: tabular-nums; }
.input.code { font-family: var(--f-mono); font-size: 12.5px; }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); background: var(--surface); }
.select {
  appearance: none; padding-right: 26px; cursor: pointer;
  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='rgb(84,76,86)' stroke-width='2.4' 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 8px center;
}
.input-sm, .select.input-sm { height: var(--h-ctl-sm); font-size: var(--t-xs); }

/* Picker: code field + F4 list button + F9 quick-add button, then the name */
.picker { display: flex; align-items: stretch; min-width: 0; }
.picker .input { border-radius: var(--r-2) 0 0 var(--r-2); min-width: 0; }
.picker .pk-btn {
  flex: none; width: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--ctl-border); border-left: 0; color: var(--ink-2); cursor: pointer;
}
.picker .pk-btn:last-child { border-radius: 0 var(--r-2) var(--r-2) 0; }
.picker .pk-btn:hover { background: var(--sunk); color: var(--ink); }
.pick-name { display: flex; gap: 6px; min-width: 0; }
.pick-name > .picker { flex: 0 0 170px; }
.pick-name > .input { flex: 1; }
.pick-name > .ro-val:first-child { flex: 0 0 170px; }
.pick-name > .ro-val:last-child { flex: 1; min-width: 0; }

.input-suffix { position: relative; }
.input-suffix .input { padding-right: 34px; }
.input-suffix .sfx { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); border-left: 1px solid var(--line); background: var(--surface-2); border-radius: 0 var(--r-2) var(--r-2) 0; }
.input-suffix .sfx.txt { width: auto; padding: 0 8px; font-size: var(--t-xs); font-weight: 600; }

.check, .radio { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-sm); cursor: pointer; color: var(--ink); }
.check input, .radio input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); flex: none; }
.is-large .check input, .is-large .radio input { width: 20px; height: 20px; }

/* Form rows: label left (MISA habit), control right */
.fgrid { display: grid; grid-template-columns: var(--lab, 118px) minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.fgrid > .lab { font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; }
.fgrid > .lab.req::after, .field > .lab.req::after { content: " *"; color: var(--danger); }
.fgrid > .span-2 { grid-column: 1 / -1; }
.fgrid-2 { display: grid; grid-template-columns: var(--lab, 118px) minmax(0, 1fr) var(--lab2, 100px) minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.fgrid-2 > .lab { font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; }
.fgrid-2 > .lab.req::after { content: " *"; color: var(--danger); }
.fgrid-2 > .span-3 { grid-column: 2 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > .lab { font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.hint { font-size: var(--t-xs); color: var(--ink-3); }
.ferr { display: flex; gap: 5px; align-items: flex-start; font-size: var(--t-xs); font-weight: 500; color: var(--danger); }
.ferr .i { width: 13px; height: 13px; margin-top: 1px; }
.inline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.inline > .input, .inline > .select { flex: 1; min-width: 0; }
.inline > .w-xs { flex: 0 0 64px; }
.inline > .w-sm { flex: 0 0 110px; }
.inline > .w-md { flex: 0 0 150px; }
.inline > .w-lg { flex: 0 0 220px; }
.inline > .lab, .vf-strip .lab { font-size: var(--t-sm); color: var(--ink-2); white-space: nowrap; flex: none; }
.inline > .lab.req::after, .vf-strip .lab.req::after { content: " *"; color: var(--danger); }

/* Fieldset blocks (Thông tin chung / Chứng từ) */
.block { border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); padding: 14px 14px 12px; position: relative; min-width: 0; margin: 0; }
.block > legend, .block-title { padding: 0 6px; margin-left: -6px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.block-title { position: absolute; top: -9px; left: 14px; background: var(--surface); line-height: 16px; }

/* Segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--sunk); border-radius: var(--r-2); }
.seg button, .seg a { height: calc(var(--h-ctl) - 4px); padding: 0 10px; border: 0; background: none; border-radius: 3px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg .is-on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-sm); cursor: pointer; }
.switch .track { width: 30px; height: 18px; border-radius: 9px; background: var(--ink-4); position: relative; flex: none; transition: background var(--d-1); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: transform var(--d-2) var(--ease-out); }
.switch.is-on .track { background: var(--brand); }
.switch.is-on .track::after { transform: translateX(12px); }

/* ---------- 7. Chips, badges, status ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; font-size: var(--t-2xs); font-weight: 600; line-height: 1; white-space: nowrap; border-radius: var(--r-1); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); }
.chip .i { width: 12px; height: 12px; }
.chip-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.chip-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.chip-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.chip-info { color: var(--info); background: var(--info-bg); border-color: var(--info-line); }
.chip-lock { color: var(--lock); background: var(--lock-bg); border-color: var(--lock-line); }
.chip-brand { color: var(--brand-ink); background: var(--brand-soft); border-color: var(--brand-line); }
.chip-muted { color: var(--ink-3); background: var(--sunk); border-color: var(--line); }
.chip-draft { color: var(--ink-2); background: var(--surface); border: 1px dashed var(--ink-3); }
.chip-lg { height: 24px; padding: 0 9px; font-size: var(--t-xs); }
.chip-lg .i { width: 14px; height: 14px; }

.acc { font-family: var(--f-mono); font-weight: 500; font-size: 12.5px; color: var(--ink); letter-spacing: 0; }
.vno { font-family: var(--f-mono); font-weight: 500; font-size: 12.5px; color: var(--brand-ink); letter-spacing: 0; text-decoration: none; }
a.vno:hover { text-decoration: underline; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; line-height: 1; background: var(--sunk); color: var(--ink-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex: none; }
.unverified { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-2xs); font-weight: 600; color: var(--warn); }

/* ---------- 8. Message bars (inline alerts, full border, no side stripe) ---------- */
.msg { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid; border-radius: var(--r-2); font-size: var(--t-sm); line-height: 1.45; }
.msg > .i { margin-top: 1px; width: 16px; height: 16px; }
.msg .msg-body { flex: 1; min-width: 0; }
.msg .msg-body strong { font-weight: 600; }
.msg .msg-act { display: flex; gap: 6px; flex: none; align-items: center; }
.msg-info { background: var(--info-bg); border-color: var(--info-line); color: oklch(0.32 0.08 250); }
.msg-info > .i { color: var(--info); }
.msg-warn { background: var(--warn-bg); border-color: var(--warn-line); color: oklch(0.34 0.07 65); }
.msg-warn > .i { color: var(--warn); }
.msg-danger { background: var(--danger-bg); border-color: var(--danger-line); color: oklch(0.38 0.14 27); }
.msg-danger > .i { color: var(--danger); }
.msg-ok { background: var(--ok-bg); border-color: var(--ok-line); color: oklch(0.34 0.08 152); }
.msg-ok > .i { color: var(--ok); }
.msg-lock { background: var(--lock-bg); border-color: var(--lock-line); color: var(--lock); }
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.msg li + li { margin-top: 2px; }

/* ---------- 9. App shell ---------- */
body.app { height: 100vh; overflow: hidden; display: grid; grid-template-rows: var(--h-top) minmax(0, 1fr) var(--h-status); min-width: 1024px; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 4px; padding: 0 10px 0 0; background: var(--chrome); color: var(--chrome-ink); position: relative; z-index: var(--z-menu); }
.brand { display: flex; align-items: center; gap: 9px; width: var(--w-side); height: 100%; padding: 0 14px; color: var(--chrome-ink); text-decoration: none; flex: none; border-right: 1px solid var(--chrome-line); }
.brand:hover { color: var(--chrome-ink); background: var(--chrome-2); }
.brand-mark { width: 24px; height: 24px; flex: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.menubar { display: flex; align-items: center; height: 100%; padding: 0 6px; }
.menu-btn { height: 30px; padding: 0 10px; background: none; border: 0; border-radius: var(--r-2); color: var(--chrome-ink-2); font-size: var(--t-sm); font-weight: 500; cursor: pointer; position: relative; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--chrome-2); color: var(--chrome-ink); }
.menu-btn:focus-visible, .tool:focus-visible, .fsearch:focus-visible, .user:focus-visible { box-shadow: 0 0 0 2px var(--chrome-ink); }
.fsearch {
  display: flex; align-items: center; gap: 8px; width: 300px; height: 30px; margin-left: 6px; padding: 0 6px 0 10px;
  background: var(--chrome-2); border: 1px solid var(--chrome-3); border-radius: var(--r-2);
  color: var(--chrome-ink-2); font-size: var(--t-sm); cursor: text; text-align: left;
}
.fsearch:hover { border-color: var(--chrome-ink-2); }
.fsearch .grow { color: var(--chrome-ink-2); }
.fsearch kbd { background: var(--chrome-3); color: var(--chrome-ink); border-color: var(--chrome-3); border-bottom-color: oklch(0.2 0.02 335); }
.fsearch.is-open { background: var(--surface); border-color: var(--surface); color: var(--ink); }
.fsearch.is-open .grow { color: var(--ink); }
.topbar-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; height: 100%; }
.tool { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 9px; background: none; border: 0; border-radius: var(--r-2); color: var(--chrome-ink-2); font-size: var(--t-sm); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.tool:hover, .tool.is-open { background: var(--chrome-2); color: var(--chrome-ink); }
.tool-date strong { color: var(--chrome-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tool-sep { width: 1px; height: 20px; background: var(--chrome-line); margin: 0 6px; }
.tool-bell { position: relative; padding: 0 8px; }
.tool-bell .count { position: absolute; top: 2px; right: 0; height: 16px; min-width: 16px; padding: 0 4px; font-size: 10px; background: var(--warn-solid); color: oklch(0.22 0.04 70); }
.user { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 4px; background: none; border: 0; border-radius: var(--r-2); color: var(--chrome-ink); font-size: var(--t-sm); font-weight: 500; cursor: pointer; }
.user:hover, .user.is-open { background: var(--chrome-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--brand); color: var(--ink-inv); box-shadow: 0 0 0 1px oklch(1 0 0 / 0.18); flex: none; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

/* Frame */
.frame { display: grid; grid-template-columns: var(--w-side) minmax(0, 1fr); min-height: 0; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); border-right: 1px solid var(--line-2); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 14px; font-size: var(--t-2xs); font-weight: 600; color: var(--ink-3); }
.modnav { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.mod { display: flex; align-items: center; gap: 9px; height: 28px; padding: 0 8px; border-radius: var(--r-2); color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; text-decoration: none; white-space: nowrap; }
.mod .i { color: var(--ink-3); }
.mod:hover { background: var(--sunk); color: var(--ink); }
.mod.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.mod.is-active .i { color: var(--brand); }
.mod .chev { margin-left: auto; width: 12px; height: 12px; color: var(--ink-3); }
.quick { list-style: none; margin: 2px 0 6px 17px; padding: 2px 0 2px 12px; border-left: 1px solid var(--brand-line); }
.quick a { display: flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--r-1); color: var(--ink-2); font-size: var(--t-xs); text-decoration: none; white-space: nowrap; }
.quick a:hover { background: var(--sunk); color: var(--ink); }
.quick a.is-current { color: var(--brand-ink); font-weight: 600; }
.side-foot { display: flex; align-items: center; gap: 8px; height: 36px; margin: 0; padding: 0 14px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink-2); font-size: var(--t-xs); font-weight: 500; text-align: left; cursor: pointer; }
.side-foot:hover { background: var(--sunk); color: var(--ink); }

.main { display: grid; grid-template-rows: var(--h-tabs) auto minmax(0, 1fr); min-width: 0; min-height: 0; }

/* Open-screen tabs */
.tabstrip { display: flex; align-items: flex-end; gap: 2px; padding: 0 8px 0 8px; background: var(--canvas); border-bottom: 1px solid var(--line-2); min-width: 0; }
.tabs-scroll { display: flex; align-items: flex-end; gap: 2px; min-width: 0; overflow: hidden; flex: 1; }
.otab { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 6px 0 11px; max-width: 220px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--r-2) var(--r-2) 0 0; color: var(--ink-2); font-size: var(--t-xs); font-weight: 500; text-decoration: none; white-space: nowrap; flex: none; position: relative; }
.otab:hover { background: var(--sunk); color: var(--ink); }
.otab .ellipsis { max-width: 160px; }
.otab.is-active { background: var(--surface); border-color: var(--line-2); color: var(--ink); font-weight: 600; margin-bottom: -1px; height: 30px; }
.otab.is-active::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px; background: var(--brand); border-radius: var(--r-2) var(--r-2) 0 0; }
.otab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--warn-solid); flex: none; }
.otab-x { width: 18px; height: 18px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: var(--r-1); color: var(--ink-3); cursor: pointer; padding: 0; }
.otab-x:hover { background: var(--line); color: var(--ink); }
.otab-x .i { width: 12px; height: 12px; }
.tabs-more { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 26px; margin-bottom: 3px; padding: 0 8px; border: 0; background: none; border-radius: var(--r-2); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tabs-more:hover, .tabs-more.is-open { background: var(--sunk); color: var(--ink); }

/* Sample-data band */
.band { display: flex; align-items: center; gap: 8px; height: var(--h-band); padding: 0 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: var(--t-xs); }
.band .i { color: var(--info); width: 14px; height: 14px; }
.band strong { font-weight: 600; color: var(--ink); }
.band .ml-auto { color: var(--ink-3); }
.pay-band { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); color: oklch(0.34 0.07 65); font-size: var(--t-xs); }

.content { min-height: 0; overflow: auto; background: var(--surface); position: relative; }
.content.on-canvas { background: var(--canvas); }

/* Status line */
.statusline { display: flex; align-items: center; gap: 0; padding: 0 6px; background: var(--surface-2); border-top: 1px solid var(--line-2); font-size: var(--t-xs); color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.sl-item { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px; border-right: 1px solid var(--line); }
.sl-item .i { width: 13px; height: 13px; color: var(--ink-3); }
.sl-item strong { font-weight: 600; color: var(--ink); }
button.sl-item { background: none; border-top: 0; border-bottom: 0; border-left: 0; cursor: pointer; font-size: var(--t-xs); color: var(--ink-2); }
button.sl-item:hover { background: var(--sunk); color: var(--ink); }
.sl-item.is-lock { color: var(--lock); }
.sl-end { margin-left: auto; border-right: 0; border-left: 1px solid var(--line); color: var(--ink-3); }

/* ---------- 10. Menus, popovers, feature search ---------- */
.menu {
  position: absolute; z-index: var(--z-menu); min-width: 240px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--sh-pop);
  color: var(--ink); font-size: var(--t-sm);
}
.menu-item { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px 0 8px; border-radius: var(--r-2); color: var(--ink); text-decoration: none; white-space: nowrap; cursor: pointer; background: none; border: 0; width: 100%; text-align: left; font-size: var(--t-sm); }
.menu-item .i { color: var(--ink-3); }
.menu-item:hover, .menu-item.is-hot { background: var(--brand-soft); color: var(--ink); }
.menu-item.is-hot .i { color: var(--brand); }
.menu-item .kbd-hint { margin-left: auto; padding-left: 24px; color: var(--ink-3); font-size: var(--t-xs); }
.menu-item .chev { margin-left: auto; width: 12px; height: 12px; color: var(--ink-3); }
.menu-item.is-disabled { color: var(--ink-4); cursor: default; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu-label { padding: 6px 10px 3px 8px; font-size: var(--t-2xs); font-weight: 600; color: var(--ink-3); }
.menu-sub { position: absolute; z-index: var(--z-menu); }
.menu .check-mark { width: 16px; display: inline-flex; justify-content: center; color: var(--brand); }

.fs-pop { position: absolute; top: 40px; z-index: var(--z-menu); width: 520px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--sh-pop); overflow: hidden; color: var(--ink); }
.fs-input { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-bottom: 1px solid var(--line); font-size: var(--t-md); }
.fs-input .typed { color: var(--ink); }
.fs-input .caret-bar { width: 1px; height: 18px; background: var(--ink); margin-left: -6px; }
.fs-group { padding: 6px 6px 2px; }
.fs-group + .fs-group { border-top: 1px solid var(--line); }
.fs-res { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r-2); font-size: var(--t-sm); color: var(--ink); text-decoration: none; }
.fs-res .path { color: var(--ink-3); }
.fs-res mark { background: none; color: var(--brand-ink); font-weight: 700; }
.fs-res.is-hot { background: var(--brand-soft); }
.fs-res .ret { margin-left: auto; color: var(--ink-3); font-size: var(--t-xs); }
.fs-foot { display: flex; gap: 14px; padding: 7px 12px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: var(--t-xs); color: var(--ink-3); }

.pop { position: absolute; z-index: var(--z-menu); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--sh-pop); color: var(--ink); }
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pop-head h2 { font-size: var(--t-md); }
.pop-body { padding: 10px 12px; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); font-size: var(--t-xs); color: var(--ink-3); }

/* Nhắc nhở panel */
.remind { width: 400px; right: 60px; top: 42px; }
.remind-list { list-style: none; max-height: 520px; overflow: auto; }
.remind-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.remind-item:hover { background: var(--hover); }
.remind-ico { width: 28px; height: 28px; border-radius: var(--r-2); display: grid; place-items: center; background: var(--sunk); color: var(--ink-2); }
.remind-ico.is-tax { background: var(--warn-bg); color: var(--warn); }
.remind-ico.is-debt { background: var(--info-bg); color: var(--info); }
.remind-ico.is-loan { background: var(--lock-bg); color: var(--lock); }
.remind-ico.is-late { background: var(--danger-bg); color: var(--danger); }
.remind-t { font-size: var(--t-sm); line-height: 1.4; }
.remind-m { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.remind-when { font-size: var(--t-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.remind-when.is-late { color: var(--danger); font-weight: 600; }

/* ---------- 11. Dialogs, drawers, toasts ---------- */
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: oklch(0.2 0.02 335 / 0.38); }
.dlg {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: var(--z-dialog);
  width: min(var(--dw, 560px), calc(100vw - 48px)); max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-3); box-shadow: var(--sh-dlg); border: 1px solid var(--line-2);
}
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: var(--t-lg); }
.dlg-head .sub { font-size: var(--t-xs); color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.dlg-head .btn-icon { margin-left: auto; }
.dlg-body { padding: 16px 18px; overflow: auto; min-height: 0; }
.dlg-body.flush { padding: 0; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); }
.dlg-foot .left { margin-right: auto; display: flex; gap: 8px; align-items: center; font-size: var(--t-xs); color: var(--ink-3); }
.dlg-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.dlg-ico.is-warn { background: var(--warn-bg); color: var(--warn); }
.dlg-ico.is-danger { background: var(--danger-bg); color: var(--danger); }
.dlg-ico.is-info { background: var(--info-bg); color: var(--info); }
.dlg-ico.is-lock { background: var(--lock-bg); color: var(--lock); }
.confirm-body { display: grid; grid-template-columns: 34px 1fr; gap: 14px; }
.confirm-body p + p { margin-top: 6px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-dialog); width: min(var(--dw, 520px), 100vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--sh-dlg); border-left: 1px solid var(--line-2); }
.drawer .dlg-body { flex: 1; }

.toast { position: fixed; z-index: var(--z-toast); left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--chrome); color: var(--chrome-ink); border-radius: var(--r-2); box-shadow: var(--sh-pop); font-size: var(--t-sm); font-weight: 500; animation: toast-in var(--d-2) var(--ease-out); }
.toast .i { color: oklch(0.80 0.12 152); }
.toast a { color: var(--chrome-ink); font-weight: 600; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- 12. Module page ---------- */
.modpage { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.mod-head { display: flex; align-items: flex-end; gap: 18px; padding: 10px 16px 0; background: var(--surface); border-bottom: 1px solid var(--line-2); flex: none; }
.mod-title { display: flex; align-items: center; gap: 9px; padding-bottom: 10px; flex: none; }
.mod-title h1 { font-size: var(--t-xl); white-space: nowrap; }
.mod-title .i { width: 20px; height: 20px; color: var(--brand); }
.subtabs { display: flex; gap: 2px; align-self: flex-end; min-width: 0; overflow-x: auto; }
.subtab { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; text-decoration: none; white-space: nowrap; }
.subtab:hover { color: var(--ink); background: var(--surface-2); }
.subtab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }
.subtab .count { height: 16px; min-width: 16px; font-size: 10px; }
.mod-figure { margin-left: auto; padding-bottom: 9px; text-align: right; white-space: nowrap; }
.mod-figure .lab { display: block; font-size: var(--t-2xs); color: var(--ink-3); font-weight: 500; }
.mod-figure .val { font-size: var(--t-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.mod-figure .val small { font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); margin-left: 3px; }

.toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.tb { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; background: none; border: 1px solid transparent; border-radius: var(--r-2); color: var(--ink); font-size: var(--t-sm); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.tb .i { color: var(--ink-2); }
.tb:hover { background: var(--sunk); }
.tb.is-primary { background: var(--brand); color: var(--ink-inv); border-color: var(--brand); font-weight: 600; }
.tb.is-primary .i, .tb.is-primary .caret { color: var(--ink-inv); }
.tb.is-primary:hover { background: var(--brand-hover); }
.tb.is-open { background: var(--sunk); border-color: var(--line-2); }
.tb[disabled], .tb.is-disabled { color: var(--ink-4); cursor: not-allowed; background: none; }
.tb[disabled] .i, .tb.is-disabled .i { color: var(--ink-4); }
.tb .caret { width: 12px; height: 12px; color: var(--ink-3); margin-left: -2px; }
.tb-sep { width: 1px; height: 18px; margin: 0 4px; background: var(--line-2); flex: none; }
.tb-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.filterbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); flex: none; }
.fb-f { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--ink-2); font-weight: 500; }
.fb-f .input, .fb-f .select { height: 26px; font-size: var(--t-xs); }
.fb-f .w-period { width: 150px; }
.fb-f .w-date { width: 104px; }
.fb-f .w-sel { width: 140px; }
.fb-f .w-wide { width: 220px; }
.filterbar .ferr { width: 100%; }

.groupbar { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 12px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: var(--t-xs); flex: none; }
.groupbar .gb-hint { border: 1px dashed var(--line-2); border-radius: var(--r-1); padding: 1px 8px; }
.gchip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 4px 0 8px; background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--r-1); color: var(--ink); font-size: var(--t-xs); font-weight: 600; }
.gchip button { width: 16px; height: 16px; display: grid; place-items: center; border: 0; background: none; padding: 0; color: var(--ink-3); cursor: pointer; }

.split { display: grid; grid-template-rows: minmax(0, 1fr) 6px var(--detail-h, 214px); flex: 1; min-height: 0; }
.split-bar { background: var(--canvas); border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); cursor: row-resize; display: grid; place-items: center; }
.split-bar::after { content: ""; width: 28px; height: 2px; border-top: 1px solid var(--ink-4); border-bottom: 1px solid var(--ink-4); }
.detail { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.detail-head { display: flex; align-items: flex-end; gap: 4px; padding: 0 12px; height: 32px; border-bottom: 1px solid var(--line); flex: none; }
.detail-head .subtab { height: 30px; font-size: var(--t-xs); }
.detail-head .meta { margin-left: auto; align-self: center; font-size: var(--t-xs); color: var(--ink-3); }

.pane { flex: 1; min-height: 0; overflow: auto; position: relative; background: var(--surface); }
.page-pad { padding: 16px; }
.page-pad-lg { padding: 20px 24px; }

/* ---------- 13. Data grid ---------- */
.dg-wrap { overflow: auto; min-height: 0; height: 100%; position: relative; }
table.dg { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-sm); table-layout: auto; }
.dg th, .dg td { height: var(--h-row); padding: 0 8px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.dg th:last-child, .dg td:last-child { border-right: 0; }
.dg thead th { position: sticky; top: 0; z-index: 2; height: var(--h-head); background: var(--surface-2); color: var(--ink-2); font-size: var(--t-xs); font-weight: 600; border-bottom: 1px solid var(--line-2); }
.dg thead th .i { width: 12px; height: 12px; color: var(--ink-3); margin-left: 3px; }
.dg thead th.is-sorted { color: var(--ink); }
.dg thead tr.dg-filter th { top: var(--h-head); height: 28px; padding: 2px 3px; background: var(--surface); font-weight: 400; border-bottom: 1px solid var(--line-2); }
.dg-filter .fcell { display: flex; align-items: center; height: 22px; border: 1px solid var(--line); border-radius: var(--r-1); background: var(--surface); }
.dg-filter .fcell .op { width: 18px; text-align: center; color: var(--ink-3); font-size: 11px; border-right: 1px solid var(--line); flex: none; }
.dg-filter .fcell .fv { flex: 1; padding: 0 5px; font-size: var(--t-xs); color: var(--ink); overflow: hidden; }
.dg-filter .fcell.is-set { border-color: var(--brand-line); background: var(--brand-soft); }
.dg tbody td { background: var(--surface); }
.dg tbody tr:hover td { background: var(--hover); }
.dg tbody tr.is-sel td { background: var(--sel); }
.dg tbody tr.is-sel td.c-mark { color: var(--brand); }
.dg tbody tr.is-err td { background: var(--danger-bg); }
.dg tbody tr.is-warn td { background: var(--warn-bg); }
.dg tbody tr.is-muted td { color: var(--ink-3); }
.dg tbody tr.is-group td { background: var(--sunk); font-weight: 600; color: var(--ink); height: 26px; }
.dg tbody tr.is-group td .i { width: 12px; height: 12px; color: var(--ink-3); }
.dg tbody tr.is-sub td { background: var(--surface-2); font-weight: 600; }
.dg tbody tr.is-new td { color: var(--ink-3); font-style: normal; }
.dg tfoot td { position: sticky; bottom: 0; z-index: 2; height: 28px; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--rule-ink); border-bottom: 0; color: var(--ink); }
.dg tfoot td.lab { color: var(--ink-2); font-weight: 500; }
.dg .c-mark { width: 22px; min-width: 22px; padding: 0; text-align: center; color: var(--ink-3); background: var(--surface-2) !important; border-right: 1px solid var(--line-2); }
.dg .c-mark .i { width: 11px; height: 11px; }
.dg .c-chk { width: 30px; min-width: 30px; padding: 0; text-align: center; }
.dg .c-chk input { width: 14px; height: 14px; margin: 0; vertical-align: middle; accent-color: var(--brand); }
.dg .c-stt { width: 40px; text-align: right; color: var(--ink-3); }
.dg .num { text-align: right; }
.dg .date { font-variant-numeric: tabular-nums; }
.dg .wrap-cell { white-space: normal; line-height: 1.35; padding-top: 4px; padding-bottom: 4px; }
.dg .c-no { background: var(--no-bg); }
.dg .c-co { background: var(--co-bg); }
.dg thead th.c-no { background: var(--no-head); color: var(--no); }
.dg thead th.c-co { background: var(--co-head); color: var(--co); }
.dg tbody tr:hover td.c-no, .dg tbody tr:hover td.c-co { background: var(--hover); }
.dg tbody tr.is-sel td.c-no, .dg tbody tr.is-sel td.c-co { background: var(--sel); }
.dg td.is-total { font-weight: 600; }
.dg td.indent-1 { padding-left: 24px; }
.dg td.indent-2 { padding-left: 40px; }
.dg td.indent-3 { padding-left: 56px; }
.dg td a.drill { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.dg td a.drill:hover { color: var(--brand-ink); border-bottom-color: var(--brand); }
.dg-compact th, .dg-compact td { height: 26px; }
.dg-plain th, .dg-plain td { border-right: 0; }

/* Editable cells (voucher grids) */
.dg.is-edit tbody td { cursor: cell; }
.dg td.is-cell { position: relative; }
.dg td.is-active { box-shadow: var(--focus-in); background: var(--surface) !important; }
.dg td.is-active .caret-bar { display: inline-block; width: 1px; height: 15px; background: var(--ink); vertical-align: -3px; margin-left: 1px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dg td.is-err-cell { box-shadow: inset 0 0 0 1px var(--danger); background: var(--danger-bg) !important; color: var(--danger); font-weight: 600; }
.dg td.is-err-cell .i { width: 13px; height: 13px; }
.dg td.is-ro { background: var(--surface-2); color: var(--ink-2); }
.dg td .cell-pick { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.dg td .cell-pick .i { width: 12px; height: 12px; color: var(--ink-3); }
.dg tr.is-new td:nth-child(2) { color: var(--ink-3); }
.dg .row-x { width: 20px; height: 20px; display: inline-grid; place-items: center; border: 0; background: none; color: var(--ink-3); border-radius: var(--r-1); cursor: pointer; padding: 0; }
.dg .row-x:hover { background: var(--danger-bg); color: var(--danger); }

/* In-cell dropdown (F4 list) */
.cell-list { position: absolute; z-index: var(--z-menu); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); box-shadow: var(--sh-pop); font-size: var(--t-xs); overflow: hidden; }
.cell-list table { border-collapse: collapse; width: 100%; }
.cell-list th { text-align: left; padding: 5px 8px; background: var(--surface-2); color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--line); }
.cell-list td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cell-list tr.is-hot td { background: var(--brand-soft); }
.cell-list mark { background: none; color: var(--brand-ink); font-weight: 700; }
.cell-list .cl-foot { display: flex; justify-content: space-between; gap: 10px; padding: 5px 8px; background: var(--surface-2); color: var(--ink-3); }

/* Grid foot line under grids: Số dòng + totals */
.gridfoot { display: flex; align-items: center; gap: 18px; height: 28px; padding: 0 12px; border-top: 1px solid var(--line-2); background: var(--surface-2); font-size: var(--t-xs); color: var(--ink-2); flex: none; }
.gridfoot strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.gridfoot .ml-auto { display: flex; gap: 18px; }

/* Result panel after a bulk action */
.result { border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); box-shadow: var(--sh-pop); }

/* ---------- 14. Voucher form page ---------- */
.vf { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--canvas); }
.vf-bar { display: flex; align-items: center; gap: 2px; padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--line-2); flex: none; flex-wrap: wrap; }
.vf-bar .tb { height: 30px; padding: 0 8px; }
.vf-bar .tb .k { font-size: 10px; color: var(--ink-3); font-weight: 600; margin-left: 1px; }
.vf-bar .tb.is-primary .k { color: oklch(0.95 0.02 335); }
.vf-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.vf-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vf-head h1 { font-size: var(--t-xl); }
.vf-head .vno { font-size: 14px; }
.vf-head .vf-type { width: 300px; flex: none; }
.vf-head .vf-meta { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: var(--t-xs); color: var(--ink-3); }
.vf-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: var(--t-sm); }
.vf-top { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; align-items: stretch; }
.vf-top.three { grid-template-columns: minmax(0, 1fr) 270px 270px; }
.vf-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vf-strip .fx { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); color: var(--ink-2); }
.vf-strip .fx .select { width: 84px; }
.vf-strip .fx .input { width: 110px; }
.vf-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); }
.vf-tab { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid transparent; border-bottom: 0; border-radius: var(--r-2) var(--r-2) 0 0; color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; text-decoration: none; white-space: nowrap; background: none; cursor: pointer; }
.vf-tab u { text-decoration: none; border-bottom: 1px solid currentColor; }
.vf-tab:hover { color: var(--ink); background: var(--sunk); }
.vf-tab.is-active { background: var(--surface); border-color: var(--line-2); color: var(--ink); font-weight: 600; margin-bottom: -1px; height: 33px; }
.vf-tab .chip { height: 16px; padding: 0 5px; font-size: 10px; }
.vf-grid { background: var(--surface); border: 1px solid var(--line-2); border-top: 0; border-radius: 0 0 var(--r-3) var(--r-3); display: flex; flex-direction: column; min-height: 0; }
.vf-grid .dg-wrap { max-height: 300px; height: auto; }
.vf-grid.tall .dg-wrap { max-height: 380px; }
.vf-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: start; padding-bottom: 12px; }
.words { font-size: var(--t-sm); color: var(--ink-2); }
.words strong { color: var(--ink); font-weight: 600; font-style: italic; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 28px; font-size: var(--t-sm); min-width: 300px; }
.totals.two { grid-template-columns: auto auto auto auto; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.totals .grand { padding-top: 6px; border-top: 1px solid var(--rule-ink); font-weight: 700; font-size: var(--t-md); color: var(--ink); }
.totals dd.grand { border-bottom: 3px double var(--rule-ink); padding-bottom: 2px; }
.balance { display: inline-flex; align-items: center; gap: 8px; height: 26px; padding: 0 10px; border-radius: var(--r-2); font-size: var(--t-xs); font-weight: 600; border: 1px solid; }
.balance.is-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.balance.is-bad { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-line); }
.balance .side-no { color: var(--no); }
.balance .side-co { color: var(--co); }
.keyhint { display: flex; align-items: center; gap: 14px; height: 28px; padding: 0 14px; border-top: 1px solid var(--line-2); background: var(--surface); font-size: var(--t-xs); color: var(--ink-3); flex: none; }
.keyhint span { display: inline-flex; align-items: center; gap: 5px; }
.keyhint .ml-auto { color: var(--ink-3); }
.state-line { display: flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: var(--ink-3); }
.origin { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--lock-line); background: var(--lock-bg); color: var(--lock); border-radius: var(--r-2); font-size: var(--t-sm); }
.vf-msgs { display: flex; flex-direction: column; gap: 8px; }

/* Read-only display of form values (posted, Sửa nhanh locked fields) */
.ro-val { display: flex; align-items: center; min-height: var(--h-ctl); padding: 0 8px; background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-2); font-size: var(--t-sm); color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ro-val.num { justify-content: flex-end; }

/* ---------- 15. Panels (flat, bordered; for sections, not decoration) ---------- */
.panel { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: var(--t-md); font-weight: 600; }
.panel-head .unit { font-size: var(--t-xs); color: var(--ink-3); font-weight: 400; }
.panel-head .tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.panel-body { padding: 12px 14px; }
.panel-body.flush { padding: 0; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-3); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); }

/* Key/value statement rows (Tình hình tài chính, summaries) */
.kv { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.kv tr:last-child td { border-bottom: 0; }
.kv td.k { color: var(--ink-2); }
.kv td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.kv tr.sub td.k { padding-left: 16px; color: var(--ink-3); }
.kv tr.sub td.v { font-weight: 500; color: var(--ink-2); }
.kv tr.total td { border-top: 1px solid var(--rule-ink); font-weight: 700; color: var(--ink); }
.kv tr.total td.v { border-bottom: 3px double var(--rule-ink); }
.kv a.drill { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.kv a.drill:hover { color: var(--brand-ink); border-bottom-color: var(--brand); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: var(--t-sm); }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; color: var(--ink); font-weight: 500; }

/* Summary strip (several labelled figures in one row, separated by rules) */
.figs { display: flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); }
.fig { flex: 1 1 0; min-width: 140px; padding: 9px 14px; border-right: 1px solid var(--line); }
.fig:last-child { border-right: 0; }
.fig .lab { font-size: var(--t-xs); color: var(--ink-3); }
.fig .val { font-size: var(--t-lg); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.fig .val.is-neg { color: var(--danger); }
.fig .note { font-size: var(--t-2xs); color: var(--ink-3); margin-top: 1px; }

/* Split bar: trong hạn / quá hạn */
.sbar { display: flex; height: 10px; border-radius: 2px; overflow: hidden; background: var(--sunk); gap: 2px; }
.sbar > span { display: block; height: 100%; }
.sbar .s-in { background: var(--c-2); }
.sbar .s-late { background: var(--danger); }
.sbar-legend { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: var(--t-xs); color: var(--ink-2); }
.sbar-legend .v { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
.hbar { height: 8px; background: var(--sunk); border-radius: 1px; overflow: hidden; }
.hbar > span { display: block; height: 100%; background: var(--c-1); }
.hbar.is-2 > span { background: var(--c-2); }
.hbar.is-warn > span { background: var(--warn-solid); }
.hbar.is-danger > span { background: var(--danger); }
.hbar.is-ok > span { background: var(--ok); }

/* Ranked list */
.rank { list-style: none; }
.rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) 120px 110px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.rank li:last-child { border-bottom: 0; }
.rank .n { color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.rank .v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Charts (inline SVG) */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--f-ui); font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis-l { stroke: var(--line-2); stroke-width: 1; }
.chart .s1 { fill: var(--c-1); }
.chart .s2 { fill: var(--c-2); }
.chart .s3 { fill: var(--c-3); }
.chart .s4 { fill: var(--c-4); }
.chart .s5 { fill: var(--c-5); }
.chart .l1 { stroke: var(--c-1); stroke-width: 2; fill: none; }
.chart .l2 { stroke: var(--c-2); stroke-width: 2; fill: none; stroke-dasharray: 5 4; }
.chart .l3 { stroke: var(--c-3); stroke-width: 2; fill: none; }
.chart .pt1 { fill: var(--surface); stroke: var(--c-1); stroke-width: 2; }
.chart .neg-bar { fill: var(--danger); }
.chart .zero-l { stroke: var(--ink-3); stroke-width: 1; }
.chart .lbl-v { fill: var(--ink-2); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--t-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }
.legend .sw-line { width: 14px; height: 0; border-top: 2px solid; border-radius: 0; }

/* Period selector chip in panel heads */
.period { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); cursor: pointer; }
.period .i { width: 12px; height: 12px; color: var(--ink-3); }
.stamp-time { font-size: var(--t-xs); color: var(--ink-3); }

/* ---------- 16. Empty, loading, error ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 40px 20px; text-align: center; color: var(--ink-3); font-size: var(--t-sm); }
.empty > .i { width: 30px; height: 30px; color: var(--ink-4); margin-bottom: 4px; }
.empty strong { color: var(--ink-2); font-size: var(--t-md); font-weight: 600; }
.empty .row { margin-top: 8px; justify-content: center; }
.block-err { display: flex; align-items: center; gap: 10px; padding: 18px 14px; color: var(--ink-2); font-size: var(--t-sm); }
.block-err .i { color: var(--warn); }
.sk { display: inline-block; height: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--sunk) 0%, var(--surface-2) 50%, var(--sunk) 100%); background-size: 200% 100%; animation: sk 1.3s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- 17. Trees ---------- */
.tree { list-style: none; font-size: var(--t-sm); }
.tree ul { list-style: none; }
.tree-row { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: var(--r-2); color: var(--ink); text-decoration: none; white-space: nowrap; cursor: pointer; }
.tree-row:hover { background: var(--hover); }
.tree-row.is-sel { background: var(--sel); font-weight: 600; }
.tree-row .tw { width: 14px; height: 14px; display: inline-grid; place-items: center; color: var(--ink-3); flex: none; }
.tree-row .tw .i { width: 12px; height: 12px; }
.tree-row .i-node { color: var(--ink-3); }
.tree-row .cnt { margin-left: auto; font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tree .l1 { padding-left: 22px; }
.tree .l2 { padding-left: 40px; }
.tree .l3 { padding-left: 58px; }
.treegrid td.t-cell { padding-left: calc(8px + var(--lvl, 0) * 18px); }
.treegrid .tw { display: inline-grid; place-items: center; width: 14px; height: 14px; margin-right: 4px; color: var(--ink-3); vertical-align: -2px; }
.treegrid .tw .i { width: 12px; height: 12px; }
.treegrid tr.is-parent td { font-weight: 600; }

/* Two-pane layouts: tree or list left, content right */
.twopane { display: grid; grid-template-columns: var(--left, 260px) minmax(0, 1fr); height: 100%; min-height: 0; }
.twopane > .left { border-right: 1px solid var(--line-2); background: var(--surface-2); overflow: auto; min-height: 0; }
.twopane > .right { display: flex; flex-direction: column; min-width: 0; min-height: 0; text-align: left; }
.left-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.left-body { padding: 0 6px 10px; }

/* ---------- 18. Quy trình (process map) ---------- */
.flow { position: relative; padding: 24px; min-height: 100%; background: var(--surface); }
.flow svg.links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.flow svg.links path { fill: none; stroke: var(--ink-4); stroke-width: 1.5; }
.flow svg.links .arrow { fill: var(--ink-4); }
.flow-lane { position: absolute; border: 1px dashed var(--line-2); border-radius: var(--r-3); }
.flow-lane > span { position: absolute; top: -9px; left: 12px; padding: 0 6px; background: var(--surface); font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); }
.fnode { position: absolute; display: flex; align-items: center; gap: 9px; width: 168px; height: 52px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); color: var(--ink); font-size: var(--t-sm); font-weight: 600; line-height: 1.25; text-decoration: none; box-shadow: var(--sh-1); }
.fnode .i { width: 20px; height: 20px; color: var(--brand); flex: none; }
.fnode:hover { border-color: var(--brand); background: var(--brand-soft); }
.fnode.is-module { background: var(--brand); border-color: var(--brand); color: var(--ink-inv); }
.fnode.is-module .i { color: var(--ink-inv); }
.fnode.is-module:hover { background: var(--brand-hover); }
.fnode.is-ext { background: var(--surface-2); border-style: dashed; color: var(--ink-2); font-weight: 500; }
.fnode.is-ext .i { color: var(--ink-3); }
.fnode.is-nolink { cursor: default; box-shadow: none; }
.fnode.is-nolink:hover { border-color: var(--line-2); background: var(--surface); }
.fnode small { display: block; font-weight: 400; font-size: var(--t-2xs); color: var(--ink-3); }
.fnode.is-module small { color: oklch(0.92 0.02 335); }
.fnode.is-hub { width: 190px; height: 64px; font-size: var(--t-md); }

/* ---------- 19. Wizard steps ---------- */
.steps { display: flex; align-items: center; gap: 0; list-style: none; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); counter-reset: st; }
.steps li { display: flex; align-items: center; gap: 8px; font-size: var(--t-sm); color: var(--ink-3); font-weight: 500; white-space: nowrap; }
.steps li + li::before { content: ""; width: 44px; height: 1px; background: var(--line-2); margin: 0 12px; }
.steps .no { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: var(--t-xs); font-weight: 700; border: 1px solid var(--line-2); color: var(--ink-3); background: var(--surface); }
.steps li.is-done { color: var(--ink-2); }
.steps li.is-done .no { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.steps li.is-now { color: var(--ink); font-weight: 600; }
.steps li.is-now .no { background: var(--brand); border-color: var(--brand); color: var(--ink-inv); }
.steps li.is-locked .no { background: var(--sunk); }

/* ---------- 20. Calendar (Công việc) ---------- */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: var(--t-xs); }
.cal th { padding: 4px 0; color: var(--ink-3); font-weight: 600; text-align: center; }
.cal td { height: 30px; text-align: center; color: var(--ink); font-variant-numeric: tabular-nums; }
.cal td span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.cal td.is-out { color: var(--ink-4); }
.cal td.is-today span { background: var(--brand); color: var(--ink-inv); font-weight: 700; }
.cal td.has-task span { box-shadow: inset 0 -2px 0 var(--warn-solid); }
.cal td.is-pick span { outline: 1px solid var(--brand); }
.calbig { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: var(--t-xs); }
.calbig th { padding: 6px 8px; text-align: left; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--line-2); }
.calbig td { height: 92px; vertical-align: top; padding: 4px 6px; border: 1px solid var(--line); }
.calbig .d { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.calbig td.is-out .d { color: var(--ink-4); }
.calbig td.is-today .d { color: var(--ink-inv); background: var(--brand); border-radius: var(--r-1); padding: 0 4px; }
.ev { display: block; margin-top: 3px; padding: 2px 5px; border-radius: var(--r-1); font-size: 11px; line-height: 1.3; background: var(--info-bg); color: oklch(0.32 0.08 250); border: 1px solid var(--info-line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-decoration: none; }
.ev.is-task { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }
.ev.is-late { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }

/* ---------- 21. Report centre and report result ---------- */
.rc { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100%; min-height: 0; }
.rc-groups { border-right: 1px solid var(--line-2); background: var(--surface-2); overflow: auto; padding: 8px 6px; }
.rc-g { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: var(--r-2); color: var(--ink-2); font-size: var(--t-sm); text-decoration: none; }
.rc-g:hover { background: var(--sunk); color: var(--ink); }
.rc-g.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.rc-g .count { margin-left: auto; background: var(--surface); }
.rc-g .i { color: var(--ink-3); }
.rc-g.is-active .i { color: var(--brand); }
.rc-main { display: flex; flex-direction: column; min-height: 0; }
.rc-search { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.rc-search .input-ico { position: relative; width: 420px; }
.rc-search .input-ico .i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.rc-search .input-ico .input { padding-left: 32px; height: 34px; font-size: var(--t-md); }
.rl { list-style: none; }
.rl-sec { padding: 14px 16px 6px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.rl-item { display: grid; grid-template-columns: 26px minmax(0, 1fr) 120px 24px; gap: 8px; align-items: center; min-height: 38px; padding: 4px 16px; border-bottom: 1px solid var(--line); font-size: var(--t-sm); color: var(--ink); text-decoration: none; }
.rl-item:hover { background: var(--hover); }
.rl-item .form-no { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); text-align: right; }
.rl-item .star { width: 24px; height: 24px; display: grid; place-items: center; border: 0; background: none; color: var(--ink-4); cursor: pointer; border-radius: var(--r-1); padding: 0; }
.rl-item .star.is-on { color: var(--warn-solid); }
.rl-item .star:hover { background: var(--sunk); }
.rl-item .ri { color: var(--ink-3); }
.rl-item .desc { display: block; font-size: var(--t-xs); color: var(--ink-3); }
.rl-item mark { background: none; color: var(--brand-ink); font-weight: 700; }

.rpt-bar { display: flex; align-items: center; gap: 4px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--line-2); flex: none; }
.rpt-bar .title { font-weight: 600; font-size: var(--t-md); margin-right: 8px; }
.rpt-stage { flex: 1; min-height: 0; overflow: auto; background: var(--canvas); padding: 18px 24px 40px; }
.rpt-doc { background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--sh-paper); padding: 22px 26px 26px; min-width: 0; }
.rpt-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; font-size: var(--t-xs); color: var(--ink-2); }
.rpt-head .co strong { display: block; color: var(--ink); font-size: var(--t-sm); }
.rpt-head .form { text-align: center; }
.rpt-head .form strong { display: block; color: var(--ink); }
.rpt-title { text-align: center; margin: 14px 0 12px; }
.rpt-title h2 { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.rpt-title .p { font-size: var(--t-sm); color: var(--ink-2); margin-top: 3px; }
.rpt-title .p2 { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.rpt-note { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: var(--t-xs); color: var(--warn); }
table.rt { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rt th, .rt td { border: 1px solid var(--line-2); padding: 4px 6px; vertical-align: top; }
.rt thead th { background: var(--surface-2); font-weight: 600; text-align: center; color: var(--ink); line-height: 1.3; vertical-align: middle; }
.rt thead tr.colno th { font-weight: 500; color: var(--ink-3); font-size: 11px; padding: 2px 6px; }
.rt td.num { text-align: right; white-space: nowrap; }
.rt tr.r-open td, .rt tr.r-sum td { font-weight: 600; background: var(--surface-2); }
.rt tr.r-total td { font-weight: 700; border-top: 1px solid var(--rule-ink); }
.rt tr.r-total td.num { border-bottom: 3px double var(--rule-ink); }
.rt tr.r-bold td { font-weight: 600; }
.rt a.drill { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
.rt a.drill:hover { color: var(--brand-ink); border-bottom-color: var(--brand); }
.rt td.is-hot { background: var(--sel); box-shadow: inset 0 0 0 2px var(--brand); }
.rt .lvl-1 { padding-left: 18px; }
.rt .lvl-2 { padding-left: 32px; }
.rpt-check { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 7px 10px; border: 1px solid var(--ok-line); background: var(--ok-bg); color: oklch(0.34 0.08 152); border-radius: var(--r-2); font-size: var(--t-sm); font-weight: 500; }
.rpt-check.is-bad { border-color: var(--danger-line); background: var(--danger-bg); color: oklch(0.38 0.14 27); }
.rpt-check a { color: inherit; font-weight: 600; }
.rt tr.r-cap td { font-weight: 700; text-align: center; letter-spacing: 0.04em; background: var(--surface); padding: 7px 6px; }
.rt td.c { text-align: center; }
.rt td.tm { text-align: center; color: var(--ink-3); font-size: 11.5px; }
.rpt-doc.is-statement { max-width: 1100px; margin: 0 auto; }
.rpt-signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; text-align: center; font-size: var(--t-sm); }
.rpt-signs .r { font-weight: 600; }
.rpt-signs .n { font-style: italic; font-size: var(--t-xs); color: var(--ink-3); }
.rpt-signs .nm { margin-top: 40px; font-weight: 600; }
.rpt-signs .d { grid-column: 3; font-style: italic; font-size: var(--t-xs); color: var(--ink-2); margin-bottom: -6px; }
.rpt-bar .subtabs { align-self: stretch; margin: -6px 0; }
.rpt-bar .subtab { height: 40px; }

.peek { position: absolute; z-index: var(--z-menu); width: 520px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); box-shadow: var(--sh-pop); }
.peek::before { content: ""; position: absolute; top: -7px; left: var(--arrow-x, 40px); width: 12px; height: 12px; background: var(--surface); border-left: 1px solid var(--line-2); border-top: 1px solid var(--line-2); transform: rotate(45deg); }

/* ---------- 22. A4 print preview (S6, S24) ---------- */
.pv { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--canvas); }
.pv-stage { flex: 1; min-height: 0; overflow: auto; padding: 24px 0 48px; }
.sheet { width: 794px; min-height: 1123px; margin: 0 auto; padding: 48px 56px 56px; background: oklch(1 0 0); box-shadow: var(--sh-paper); color: oklch(0.15 0 0); font-size: 13px; line-height: 1.5; position: relative; }
.sheet.is-land { width: 1123px; min-height: 794px; }
.sheet .s-top { display: grid; grid-template-columns: 1fr auto; gap: 24px; font-size: 12px; }
.sheet .s-co strong { display: block; font-size: 13px; text-transform: uppercase; }
.sheet .s-form { text-align: center; font-size: 12px; }
.sheet .s-form strong { display: block; font-size: 13px; }
.sheet .s-form em { display: block; font-style: italic; font-size: 11px; }
.sheet .s-title { text-align: center; margin: 22px 0 4px; }
.sheet .s-title h2 { font-size: 22px; font-weight: 700; letter-spacing: 0.03em; }
.sheet .s-title .d { font-style: italic; font-size: 13px; margin-top: 2px; }
.sheet .s-meta { position: absolute; right: 56px; top: 132px; font-size: 12px; text-align: left; }
.sheet .s-lines { margin-top: 18px; display: grid; gap: 5px; }
.sheet .s-lines .ln { display: grid; grid-template-columns: max-content 1fr; gap: 6px; }
.sheet .s-lines .ln .f { border-bottom: 1px dotted oklch(0.55 0 0); min-height: 19px; font-weight: 500; }
.sheet table.st { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 12px; }
.sheet .st th, .sheet .st td { border: 1px solid oklch(0.2 0 0); padding: 4px 6px; vertical-align: top; }
.sheet .st thead th { font-weight: 700; text-align: center; vertical-align: middle; }
.sheet .st td.num { text-align: right; white-space: nowrap; }
.sheet .st tr.tot td { font-weight: 700; }
.sheet .s-date { text-align: right; font-style: italic; margin-top: 18px; font-size: 12.5px; }
.sheet .signs { display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 8px; margin-top: 6px; text-align: center; font-size: 12px; }
.sheet .signs .r { font-weight: 700; }
.sheet .signs .n { font-style: italic; font-size: 11px; }
.sheet .signs .nm { margin-top: 58px; font-weight: 600; }
.sheet .s-foot { position: absolute; left: 56px; right: 56px; bottom: 24px; display: flex; justify-content: space-between; font-size: 10.5px; color: oklch(0.45 0 0); }
.sheet .wm { position: absolute; top: 300px; left: 50%; transform: translateX(-50%) rotate(-18deg); padding: 6px 18px; border: 3px solid oklch(0.55 0.02 335 / 0.55); color: oklch(0.45 0.02 335 / 0.65); font-size: 34px; font-weight: 700; letter-spacing: 0.08em; border-radius: var(--r-2); white-space: nowrap; pointer-events: none; }
.pv-bar { display: flex; align-items: center; gap: 6px; padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--line-2); flex: none; }
.pv-bar .title { font-weight: 600; margin-right: 6px; }
.pv-bar .chip { margin-right: 4px; }

/* ---------- 23. Sign-in ---------- */
body.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 44%) minmax(0, 1fr); background: var(--surface); }
.si-side { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; background: var(--chrome); color: var(--chrome-ink); overflow: hidden; }
.si-side .brand-big { display: flex; align-items: center; gap: 12px; }
.si-side .brand-big svg { width: 40px; height: 40px; }
.si-side .brand-big strong { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.si-ledger { position: absolute; left: 48px; right: 48px; top: 50%; transform: translateY(-46%); }
.si-ledger .t { display: grid; grid-template-columns: 1fr 1fr; border-top: 3px double oklch(0.95 0.006 335 / 0.55); }
.si-ledger .t > div { padding: 12px 16px 0; }
.si-ledger .t > div + div { border-left: 1px solid oklch(0.95 0.006 335 / 0.55); }
.si-ledger .t .h { font-size: 13px; font-weight: 600; color: var(--chrome-ink-2); margin-bottom: 8px; }
.si-ledger .t .r { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid oklch(0.95 0.006 335 / 0.12); font-size: 13px; color: var(--chrome-ink-2); font-variant-numeric: tabular-nums; }
.si-ledger .t .r span:last-child { color: var(--chrome-ink); }
.si-ledger .t .r.tot { border-bottom: 3px double oklch(0.95 0.006 335 / 0.45); border-top: 1px solid oklch(0.95 0.006 335 / 0.45); color: var(--chrome-ink); font-weight: 600; margin-top: 4px; }
.si-ledger .cap { margin-top: 22px; max-width: 440px; font-size: 15px; line-height: 1.55; color: var(--chrome-ink-2); }
.si-ledger .cap strong { color: var(--chrome-ink); font-weight: 600; }
.si-side .si-foot { font-size: 12px; color: var(--chrome-ink-2); display: flex; gap: 16px; }
.si-main { display: flex; align-items: center; justify-content: center; padding: 40px; }
.si-form { width: 380px; }
.si-form h1 { font-size: var(--t-3xl); font-weight: 600; letter-spacing: -0.015em; }
.si-form .lead { margin-top: 6px; color: var(--ink-2); font-size: var(--t-md); }
.si-form .co-line { margin-top: 22px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface-2); font-size: var(--t-sm); }
.si-form .co-line .i { color: var(--brand); }
.si-form .field { margin-top: 16px; }
.si-form .field > .lab { font-size: var(--t-sm); }
.si-form .input { height: 40px; font-size: var(--t-md); padding: 0 12px; }
.si-form .pw { position: relative; }
.si-form .pw .input { padding-right: 44px; }
.si-form .pw .btn-icon { position: absolute; right: 4px; top: 4px; height: 32px; width: 36px; border: 0; }
.si-form .btn-primary { width: 100%; height: 42px; margin-top: 20px; font-size: var(--t-md); }
.si-form .forgot { margin-top: 16px; font-size: var(--t-sm); color: var(--ink-2); display: flex; gap: 8px; align-items: flex-start; }
.si-form .forgot .i { color: var(--ink-3); margin-top: 1px; }
.si-form .msg { margin-top: 18px; }
.si-form .row-opts { margin-top: 12px; }

/* ---------- 24. Standalone pages (Không có quyền) ---------- */
.notice { max-width: 560px; margin: 72px auto; padding: 0 24px; }
.notice .ico { width: 48px; height: 48px; border-radius: var(--r-3); display: grid; place-items: center; background: var(--lock-bg); color: var(--lock); border: 1px solid var(--lock-line); }
.notice h1 { margin-top: 18px; font-size: 22px; }
.notice p { margin-top: 8px; color: var(--ink-2); font-size: var(--t-md); max-width: 60ch; }
.notice .row { margin-top: 22px; }
.notice dl { margin-top: 22px; }

/* ---------- 25. Settings pages (Thông tin dữ liệu, Tùy chọn) ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; min-height: 0; }
.settings-nav { border-right: 1px solid var(--line-2); background: var(--surface-2); padding: 12px 8px; overflow: auto; }
.settings-nav a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: var(--r-2); color: var(--ink-2); font-size: var(--t-sm); text-decoration: none; }
.settings-nav a:hover { background: var(--sunk); color: var(--ink); }
.settings-nav a.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.settings-body { overflow: auto; padding: 18px 24px 32px; min-height: 0; }
.settings-body section { max-width: 880px; }
.settings-body section + section { margin-top: 26px; }
.settings-body h2 { font-size: var(--t-lg); margin-bottom: 4px; }
.settings-body .sec-desc { color: var(--ink-3); font-size: var(--t-sm); margin-bottom: 12px; }
.opt { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.opt .t { font-size: var(--t-sm); font-weight: 500; }
.opt .d { font-size: var(--t-xs); color: var(--ink-3); margin-top: 2px; }
.page-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-2); background: var(--surface-2); flex: none; }
.page-foot .left { margin-right: auto; font-size: var(--t-xs); color: var(--ink-3); display: flex; align-items: center; gap: 8px; }

/* ---------- 26. Checks list (Kiểm tra, đối chiếu) ---------- */
.checks { list-style: none; border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--surface); }
.ck { display: grid; grid-template-columns: 28px minmax(0, 1fr) 210px 120px; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ck:last-child { border-bottom: 0; }
.ck .no { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: var(--t-xs); text-align: right; }
.ck .t { font-size: var(--t-sm); font-weight: 500; }
.ck .d { font-size: var(--t-xs); color: var(--ink-3); margin-top: 1px; }
.ck .res { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; }
.ck .res.is-ok { color: var(--ok); }
.ck .res.is-bad { color: var(--danger); }
.ck .res.is-fail { color: var(--warn); }
.ck .res.is-none { color: var(--ink-3); font-weight: 500; }
.ck.is-open { background: var(--surface-2); }
.t-thu, .t-chi { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.t-thu { color: var(--ok); }
.t-chi { color: var(--co); }
.checks.is-compact { border: 0; border-radius: 0; }
.checks.is-compact .ck { grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; padding: 9px 14px; }
.checks.is-compact .ck:last-child { border-bottom: 0; }
.ck-detail { grid-column: 2 / -1; }

/* ---------- 27. File list (Tài liệu) ---------- */
.ftype { display: inline-grid; place-items: center; width: 26px; height: 18px; border-radius: var(--r-1); font-size: 9.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink-inv); }
.ftype.pdf { background: oklch(0.50 0.17 27); }
.ftype.xls { background: oklch(0.48 0.11 152); }
.ftype.doc { background: oklch(0.48 0.12 255); }
.ftype.img { background: oklch(0.55 0.10 300); }
.ftype.txt { background: oklch(0.50 0.01 335); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px; border: 1.5px dashed var(--ctl-border); border-radius: var(--r-3); background: var(--surface-2); color: var(--ink-2); font-size: var(--t-sm); text-align: center; }
.drop .i { width: 24px; height: 24px; color: var(--ink-3); }
.drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.progress { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
.progress.is-err > span { background: var(--danger); }

/* ---------- 28. Large mode details (Thủ quỹ / Thủ kho) ---------- */
.is-large .toolbar .tb, .is-large .vf-bar .tb { height: 40px; padding: 0 14px; font-size: var(--t-md); }
.is-large .dg td, .is-large .dg th { padding: 0 12px; }
.is-large .dg thead th { font-size: 14px; }
.is-large .dg .c-chk input { width: 20px; height: 20px; }
.is-large .subtab { height: 44px; font-size: var(--t-md); padding: 0 16px; }
.is-large .filterbar .input, .is-large .filterbar .select { height: 36px; font-size: var(--t-sm); }
.is-large .fb-f { font-size: var(--t-sm); }
.is-large .btn { font-size: var(--t-md); }
.is-large .chip { height: 24px; font-size: 13px; padding: 0 9px; }
.is-large .gridfoot { height: 40px; font-size: var(--t-sm); }
.is-large .mod { height: 40px; font-size: 15px; }
.is-large .quick a { height: 36px; font-size: 14px; }
.is-large .seg a, .is-large .seg button { font-size: var(--t-sm); padding: 0 12px; }
.is-large .topbar .t-txt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.big-act { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; font-size: 16px; font-weight: 600; }
.qty-in { width: 110px; height: 36px; text-align: right; font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- 29b. Chrome links behave like buttons ---------- */
.menu-btn, .fsearch, .tool, .user, .tabs-more, .side-foot, .otab, .subtab, .mod, .tb, .rc-g, .menu-item, .fs-res, .remind-item { text-decoration: none; white-space: nowrap; }
.menu-btn { display: inline-flex; align-items: center; }
.subtabs { overflow-y: hidden; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab { margin-bottom: 0; }

/* Keep wide grids inside their pane: every flex/grid ancestor may shrink. */
body.app { grid-template-columns: minmax(0, 1fr); }
.main > *, .content, .vf-scroll > *, .vf-top > *, .vf-grid, .modpage > *, .pane > *, .split > *, .detail > *, .twopane > *, .rc > *, .settings > * { min-width: 0; }
.vf-tab > span u { text-decoration: underline; text-underline-offset: 2px; border: 0; }
.vf-bar { flex-wrap: nowrap; overflow: hidden; }
.vf-bar .tb { padding: 0 7px; gap: 5px; }
.vf-bar .tb-sep { margin: 0 3px; }
.menu-btn { padding: 0 8px; }
.fsearch { width: 250px; }

/* ---------- 29a. Popover anchors ---------- */
.menu-anchor { position: relative; display: inline-flex; align-items: center; height: 100%; }
.statusline .menu-anchor > a.sl-item { height: 26px; }
.statusline .menu-anchor > a.sl-item:hover { background: var(--sunk); color: var(--ink); }
.tabstrip .menu-anchor { height: auto; align-self: flex-end; }
.mb-2 { margin-bottom: var(--s-3); }

/* ---------- 29. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------- 30. Narrow desktop (1366x768 and zoomed) ---------- */
@media (max-width: 1400px) {
  :root { --w-side: 196px; }
  .fsearch { width: 220px; }
  .tool .tool-label { display: none; }
}
@media (max-width: 1180px) {
  .fsearch .grow { display: none; }
  .fsearch { width: auto; }
  .tool .t-txt { display: none; }
}

/* ---------- 31. Print ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body, body.app { display: block; height: auto; overflow: visible; background: oklch(1 0 0); min-width: 0; }
  .topbar, .side, .tabstrip, .band, .statusline, .pv-bar, .rpt-bar, .no-print, .scrim, .dlg { display: none !important; }
  .frame, .main { display: block; }
  .content, .pv, .pv-stage, .rpt-stage { overflow: visible; height: auto; padding: 0; background: none; }
  .sheet, .rpt-doc { box-shadow: none; border: 0; margin: 0; width: auto; min-height: 0; padding: 0; }
  .rt thead, .st thead { display: table-header-group; }
  .rt tr, .st tr { break-inside: avoid; }
}

/* 29c. Print preview pages, wide filter fields */
.sheet + .sheet { margin-top: 24px; }
.sheet .st td.c { text-align: center; }
.sheet .st tr.colno th { font-weight: 400; font-style: italic; font-size: 11px; padding: 1px 4px; }
.sheet .st tfoot td { font-weight: 700; }
.pv-bar { white-space: nowrap; overflow: hidden; }
.fb-f .w-xwide { width: 330px; }

/* Grouped header row above a grid header (Theo sổ / Kiểm kê / Chênh lệch …) */
.dg thead th.grp { text-align: center; font-size: var(--t-xs); font-weight: 600; letter-spacing: 0.01em; border-bottom: 1px solid var(--line-2); }

/* 29d. Timesheet (Bảng chấm công): one narrow column per day */
table.dg.ts { width: max-content; min-width: 100%; }
.dg.ts th.d, .dg.ts td.d { width: 27px; min-width: 27px; max-width: 27px; padding: 0; text-align: center; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }
.dg.ts th.d { line-height: 1.15; padding: 3px 0; font-family: inherit; }
.dg.ts th.d small { display: block; font-size: 10px; font-weight: 500; color: var(--ink-3); }
.dg.ts .wk { background: color-mix(in oklch, var(--line) 55%, var(--surface)); color: var(--ink-3); }
.vf-grid.xtall .dg-wrap { max-height: 462px; }
.dg.ts td.s-p { color: var(--info); font-weight: 600; }
.dg.ts td.s-o { color: var(--warn); font-weight: 600; }
.dg.ts td.s-k { color: var(--danger); font-weight: 600; }
.dg.ts td.s-n { color: var(--ink-4); }
.dg.ts td.is-active { box-shadow: inset 0 0 0 2px var(--brand); background: var(--surface); }
.dg.ts td.is-err-cell { box-shadow: inset 0 0 0 2px var(--danger); }
.dg.ts th.sticky, .dg.ts td.sticky { position: sticky; left: 0; z-index: 1; background: inherit; }
.ts-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-2); }
.ts-legend b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; color: var(--ink); margin-right: 4px; }

/* 29e. Run pages (Tính giá xuất kho, Phân bổ, Tính khấu hao, Giá thành wizard) */
.runpage { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 12px; padding: 12px 14px; align-content: start; align-items: start; min-height: 0; }
.runpage > .span { grid-column: 1 / -1; }
.run-log { list-style: none; font-size: var(--t-sm); }
.run-log li { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.run-log li:last-child { border-bottom: 0; }
.run-log .when { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: var(--t-xs); }
.wiz { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.wiz > .steps { flex: none; }
.wiz-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.wiz-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-2); background: var(--surface); flex: none; }
.wiz-foot .left { margin-right: auto; font-size: var(--t-xs); color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.steps a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.steps a:hover { color: var(--brand-ink); }