/* FELIX Operation — design system v2 (CHỈ GIAO DIỆN SÁNG, không có chế độ tối).
 * Tài liệu đầy đủ: app/docs/THIET-KE.md · Artifact "FELIX Operation — Design System".
 *
 * Lớp dùng chung cho module (đừng tự viết CSS riêng nếu đã có ở đây):
 *   Bố cục   .card  .card-head  .grid-2  .grid-3  .stack  .row  .toolbar  .filter-bar  .page-actions  .sec-title
 *   Bảng     .table-wrap > table.table   td.num (số canh phải)   tr.is-sheet (dòng từ Sheet)   tr.is-total
 *            .table-wrap.is-tall (cuộn dọc trong khung, tiêu đề dính)   table.pin-first (ghim cột đầu)
 *   Nút      .btn  .btn-primary  .btn-ghost  .btn-danger  .btn-danger-solid  .btn-sm  .btn-lg  .btn-block  .btn-icon
 *   Form     .form-grid > .field > label + input/select/textarea   .field-error  .help   .field.has-error   .form-actions
 *   Nhãn     .badge  .badge-sheet  .badge-ok  .badge-warn  .badge-danger  .badge-muted  .badge-info  .badge-dot
 *            .tt  .tt-trong  .tt-dang_thue  .tt-sap_het_han  .tt-qua_han  .tt-bao_tri   (trạng thái phòng)
 *   KPI      .kpis > .kpi (hoặc a.kpi) > .kpi-label + .kpi-value + .kpi-sub     style="--tone:var(--c-luc)"
 *   Số       a.so (số bấm được)  .am (âm/nợ)  .duong (dương)  .meter > i (thanh tỷ lệ)
 *   Lọc      .chips > a.chip(.on)   .tabs > a(.on)   .tabs-line > a(.on)
 *   Sơ đồ    .so-do > .tang > .tang-nhan + .tang-o > a.o.tt-<mau> > .o-ma + .o-phu
 *   Báo      .alert  .alert-ok  .alert-warn  .alert-error  .alert-info     .empty (trạng thái rỗng)   .toast
 *   Khác     .dl (dt/dd)  .dl-luoi  .legend  .note  .chart-scroll  svg.bd  .luoi-tep  .ma-chep  .ds-gon  .sr-only
 *   Thẻ ĐT   table.bang-the + td[data-nhan] .the-tieu .the-so .the-nut .the-khoi   (bảng → thẻ ≤ 640px)
 *   Ô nhập   input[data-ngay] (dd/mm/yyyy)  input[data-ky] (mm/yyyy)  input[data-tien]  — app.js gắn mặt nạ, nút lịch
 *            .o-kem (ô + nút)  label.o-tick(.khung)  fieldset.field > legend.nhan  .thanh-dinh (thanh nút dính đáy)
 *   Dòng     tr.is-warn  tr.is-error  tr.is-muted  tr.is-chon (đang chọn)  td.dim
 *   Đợt B    a.kpi.on (KPI đang lọc)  .legend i.mau-xanh/dat/luc/vang  svg.bd .bd-* (màu biểu đồ = token)  .ngat-tu
 *   Chữ      .muted  .mono  .nowrap  .text-right  .num  .an-mobile (ẩn ≤640px)  .chi-mobile (chỉ hiện ≤640px)
 *   htmx     .htmx-indicator (hiện khi đang tải)  .spinner
 * Màu biểu đồ: var(--c-xanh) var(--c-dat) var(--c-luc) var(--c-vang)
 * Mốc màn hình: 480 (điện thoại nhỏ) · 640 (ẩn cột phụ) · 860 (menu thành ngăn kéo + thanh dưới) · 1280.
 */

/* ---------- Font: Be Vietnam Pro, nhúng sẵn (latin + vietnamese) — không gọi CDN ---------- */
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/be-vietnam-pro-vietnamese-400-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/be-vietnam-pro-latin-400-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/be-vietnam-pro-vietnamese-500-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/be-vietnam-pro-latin-500-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/be-vietnam-pro-vietnamese-600-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/be-vietnam-pro-latin-600-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/be-vietnam-pro-vietnamese-700-normal.woff2?v=5) 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: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/be-vietnam-pro-latin-700-normal.woff2?v=5) 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; }

/* Chữ số: Be Vietnam Pro KHÔNG có bảng số đều (tnum) → mượn riêng 10 chữ số 0–9 của Inter (OFL),
   có tnum, cùng chiều cao. Họ "FELIX So" chỉ phủ U+0030-0039 nên mọi ký tự khác vẫn là Be Vietnam Pro. */
@font-face { font-family: "FELIX So"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/inter-latin-400-normal.woff2?v=5) format("woff2"); unicode-range: U+0030-0039; }
@font-face { font-family: "FELIX So"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/inter-latin-500-normal.woff2?v=5) format("woff2"); unicode-range: U+0030-0039; }
@font-face { font-family: "FELIX So"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/inter-latin-600-normal.woff2?v=5) format("woff2"); unicode-range: U+0030-0039; }
@font-face { font-family: "FELIX So"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/inter-latin-700-normal.woff2?v=5) format("woff2"); unicode-range: U+0030-0039; }

/* ======================================================================
   TOKEN — một nguồn duy nhất. Tên cũ (--bg, --text, --line…) giữ nguyên
   để template module đang dùng không vỡ; tên mới là thang màu + ngữ nghĩa.
   ====================================================================== */
