/* ==========================================================================
   Sổ Bán Hàng Hoa Nam Khánh — shared mockup stylesheet (tokens + components)
   Visual contract for app/tenants/hoanamkhanh. Plain CSS, no remote assets.

   Identity: "đồng và than chì" (copper + graphite). The trade sells copper
   conductor wire and pipe; the shop counter is lit by white fluorescent tubes
   and the person at the keyboard reads numbers fast while a thợ waits. So:
   pure white work surfaces, cool graphite ink, one copper action colour, a
   sparing teal ("nước") second accent, hairline rules, right-aligned figures.
   Type: IBM Plex Sans (UI, data) + IBM Plex Mono (codes, document numbers).
   ========================================================================== */

/* ---------- Fonts (local, Vietnamese subsets) ---------- */
@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 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 Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/plex-mono-400-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: 400; font-display: swap; src: url("fonts/plex-mono-400-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.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: 600; font-display: swap; src: url("fonts/plex-mono-600-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: 600; font-display: swap; src: url("fonts/plex-mono-600-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; }

/* ==========================================================================
   1. Tokens
   ========================================================================== */
:root {
  /* Graphite neutrals (hue 255, cool) */
  --white: oklch(1 0 0);
  --canvas: oklch(0.966 0.004 255);      /* app background behind panels */
  --surface: oklch(1 0 0);               /* panels, grid, tables */
  --surface-2: oklch(0.982 0.003 255);   /* table heads, footers, gutters */
  --sunk: oklch(0.947 0.005 255);        /* locked cells, disabled, hover */
  --line: oklch(0.905 0.006 255);        /* hairlines */
  --line-2: oklch(0.84 0.008 255);       /* section rules, grid outer border */
  --line-field: oklch(0.64 0.012 255);   /* input borders (≥ 3:1 on white) */
  --ink: oklch(0.225 0.016 255);         /* body text, figures */
  --ink-2: oklch(0.37 0.015 255);        /* secondary text, labels */
  --ink-3: oklch(0.49 0.013 255);        /* muted meta (≥ 4.5:1 on white and canvas) */
  --ink-inv: oklch(1 0 0);

  /* Copper — the brand and the only action colour */
  --cu-50: oklch(0.976 0.013 62);
  --cu-100: oklch(0.948 0.032 60);
  --cu-200: oklch(0.895 0.062 56);
  --cu-500: oklch(0.635 0.145 50);
  --cu-600: oklch(0.555 0.15 46);        /* primary fill (white text 4.7:1) */
  --cu-700: oklch(0.48 0.135 44);        /* hover, links on white (6.4:1) */
  --cu-800: oklch(0.4 0.11 42);          /* selected nav text */

  /* Teal "nước" — second accent: Giá thợ, info, dịch vụ. ≤ 10 % of any screen */
  --nc-50: oklch(0.972 0.014 210);
  --nc-100: oklch(0.935 0.034 210);
  --nc-200: oklch(0.86 0.055 212);
  --nc-600: oklch(0.5 0.09 215);
  --nc-700: oklch(0.43 0.08 220);

  /* States — always paired with an icon and a word, never colour alone */
  --ok: oklch(0.47 0.12 150);
  --ok-bg: oklch(0.962 0.033 152);
  --ok-line: oklch(0.84 0.07 150);
  --warn: oklch(0.47 0.1 70);
  --warn-bg: oklch(0.968 0.05 90);
  --warn-line: oklch(0.85 0.1 85);
  --warn-mark: oklch(0.76 0.15 80);
  --bad: oklch(0.51 0.19 26);
  --bad-bg: oklch(0.962 0.024 22);
  --bad-line: oklch(0.85 0.07 22);

  /* Type */
  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --fs-xs: 12px;     /* captions, gutter numbers */
  --fs-sm: 13px;     /* meta, table heads */
  --fs-grid: 14px;   /* Excel-like grid (PRODUCT: 14 px allowed in grids) */
  --fs-data: 15px;   /* read tables */
  --fs-body: 16px;   /* body (PRODUCT: thân bài 16 px) */
  --fs-h3: 18px;
  --fs-h2: 20px;
  --fs-h1: 24px;
  --fs-fig: 30px;    /* headline figures */
  --lh: 1.5;
  --lh-tight: 1.25;

  /* Space (4 px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;

  /* Shape, depth, layers, motion */
  --r-1: 3px;
  --r-2: 6px;
  --r-3: 10px;
  --sh-1: 0 1px 2px oklch(0.225 0.016 255 / 0.06);
  --sh-pop: 0 12px 32px -8px oklch(0.225 0.016 255 / 0.24), 0 2px 6px oklch(0.225 0.016 255 / 0.08);
  --sh-dialog: 0 24px 64px -12px oklch(0.225 0.016 255 / 0.32), 0 4px 12px oklch(0.225 0.016 255 / 0.1);
  --z-sticky: 10;
  --z-top: 20;
  --z-dropdown: 30;
  --z-scrim: 40;
  --z-dialog: 50;
  --z-toast: 60;
  --dur-1: 120ms;
  --dur-2: 200ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --side-w: 236px;
  --top-h: 56px;
  --row-h: 34px;     /* grid row */
}

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  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(--fs-h1); }
h2 { font-size: var(--fs-h3); }
h3 { font-size: var(--fs-body); }
p { margin: 0; text-wrap: pretty; }
a { color: var(--cu-700); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--cu-800); }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; }
button, input, select, textarea { font: inherit; color: inherit; }
mark { background: var(--cu-100); color: var(--ink); border-radius: 2px; padding: 0 1px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }

:focus-visible { outline: 2px solid var(--cu-600); outline-offset: 2px; }

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: var(--z-toast); padding: 10px 14px; background: var(--ink); color: var(--ink-inv); border-radius: var(--r-1); font-weight: 600; }
.skip:focus { top: 8px; color: var(--ink-inv); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.92em; 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(--bad); }
.pos { color: var(--ok); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: var(--sp-3); }
.stack-lg > * + * { margin-top: var(--sp-5); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.void-text { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--ink-3); }