:root {
  color-scheme: light only;

  /* Rêu — màu nhấn thương hiệu (600 = #215c4b đã chốt) */
  --reu-50: #eef5f2; --reu-100: #dcebe4; --reu-200: #b8d6c9; --reu-300: #8bb9a6; --reu-400: #5a9781;
  --reu-500: #367a64; --reu-600: #215c4b; --reu-700: #1a4b3d; --reu-800: #153d32; --reu-900: #0f2d25;
  /* Xám rêu — trung tính ngả xanh (100 = nền #eef0ee đã chốt) */
  --xam-0: #ffffff; --xam-25: #fafbfa; --xam-50: #f5f7f5; --xam-100: #eef0ee; --xam-150: #e6e9e6;
  --xam-200: #d8ddd9; --xam-300: #c2c9c4; --xam-400: #8a948d; --xam-500: #636e67; --xam-600: #56605a;
  --xam-700: #3d4640; --xam-800: #2a312d; --xam-900: #1d2420;
  /* Bốn màu dữ liệu (500 = màu đã chốt) */
  --xanh-50: #eef3f9; --xanh-100: #dce6f2; --xanh-200: #b8cde6; --xanh-300: #8badd4; --xanh-500: #3d6fa8; --xanh-700: #2a4c74; --xanh-800: #213b5a;
  --dat-50: #fcf2ec;  --dat-100: #f7e1d4;  --dat-200: #eec2a9;  --dat-300: #e19c73;  --dat-500: #c2683a;  --dat-700: #844427;  --dat-800: #64341e;
  --luc-50: #edf6f1;  --luc-100: #d7ece1;  --luc-200: #afd8c2;  --luc-300: #80be9e;  --luc-500: #3f8f6b;  --luc-700: #2a5f48;  --luc-800: #204937;
  --vang-50: #fcf7e7; --vang-100: #f6ecc8; --vang-200: #ecd890; --vang-300: #ddbf59; --vang-500: #bd9526; --vang-700: #7a6019; --vang-800: #5b4813;
  /* Đỏ gạch — lỗi, quá hạn, nguy hiểm (500 = #b4432a cũ) */
  --do-50: #fcefec; --do-100: #f7dcd5; --do-200: #edb5a8; --do-300: #e0897a; --do-500: #b4432a; --do-600: #973823; --do-700: #7a2d1c;

  /* Ngữ nghĩa — tên cũ, module đang dùng */
  --bg: var(--xam-100);
  --surface: var(--xam-0);
  --surface-2: var(--xam-50);
  --line: var(--xam-200);
  --line-soft: var(--xam-150);
  --text: var(--xam-900);
  --text-2: var(--xam-600);
  --accent: var(--reu-600);
  --accent-hover: var(--reu-700);
  --accent-soft: #e2ece8;
  --c-xanh: var(--xanh-500);
  --c-dat: var(--dat-500);
  --c-luc: var(--luc-500);
  --c-vang: var(--vang-500);
  --danger: var(--do-500);
  /* Ngữ nghĩa — mới */
  --text-3: var(--xam-500);       /* chú thích, placeholder — đạt 4.5:1 trên trắng và nền */
  --line-strong: var(--xam-300);  /* viền tfoot, phân cách đậm */
  --line-input: var(--xam-400);   /* viền ô nhập — đạt 3:1 trên trắng */
  --accent-ink: var(--reu-700);   /* chữ rêu trên nền --accent-soft */
  --focus: var(--reu-600);
  --ok-bg: var(--luc-50);    --ok-line: var(--luc-200);    --ok-ink: var(--luc-700);
  --warn-bg: var(--vang-50); --warn-line: var(--vang-200); --warn-ink: var(--vang-800);
  --err-bg: var(--do-50);    --err-line: var(--do-200);    --err-ink: var(--do-700);
  --info-bg: var(--xanh-50); --info-line: var(--xanh-200); --info-ink: var(--xanh-700);

  /* Chữ */
  --font: "FELIX So", "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", "Liberation Mono", monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-base: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 28px;

  /* Khoảng cách — bước 4px */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  /* Bo góc */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;
  --radius: var(--r-lg);
  /* Bóng — ba cấp */
  --sh-1: 0 1px 2px rgba(29, 36, 32, .05), 0 1px 1px rgba(29, 36, 32, .03);
  --sh-2: 0 1px 2px rgba(29, 36, 32, .05), 0 8px 20px -10px rgba(29, 36, 32, .20);
  --sh-3: 0 2px 6px rgba(29, 36, 32, .06), 0 18px 40px -16px rgba(29, 36, 32, .32);
  --shadow: var(--sh-1);

  /* Kích thước */
  --sidebar-w: 236px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --tap: 44px;          /* vùng chạm tối thiểu trên điện thoại */
  --ctl-h: 40px;        /* chiều cao nút, ô nhập trên máy tính */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: .16s;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5rem; color: var(--text); text-wrap: balance; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.012em; }
h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.006em; }
h3 { font-size: var(--fs-base); font-weight: 600; }
p { margin: 0 0 .75rem; }
img, svg { max-width: 100%; }
img { height: auto; }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }
::selection { background: var(--reu-100); color: var(--reu-900); }

/* Biểu tượng nét (do hàm template {{icon "ten"}} sinh) */
.ic { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.ic-sm { width: 16px; height: 16px; vertical-align: -3px; }

/* Liên kết "bỏ qua menu" cho bàn phím */
.skip { position: absolute; left: var(--sp-2); top: -60px; z-index: 100; padding: var(--sp-2) var(--sp-3);
  background: var(--surface); border: 2px solid var(--focus); border-radius: var(--r-md); font-weight: 600; }
.skip:focus { top: var(--sp-2); }

/* ======================================================================
   KHUNG TRANG — sidebar trái (máy tính) · topbar + ngăn kéo + thanh dưới (điện thoại)
   ====================================================================== */
.shell { display: flex; min-height: 100vh; }
/* Màn rộng: nền trắng + viền phải của sidebar kéo dài hết trang dài (sidebar dính top:0, cao 100vh, cuộn riêng). */
@media (min-width: 861px) {
  .shell {
    background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--line) calc(var(--sidebar-w) - 1px) var(--sidebar-w), transparent var(--sidebar-w)) no-repeat;
  }
}
.sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
}
.brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-2) var(--sp-4); font-weight: 700; color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand-sub { font-size: var(--fs-xs); font-weight: 500; color: var(--text-3); }
.logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; background: var(--accent); color: #fff; font-size: .8rem; letter-spacing: .5px;
}
.menu-nhom {
  margin: var(--sp-4) var(--sp-3) var(--sp-1); font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3);
}
.menu-nhom:first-child { margin-top: 0; }
.menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.menu a {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  min-height: 40px; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  color: var(--xam-700); font-weight: 500; font-size: var(--fs-md);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.menu a .ic { color: var(--text-3); transition: color var(--dur) var(--ease); }
.menu a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.menu a:hover .ic { color: var(--text-2); }
.menu a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.menu a.active .ic { color: var(--accent); }
.menu a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--accent);
}
.viewer {
  margin-top: auto; padding: var(--sp-3); border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: var(--surface-2); display: grid; grid-template-columns: 36px 1fr; gap: 2px var(--sp-3); align-items: center;
}
.viewer .avatar {
  grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--reu-100); color: var(--reu-800); font-weight: 700; font-size: 14px;
}
.viewer .who { font-weight: 600; font-size: var(--fs-md); line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.viewer .role { color: var(--text-2); font-size: var(--fs-xs); line-height: 1.3; margin-bottom: 0; }
.viewer .viewer-nut { grid-column: 1 / -1; display: flex; gap: var(--sp-1); flex-wrap: wrap; margin-top: var(--sp-2); }
.viewer form { margin: 0; }

.main { flex: 1; min-width: 0; padding: var(--sp-6) var(--sp-8) var(--sp-12); }
@media (max-width: 1440px) { .main { padding-left: var(--sp-6); padding-right: var(--sp-6); } }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-head h1 { margin: 0; }
.page-head .phu-de { margin: 2px 0 0; color: var(--text-2); font-size: var(--fs-md); }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-actions:empty { display: none; }

.topbar, .nav-toggle, .scrim, .tabbar { display: none; }

/* ---------- Điện thoại / máy tính bảng dọc (≤ 860px) ---------- */
@media (max-width: 860px) {
  .topbar {
    display: flex; align-items: center; gap: var(--sp-2);
    position: sticky; top: 0; z-index: 30;
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) var(--sp-2) 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  /* Tiêu đề trên topbar chỉ hiện khi đã cuộn qua <h1> (app.js gắn .js-tieu-de / .hien-tieu-de) */
  .js-tieu-de .topbar-title { opacity: 0; transform: translateY(4px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
  .js-tieu-de .topbar.hien-tieu-de .topbar-title { opacity: 1; transform: none; }
  .topbar-ten { font-weight: 700; font-size: 15px; letter-spacing: .01em; white-space: nowrap; transition: opacity var(--dur) var(--ease); }
  .topbar-ten { position: absolute; left: 96px; opacity: 0; pointer-events: none; }
  .js-tieu-de .topbar-ten { opacity: 1; }
  .js-tieu-de .topbar.hien-tieu-de .topbar-ten { opacity: 0; }
  .topbar .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
  .topbar-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .nav-btn {
    display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    width: var(--tap); height: var(--tap); flex: 0 0 auto; cursor: pointer; border-radius: var(--r-md);
  }
  .nav-btn span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
  .nav-btn:hover, .nav-btn:active { background: var(--surface-2); }
  .nav-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; height: 100%; height: 100dvh;
    width: min(86vw, 300px); flex-basis: auto;
    padding-top: calc(var(--sp-4) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-102%); visibility: hidden;
    transition: transform .22s var(--ease), visibility 0s linear .22s;
    box-shadow: var(--sh-3); border-right: 0;
  }
  .menu a { min-height: var(--tap); font-size: var(--fs-base); }
  .nav-toggle:checked ~ .shell .sidebar { transform: none; visibility: visible; transition: transform .22s var(--ease); }
  .nav-toggle:checked ~ .shell .scrim {
    display: block; position: fixed; inset: 0; z-index: 40; background: rgba(29, 36, 32, .32);
  }
  body:has(.nav-toggle:checked) { overflow: hidden; }
  .main { padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--sp-8) + env(safe-area-inset-bottom, 0px)); }
  .page-head { margin-bottom: var(--sp-4); }
  .page-head h1 { font-size: 20px; }
  .page-actions .btn { flex: 1 1 auto; }

  /* Thanh điều hướng dưới — ngón cái với tới */
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; z-index: 35; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 var(--sp-1) env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px -12px rgba(29, 36, 32, .25);
  }
  .tabbar a, .tabbar label {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; min-height: var(--tap); padding: var(--sp-1) 2px; border-radius: var(--r-md);
    color: var(--text-2); font-size: 11.5px; font-weight: 500; line-height: 1.2; cursor: pointer;
    text-align: center; -webkit-tap-highlight-color: transparent;
  }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar a:hover { text-decoration: none; color: var(--text); }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .tabbar a.active .ic { stroke-width: 2.2; }
  .tabbar a:focus-visible, .tabbar label:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
}

/* ======================================================================
   THẺ, LƯỚI
   ====================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-head h2, .card-head h3 { margin: 0; }
.card-head h2 { font-size: 16px; }
.grid-2, .grid-3 { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.card.card-hep { max-width: 560px; }   /* thẻ thông báo / kết quả một cột */
/* Mã cần chép (mật khẩu tạm, mã tra cứu): bấm một lần chọn hết */
.ma-chep {
  display: inline-block; padding: 4px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--line-strong);
  font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: 700; letter-spacing: .04em; user-select: all; -webkit-user-select: all;
}
.grid-2 + *, .grid-3 + * { margin-top: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-3); }
.ds-gon { margin: 0; padding-left: var(--sp-5); }   /* danh sách gạch đầu dòng gọn trong thẻ */
.ds-gon > li + li { margin-top: var(--sp-2); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.tach { justify-content: space-between; }   /* hai đầu: nhãn trái — số phải */
.sec-title { display: flex; align-items: baseline; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; margin: var(--sp-8) 0 var(--sp-3); }
.sec-title h2 { margin: 0; font-size: 16px; }
.toolbar + .sec-title, .loc-gon + .sec-title { margin-top: var(--sp-2); }
.sec-title .muted { font-size: var(--fs-sm); }

/* Thanh lọc: .toolbar (trong suốt) hoặc .filter-bar (có khung) */
.toolbar {
  display: flex; gap: var(--sp-2) var(--sp-3); align-items: end; flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.toolbar .field { min-width: 150px; flex: 0 1 190px; }
.toolbar .field:has(input[type=search]), .toolbar .field.rong { flex: 1 1 220px; }
.toolbar .field.hep { min-width: 120px; flex: 0 1 150px; }
@media (max-width: 640px) {
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .toolbar .field { min-width: 0; }
  .toolbar .field:has(input[type=search]), .toolbar .field.rong, .toolbar .field.full { grid-column: 1 / -1; }
  .toolbar > .btn { width: 100%; }
}
/* Thanh lọc gọn trên điện thoại: <details class="loc-gon"><summary>Bộ lọc <span class="badge">2</span></summary> <form class="toolbar">…</form></details>
   Máy tính: luôn mở, ẩn summary (app.js mở sẵn). */
details.loc-gon { margin-bottom: var(--sp-4); }
details.loc-gon > summary {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); padding: 0 var(--sp-4);
  border: 1px solid var(--line-input); border-radius: var(--r-md); background: var(--surface); list-style: none;
}
details.loc-gon > summary::-webkit-details-marker { display: none; }
details.loc-gon > summary::after { content: "▾"; margin-left: auto; color: var(--text-2); }
details.loc-gon[open] > summary { margin-bottom: var(--sp-3); }
details.loc-gon > .toolbar { margin-bottom: 0; }
@media (min-width: 641px) { details.loc-gon > summary { display: none; } }
.filter-bar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
}