/* Money: figure + small unit, aligned on the digits */
.tien { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tien small { font-size: 0.78em; font-weight: 500; color: var(--ink-3); margin-left: 2px; }

/* ==========================================================================
   3. Icons (inline sprite, 24 grid, stroke)
   ========================================================================== */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i-sm { width: 15px; height: 15px; vertical-align: -2px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 32px; height: 32px; stroke-width: 1.6; }

/* Brand mark: cable cross-section (graphite sheath, copper core) */
.mark { display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; }
.mark svg { width: 100%; height: 100%; display: block; }
.mark-lg { width: 52px; height: 52px; }

/* ==========================================================================
   4. Buttons, keys
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  font-size: 15px; font-weight: 600; line-height: 1;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-field); border-radius: var(--r-1);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn:active { background: var(--sunk); }
.btn .i { margin-left: -2px; }
.btn-primary { background: var(--cu-600); border-color: var(--cu-600); color: var(--ink-inv); }
.btn-primary:hover { background: var(--cu-700); border-color: var(--cu-700); color: var(--ink-inv); }
.btn-primary:active { background: var(--cu-800); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunk); border-color: transparent; }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: var(--ink-inv); }
.btn-danger-solid:hover { background: oklch(0.45 0.18 26); color: var(--ink-inv); }
.btn-link { min-height: 0; padding: 0; border: 0; background: none; color: var(--cu-700); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { background: none; color: var(--cu-800); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 16px; }
.btn-xl { min-height: 56px; padding: 0 24px; font-size: 18px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn[disabled], .btn.is-disabled, .btn[aria-disabled="true"] { background: var(--sunk); border-color: var(--line); color: var(--ink-3); cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-1) 0 0 var(--r-1); }
.btn-group .btn:last-child { border-radius: 0 var(--r-1) var(--r-1) 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-primary + .btn-primary { border-left-color: var(--cu-700); }

.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px; font-family: var(--mono); font-size: 12px; font-weight: 500; 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); white-space: nowrap; }
.btn .kbd { height: 20px; min-width: 20px; font-size: 11.5px; margin-right: -4px; }
.btn-primary .kbd { color: var(--ink-inv); background: oklch(1 0 0 / 0.12); border-color: oklch(1 0 0 / 0.38); }
.btn[disabled] .kbd { color: var(--ink-3); background: transparent; }

/* ==========================================================================
   5. Forms
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.label .opt, .field .opt { font-weight: 400; color: var(--ink-3); }
.req::after { content: " *"; color: var(--bad); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 11px;
  font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-field); border-radius: var(--r-1);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23394150' stroke-width='2.2' 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 11px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-2); }
.input:focus, .select:focus, .textarea:focus, .input.is-focus { outline: none; border-color: var(--cu-600); box-shadow: 0 0 0 1px var(--cu-600); }
.input[readonly], .input:disabled, .select:disabled, .textarea:disabled, .input.is-locked { background: var(--sunk); color: var(--ink-2); border-color: var(--line-2); cursor: not-allowed; }
.input.num, .input.tien-in { text-align: right; font-variant-numeric: tabular-nums; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); background: var(--bad-bg); }
.input.is-warn { border-color: var(--warn-mark); box-shadow: 0 0 0 1px var(--warn-mark); }
.input-lg { min-height: 48px; font-size: 18px; }
.input-xl { min-height: 56px; font-size: 24px; font-weight: 600; }
.hint { font-size: var(--fs-sm); color: var(--ink-3); line-height: 1.4; }
.err { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; font-weight: 500; color: var(--bad); line-height: 1.4; }
.err .i { margin-top: 1px; }
.warn-text { display: flex; align-items: flex-start; gap: 6px; font-size: 14px; font-weight: 500; color: var(--warn); line-height: 1.4; }
.input-group { display: flex; align-items: stretch; }
.input-group > .input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-group > .addon { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 0 10px; border: 1px solid var(--line-field); border-left: 0; border-radius: 0 var(--r-1) var(--r-1) 0; background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 600; white-space: nowrap; }
.input-group > .addon-btn { cursor: pointer; }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-icon > .input { padding-left: 36px; }
.input-icon > .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }

.check, .radio { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; min-height: 32px; }
.check input, .radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--cu-600); flex: none; }

fieldset.fs { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.fs > legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }

/* Segmented control (radio group) */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.seg > a, .seg > button, .seg > label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 0; border-radius: 4px; background: none; color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.seg > a:hover, .seg > button:hover, .seg > label:hover { color: var(--ink); background: oklch(1 0 0 / 0.6); }
.seg .is-on, .seg [aria-pressed="true"], .seg [aria-current="page"], .seg [aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1), 0 0 0 1px var(--line-2); }
.seg .count { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.field > .seg { align-self: flex-start; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.switch .track { position: relative; width: 40px; height: 24px; flex: none; border-radius: 999px; background: var(--line-field); transition: background-color var(--dur-2) var(--ease-out); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); box-shadow: var(--sh-1); transition: transform var(--dur-2) var(--ease-out); }
.switch.is-on .track { background: var(--cu-600); }
.switch.is-on .track::after { transform: translateX(16px); }

/* File drop / attachments */
.tep-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tep { display: inline-flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); font-size: 14px; text-decoration: none; color: var(--ink); max-width: 280px; }
.tep:hover { border-color: var(--ink-3); color: var(--ink); }
.tep-thumb { width: 40px; height: 40px; flex: none; border-radius: 4px; display: grid; place-items: center; color: var(--ink-3); background: repeating-linear-gradient(135deg, var(--surface-2) 0 5px, var(--sunk) 5px 10px); border: 1px solid var(--line); }
.tep-thumb.pdf { background: var(--bad-bg); color: var(--bad); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.tep-meta { min-width: 0; line-height: 1.3; }
.tep-meta strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tep-meta small { color: var(--ink-3); font-size: 12px; }
.tep-add { display: inline-flex; align-items: center; gap: 8px; min-height: 54px; padding: 0 14px; border: 1px dashed var(--line-field); border-radius: var(--r-2); background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer; }
.tep-add:hover { border-color: var(--cu-600); color: var(--cu-700); background: var(--cu-50); }

/* ==========================================================================
   6. Status tags, price-tier chips, document numbers
   ========================================================================== */
.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; border-radius: var(--r-1); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); }
.tag .i { width: 14px; height: 14px; stroke-width: 2; vertical-align: 0; }
.tag-sm { height: 20px; padding: 0 6px; font-size: 12px; }
.tag-nhap { background: var(--surface-2); color: var(--ink-2); border-style: dashed; border-color: var(--line-field); }
.tag-gui { background: var(--nc-50); color: var(--nc-700); border-color: var(--nc-200); }
.tag-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.tag-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.tag-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.tag-mute { background: var(--sunk); color: var(--ink-2); border-color: var(--line-2); }
.tag-solid-ok { background: var(--ok); color: var(--ink-inv); border-color: var(--ok); }
.tag-huy { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }

/* Price tier: Giá lẻ (neutral) / Giá thợ (teal) */
.tier { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; font-size: 12.5px; font-weight: 600; border-radius: var(--r-1); border: 1px solid var(--line-2); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
.tier-tho { color: var(--nc-700); background: var(--nc-50); border-color: var(--nc-200); }
.kind { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; font-size: 12.5px; font-weight: 500; border-radius: var(--r-1); background: var(--sunk); color: var(--ink-2); white-space: nowrap; }

/* Document number: mono, links to the source document */
.so { font-family: var(--mono); font-size: 0.9em; font-weight: 500; letter-spacing: 0; white-space: nowrap; }
a.so { color: var(--cu-700); text-decoration: none; border-bottom: 1px solid var(--cu-200); }
a.so:hover { color: var(--cu-800); border-bottom-color: var(--cu-700); }
.ma { font-family: var(--mono); font-size: 0.88em; color: var(--ink-2); white-space: nowrap; }

/* A figure that can be clicked to its source (PRODUCT principle 4) */
a.truy { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--ink-3); }
a.truy:hover { color: var(--cu-700); border-bottom: 1px solid var(--cu-700); }

/* ==========================================================================
   7. App shell (office ≥ 1024 px, designed at 1440 × 900)
   ========================================================================== */
body.office { min-width: 1024px; }
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line-2); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; height: var(--top-h); padding: 0 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand-name { min-width: 0; line-height: 1.2; }
.brand-name strong { display: block; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-name small { display: block; font-size: 12px; color: var(--ink-3); }

.side { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.nav { padding: 10px 10px 12px; flex: 1; }
.nav-group + .nav-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.nav-label { padding: 2px 10px 3px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 10px; border-radius: var(--r-2); color: var(--ink-2); text-decoration: none; font-size: 14.5px; font-weight: 500; }
.nav a .i { color: var(--ink-3); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--cu-50); color: var(--cu-800); font-weight: 600; box-shadow: inset 0 0 0 1px var(--cu-100); }
.nav a[aria-current="page"] .i { color: var(--cu-600); }
.nav .badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.nav .sub { padding-left: 38px; min-height: 32px; font-size: 14px; }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--sunk); color: var(--ink-2); font-size: 13px; font-weight: 700; border: 1px solid var(--line-2); }
.who { flex: 1; min-width: 0; line-height: 1.3; }
.who strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { display: block; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: var(--z-top); display: flex; align-items: center; gap: var(--sp-4); height: var(--top-h); padding: 0 var(--sp-7); background: var(--surface); border-bottom: 1px solid var(--line-2); }
.top-search { position: relative; width: min(480px, 42%); }
.top-search .input { min-height: 38px; padding-left: 38px; padding-right: 44px; background: var(--surface-2); border-color: var(--line-2); font-size: 15px; }
.top-search .input:focus { background: var(--surface); }
.top-search > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.top-search > .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.top-meta { font-size: 13px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.top-user { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px 0 4px; border: 1px solid transparent; border-radius: var(--r-2); background: none; cursor: pointer; text-align: left; color: var(--ink); }
.top-user:hover { background: var(--surface-2); border-color: var(--line); }
.top-user .avatar { width: 32px; height: 32px; }
.top-user .who strong { font-size: 14px; }
.top-user .who small { font-size: 12.5px; }
.top-user > .i { color: var(--ink-3); }

/* Popover menu (Tạo nhanh, more actions). Positioned outside scroll parents. */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: var(--z-dropdown); min-width: 248px; padding: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); box-shadow: var(--sh-pop); }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 4px; background: none; color: var(--ink); font-size: 15px; font-weight: 500; text-decoration: none; text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover, .menu .is-on { background: var(--cu-50); color: var(--ink); }
.menu .i { color: var(--ink-3); }
.menu .kbd { margin-left: auto; }
.menu hr { margin: 6px 0; }

.page { padding: var(--sp-6) var(--sp-7) var(--sp-9); min-width: 0; }
.page-narrow { max-width: 980px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs .i { width: 14px; height: 14px; color: var(--line-field); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; color: var(--ink-3); font-size: 15px; }
.actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ==========================================================================
   8. Panels, notes, toasts
   ========================================================================== */
.panel { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 50px; padding: 10px var(--sp-4); border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-head .meta { font-size: 13.5px; color: var(--ink-3); }
.panel-body { padding: var(--sp-4); }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 10px var(--sp-4); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-2) var(--r-2); font-size: 14px; color: var(--ink-3); }
.panel-flush > .panel-body { padding: 0; }
.section-title { font-size: 16px; font-weight: 600; margin: var(--sp-6) 0 var(--sp-3); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Notes: full border + tint + leading icon (no side stripes) */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border: 1px solid; border-radius: var(--r-2); font-size: 15px; line-height: 1.45; }
.note > .i { margin-top: 2px; }
.note strong { font-weight: 600; }
.note .grow > * + * { margin-top: 4px; }
.note .note-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.note-info { background: var(--nc-50); border-color: var(--nc-200); color: oklch(0.32 0.06 220); }
.note-info > .i { color: var(--nc-600); }
.note-warn { background: var(--warn-bg); border-color: var(--warn-line); color: oklch(0.36 0.08 65); }
.note-warn > .i { color: var(--warn); }
.note-bad { background: var(--bad-bg); border-color: var(--bad-line); color: oklch(0.38 0.14 26); }
.note-bad > .i { color: var(--bad); }
.note-ok { background: var(--ok-bg); border-color: var(--ok-line); color: oklch(0.34 0.09 150); }
.note-ok > .i { color: var(--ok); }
.note-lock { background: var(--sunk); border-color: var(--line-2); color: var(--ink-2); }
.note-lock > .i { color: var(--ink-2); }

/* Error summary above a grid: every bad cell, clickable */
.loi-tong { border: 1px solid var(--bad-line); background: var(--bad-bg); border-radius: var(--r-2); padding: 12px 14px; }
.loi-tong-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: oklch(0.38 0.14 26); }
.loi-tong-head .i { color: var(--bad); }
.loi-tong ul { list-style: none; margin-top: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; }
.loi-tong li { font-size: 14px; color: oklch(0.38 0.14 26); display: flex; gap: 8px; }
.loi-tong li a { color: inherit; font-weight: 600; white-space: nowrap; }

.toast-host { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px 10px 12px; background: var(--ink); color: var(--ink-inv); border-radius: var(--r-2); box-shadow: var(--sh-pop); font-size: 15px; font-weight: 500; max-width: 440px; animation: toast-in var(--dur-2) var(--ease-out); }
.toast .i { color: oklch(0.82 0.13 150); }
.toast .so { color: var(--ink-inv); }
.toast .btn-link { color: oklch(0.86 0.08 60); margin-left: 6px; }
.toast-bad { background: oklch(0.36 0.12 26); }
.toast-bad .i { color: oklch(0.86 0.08 26); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   9. Tabs, filters, status totals, pagination
   ========================================================================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: var(--sp-4); overflow-x: auto; }
.tabs a, .tabs button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-3); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--ink); border-bottom-color: var(--cu-600); }
.tabs .count { font-size: 12.5px; padding: 1px 7px; border-radius: 999px; background: var(--sunk); color: var(--ink-2); font-weight: 600; }

.loc { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); padding: 12px var(--sp-4); border-bottom: 1px solid var(--line); }
.loc .field { min-width: 150px; }
.loc .field.wide { flex: 1; min-width: 260px; }
.loc .field > label { font-size: 13px; }
.loc .input, .loc .select { min-height: 38px; font-size: 14.5px; }
.loc .loc-end { margin-left: auto; display: flex; gap: var(--sp-2); }
.loc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px var(--sp-4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip .n { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.chip[aria-pressed="true"], .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--ink-inv); }
.chip[aria-pressed="true"] .n, .chip.is-on .n { color: oklch(0.85 0.01 255); }
.chip .i { width: 15px; height: 15px; }

/* Status totals strip (S2): money per status, a reading row, not cards */
.tong-tt { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.tong-tt > a { display: block; padding: 12px var(--sp-4); text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); }
.tong-tt > a:last-child { border-right: 0; }
.tong-tt > a:hover { background: var(--surface-2); }
.tong-tt > a[aria-current="true"] { background: var(--cu-50); box-shadow: inset 0 -2px 0 var(--cu-600); }
.tong-tt .k { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.tong-tt .v { display: block; margin-top: 4px; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tong-tt .c { font-size: 13px; color: var(--ink-3); }

.trang { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--sp-4); border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
.trang .pages { display: flex; gap: 4px; }
.trang .pages a, .trang .pages span { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--r-1); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 600; }
.trang .pages [aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--ink-inv); }
.trang .pages .gap { border: 0; background: none; }

/* ==========================================================================
   10. Read tables (lists, ledgers, reports)
   ========================================================================== */