/* ======================================================================
   BẢNG DỮ LIỆU
   ====================================================================== */
.table-wrap {
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--surface);
  /* Bóng mờ hai mép khi còn cột bị che — báo hiệu "vuốt ngang được" */
  background-image:
    linear-gradient(to right, var(--surface) 40%, rgba(255, 255, 255, 0)),
    linear-gradient(to left, var(--surface) 40%, rgba(255, 255, 255, 0)),
    radial-gradient(farthest-side at 0 50%, rgba(29, 36, 32, .16), rgba(29, 36, 32, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(29, 36, 32, .16), rgba(29, 36, 32, 0));
  background-position: left center, right center, left center, right center;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.card > .table-wrap { margin-top: var(--sp-1); }
.table-wrap + .note, .table-wrap + p { margin-top: var(--sp-2); }
.table-wrap.is-tall { max-height: min(72vh, 720px); overflow: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.table th {
  background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: var(--fs-sm);
  white-space: nowrap; position: sticky; top: 0; z-index: 1; border-bottom-color: var(--line);
}
.table thead tr:first-child th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
.table thead tr:first-child th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--xam-25); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td, .table tr.is-total td {
  font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line-strong); border-bottom: 0;
}
.table tr.is-sheet td:first-child { box-shadow: inset 3px 0 0 var(--xanh-200); }
.table tr.is-warn td { background: var(--warn-bg); }    /* dòng thiếu thông tin, cần xem lại */
.table tr.is-error td { background: var(--err-bg); }    /* dòng nhập sai */
.table tr.is-muted td { background: var(--surface-2); color: var(--text-2); }  /* dòng đã khóa / không sửa */
.table tr.is-chon td { background: var(--accent-soft); }  /* dòng đang chọn (vd kỳ đang xem) */
.table td.dim, .table th.dim { color: var(--text-2); }   /* cột phụ (chi tiết của cột chính) */
.table td.empty { padding: var(--sp-8) var(--sp-4); }
.table th:first-child, .table td:first-child { padding-left: 14px; }
.table th:last-child, .table td:last-child { padding-right: 14px; }
/* Bảng nhiều cột tiền (≥ 10 cột): gọn hơn để vừa màn 1366 */
.table.table-compact { font-size: 13px; }
.table.table-compact th, .table.table-compact td { padding: 7px 8px; }
.table.pin-first th:first-child, .table.pin-first td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--line-soft);
}
.table.pin-first th:first-child { z-index: 3; background: var(--surface-2); }
.table.pin-first tfoot td:first-child { background: var(--surface-2); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.num { font-feature-settings: "tnum" 1, "lnum" 1; }

/* Bảng → thẻ trên điện thoại (≤ 640px). <table class="table bang-the">, mỗi ô có data-nhan="Còn nợ".
   td.the-tieu: tiêu đề thẻ (trái, hàng đầu) · td.the-so: con số chính (phải, cùng hàng tiêu đề)
   td.the-nut: hàng nút (rộng hết thẻ, cao 44px) · ô còn lại: "nhãn ……… giá trị" một hàng · .an-mobile vẫn ẩn. */
@media (max-width: 640px) {
  .table-wrap:has(> .bang-the) { border: 0; border-radius: 0; background: none; overflow: visible; }
  .table.bang-the, .table.bang-the > tbody, .table.bang-the > tfoot { display: block; }
  .table.bang-the > thead { display: none; }
  .table.bang-the tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--sp-3); align-items: start;
    padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-2);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-1);
  }
  .table.bang-the tbody tr:hover { background: var(--surface); }
  .table.bang-the tr.is-sheet { box-shadow: inset 3px 0 0 var(--xanh-200), var(--sh-1); }
  .table.bang-the tfoot tr, .table.bang-the tr.is-total { background: var(--surface-2); }
  .table.bang-the td, .table.bang-the tfoot td, .table.bang-the tr.is-total td {
    display: flow-root; grid-column: 1 / -1;
    padding: 0; border: 0; background: none; text-align: right; min-width: 0; font-weight: inherit;
  }
  .table.bang-the tr.is-sheet td:first-child, .table.bang-the td { box-shadow: none; position: static; }   /* bỏ ghim cột (pin-first) khi là thẻ */
  .table.bang-the tr.is-chon { background: var(--accent-soft); border-color: var(--reu-300); }
  .table.bang-the tr.is-warn { background: var(--warn-bg); border-color: var(--warn-line); }
  .table.bang-the tr.is-muted { background: var(--surface-2); }
  .table.bang-the.pin-first th:first-child, .table.bang-the.pin-first td:first-child, .table.bang-the.pin-first tfoot td:first-child { background: none; }
  /* Nhãn trái (float), giá trị canh phải — ô nhiều nút con vẫn chung một dòng chảy */
  .table.bang-the td[data-nhan]::before {
    content: attr(data-nhan); float: left; margin-right: var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; text-align: left;
  }
  .table.bang-the td.the-tieu { grid-column: 1; grid-row: 1; display: block; text-align: left; font-size: var(--fs-base); font-weight: 600; }
  .table.bang-the td.the-so { grid-column: 2; grid-row: 1; display: block; font-size: var(--fs-lg); font-weight: 700; line-height: 1.3; }
  .table.bang-the td.the-tieu::before, .table.bang-the td.the-so::before { content: none; }
  .table.bang-the td.the-khoi { display: block; text-align: left; }   /* ô nhiều dòng (nhóm radio, ghi chú dài): nhãn ở trên */
  .table.bang-the td.the-khoi[data-nhan]::before { float: none; display: block; margin-bottom: 2px; }
  .table.bang-the td.the-nut { display: block; margin-top: var(--sp-1); }
  .table.bang-the td.the-nut .btn { width: 100%; min-height: var(--tap); }
  .table.bang-the td:empty, .table.bang-the td.an-mobile { display: none; }
  .table.bang-the td.empty { display: block; text-align: center; padding: var(--sp-6) var(--sp-2); }
}