.bang-wrap { overflow-x: auto; }
table.bang { width: 100%; font-size: var(--fs-data); }
.bang th, .bang td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.bang thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: 13.5px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line-2); white-space: nowrap; height: 42px; }
.bang thead th .i { width: 14px; height: 14px; color: var(--ink-3); }
.bang th.num, .bang td.num { text-align: right; }
.bang th.center, .bang td.center { text-align: center; }
.bang tbody tr:hover td { background: var(--surface-2); }
.bang td.ten { min-width: 220px; }
.bang td.ten small { display: block; font-size: 13px; color: var(--ink-3); margin-top: 1px; }
.bang .sub-line { display: block; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bang td.act { text-align: right; white-space: nowrap; width: 1%; }
.bang tr.is-void td { color: var(--ink-3); background: repeating-linear-gradient(135deg, transparent 0 8px, oklch(0.5 0 0 / 0.025) 8px 16px); }
.bang tr.is-void td.num, .bang tr.is-void td .so, .bang tr.is-void td .ten-k { text-decoration: line-through; text-decoration-thickness: 1px; }
.bang tr.is-sel td { background: var(--cu-50); }
.bang tr.is-flash td { background: var(--ok-bg); }
.bang tr.mo td { background: var(--surface-2); color: var(--ink-2); font-style: italic; }
.bang tr.mo td.num { font-style: normal; }
.bang tr.nhom td { background: var(--sunk); font-weight: 600; font-size: 14px; color: var(--ink-2); }
.bang tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
.bang tfoot tr.tong td { font-size: 16px; border-top: 2px solid var(--ink); }
.bang td.run { font-weight: 600; background: oklch(0.982 0.003 255 / 0.7); }
.bang td.cot-an { color: var(--ink-3); text-align: center; }
.bang-compact th, .bang-compact td { padding: 7px 10px; }
.bang-compact thead th { height: 36px; }
.bang tr.dong-link { cursor: pointer; }
.bang .vao { color: var(--ok); }
.bang .ra { color: var(--ink); }

/* ==========================================================================
   11. Overview (S1)
   ========================================================================== */
.tq-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: var(--sp-4); }
.tq-band { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.tq-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-right: 1px solid var(--line); }
.fig { padding: 18px 20px 16px; text-decoration: none; color: var(--ink); display: block; border-right: 1px solid var(--line); }
.fig:last-child { border-right: 0; }
a.fig:hover { background: var(--surface-2); color: var(--ink); }
.fig .k { font-size: 14px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.fig .v { display: block; margin-top: 6px; font-size: var(--fs-fig); font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fig .v small { font-size: 15px; font-weight: 500; color: var(--ink-3); margin-left: 3px; letter-spacing: 0; }
.fig .d { margin-top: 6px; font-size: 13.5px; color: var(--ink-3); }
.fig .d .up { color: var(--ok); font-weight: 600; }
.fig .d .down { color: var(--bad); font-weight: 600; }
.tq-month { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 28px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 14px; color: var(--ink-2); border-radius: 0 0 var(--r-2) var(--r-2); }
.tq-month strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.tq-chart { padding: 14px 20px 12px; display: flex; flex-direction: column; min-width: 0; }
.tq-chart .k { font-size: 14px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; }
.bars { flex: 1; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); align-items: end; gap: 5px; min-height: 92px; margin-top: 10px; padding-bottom: 2px; border-bottom: 1px solid var(--line-2); }
.bars span { display: block; background: var(--line-2); border-radius: 2px 2px 0 0; min-height: 3px; }
.bars span.cn { background: var(--sunk); }
.bars span.today { background: var(--cu-600); }
.bars-x { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 5px; margin-top: 4px; font-size: 11.5px; color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }
.bars-x .today { color: var(--cu-700); font-weight: 600; }

.tq-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--sp-4); margin-top: var(--sp-4); }
.so-du { list-style: none; }
.so-du li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px var(--sp-4); border-bottom: 1px solid var(--line); }
.so-du li:last-child { border-bottom: 0; }
.so-du .k { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 15px; min-width: 0; }
.so-du .k small { color: var(--ink-3); font-size: 13px; }
.so-du .v { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.so-du li.tong { background: var(--surface-2); }
.so-du li.tong .k { font-weight: 600; color: var(--ink); }
.so-du li.tong .v { font-size: 19px; }
.so-du .ghi { display: block; font-size: 13px; color: var(--ink-3); font-weight: 400; }

/* "Việc cần làm": action list — count + sentence + chevron */
.viec { list-style: none; }
.viec li + li { border-top: 1px solid var(--line); }
.viec a { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px var(--sp-4); text-decoration: none; color: var(--ink); min-height: 60px; }
.viec a:hover { background: var(--surface-2); color: var(--ink); }
.viec .n { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); }
.viec .n.warn { color: var(--warn); }
.viec .n.bad { color: var(--bad); }
.viec .t strong { display: block; font-weight: 600; font-size: 15px; }
.viec .t small { display: block; font-size: 13.5px; color: var(--ink-3); }
.viec .i { color: var(--ink-3); }

.start-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px 20px; border: 1px dashed var(--cu-200); background: var(--cu-50); border-radius: var(--r-2); }
.start-card .step { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--cu-200); color: var(--cu-700); }
.start-steps { list-style: none; counter-reset: s; display: grid; gap: 0; }
.start-steps li { counter-increment: s; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px var(--sp-4); border-bottom: 1px solid var(--line); }
.start-steps li:last-child { border-bottom: 0; }
.start-steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--sunk); color: var(--ink-2); }
.start-steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.start-steps strong { display: block; font-weight: 600; }
.start-steps small { color: var(--ink-3); font-size: 13.5px; }

/* ==========================================================================
   12. Documents: bar, header form, customer box, totals, payment, status track
   ========================================================================== */
.doc-bar { position: sticky; top: var(--top-h); z-index: var(--z-sticky); display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-7); background: var(--surface); border-bottom: 1px solid var(--line-2); min-height: 60px; }
.doc-bar h1 { font-size: 20px; display: flex; align-items: center; gap: 10px; }
.doc-bar .so { font-size: 15px; color: var(--ink-2); }
.doc-bar .meta { font-size: 13.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.doc-bar .actions { margin-left: auto; }
.autosave { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink-3); }
.autosave .i { color: var(--ok); }

.phieu { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-4); align-items: start; }
.phieu-1 { display: block; }
.phieu-main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.phieu-side { display: flex; flex-direction: column; gap: var(--sp-4); position: sticky; top: calc(var(--top-h) + 76px); }

.dau-phieu { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; padding: var(--sp-4); }
.dau-phieu .c-2 { grid-column: span 2; } .dau-phieu .c-3 { grid-column: span 3; } .dau-phieu .c-4 { grid-column: span 4; } .dau-phieu .c-5 { grid-column: span 5; } .dau-phieu .c-6 { grid-column: span 6; } .dau-phieu .c-8 { grid-column: span 8; } .dau-phieu .c-12 { grid-column: 1 / -1; }
.dau-phieu .input, .dau-phieu .select { min-height: 38px; }
.dau-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--sp-4); align-items: stretch; }
.duoi-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: var(--sp-4); align-items: start; }
.doc-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.lich-su { list-style: none; }
.lich-su li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 9px var(--sp-4); border-bottom: 1px solid var(--line); font-size: 14px; }
.lich-su li:last-child { border-bottom: 0; }
.lich-su time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.from-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px var(--sp-4); border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: 14px; color: var(--ink-2); border-radius: var(--r-2) var(--r-2) 0 0; }

/* Customer combobox with live debt facts */
.combo { position: relative; }
.combo .input { padding-right: 70px; font-weight: 500; }
.combo .combo-end { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; align-items: center; }
.the-khach { border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); }
.the-khach-head { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.the-khach-head strong { display: block; font-size: 16px; font-weight: 600; }
.the-khach-head small { display: block; color: var(--ink-3); font-size: 13.5px; }
.no-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.no-dl > div { padding: 10px 14px; border-right: 1px solid var(--line); }
.no-dl > div:last-child { border-right: 0; }
.no-dl dt, .no-dl .k { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.no-dl dd, .no-dl .v { margin: 2px 0 0; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter { height: 6px; border-radius: 999px; background: var(--sunk); overflow: hidden; margin: 0 14px 12px; }
.meter > span { display: block; height: 100%; background: var(--nc-600); border-radius: 999px; }
.meter.warn > span { background: var(--warn-mark); }
.meter.bad > span { background: var(--bad); }
.meter-cap { display: flex; justify-content: space-between; padding: 8px 14px 6px; font-size: 13px; color: var(--ink-3); }

/* Totals list */
.tong { list-style: none; padding: 6px 0; }
.tong li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 16px; font-size: 15px; color: var(--ink-2); }
.tong li .v { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.tong li.tong-cong { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line-2); color: var(--ink); font-weight: 600; font-size: 16px; }
.tong li.tong-cong .v { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.tong li.no { color: var(--warn); font-weight: 600; }
.tong li.no .v { color: var(--warn); }
.tong li.sub { font-size: 14px; color: var(--ink-3); padding-top: 2px; }
.bang-chu { padding: 0 16px 12px; font-size: 13.5px; color: var(--ink-3); font-style: italic; }

/* Payment panel (S6) */
.thanh-toan { padding: 14px 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.tt-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 8px; align-items: end; }
.tt-out { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; border-radius: var(--r-2); background: var(--surface-2); border: 1px solid var(--line); font-size: 15px; }
.tt-out .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tt-out.thua { background: var(--ok-bg); border-color: var(--ok-line); color: oklch(0.34 0.09 150); }
.tt-out.no { background: var(--warn-bg); border-color: var(--warn-line); color: oklch(0.36 0.08 65); }
.tt-out.bad { background: var(--bad-bg); border-color: var(--bad-line); color: oklch(0.38 0.14 26); }
.phieu-side .no-dl { grid-template-columns: 1fr; }
.phieu-side .no-dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
.phieu-side .no-dl > div:last-child { border-bottom: 0; }
.phieu-side .no-dl dt { font-size: 13.5px; }
.phieu-side .no-dl dd { font-size: 15px; margin: 0; }
.phieu-side .the-khach-head { padding: 10px 14px; }
.phieu-side .tong { padding: 4px 0; }
.phieu-side .tong li { padding: 4px 16px; }
.phieu-side .tong li.tong-cong { padding-top: 10px; margin-top: 4px; }
.phieu-side .thanh-toan { padding: 12px 16px; gap: 10px; }
.tt-row { grid-template-columns: minmax(0, 1fr) 136px; }
.tt-row .input, .tt-row .select { min-height: 48px; }
.tt-row .input { font-size: 18px; font-weight: 600; }
.tt-row .select { font-size: 14px; padding-right: 28px; background-position: right 8px center; }
.side-actions { display: grid; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-2) var(--r-2); }
.side-actions .btn { width: 100%; justify-content: space-between; }

/* Status track: the quote's life as a wire with junctions */
.track { display: flex; align-items: center; list-style: none; padding: 14px var(--sp-4); gap: 0; }
.track li { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.track li + li::before { content: ""; width: 48px; height: 2px; background: var(--line-2); margin: 0 12px; }
.track .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-field); background: var(--surface); flex: none; }
.track li.done { color: var(--ink-2); }
.track li.done .dot { background: var(--cu-600); border-color: var(--cu-600); }
.track li.done + li::before, .track li.now::before { background: var(--cu-600); }
.track li.now { color: var(--ink); }
.track li.now .dot { border-color: var(--cu-600); box-shadow: 0 0 0 4px var(--cu-100); background: var(--cu-600); }
.track li.off { color: var(--ink-3); }
.track li.off .dot { border-style: dashed; }
.track .track-note { margin-left: auto; font-size: 13.5px; font-weight: 400; color: var(--ink-3); }

.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 15px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; font-weight: 500; }
.dl-2 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.dl-2 > div { padding: 12px var(--sp-4); border-right: 1px solid var(--line); min-width: 0; }
.dl-2 > div:last-child { border-right: 0; }
.dl-2 dt { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.dl-2 dd { margin: 3px 0 0; font-size: 15px; font-weight: 500; }

/* ==========================================================================
   13. Excel-like line grid (role="grid")
   ========================================================================== */
.luoi-khung { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.luoi-tool { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 12px; border-bottom: 1px solid var(--line-2); min-height: 50px; white-space: nowrap; }
.luoi-tool h2 { font-size: 15px; font-weight: 600; margin-right: 6px; white-space: nowrap; }
.luoi-tool .hint { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.luoi-tool .count { font-size: 13.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.luoi-tool .sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.luoi-cuon { overflow: auto; max-height: 520px; }
table.luoi { width: 100%; min-width: 980px; table-layout: fixed; font-size: var(--fs-grid); border-collapse: separate; border-spacing: 0; }
.luoi th, .luoi td { height: var(--row-h); padding: 0 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.luoi thead th { position: sticky; top: 0; z-index: 2; height: 32px; background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: left; border-bottom: 1px solid var(--line-2); }
.luoi thead th.num { text-align: right; }
.luoi thead th .i { width: 13px; height: 13px; color: var(--ink-3); }
.luoi th:last-child, .luoi td:last-child { border-right: 0; }
.luoi .gutter { width: 40px; padding: 0; text-align: center; background: var(--surface-2); color: var(--ink-3); font-family: var(--mono); font-size: 12px; position: sticky; left: 0; z-index: 1; }
.luoi thead .gutter { z-index: 3; }
.luoi td.num { text-align: right; font-variant-numeric: tabular-nums; }
.luoi td.khoa { color: var(--ink-2); background: var(--surface-2); }
.luoi td.ma-o { font-family: var(--mono); font-size: 13px; }
.luoi td .unit-pick { display: inline-flex; align-items: center; gap: 4px; }
.luoi td .unit-pick .i { width: 12px; height: 12px; color: var(--ink-3); }
.luoi td.ton { color: var(--ink-3); font-size: 13px; }
.luoi td.ton .thieu { color: var(--warn); font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.luoi td.ton .thieu .i { width: 13px; height: 13px; }
.luoi td.dv { color: var(--ink-3); font-style: italic; font-size: 13px; }
.luoi tr.active-row .gutter { background: var(--cu-100); color: var(--cu-800); font-weight: 600; }
.luoi td.o-chon { box-shadow: inset 0 0 0 2px var(--cu-600); background: var(--surface); position: relative; }
.luoi td.o-sua { box-shadow: inset 0 0 0 2px var(--cu-600); background: var(--surface); color: var(--ink); overflow: visible; }
.luoi td.o-sua .caret { display: inline-block; width: 1px; height: 16px; margin-left: 1px; vertical-align: -3px; background: var(--ink); animation: blink 1s steps(1) infinite; }
.luoi td.o-vung { background: var(--cu-50); }
.luoi td.o-loi { background: var(--bad-bg); color: oklch(0.38 0.14 26); position: relative; }
.luoi td.o-loi::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 8px 8px 0; border-color: transparent var(--bad) transparent transparent; }
.luoi td.o-canh { background: var(--warn-bg); position: relative; }
.luoi td.o-canh::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 8px 8px 0; border-color: transparent var(--warn-mark) transparent transparent; }
.luoi td.o-doi { background: var(--nc-50); position: relative; font-weight: 600; }
.luoi td.o-doi::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--nc-600) transparent transparent; }
.luoi td.o-loi.o-chon { box-shadow: inset 0 0 0 2px var(--bad); }
.luoi tr.nhom-dong td { background: var(--sunk); font-weight: 600; color: var(--ink); }
.luoi tr.nhom-dong td.ten-nhom { overflow: visible; }
.luoi tr.nhom-dong .tag { margin-right: 6px; }
.luoi tr.tieu-ket td { background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.luoi tr.dong-moi td { color: var(--ink-3); }
.luoi tr.dong-moi td.go { font-style: italic; }
.luoi tr.dong-0 td:not(.gutter) { color: var(--ink-3); }
.luoi tr.dem-lai td:not(.gutter) { background: var(--warn-bg); }
.luoi .flag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--r-1); font-size: 12px; font-weight: 600; background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.luoi .flag .i { width: 12px; height: 12px; }
.luoi .flag-bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.luoi .flag-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.luoi .flag-mute { background: var(--sunk); color: var(--ink-2); border-color: var(--line-2); }
.luoi .goi-y-gia { color: var(--ink-3); font-size: 12px; margin-right: 6px; }
.luoi.chu-to { font-size: 16px; }
.luoi.chu-to th, .luoi.chu-to td { height: 40px; }
@keyframes blink { 50% { opacity: 0; } }

/* Cell error bubble (anchored under the active bad cell) */
.o-bubble { position: absolute; z-index: var(--z-dropdown); max-width: 340px; padding: 8px 10px; background: var(--bad); color: var(--ink-inv); font-size: 13.5px; font-weight: 500; line-height: 1.4; border-radius: var(--r-1); box-shadow: var(--sh-pop); }
.o-bubble::before { content: ""; position: absolute; top: -5px; left: 14px; width: 10px; height: 10px; background: var(--bad); transform: rotate(45deg); }
.o-bubble.warn { background: oklch(0.42 0.09 68); }
.o-bubble.warn::before { background: oklch(0.42 0.09 68); }

/* Grid footer: totals + keyboard legend */
.luoi-chan > span:first-child { white-space: nowrap; }
.luoi-chan { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 12px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--r-2) var(--r-2); font-size: 13.5px; color: var(--ink-3); }
.phim { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--ink-3); }
.phim span { display: inline-flex; align-items: center; gap: 5px; }