/* Thanh nút dính đáy (form dài: lập bill, đối soát). Điện thoại: nằm trên thanh điều hướng dưới.
   <div class="thanh-dinh"><span class="thanh-dinh-chu">…</span><button class="btn">…</button></div> */
.thanh-dinh {
  position: sticky; bottom: var(--sp-2); z-index: 5;
  display: flex; gap: var(--sp-2) var(--sp-3); align-items: center; justify-content: flex-end; flex-wrap: wrap;
  margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sh-3);
}
.thanh-dinh-chu { margin-right: auto; color: var(--text-2); font-size: var(--fs-sm); line-height: 1.45; min-width: 0; }
.thanh-dinh-chu strong { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .thanh-dinh { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-2)); padding: var(--sp-2) var(--sp-3); }
  .thanh-dinh > .btn { flex: 1 1 0; }
  .thanh-dinh-chu { flex: 1 1 100%; }
}

/* Số bấm được — nguyên tắc "mọi con số đều bấm xuống được danh sách" */
a.so {
  color: inherit; text-decoration: none; font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted var(--xam-400); transition: color var(--dur), border-color var(--dur);
}
a.so:hover { color: var(--accent); border-bottom: 1px solid var(--accent); text-decoration: none; }
.am, .am a.so, td.am { color: var(--do-600); }
.duong { color: var(--luc-700); }

/* ======================================================================
   NÚT
   ====================================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--ctl-h); padding: 8px 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-input); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-md); font-weight: 600; line-height: 1.25; cursor: pointer;
  text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--xam-500); color: var(--text); text-decoration: none; }
.btn:active { background: var(--xam-150); }
.btn:focus-visible, .menu a:focus-visible,
a:focus-visible, summary:focus-visible, .chip:focus-visible, .o:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(15, 45, 37, .2); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-primary:active { background: var(--reu-800); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent-ink); }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-ghost:active { background: var(--reu-100); }
.btn-danger { color: var(--do-600); border-color: var(--do-200); background: var(--surface); }
.btn-danger:hover { background: var(--do-50); border-color: var(--do-300); color: var(--do-700); }
.btn-danger-solid { background: var(--do-500); border-color: var(--do-500); color: #fff; }
.btn-danger-solid:hover { background: var(--do-600); border-color: var(--do-600); color: #fff; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: var(--fs-base); }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: var(--ctl-h); }
.btn[disabled], .btn[aria-disabled="true"], .btn:disabled { opacity: .45; pointer-events: none; box-shadow: none; }
/* Vùng chạm ≥ 44px trên màn cảm ứng mà không phình nút nhỏ */
@media (pointer: coarse) {
  .btn { min-height: var(--tap); }
  .btn-sm { min-height: 36px; }
  .btn-sm::after { content: ""; position: absolute; inset: -4px 0; }
}

/* ======================================================================
   FORM
   ====================================================================== */
.form-grid { display: grid; gap: var(--sp-4) var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
[hidden] { display: none !important; }   /* thuộc tính hidden thắng .field { display:flex } */
/* Nhóm ô chọn trong form: <fieldset class="field full"><legend class="nhan">Tòa được giao</legend><div class="row">…</div></fieldset> */
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field > legend.nhan { padding: 0; margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--xam-700); }
.field label, .field > .nhan { font-size: var(--fs-sm); font-weight: 600; color: var(--xam-700); }
.field label .bat-buoc, .field .bat-buoc { color: var(--do-600); margin-left: 2px; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=email],
input[type=tel], input[type=password], input[type=search], input[type=url], input[type=datetime-local],
input:not([type]), select, textarea {
  width: 100%; min-height: var(--ctl-h); padding: 8px 12px;
  border: 1px solid var(--line-input); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-md); line-height: 1.4;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input:hover:not(:disabled):not([readonly]), select:hover:not(:disabled), textarea:hover:not([readonly]) { border-color: var(--xam-500); }
/* Tiêu điểm ô nhập: vòng rêu đặc 2px (viền + bóng 1px) — tương phản 7.8:1 trên trắng */
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); outline: none; }
input[type=number] { font-variant-numeric: tabular-nums; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2356605a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 8l4.5 4.5L14.5 8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 18px 18px;
}
select:not([multiple]):not([size]) { padding-right: 32px; }  /* chỗ cho mũi tên, thắng cả CSS module đặt padding ngắn */
select[multiple] { background-image: none; padding-right: 12px; }
textarea { min-height: 96px; resize: vertical; }
input[readonly], input:disabled, select:disabled, textarea[readonly], textarea:disabled {
  background-color: var(--surface-2); color: var(--text-2); border-color: var(--line);
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
input[type=file] { font: inherit; font-size: var(--fs-sm); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; margin-right: var(--sp-3); padding: 8px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-input); background: var(--surface); color: var(--text); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }
.field-error { color: var(--do-600); font-size: var(--fs-sm); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }
.field-error::before {
  content: "!"; flex: 0 0 auto; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-top: 2px;
  border-radius: 50%; background: var(--do-500); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--do-500); background-color: var(--do-50); }
.field.has-error input:focus, .field.has-error select:focus, .field.has-error textarea:focus { border-color: var(--do-600); box-shadow: 0 0 0 1px var(--do-600); }
.field.has-error label { color: var(--do-700); }
.help { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.45; }