/* Suggestion list for the Mã hàng cell */
.goi-y { position: absolute; z-index: var(--z-dropdown); width: 640px; background: var(--surface); border: 1px solid var(--line-field); border-radius: var(--r-2); box-shadow: var(--sh-pop); overflow: hidden; }
.goi-y-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 13px; color: var(--ink-3); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.goi-y ul { list-style: none; }
.goi-y li { display: grid; grid-template-columns: 92px minmax(0, 1fr) 128px 100px 92px; gap: 10px; align-items: center; min-height: 42px; padding: 4px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.goi-y li:last-child { border-bottom: 0; }
.goi-y li.is-on { background: var(--cu-50); box-shadow: inset 0 0 0 1px var(--cu-200); }
.goi-y .ma { font-size: 12.5px; }
.goi-y .ten-k { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goi-y .dvts { font-size: 12.5px; color: var(--ink-3); }
.goi-y .gia { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.goi-y .gia small { display: block; font-size: 11.5px; font-weight: 500; color: var(--nc-700); }
.goi-y .tonk { text-align: right; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.goi-y-foot { display: flex; gap: 14px; padding: 7px 12px; font-size: 12.5px; color: var(--ink-3); background: var(--surface-2); border-top: 1px solid var(--line); }

/* "Chưa khớp" side panel after a paste */
.chua-khop { border: 1px solid var(--bad-line); border-radius: var(--r-2); background: var(--surface); }
.chua-khop-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--bad-line); background: var(--bad-bg); color: oklch(0.38 0.14 26); font-weight: 600; border-radius: var(--r-2) var(--r-2) 0 0; }
.chua-khop ol { list-style: none; }
.chua-khop li { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chua-khop li:last-child { border-bottom: 0; }
.chua-khop .src { font-weight: 600; }
.chua-khop .src small { font-weight: 400; color: var(--ink-3); }
.chua-khop .why { font-size: 13.5px; color: var(--bad); margin-top: 2px; }
.chua-khop .gan { margin-top: 8px; display: grid; gap: 4px; }
.chua-khop .gan a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: var(--r-1); font-size: 13.5px; text-decoration: none; color: var(--ink); }
.chua-khop .gan a:hover { border-color: var(--cu-600); background: var(--cu-50); }
.chua-khop .gan a span { color: var(--ink-3); }

/* ==========================================================================
   14. Dialog, scrim, drawer
   ========================================================================== */
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: oklch(0.225 0.016 255 / 0.42); }
.dialog { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: var(--z-dialog); width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border-radius: var(--r-3); box-shadow: var(--sh-dialog); }
.dialog-wide { width: min(640px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 8px; }
.dialog-head .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--sunk); color: var(--ink-2); }
.dialog-head .ic.warn { background: var(--warn-bg); color: var(--warn); }
.dialog-head .ic.bad { background: var(--bad-bg); color: var(--bad); }
.dialog-head h2 { font-size: 19px; }
.dialog-head p { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.dialog-body { padding: 10px 22px 18px; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-3) var(--r-3); }
.dialog-foot .left { margin-right: auto; font-size: 13.5px; color: var(--ink-3); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-dialog); width: min(520px, 100vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--sh-dialog); border-left: 1px solid var(--line-2); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* Reason chips (Không thành, Hủy) */
.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reasons label { position: relative; }
.reasons input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.reasons span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-field); border-radius: var(--r-1); font-size: 15px; font-weight: 500; cursor: pointer; background: var(--surface); }
.reasons input:checked + span { border-color: var(--cu-600); background: var(--cu-50); box-shadow: inset 0 0 0 1px var(--cu-600); font-weight: 600; }
.reasons input:focus-visible + span { outline: 2px solid var(--cu-600); outline-offset: 2px; }

/* ==========================================================================
   15. Empty, loading
   ========================================================================== */
.trong { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; color: var(--ink-2); }
.trong .ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--ink-3); margin-bottom: 4px; }
.trong strong { font-size: 17px; color: var(--ink); }
.trong p { max-width: 52ch; color: var(--ink-3); font-size: 15px; }
.trong .actions { margin-top: 8px; justify-content: center; }
.sk { display: block; height: 12px; border-radius: 3px; 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; } }

/* ==========================================================================
   16. Print sheets (A4 / A5) — preview on screen, real output on paper
   ========================================================================== */