/* Ô ngày / kỳ kiểu Việt Nam — không phụ thuộc ngôn ngữ trình duyệt.
   <input type="text" name="ngay_thu" value="{{ngay .HomNay}}" data-ngay …>  → dd/mm/yyyy (server: web.ParseNgay)
   <input type="text" name="ky" value="{{ky .Ky}}" data-ky …>                → mm/yyyy    (server: web.ParseKy)
   app.js tự thêm mặt nạ gõ số, nút lịch (.o-lich-nut) và dòng đọc ngày "Thứ bảy, 04 tháng 10 năm 2026" (.o-ngay-doc). */
.o-lich { position: relative; display: block; min-width: 0; }
.o-lich > input[data-ngay], .o-lich > input[data-ky] { padding-right: 48px; }
.o-lich-nut {
  position: absolute; top: 0; right: 0; bottom: 0; width: 44px; display: grid; place-items: center;
  padding: 0; border: 1px solid transparent; border-radius: 0 var(--r-md) var(--r-md) 0; background: transparent;
  color: var(--text-2); cursor: pointer; -webkit-tap-highlight-color: transparent; background-clip: padding-box;
}
.o-lich-nut:hover { color: var(--accent); background: var(--surface-2); }
.o-lich-nut:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.o-lich > .o-lich-an {
  position: absolute; right: 0; bottom: 0; width: 42px; min-width: 0; height: 100%; min-height: 0; padding: 0; margin: 0;
  border: 0; opacity: 0; pointer-events: none; font-size: 16px;
}
.o-lich.cham-truc-tiep > .o-lich-an { pointer-events: auto; cursor: pointer; }  /* trình duyệt không có showPicker: chạm thẳng vào ô gốc */
.o-ngay-doc { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.4; min-height: 1.4em; }
.o-ngay-doc:empty { display: none; }

/* Ô đánh dấu có nhãn — vùng chạm ≥ 44px. <label class="o-tick"><input type="checkbox"> Nhãn</label>
   .o-tick.khung = viên có viền (chọn nhiều tòa, lọc) */
.o-tick { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); cursor: pointer; font-size: var(--fs-md); line-height: 1.35; }
.o-tick.khung {
  padding: 0 var(--sp-4) 0 var(--sp-3); border: 1px solid var(--line-input); border-radius: var(--r-pill); background: var(--surface); font-weight: 600;
}
.o-tick.khung:hover { border-color: var(--accent); }
.o-tick.khung:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.o-tick:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.o-tick:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-5); flex-wrap: wrap; }
.form-actions.trai { justify-content: flex-start; }
.form-grid > .form-actions { grid-column: 1 / -1; margin-top: 0; }
/* Ô kèm nút cùng hàng (vd giá niêm yết + Lưu): <div class="o-kem"><input …><button class="btn">…</button></div> */
.o-kem { display: flex; gap: var(--sp-2); align-items: stretch; }
.o-kem > input, .o-kem > select, .o-kem > .o-lich { flex: 1 1 auto; min-width: 0; }
.o-kem > .btn { flex: 0 0 auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4) var(--sp-4); margin: 0 0 var(--sp-4); min-width: 0; }
legend { padding: 0 var(--sp-2); font-weight: 600; font-size: var(--fs-md); color: var(--text-2); }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
@media (max-width: 860px) {
  /* 16px để iOS không tự phóng to khi chạm vào ô nhập */
  input[type=text], input[type=number], input[type=date], input[type=month], input[type=email],
  input[type=tel], input[type=password], input[type=search], input[type=url], input[type=datetime-local],
  input:not([type]), select, textarea { font-size: 16px; min-height: var(--tap); }
  .form-actions .btn { flex: 1 1 140px; }
  input[type=file] { min-height: var(--tap); }
  input[type=file]::file-selector-button { min-height: var(--tap); padding: 10px 16px; }
}

/* ======================================================================
   NHÃN TRẠNG THÁI
   ====================================================================== */
.badge {
  display: inline-block; padding: 1px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 20px; white-space: nowrap; vertical-align: 1px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
a.badge:hover { text-decoration: none; filter: brightness(.97); }
.badge-sheet, .badge-info { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }
.badge-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--ok-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.badge-danger { background: var(--err-bg); color: var(--err-ink); border-color: var(--err-line); }
.badge-muted { background: var(--surface-2); color: var(--text-2); border-color: var(--line); }
.badge-dot::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%;
  background: currentColor; vertical-align: 1px;
}
/* Trạng thái phòng — mã khớp phong.TinhTrang (tt-<mau>) */
.tt {
  display: inline-block; padding: 1px 9px; border-radius: var(--r-pill); border: 1px solid;
  font-size: var(--fs-xs); font-weight: 600; line-height: 20px; white-space: nowrap;
}
.tt-trong { background: var(--xanh-50); color: var(--xanh-800); border-color: var(--xanh-300); }
.tt-dang_thue { background: var(--luc-50); color: var(--luc-800); border-color: var(--luc-300); }
.tt-sap_het_han { background: var(--vang-50); color: var(--vang-800); border-color: var(--vang-300); }
.tt-qua_han { background: var(--do-50); color: var(--do-700); border-color: var(--do-300); }
.tt-bao_tri {
  background-color: var(--xam-150); color: var(--xam-700); border-color: var(--xam-300);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(29, 36, 32, .06) 6px 12px);
}

/* ======================================================================
   KPI — số liệu là trung tâm
   ====================================================================== */
.kpis { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); margin-bottom: var(--sp-5); }
.kpi {
  position: relative; overflow: hidden; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-4) 14px; box-shadow: var(--shadow);
}
/* Không để một thẻ lẻ loi ở hàng cuối: 4/8 thẻ → 4 cột, 6/9 thẻ → 3 cột (màn rộng) */
@media (min-width: 1101px) {
  .kpis:has(> :nth-child(4):last-child), .kpis:has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpis:has(> :nth-child(6):last-child), .kpis:has(> :nth-child(9):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tone, transparent); }