body.print-view { background: oklch(0.9 0.006 255); min-width: 1024px; }
.in-bar { position: sticky; top: 0; z-index: var(--z-top); display: flex; align-items: center; gap: var(--sp-3); height: 60px; padding: 0 var(--sp-7); background: var(--surface); border-bottom: 1px solid var(--line-2); }
.in-bar h1 { font-size: 17px; display: flex; align-items: center; gap: 10px; }
.in-bar .actions { margin-left: auto; }
.in-stage { padding: 28px 0 56px; display: flex; flex-direction: column; align-items: center; gap: 24px; }
.giay { width: 794px; min-height: 1123px; padding: 56px 60px 64px; background: #fff; color: #111; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 12px 32px -12px rgba(0,0,0,.25); font-size: 13px; line-height: 1.45; }
.giay.a5 { width: 559px; min-height: 794px; padding: 36px 36px 40px; font-size: 12px; }
.giay .ld { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding-bottom: 14px; border-bottom: 2px solid #111; }
.giay .ld .mark { width: 46px; height: 46px; }
.giay.a5 .ld .mark { width: 36px; height: 36px; }
.giay .ld strong { display: block; font-size: 16px; letter-spacing: -0.01em; text-transform: uppercase; }
.giay.a5 .ld strong { font-size: 13.5px; }
.giay .ld p { font-size: 12px; color: #333; line-height: 1.5; }
.giay.a5 .ld p { font-size: 10.5px; }
.giay .ld .so-box { text-align: right; font-size: 12px; color: #333; line-height: 1.6; }
.giay .ld .so-box .so { font-size: 13px; color: #111; font-weight: 600; }
.giay h1.tieu-de { margin: 22px 0 4px; text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.giay.a5 h1.tieu-de { font-size: 18px; margin-top: 14px; }
.giay .tieu-de-sub { text-align: center; font-size: 12.5px; color: #333; }
.giay .kh { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; margin: 18px 0 14px; font-size: 13px; }
.giay.a5 .kh { font-size: 11.5px; margin: 12px 0 10px; grid-template-columns: 1fr; }
.giay .kh div { display: flex; gap: 6px; }
.giay .kh span { color: #555; white-space: nowrap; }
.giay table.in { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.giay.a5 table.in { font-size: 11px; }
.giay table.in th, .giay table.in td { border: 1px solid #444; padding: 5px 7px; vertical-align: top; }
.giay table.in thead th { background: #eee; font-weight: 600; text-align: center; font-size: 12px; }
.giay table.in td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.giay table.in td.c { text-align: center; }
.giay table.in tr.nhom td { background: #f4f4f4; font-weight: 600; }
.giay table.in tr.tk td { font-weight: 600; font-style: italic; }
.giay table.in tfoot td { font-weight: 600; }
.giay table.in tfoot tr.tc td { font-size: 14px; background: #eee; }
.giay .chu { margin-top: 10px; font-size: 13px; }
.giay .chu em { font-weight: 600; }
.giay .dk { margin-top: 14px; font-size: 12.5px; color: #222; }
.giay .dk ol { padding-left: 18px; margin-top: 4px; }
.giay .ky { display: grid; grid-template-columns: repeat(2, 1fr); text-align: center; margin-top: 26px; font-size: 13px; }
.giay .ky.ba { grid-template-columns: repeat(3, 1fr); }
.giay .ky strong { display: block; }
.giay .ky small { display: block; color: #555; font-style: italic; }
.giay .ky .ten-ky { margin-top: 64px; font-weight: 600; }
.giay.a5 .ky .ten-ky { margin-top: 44px; }
.giay .ngay-ky { text-align: right; font-style: italic; margin-top: 16px; font-size: 13px; }
.giay .chan-in { margin-top: 18px; padding-top: 8px; border-top: 1px solid #bbb; font-size: 11px; color: #555; display: flex; justify-content: space-between; }
.giay .lan-sua { display: inline-block; padding: 1px 8px; border: 1px solid #111; font-size: 11.5px; font-weight: 600; margin-top: 4px; }
.giay .void-stamp { display: inline-block; padding: 2px 10px; border: 2px solid #b3261e; color: #b3261e; font-weight: 700; letter-spacing: .08em; transform: rotate(-4deg); }

/* Spreadsheet preview (xlsx layout mockups) */
.xl-wrap { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); overflow: auto; }
table.xl { border-collapse: collapse; font-family: Calibri, "Segoe UI", Arial, sans-serif; font-size: 13px; }
.xl th.col, .xl td.rn { background: #f0f2f5; color: #666; font-weight: 400; font-size: 12px; text-align: center; border: 1px solid #d4d8de; }
.xl th.col { height: 22px; }
.xl td.rn { width: 36px; }
.xl td { height: 22px; padding: 0 6px; border: 1px solid #e1e4e8; white-space: nowrap; }
.xl td.b { font-weight: 700; }
.xl td.h { background: #e9ecef; font-weight: 700; text-align: center; border-color: #9aa1aa; }
.xl td.n { text-align: right; }
.xl td.t { font-size: 16px; font-weight: 700; }
.xl td.g { background: #f6f6f6; font-weight: 700; }
.xl td.tc { font-weight: 700; border-top: 2px solid #333; }
.xl-tabs { display: flex; gap: 2px; padding: 0 8px; border-top: 1px solid var(--line-2); background: #f0f2f5; font-size: 12.5px; }
.xl-tabs span { padding: 5px 14px; background: #e3e6ea; color: #444; }
.xl-tabs span.on { background: #fff; color: #1d6f42; font-weight: 600; box-shadow: inset 0 -2px 0 #1d6f42; }

/* ==========================================================================
   17. Phone (designed at 390 × 844) — list-per-line, no grids
   ========================================================================== */
body.dt { font-size: 16px; background: var(--canvas); }
.m-app { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--canvas); position: relative; }
.m-top { position: sticky; top: 0; z-index: var(--z-top); display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 6px 8px 6px 4px; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.m-top h1 { flex: 1; min-width: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; }
.m-top h1 small { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.m-top .mark { width: 32px; height: 32px; margin-left: 8px; }
.m-ib { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--ink); border-radius: var(--r-2); text-decoration: none; flex: none; cursor: pointer; }
.m-ib:hover { background: var(--sunk); color: var(--ink); }
.m-ib .i { width: 22px; height: 22px; }
.m-body { flex: 1; padding: 16px 16px 96px; display: flex; flex-direction: column; gap: 16px; }
.m-body.has-bar { padding-bottom: 180px; }
.m-search { position: relative; }
.m-search .input { min-height: 48px; font-size: 17px; padding-left: 44px; border-radius: var(--r-2); }
.m-search > .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); }
.m-search .m-scan { position: absolute; right: 2px; top: 2px; }
.m-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 2px -6px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.m-sec a { font-size: 15px; font-weight: 600; }
.m-card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.m-list { list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); overflow: hidden; }
.m-list > li + li { border-top: 1px solid var(--line); }
.m-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; color: var(--ink); text-decoration: none; }
a.m-row:hover { background: var(--surface-2); color: var(--ink); }
.m-row .grow strong { display: block; font-weight: 600; font-size: 16px; line-height: 1.3; }
.m-row .grow small { display: block; font-size: 14px; color: var(--ink-3); line-height: 1.35; margin-top: 2px; }
.m-row .amt { text-align: right; font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-row .amt small { display: block; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.m-row > .i { color: var(--ink-3); }
.m-fig { padding: 14px 16px; }
.m-fig .k { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.m-fig .v { display: block; margin-top: 2px; font-size: 30px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.m-fig .v small { font-size: 15px; font-weight: 500; color: var(--ink-3); }
.m-fig .d { font-size: 14px; color: var(--ink-3); margin-top: 2px; }
.m-pair { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.m-pair > a, .m-pair > div { display: block; padding: 12px 16px; text-decoration: none; color: var(--ink); }
.m-pair > :first-child { border-right: 1px solid var(--line); }
.m-pair .k { font-size: 13.5px; color: var(--ink-3); font-weight: 600; }
.m-pair .v { display: block; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.m-tab { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(430px, 100vw); z-index: var(--z-top); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom, 0); }
.m-tab a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 64px; color: var(--ink-3); text-decoration: none; font-size: 12.5px; font-weight: 600; position: relative; }
.m-tab a .i { width: 24px; height: 24px; }
.m-tab a[aria-current="page"] { color: var(--cu-700); }
.m-tab a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--cu-600); }
.m-tab a.ban .i { color: var(--cu-600); }

.m-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 64px; width: min(430px, 100vw); z-index: var(--z-sticky); background: var(--surface); border-top: 1px solid var(--line-2); padding: 12px 16px 14px; box-shadow: 0 -8px 20px -10px oklch(0.225 0.016 255 / 0.18); }
.m-bar.no-tab { bottom: 0; }
.m-bar .m-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 15px; color: var(--ink-2); }
.m-bar .m-total strong { font-size: 24px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.dt .btn { min-height: 48px; font-size: 16px; }
.dt .btn-sm { min-height: 44px; font-size: 15px; }
.dt .btn-xl { min-height: 56px; font-size: 18px; }
.dt .input, .dt .select, .dt .textarea { min-height: 48px; font-size: 17px; }
.dt .field > label { font-size: 15px; color: var(--ink); }
.dt .seg { display: flex; }
.dt .seg > * { flex: 1; justify-content: center; min-height: 44px; font-size: 15px; }
.dt .tag { height: 26px; font-size: 13.5px; }

/* Phone item card (Tra hàng) */
.m-hang { padding: 14px 16px; }
.m-hang + .m-hang { border-top: 1px solid var(--line); }
.m-hang .t { font-weight: 600; font-size: 16.5px; line-height: 1.3; }
.m-hang .m { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.m-hang .g { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.m-hang .g div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-1); padding: 6px 8px; }
.m-hang .g .k { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.m-hang .g .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; display: block; }
.m-hang .g .v.tho { color: var(--nc-700); }

/* Phone line editor (Bán, Kiểm kho): one card per line */
.m-line { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); padding: 12px 14px; }
.m-line-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.m-line-top strong { font-size: 16px; line-height: 1.3; }
.m-line-top small { display: block; font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.m-line-ctl { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-field); border-radius: var(--r-2); overflow: hidden; }
.stepper button { width: 48px; min-height: 48px; border: 0; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.stepper input { width: 64px; border: 0; border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); text-align: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.m-line-sum { margin-left: auto; text-align: right; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.m-line-sum small { display: block; font-size: 13px; color: var(--ink-3); font-weight: 500; }
.m-count { text-align: center; padding: 20px 16px; }
.m-count .t { font-size: 20px; font-weight: 600; line-height: 1.3; }
.m-count .m { font-size: 14px; color: var(--ink-3); margin-top: 4px; }
.m-count .so-dem { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.m-count .so-dem .input { width: 150px; min-height: 72px; text-align: center; font-size: 36px; font-weight: 600; }
.m-count .so-dem .dvt { font-size: 18px; color: var(--ink-2); font-weight: 600; }
.m-progress { height: 6px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.m-progress span { display: block; height: 100%; background: var(--cu-600); }
.m-sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(430px, 100vw); z-index: var(--z-dialog); background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--sh-dialog); padding-bottom: 12px; }
.m-sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 10px auto 6px; }
.m-sheet h2 { font-size: 18px; padding: 6px 20px 10px; }
.m-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--line); }
.m-grid a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 92px; padding: 10px 6px; text-align: center; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1.25; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.m-grid a:nth-child(3n) { border-right: 0; }
.m-grid a .i { width: 26px; height: 26px; color: var(--cu-600); stroke-width: 1.7; }
.m-grid a:hover { background: var(--cu-50); color: var(--ink); }
.m-grid-label { padding: 14px 20px 8px; font-size: 14px; font-weight: 600; color: var(--ink-3); }

/* ==========================================================================
   18. Sign-in, system pages
   ========================================================================== */
body.auth { min-height: 100vh; display: grid; grid-template-rows: 1fr auto; background: var(--canvas); }
.auth-wrap { display: grid; place-items: center; padding: 48px 16px; }
.auth-card { width: min(420px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-brand strong { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; }
.auth-brand small { display: block; font-size: 15px; color: var(--ink-3); margin-top: 2px; }
.auth-panel { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-3); padding: 26px 26px 22px; box-shadow: var(--sh-1); }
.auth-panel h1 { font-size: 20px; margin-bottom: 4px; }
.auth-panel .lead { color: var(--ink-3); font-size: 15px; margin-bottom: 20px; }
.auth-panel form { display: grid; gap: 16px; }
.auth-panel .input { min-height: 46px; font-size: 16px; }
.pw { position: relative; }
.pw .input { padding-right: 52px; }
.pw .m-ib { position: absolute; right: 1px; top: 1px; width: 44px; height: 44px; }
.auth-help { margin-top: 16px; display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.auth-help .i { color: var(--ink-3); margin-top: 2px; }
.auth-foot { display: flex; justify-content: center; gap: 18px; padding: 16px; font-size: 13px; color: var(--ink-3); }

.sys { min-height: calc(100vh - var(--top-h)); display: grid; place-items: center; padding: 48px 24px; }
.sys-card { max-width: 560px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sys-card .ic { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--ink-2); margin-bottom: 6px; }
.sys-card .ic .i { width: 30px; height: 30px; }
.sys-card .code { font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.sys-card h1 { font-size: 24px; }
.sys-card p { color: var(--ink-2); font-size: 16px; max-width: 48ch; }
.sys-card .actions { margin-top: 10px; justify-content: center; }

/* ==========================================================================
   19. Mockup index (not part of the app)
   ========================================================================== */
.mx { max-width: 1200px; margin: 0 auto; padding: 40px 32px 64px; }
.mx-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.mx-head h1 { font-size: 26px; }
.mx-lead { color: var(--ink-2); max-width: 75ch; margin-bottom: 24px; }
.mx-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 28px; }
.mx-swatches span { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); font-size: 13px; }
.mx-swatches i { width: 22px; height: 22px; border-radius: 4px; border: 1px solid oklch(0 0 0 / 0.08); }
.mx-group { margin-top: 26px; }
.mx-group h2 { font-size: 17px; margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; }
.mx-group h2 .muted { font-weight: 400; font-size: 14px; }
.mx-list { list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.mx-list li { display: grid; grid-template-columns: 300px minmax(0, 1fr) 96px; gap: 16px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.mx-list li:last-child { border-bottom: 0; }
.mx-list a { font-family: var(--mono); font-size: 13.5px; }
.mx-list .vp { font-size: 12.5px; color: var(--ink-3); text-align: right; font-family: var(--mono); }

/* ==========================================================================
   20. Responsive, motion, print
   ========================================================================== */
@media (max-width: 1279px) {
  :root { --side-w: 208px; }
  .page { padding: var(--sp-5) var(--sp-5) var(--sp-8); }
  .top, .doc-bar { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .phieu { grid-template-columns: minmax(0, 1fr) 300px; }
  .tq-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .luoi td.o-sua .caret { animation: none; }
}
@media print {
  @page { size: A4; margin: 0; }
  body.print-view { background: #fff; min-width: 0; }
  .in-bar, .no-print { display: none !important; }
  .in-stage { padding: 0; gap: 0; }
  .giay { box-shadow: none; width: auto; min-height: 0; }
  .side, .top, .doc-bar { display: none !important; }
  .app { display: block; }
}