a.kpi { display: block; color: inherit; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
a.kpi::after {
  content: ""; position: absolute; top: 14px; right: 14px; width: 16px; height: 16px; opacity: .55;
  background: var(--text-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 5l5 5-5 5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 5l5 5-5 5'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--dur) var(--ease), opacity var(--dur);
}
a.kpi:hover { border-color: var(--reu-300); box-shadow: var(--sh-2); text-decoration: none; color: inherit; }
a.kpi:hover::after { background: var(--accent); opacity: 1; transform: translateX(2px); }
a.kpi:active { transform: translateY(1px); }
a.kpi.on, a.kpi[aria-current] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), var(--sh-1); }   /* thẻ KPI đang là bộ lọc */
.kpi-label { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; line-height: 1.35; padding-right: 18px; }
.kpi-value {
  font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.015em; margin-top: 6px;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.kpi-value.kpi-chu { font-size: var(--fs-xl); letter-spacing: 0; }   /* giá trị là chữ (vd "Tầng 2") */
.kpi-value small { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 3px; letter-spacing: 0; }
.kpi-value a { color: inherit; }
.kpi-value a:hover { color: var(--accent); text-decoration: none; }
.kpi-sub { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; margin-top: 4px; }
.meter { height: 6px; border-radius: var(--r-pill); background: var(--xam-150); overflow: hidden; margin: 10px 0 4px; }
.meter > i, .meter > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--tone, var(--c-luc)); }
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
  .kpi { padding: var(--sp-3) var(--sp-3) var(--sp-3); }
  .kpi-value { font-size: 20px; }
  .kpi-label, .kpi-sub { font-size: 12.5px; }
  a.kpi::after { top: 10px; right: 8px; width: 14px; height: 14px; }
  .kpi-rong { grid-column: 1 / -1; }
}

/* ======================================================================
   LỌC NHANH, TAB
   ====================================================================== */
.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 14px;
  border-radius: var(--r-pill); border: 1px solid var(--line-input); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: var(--fs-sm); white-space: nowrap;
}
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip b { font-variant-numeric: tabular-nums; font-weight: 700; }
.chip.on b, .chip.on .am { color: inherit; }
@media (max-width: 640px) {
  /* Một hàng vuốt ngang, tràn sát mép màn hình */
  .main .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: calc(-1 * var(--sp-4)); margin-right: calc(-1 * var(--sp-4)); padding: 0 var(--sp-4) 2px; }
  .main .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}
.chip .tt { width: 12px; height: 12px; padding: 0; border-radius: 3px; font-size: 0; line-height: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--sp-4); }
.tabs a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 4px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line-input); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 600;
}
.tabs a:hover { text-decoration: none; border-color: var(--accent); }
.tabs a.on, .tabs a[aria-current] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs-line { display: flex; gap: var(--sp-1); margin: 0 0 var(--sp-4); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs-line a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--sp-3); white-space: nowrap;
  color: var(--text-2); font-weight: 600; font-size: var(--fs-md); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs-line a:hover { color: var(--text); text-decoration: none; }
.tabs-line a.on, .tabs-line a[aria-current] { color: var(--accent-ink); border-bottom-color: var(--accent); }
@media (pointer: coarse) { .chip, .tabs a { min-height: var(--tap); } }

/* ======================================================================
   SƠ ĐỒ PHÒNG THEO TẦNG — ô phòng
   ====================================================================== */
.chu-thich { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.so-do { display: flex; flex-direction: column; gap: var(--sp-3); }
.tang { display: grid; grid-template-columns: 88px 1fr; gap: var(--sp-3); align-items: start; padding-top: var(--sp-3); border-top: 1px dashed var(--line); }
.tang:first-child { border-top: 0; padding-top: 0; }
.tang-nhan { font-weight: 600; color: var(--text-2); font-size: var(--fs-sm); padding-top: 10px; }
.tang-o { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: var(--sp-2); }
.o {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 64px; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md); border: 1px solid; line-height: 1.25;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
:where(.o) { border-color: var(--line); background: var(--surface); color: var(--text); }  /* mặc định; .tt-* ghi đè */
a.o:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--sh-2); }
.o-ma { font-weight: 700; font-size: var(--fs-md); letter-spacing: .01em; }
.o-phu { font-size: var(--fs-xs); opacity: .92; font-variant-numeric: tabular-nums; }
.o.tt-qua_han { border-width: 2px; padding: 7px 11px; }
@media (max-width: 600px) {
  .tang { grid-template-columns: 1fr; gap: var(--sp-2); }
  .tang-nhan { padding-top: 0; }
  /* 4 ô một hàng ở 375px (tầng 4 phòng không bị rơi 1 ô xuống dòng) */
  .tang-o { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 6px; }
  .o { padding: 6px var(--sp-2); min-height: 60px; }
  .o.tt-qua_han { padding: 5px 7px; }
}

/* ======================================================================
   DANH SÁCH ĐỊNH NGHĨA, CHÚ GIẢI, BIỂU ĐỒ
   ====================================================================== */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; }
.dl dt { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; padding-top: 1px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: var(--sp-2); } }
/* Lưới thông tin ngang (đầu trang chi tiết bill/HĐ): <dl class="dl-luoi"><div><dt>Tòa</dt><dd>FELIX 5</dd></div>…</dl> */
.dl-luoi { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: var(--sp-3) var(--sp-5); margin: 0; }
.dl-luoi > div { min-width: 0; }
.dl-luoi dt { color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; }
.dl-luoi dd { margin: 2px 0 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .dl-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); } }

/* Lưới tệp đính kèm (ảnh CCCD, PDF hợp đồng): <div class="luoi-tep"><figure><a><img></a><figcaption>…</figcaption></figure></div>
   Tệp không phải ảnh: <a class="tep-loai" href="…">PDF</a> thay cho <img>. */
.luoi-tep { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.luoi-tep figure { margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.luoi-tep img, .luoi-tep .tep-loai { display: block; width: 100%; height: 120px; border-radius: var(--r-sm); background: var(--surface); }
.luoi-tep img { object-fit: cover; }
.luoi-tep .tep-loai { display: grid; place-items: center; font-weight: 700; color: var(--do-600); }
.luoi-tep .tep-loai:hover { text-decoration: none; background: var(--do-50); }
.luoi-tep figcaption { margin-top: 6px; font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; }
@media (max-width: 480px) { .luoi-tep { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px var(--sp-4); font-size: var(--fs-sm); color: var(--text-2); margin: var(--sp-3) 0 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--xam-400); }
.legend i.mau-xanh { background: var(--c-xanh); }
.legend i.mau-dat { background: var(--c-dat); }
.legend i.mau-luc { background: var(--c-luc); }
.legend i.mau-vang { background: var(--c-vang); }
.note { font-size: var(--fs-sm); color: var(--text-2); margin: var(--sp-3) 0 0; line-height: 1.55; }
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--sp-1); }
svg.bd, svg.bd text { font-family: var(--font); }
svg.bd { display: block; max-width: none; height: auto; }
svg.bd.bd-fit { width: 100%; max-width: 560px; }
svg.bd text { font-variant-numeric: tabular-nums; }
svg.bd a rect { transition: opacity var(--dur) var(--ease); }
svg.bd a:hover rect, svg.bd a:focus rect { opacity: .78; }
svg.bd a:focus { outline: none; }
svg.bd a:focus-visible rect { outline: none; stroke: var(--focus); stroke-width: 2px; }
/* Màu biểu đồ = token (chart.go gắn lớp; thuộc tính fill/stroke trong SVG chỉ là màu dự phòng) */
svg.bd .bd-xanh { fill: var(--c-xanh); }
svg.bd .bd-dat { fill: var(--c-dat); }
svg.bd .bd-luc { fill: var(--c-luc); }
svg.bd .bd-vang { fill: var(--c-vang); }
svg.bd .bd-nen { fill: var(--accent-soft); }
svg.bd .bd-chu { fill: var(--text-2); }
svg.bd .bd-chu1 { fill: var(--text); }
svg.bd .bd-nhan { fill: var(--accent); }
svg.bd .bd-canh { fill: var(--warn-ink); }
svg.bd .bd-am { fill: var(--do-600); }
svg.bd .bd-luoi { stroke: var(--line-soft); }
svg.bd .bd-truc { stroke: var(--line-strong); }
svg.bd a:hover .bd-nhan { fill: var(--accent-hover); text-decoration: underline; }

/* ======================================================================
   THÔNG BÁO
   ====================================================================== */
.alert {
  position: relative; padding: 12px 14px 12px 44px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  margin-bottom: var(--sp-4); line-height: 1.5;
}
.alert::before {
  content: ""; position: absolute; left: 14px; top: 13px; width: 20px; height: 20px; background: var(--text-2);
  -webkit-mask: var(--alert-ic) center / contain no-repeat; mask: var(--alert-ic) center / contain no-repeat;
  --alert-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v6M12 7.5v.5'/%3E%3C/svg%3E");
}
.alert-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--luc-800); }
.alert-ok::before { background: var(--luc-500);
  --alert-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M8 12.5l2.7 2.7L16 9.8'/%3E%3C/svg%3E"); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--vang-800); }
.alert-warn::before { background: var(--vang-700);
  --alert-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.2L2.8 17.5A2 2 0 004.5 20.5h15a2 2 0 001.7-3L13.7 4.2a2 2 0 00-3.4 0z'/%3E%3Cpath d='M12 9.5v4.5M12 17v.5'/%3E%3C/svg%3E"); }
.alert-error { background: var(--err-bg); border-color: var(--err-line); color: var(--do-700); }
.alert-error::before { background: var(--do-500);
  --alert-ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M9 9l6 6M15 9l-6 6'/%3E%3C/svg%3E"); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--xanh-800); }
.alert-info::before { background: var(--xanh-500); }
.alert > :last-child { margin-bottom: 0; }
.dl + .alert, .dl-luoi + .alert, .table-wrap + .alert, .bang-tien + .alert { margin-top: var(--sp-4); }

.empty { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--text-2); }
.empty:not(td)::before {
  content: ""; display: block; width: 48px; height: 48px; margin: 0 auto var(--sp-3); border-radius: 50%;
  background-color: var(--accent-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23215c4b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='14' rx='2'/%3E%3Cpath d='M4 10h16M9 14h6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 24px 24px;
}
.empty h2 { color: var(--accent-ink); margin-bottom: var(--sp-1); }
.empty p { max-width: 52ch; margin-left: auto; margin-right: auto; }

.toast {
  position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 60; max-width: min(420px, calc(100vw - 2rem));
  padding: 12px 16px 12px 44px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--err-line);
  color: var(--do-700); box-shadow: var(--sh-3); font-weight: 500;
}
.toast::before {
  content: "!"; position: absolute; left: 14px; top: 12px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--do-500); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.toast.toast-ok { border-color: var(--ok-line); color: var(--luc-800); }
.toast.toast-ok::before { content: "✓"; background: var(--luc-500); }
@media (max-width: 860px) {
  .toast { left: var(--sp-3); right: var(--sp-3); max-width: none; bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom, 0px)); }
}

/* ======================================================================
   PHÂN TRANG
   ====================================================================== */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); margin: var(--sp-5) 0; flex-wrap: wrap; }
.pager .muted { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pager .btn { min-width: 96px; border-color: var(--line-input); }
.pager .btn[aria-disabled="true"] { opacity: .4; }
@media (max-width: 600px) {
  .pager { display: grid; grid-template-columns: 1fr 1fr; }
  .pager .muted { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .pager .btn { min-height: var(--tap); }
}

/* ======================================================================
   CHỮ & TIỆN ÍCH
   ====================================================================== */
.muted { color: var(--text-2); }
.mono { font-family: var(--font-mono); font-size: .9em; letter-spacing: 0; }
.nowrap { white-space: nowrap; }
.ngat-tu { overflow-wrap: anywhere; word-break: break-word; }   /* đường dẫn file, chuỗi dài không dấu cách */
/* Chỉ cho trình đọc màn hình (tiêu đề cột thao tác, nhãn ẩn) */
.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; }
.text-right { text-align: right; }
.chi-mobile { display: none; }
@media (max-width: 640px) {
  .an-mobile { display: none; }
  .chi-mobile { display: initial; }
}

/* ---------- htmx ---------- */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request.btn, .htmx-request .btn[type=submit] { opacity: .7; cursor: progress; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px;
  border: 2px solid var(--reu-200); border-top-color: var(--accent); animation: quay .7s linear infinite;
}
@keyframes quay { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

@media print {
  .sidebar, .topbar, .tabbar, .page-actions, .toast, .skip, .pager { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .main { padding: 0; }
  .card, .kpi, .table-wrap { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; background-image: none; }
  a.so { border-bottom: 0; }
}
