/* =========================================================================
   QLCV – Design system (tự viết, không Bootstrap/Tailwind)
   Mobile-first. Tài liệu: docs/DESIGN_SYSTEM.md
   Thứ tự: phông → token → nền tảng → khung ứng dụng → thành phần → trang → in
   ========================================================================= */

/* ---------- 1. Phông Be Vietnam Pro (tự lưu trữ, OFL) ---------- */
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/BeVietnamPro-Regular.8283fb698524.woff2") format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/BeVietnamPro-Medium.4a265ab0cbba.woff2") format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/BeVietnamPro-SemiBold.86372b4bf9d3.woff2") format("woff2"); }
@font-face { font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/BeVietnamPro-Bold.67824218b2ef.woff2") format("woff2"); }

/* ---------- 2. Token ---------- */
:root {
  /* Nhận diện: xanh lam đo từ logo CVP */
  --brand: #0060AF;
  --brand-hover: #00518F;
  --brand-press: #004478;
  --brand-tint: #E3EFFA;
  --brand-tint-2: #CFE2F6;

  /* Thanh điều hướng (rail) xanh đậm */
  --rail: #0B2B4F;
  --rail-2: #123A66;          /* hover */
  --rail-active: #17497F;     /* mục đang mở */
  --rail-line: rgba(255, 255, 255, .09);
  --rail-ink: #E4ECF6;
  --rail-ink-2: #9FB7D2;

  /* Nền & bề mặt */
  --ground: #EDF1F6;
  --surface: #FFFFFF;
  --surface-2: #F5F8FB;       /* đầu bảng, vùng phụ */
  --surface-3: #E6ECF3;       /* cột cuối tuần, nền nhấn nhẹ */
  --line: #D9E1EA;
  --line-soft: #E6EBF1;
  --line-strong: #7A899D;     /* viền ô nhập: ≥3:1 trên nền trắng */

  /* Chữ */
  --ink: #172A41;
  --ink-2: #44566C;
  --ink-3: #5B6B7F;
  --ink-on-brand: #FFFFFF;

  /* Sắc thái ngữ nghĩa: fg (chữ, ≥4.5:1 trên bg), bg (nền nhạt), solid (vạch/chấm) */
  --slate-fg: #3E4E63;  --slate-bg: #E9EEF4;  --slate-solid: #7C8BA0;
  --blue-fg: #0A4F8F;   --blue-bg: #E3EFFA;   --blue-solid: #0060AF;
  --violet-fg: #5B3AA8; --violet-bg: #EFEAFB; --violet-solid: #7253CF;
  --amber-fg: #8A4B00;  --amber-bg: #FDF0DC;  --amber-solid: #C27803;
  --red-fg: #A61B1B;    --red-bg: #FCE7E6;    --red-solid: #C8322A;
  --green-fg: #1F6B3A;  --green-bg: #E2F3E8;  --green-solid: #2A8A4C;
  --teal-fg: #0D6466;   --teal-bg: #DFF2F1;   --teal-solid: #16807E;
  --rust-fg: #9A3D12;   --rust-bg: #FBE9DF;   --rust-solid: #B9551F;
  --grey-fg: #5C6673;   --grey-bg: #EEF0F2;   --grey-solid: #8792A0;

  /* Chữ: một họ, thang cố định ~1.2 */
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fs-xs: .75rem;      /* 12 */
  --fs-sm: .8125rem;    /* 13 */
  --fs-base: 1rem;      /* 16 trên điện thoại; 15 từ 768px */
  --fs-md: 1.0625rem;   /* 17 */
  --fs-lg: 1.25rem;     /* 20 */
  --fs-xl: 1.5rem;      /* 24 */
  --fs-2xl: 1.875rem;   /* 30 */
  --lh: 1.55;
  --lh-tight: 1.3;

  /* Khoảng cách (lưới 4px) */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.25rem;
  --sp-6: 1.5rem; --sp-8: 2rem; --sp-10: 2.5rem; --sp-12: 3rem;

  /* Bo góc theo cấp: khối lớn > điều khiển > nhãn */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-pill: 999px;

  /* Bóng: chỉ cho lớp nổi (menu, hộp thoại, thông báo nổi) */
  --sh-1: 0 1px 2px rgba(16, 42, 73, .08), 0 1px 1px rgba(16, 42, 73, .04);
  --sh-2: 0 6px 16px -4px rgba(16, 42, 73, .18), 0 2px 4px rgba(16, 42, 73, .06);
  --sh-3: 0 20px 48px -12px rgba(11, 43, 79, .35), 0 4px 10px rgba(11, 43, 79, .08);

  /* Lớp xếp chồng */
  --z-sticky: 10; --z-rail: 30; --z-topbar: 40; --z-bottomnav: 45; --z-dropdown: 50;
  --z-scrim: 55; --z-drawer: 60; --z-modal: 70; --z-toast: 80;

  /* Kích thước khung */
  --topbar-h: 3.5rem;
  --rail-w: 16rem;
  --rail-w-collapsed: 4.5rem;
  --bottomnav-h: 4rem;
  --content-max: 90rem;      /* 1440px – màn rộng không kéo dòng quá dài */
  --gutter: 1rem;
  --tap: 2.75rem;            /* vùng chạm tối thiểu 44px */
  --control-h: 2.75rem;

  /* Vòng focus đặc 2px màu nhận diện (≥3:1 trên nền trắng/xám – WCAG 1.4.11), cách 2px nền trắng để nổi cả trên nút xanh */
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 180ms;

  color-scheme: light;
  accent-color: var(--brand);
}

/* ---------- 3. Nền tảng ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + var(--sp-4)); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--ground);
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
@media (min-width: 768px) { :root { --fs-base: .9375rem; --gutter: 1.5rem; } }
@media (min-width: 1280px) { :root { --gutter: 2rem; } }

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: 600; letter-spacing: 0; text-wrap: balance; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-md); }
h3 { font-size: var(--fs-base); }
p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }
small { font-size: var(--fs-sm); }
code, kbd { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .875em; }
kbd { padding: 0 .35em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--surface); color: var(--ink-2); }
::selection { background: var(--brand-tint-2); color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
html { scrollbar-color: #A9B6C6 transparent; }

.num, .tabular, table { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.visually-hidden, .sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--sp-3); top: -100px; z-index: 100; padding: var(--sp-2) var(--sp-4); background: var(--surface); border-radius: var(--r-sm); box-shadow: var(--sh-2); }
.skip-link:focus { top: var(--sp-3); }

.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.cluster--between { justify-content: space-between; }
.grid { display: grid; gap: var(--sp-4); }
@media (min-width: 768px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Biểu tượng (sprite Lucide) – nét kế thừa màu chữ */
.icon {
  width: 1.25rem; height: 1.25rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: 1rem; height: 1rem; }
.icon--lg { width: 1.5rem; height: 1.5rem; }
.icon--xl { width: 2rem; height: 2rem; stroke-width: 1.6; }

/* ---------- 4. Khung ứng dụng (app shell) ----------
   < 768px : thanh trên + thanh điều hướng dưới; menu đầy đủ trong ngăn kéo.
   768–1279: rail chỉ biểu tượng mặc định, bấm nút để mở rộng (D-04).
   ≥ 1280  : rail mở rộng (biểu tượng + chữ) mặc định. Lựa chọn thu/mở của người dùng
             (data-sidebar, early.js đặt trước khi vẽ) được nhớ và luôn thắng mặc định.
------------------------------------------------------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.shell__main {
  min-width: 0;
  padding: var(--sp-4) var(--gutter) calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-8));
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.shell__inner { max-width: var(--content-max); margin: 0 auto; }

/* Thanh trên */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--sp-1);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--sp-2), env(safe-area-inset-right)) 0 max(var(--sp-3), env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; min-height: var(--tap); color: var(--ink); text-decoration: none; margin-right: auto; }
.topbar__brand img { width: 2.25rem; height: 2.25rem; }
.topbar__brand strong { font-size: var(--fs-md); letter-spacing: .01em; }
.topbar__menu-btn { display: none; }
.topbar__search { display: none; flex: 1 1 auto; max-width: 32rem; }
.topbar__search.is-open {
  display: flex; position: absolute; inset: 100% 0 auto 0; max-width: none;
  padding: var(--sp-2) var(--sp-3); background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--sh-2);
}
.topbar__actions { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; }
.topbar__create { display: none; }
.topbar__account-name { display: none; }

.search { position: relative; display: flex; align-items: center; width: 100%; }
.search .icon { position: absolute; left: .75rem; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 2.5rem; padding: 0 2.75rem 0 2.5rem;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  font-size: var(--fs-base);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: 2px solid transparent; border-color: var(--brand); background: var(--surface); box-shadow: var(--focus); }
.search kbd { position: absolute; right: .6rem; display: none; }
/* Màn cảm ứng hoặc hẹp: ô tìm kiếm đạt vùng chạm 44px. */
@media (pointer: coarse), (max-width: 1023px) { .search input { height: var(--tap); } }

/* Rail / ngăn kéo */
.rail {
  position: fixed; z-index: var(--z-drawer); inset: 0 auto 0 0;
  width: min(20rem, 86vw);
  display: flex; flex-direction: column;
  background: var(--rail); color: var(--rail-ink);
  transform: translateX(-100%); visibility: hidden;
  transition: transform 220ms var(--ease), visibility 0s linear 220ms;
  padding-left: env(safe-area-inset-left);
}
html[data-drawer="open"] .rail { transform: none; visibility: visible; transition: transform 220ms var(--ease); box-shadow: var(--sh-3); }
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: rgba(11, 43, 79, .5); opacity: 0; visibility: hidden; transition: opacity 200ms; }
html[data-drawer="open"] .scrim { opacity: 1; visibility: visible; }
html[data-drawer="open"] body { overflow: hidden; }

.rail__head {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--sp-2) 0 var(--sp-4);
  border-bottom: 1px solid var(--rail-line);
}
.rail__brand { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); min-width: var(--tap); min-height: var(--tap); color: #fff; text-decoration: none; border-radius: var(--r-sm); }
.rail__brand:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.rail__brand:hover { color: #fff; }
.rail__brand img { width: 2.25rem; height: 2.25rem; flex: none; }
.rail__brand-text { display: grid; line-height: 1.2; min-width: 0; }
.rail__brand-text strong { font-size: var(--fs-md); font-weight: 700; letter-spacing: .02em; }
.rail__brand-text span { font-size: var(--fs-xs); color: var(--rail-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail__close { margin-left: auto; color: var(--rail-ink); }
.rail__close:hover { background: var(--rail-2); color: #fff; }
.rail__nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-6); scrollbar-color: rgba(255,255,255,.25) transparent; }
.rail__foot { border-top: 1px solid var(--rail-line); padding: var(--sp-2) var(--sp-3) calc(var(--sp-2) + env(safe-area-inset-bottom)); display: none; }

.nav-section + .nav-section { margin-top: var(--sp-4); }
.nav-section__label { display: block; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); font-weight: 500; color: var(--rail-ink-2); }
.nav-list { list-style: none; display: grid; gap: 2px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  min-height: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--rail-ink); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.nav-link .icon { color: var(--rail-ink-2); }
.nav-link:hover { background: var(--rail-2); color: #fff; }
.nav-link:hover .icon { color: #fff; }
.nav-link[aria-current="page"] { background: var(--rail-active); color: #fff; font-weight: 600; }
.nav-link[aria-current="page"] .icon { color: #fff; }
.nav-link:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.nav-link__text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link__count { min-width: 1.5rem; padding: 0 .4rem; border-radius: var(--r-pill); background: rgba(255,255,255,.16); color: #fff; font-size: var(--fs-xs); font-weight: 600; text-align: center; line-height: 1.4rem; }
.rail-toggle { width: 100%; justify-content: flex-start; color: var(--rail-ink-2); }
.rail-toggle:hover { background: var(--rail-2); color: #fff; }

/* Thanh điều hướng dưới (điện thoại) */
.bottomnav {
  position: fixed; z-index: var(--z-bottomnav); inset: auto 0 0 0;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding: 0 max(var(--sp-1), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--sp-1), env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px -8px rgba(16, 42, 73, .16);
}
.bottomnav__item {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px;
  min-height: var(--tap); padding: .55rem 2px var(--sp-1);
  border: 0; background: none; color: var(--ink-3); text-decoration: none;
  font-size: .6875rem; font-weight: 500; line-height: 1.2; text-align: center;
}
.bottomnav__item > span:last-child { max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.15; }
.bottomnav__item .icon { width: 1.4rem; height: 1.4rem; }
.bottomnav__item[aria-current="page"] { color: var(--brand); font-weight: 600; }
.bottomnav__item[aria-current="page"] .icon { stroke-width: 2.3; }
.bottomnav__item:hover { color: var(--brand); }
.bottomnav__icon { position: relative; }
.bottomnav__dot { position: absolute; top: -4px; right: -8px; min-width: 1.1rem; padding: 0 .3rem; border-radius: var(--r-pill); background: var(--red-solid); color: #fff; font-size: .6875rem; font-weight: 700; line-height: 1.1rem; border: 2px solid var(--surface); }
.bottomnav__create { flex: 0 0 auto; padding: 0 var(--sp-2); display: flex; align-items: center; }
.bottomnav__fab {
  display: inline-grid; place-items: center; width: 3.25rem; height: 3.25rem; margin-top: -1.25rem;
  border-radius: 50%; background: var(--brand); color: #fff; text-decoration: none;
  box-shadow: 0 6px 16px -4px rgba(0, 96, 175, .55), 0 0 0 4px var(--surface);
}
.bottomnav__fab:hover { background: var(--brand-hover); color: #fff; }
.bottomnav__fab .icon { width: 1.6rem; height: 1.6rem; stroke-width: 2.4; }

@media (min-width: 640px) {
  .topbar__search { display: flex; }
  .topbar__search-btn { display: none; }
  .topbar__brand { margin-right: var(--sp-3); }
  .topbar__brand-name { display: none; }
}

/* Từ 768px: rail cố định bên trái, không còn thanh dưới */
@media (min-width: 768px) {
  .shell {
    display: grid;
    grid-template-columns: var(--rail-w-collapsed) minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "rail top" "rail main";
  }
  .shell__main { grid-area: main; padding-bottom: var(--sp-12); }
  .topbar { grid-area: top; height: var(--topbar-h); padding: 0 var(--gutter) 0 var(--sp-3); gap: var(--sp-2); }
  .topbar__brand { display: none; }
  .topbar__menu-btn { display: inline-flex; }
  .topbar__create { display: inline-flex; }
  .bottomnav { display: none; }
  .rail {
    grid-area: rail; position: sticky; top: 0; height: 100vh; height: 100dvh;
    width: var(--rail-w-collapsed); transform: none; visibility: visible; transition: none;
    z-index: var(--z-rail); padding-left: 0;
  }
  .rail__close { display: none; }
  .rail__foot { display: block; }
  .rail__head { min-height: var(--topbar-h); padding: 0 var(--sp-4); }
  .scrim { display: none; }
  /* Rail thu gọn: chỉ biểu tượng, nhãn đọc được qua aria/title */
  .rail .rail__brand-text, .rail .nav-link__text, .rail .nav-section__label, .rail .rail-toggle__text { display: none; }
  .rail .nav-section + .nav-section { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--rail-line); }
  .rail .nav-link { justify-content: center; padding: 0; }
  .rail .nav-link__count { position: absolute; top: 3px; right: 5px; min-width: 1.1rem; line-height: 1.1rem; font-size: .6875rem; background: var(--red-solid); }
  .rail .rail-toggle { justify-content: center; }
  .rail .rail__nav { padding: var(--sp-3) var(--sp-2); }
  .rail .rail__head { justify-content: center; padding: 0; }
  .rail-toggle .icon { transform: scaleX(-1); }

  /* Mở rộng (người dùng chọn) */
  html[data-sidebar="expanded"] .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  html[data-sidebar="expanded"] .rail { width: var(--rail-w); }
  html[data-sidebar="expanded"] .rail .rail__brand-text,
  html[data-sidebar="expanded"] .rail .nav-link__text,
  html[data-sidebar="expanded"] .rail .rail-toggle__text { display: initial; }
  html[data-sidebar="expanded"] .rail .rail__brand-text { display: grid; }
  html[data-sidebar="expanded"] .rail .nav-section__label { display: block; }
  html[data-sidebar="expanded"] .rail .nav-section + .nav-section { border-top: 0; padding-top: 0; margin-top: var(--sp-4); }
  html[data-sidebar="expanded"] .rail .nav-link { justify-content: flex-start; padding: 0 var(--sp-3); }
  html[data-sidebar="expanded"] .rail .nav-link__count { position: static; background: rgba(255,255,255,.16); min-width: 1.5rem; line-height: 1.4rem; font-size: var(--fs-xs); }
  html[data-sidebar="expanded"] .rail .rail-toggle { justify-content: flex-start; }
  html[data-sidebar="expanded"] .rail .rail-toggle .icon { transform: none; }
  html[data-sidebar="expanded"] .rail .rail__nav { padding: var(--sp-3) var(--sp-3) var(--sp-6); }
  html[data-sidebar="expanded"] .rail .rail__head { justify-content: flex-start; padding: 0 var(--sp-4); }
}
/* ≥1280: mặc định mở rộng, trừ khi người dùng đã thu gọn (D-04) */
@media (min-width: 1280px) {
  html:not([data-sidebar="collapsed"]) .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  html:not([data-sidebar="collapsed"]) .rail { width: var(--rail-w); }
  html:not([data-sidebar="collapsed"]) .rail .rail__brand-text { display: grid; }
  html:not([data-sidebar="collapsed"]) .rail .nav-link__text,
  html:not([data-sidebar="collapsed"]) .rail .rail-toggle__text { display: initial; }
  html:not([data-sidebar="collapsed"]) .rail .nav-section__label { display: block; }
  html:not([data-sidebar="collapsed"]) .rail .nav-section + .nav-section { border-top: 0; padding-top: 0; margin-top: var(--sp-4); }
  html:not([data-sidebar="collapsed"]) .rail .nav-link { justify-content: flex-start; padding: 0 var(--sp-3); }
  html:not([data-sidebar="collapsed"]) .rail .nav-link__count { position: static; background: rgba(255,255,255,.16); min-width: 1.5rem; line-height: 1.4rem; font-size: var(--fs-xs); }
  html:not([data-sidebar="collapsed"]) .rail .rail-toggle { justify-content: flex-start; }
  html:not([data-sidebar="collapsed"]) .rail .rail-toggle .icon { transform: none; }
  html:not([data-sidebar="collapsed"]) .rail .rail__nav { padding: var(--sp-3) var(--sp-3) var(--sp-6); }
  html:not([data-sidebar="collapsed"]) .rail .rail__head { justify-content: flex-start; padding: 0 var(--sp-4); }
}
@media (min-width: 1024px) {
  .topbar__account-name { display: block; }
  .search kbd { display: inline-block; }
}

/* Đầu trang: vị trí, tiêu đề, thao tác */
.page-head { margin-bottom: var(--sp-5); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-2); font-size: var(--fs-sm); color: var(--ink-3); margin-bottom: var(--sp-1); }
.crumbs li { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }
@media (pointer: coarse), (max-width: 1023px) { .crumbs ol { margin-bottom: 0; } .crumbs a { display: inline-flex; align-items: center; min-height: var(--tap); } }
.crumbs [aria-current] { color: var(--ink-3); }
.page-head__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3) var(--sp-4); }
.page-head__titles { min-width: 0; flex: 1 1 20rem; }
.page-title { font-size: var(--fs-lg); font-weight: 600; }
.page-title .badge, .page-title .prio { vertical-align: middle; margin-left: var(--sp-2); }
.page-sub { margin-top: var(--sp-1); color: var(--ink-2); font-size: var(--fs-sm); }
.page-sub:empty, .page-actions:empty, .crumbs ol:empty { display: none; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
@media (min-width: 768px) { .page-title { font-size: var(--fs-xl); } }
@media (max-width: 639px) {
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1 1 auto; }
}

/* ---------- 5. Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.btn:active { background: var(--surface-3); }
.btn:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--ink-on-brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn--primary:active { background: var(--brand-press); }
.btn--danger { background: var(--red-solid); border-color: var(--red-solid); color: #fff; }
.btn--danger:hover { background: #AE2620; border-color: #AE2620; color: #fff; }
.btn--success { background: #237A42; border-color: #237A42; color: #fff; }
.btn--success:hover { background: #1D6838; border-color: #1D6838; color: #fff; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn--link { border: 0; background: none; padding: 0; min-height: auto; color: var(--brand); font-weight: 500; }
.btn--link:hover { background: none; text-decoration: underline; color: var(--brand-hover); }
.btn--sm { min-height: 2.25rem; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { min-height: 3.25rem; padding: 0 var(--sp-6); font-size: var(--fs-base); }
.btn--block { width: 100%; }
.btn--icon { flex: none; width: var(--tap); min-width: var(--tap); min-height: var(--tap); padding: 0; border-color: transparent; background: transparent; color: var(--ink-2); position: relative; }
.btn--icon:hover { background: var(--surface-3); border-color: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
/* Nút chính bị vô hiệu: nền xám thay vì xanh nhạt (xanh nhạt trông vẫn bấm được) */
.btn--primary[disabled], .btn--primary[aria-disabled="true"] { opacity: 1; background: var(--surface-3); border-color: var(--line); color: var(--ink-3); box-shadow: none; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 1.1rem; height: 1.1rem;
  border: 2px solid currentColor; border-radius: 50%; border-right-color: transparent;
  color: var(--ink-2); animation: spin .7s linear infinite;
}
.btn--primary.is-busy::after, .btn--danger.is-busy::after, .btn--success.is-busy::after { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.count-dot {
  position: absolute; top: 4px; right: 3px; min-width: 1.15rem; padding: 0 .3rem;
  border-radius: var(--r-pill); background: var(--red-solid); color: #fff; border: 2px solid var(--surface);
  font-size: .6875rem; font-weight: 700; line-height: 1rem; text-align: center;
}
@media (min-width: 1024px) and (pointer: fine) {
  :root { --control-h: 2.375rem; }
  .btn--sm { min-height: 2rem; }
}

/* ---------- 6. Biểu mẫu ---------- */
.form { max-width: 48rem; }
.form-section + .form-section { margin-top: var(--sp-6); padding-top: var(--sp-6); border-top: 1px solid var(--line-soft); }
.form-section__title { font-size: var(--fs-md); margin-bottom: var(--sp-1); }
.form-section__desc { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
/* align-items/align-content: start – ô bên cạnh có dòng gợi ý/lỗi không kéo giãn ô nhập (grid mặc định stretch) */
.form-row { display: grid; gap: var(--sp-4); align-items: start; }
@media (min-width: 640px) { .form-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.field { display: grid; gap: var(--sp-1); min-width: 0; align-content: start; }
.field + .field, .form-row + .field, .field + .form-row, .form-row + .form-row { margin-top: var(--sp-4); }
.form-row > .field + .field { margin-top: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.field__req { color: var(--red-fg); margin-left: 2px; text-decoration: none; }
.field__opt { color: var(--ink-3); font-weight: 400; margin-left: var(--sp-1); }
.field__help { font-size: var(--fs-sm); color: var(--ink-3); }
.field__error { display: flex; gap: var(--sp-1); align-items: flex-start; font-size: var(--fs-sm); color: var(--red-fg); font-weight: 500; }
.field__error .icon { margin-top: .1em; }

.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), .field select, .field textarea, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: .5rem .75rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-size: 1rem; line-height: 1.4;
  transition: border-color var(--dur), box-shadow var(--dur);
}
.field textarea, .textarea { min-height: 6.5rem; resize: vertical; }
.field select, .select { padding-right: 2.25rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6B7F' stroke-width='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 .65rem center; background-size: 1rem; }
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-3); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .select:focus, .textarea:focus { outline: 2px solid transparent; border-color: var(--brand); box-shadow: var(--focus); }
.field [aria-invalid="true"], .input[aria-invalid="true"] { border-color: var(--red-solid); }
.field [aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(200, 50, 42, .25); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--surface-2); color: var(--ink-3); cursor: not-allowed; }
::placeholder { color: #66768A; opacity: 1; }
@media (min-width: 1024px) and (pointer: fine) {
  .input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, .select { font-size: var(--fs-base); }
}

.check { display: flex; align-items: flex-start; gap: var(--sp-3); min-height: var(--tap); padding: var(--sp-2) 0; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: .2rem 0 0; flex: none; }
.check__text { display: grid; }
.check__hint { font-size: var(--fs-sm); color: var(--ink-3); }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field > legend { padding: 0; margin-bottom: var(--sp-1); }
.choice-list { display: grid; gap: 0; }
.choice-list--inline { display: flex; flex-wrap: wrap; gap: 0 var(--sp-5); }

/* Lựa chọn dạng thẻ (radio lớn) – chế độ nghiệm thu, minh chứng, kết luận nghiệm thu */
.choices { display: grid; gap: var(--sp-2); }
@media (min-width: 640px) { .choices--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .choices--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice { position: relative; display: flex; gap: var(--sp-3); align-items: flex-start; min-height: 3.5rem; padding: var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; transition: border-color var(--dur), background-color var(--dur); }
.choice:hover { border-color: var(--ink-3); }
.choice input { margin: .2rem 0 0; width: 1.1rem; height: 1.1rem; flex: none; }
.choice__body { display: grid; gap: 2px; min-width: 0; }
.choice__title { font-weight: 600; font-size: var(--fs-sm); display: flex; gap: var(--sp-2); align-items: center; }
.choice__desc { font-size: var(--fs-sm); color: var(--ink-3); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.choice:has(input:focus-visible) { box-shadow: var(--focus); }
.choice--approve:has(input:checked) { border-color: var(--green-solid); background: var(--green-bg); box-shadow: inset 0 0 0 1px var(--green-solid); }
.choice--supplement:has(input:checked) { border-color: var(--amber-solid); background: var(--amber-bg); box-shadow: inset 0 0 0 1px var(--amber-solid); }
.choice--redo:has(input:checked) { border-color: var(--red-solid); background: var(--red-bg); box-shadow: inset 0 0 0 1px var(--red-solid); }
.choice--approve .choice__title .icon { color: var(--green-solid); }
.choice--supplement .choice__title .icon { color: var(--amber-solid); }
.choice--redo .choice__title .icon { color: var(--red-solid); }

/* Nhóm nút phân đoạn (ưu tiên, kỳ thời gian) */
.segmented { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border-radius: var(--r-md); background: var(--surface-3); }
.segmented label, .segmented a { position: relative; display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 2.5rem; text-wrap: balance; padding: 0 var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked), .segmented a[aria-current] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--sh-1); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus); }

.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-6); }
.form-actions--sticky {
  position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); z-index: var(--z-sticky);
  margin: var(--sp-6) calc(var(--gutter) * -1) 0; padding: var(--sp-3) var(--gutter);
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 12px -10px rgba(16, 42, 73, .3);
}
@media (min-width: 768px) { .form-actions--sticky { bottom: 0; margin: var(--sp-6) 0 0; padding: var(--sp-3) 0; background: transparent; border-top: 0; position: static; } }
.form-actions__spacer { flex: 1; }
.form-actions--flush { margin-top: 0; }
/* Thanh thao tác là con trực tiếp của .panel (form = panel): thụt lề như .panel__foot – nút chính không dính mép phải/dưới khối */
.panel > .form-actions:not(.form-actions--sticky):not(.panel__foot) { margin-top: 0; padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--line-soft); }
@media (min-width: 768px) { .panel > .form-actions:not(.panel__foot) { margin-top: 0; padding: var(--sp-3) var(--sp-5) var(--sp-4); border-top: 1px solid var(--line-soft); } }
@media (max-width: 639px) {
  .form-actions .btn { flex: 1 1 auto; }
  .form-actions--sticky { flex-wrap: nowrap; gap: var(--sp-2); }
  .form-actions--sticky .form-actions__spacer { display: none; }
  .form-actions--sticky .btn { flex: 1 1 0; min-width: 0; padding: 0 var(--sp-2); }
  .form-actions--sticky [data-step-next], .form-actions--sticky [data-step-final], .form-actions--sticky .btn--primary { flex: 2 1 0; }
}

/* Thanh lọc thu gọn được (trạng thái nhớ qua data-filters trên <html>) */
.filters { margin-bottom: var(--sp-4); }
.filters__bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.filters__toggle[aria-expanded="true"] .icon--chev { transform: rotate(180deg); }
.filters__count { font-variant-numeric: tabular-nums; display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: var(--r-pill); background: var(--brand); color: #fff; font-size: var(--fs-xs); }
.filters__panel {
  display: none; margin-top: var(--sp-3); padding: var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); gap: var(--sp-3) var(--sp-4); align-items: end;
}
.filters__panel .field + .field { margin-top: 0; }
.filters__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filters__chips { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
@media (min-width: 1280px) { .filters--open-wide .filters__panel { display: grid; } }
html[data-filters="open"] .filters__panel { display: grid; }
html[data-filters="closed"] .filters__panel { display: none; }
.chip { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: 2rem; padding: 0 var(--sp-2) 0 var(--sp-3); border-radius: var(--r-pill); background: var(--brand-tint); color: var(--blue-fg); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; }
.chip:hover { background: var(--brand-tint-2); color: var(--blue-fg); }
.chip .icon { width: .9rem; height: .9rem; }

/* ---------- 7. Nhãn trạng thái: HAI TRỤC ĐỘC LẬP ----------
   Trạng thái xử lý (.badge)  = viên thuốc NỀN NHẠT + chấm tròn.
   Tình trạng thời hạn (.dl)  = thẻ VIỀN + biểu tượng đồng hồ/kết quả, nền trắng.
   Ưu tiên (.prio)            = cờ; chỉ "Cao" và "Khẩn" mới hiện. */
.badge {
  display: inline-flex; align-items: center; gap: .4rem; max-width: 100%;
  min-height: 1.5rem; padding: 0 .6rem 0 .5rem; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.2; white-space: nowrap;
  background: var(--tone-bg, var(--slate-bg)); color: var(--tone-fg, var(--slate-fg));
}
.badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--tone-solid, var(--slate-solid)); flex: none; }
.dl {
  display: inline-flex; align-items: center; gap: .3rem; max-width: 100%;
  min-height: 1.5rem; padding: 0 .5rem 0 .35rem; border-radius: var(--r-xs);
  border: 1px solid var(--tone-solid, var(--slate-solid)); background: var(--surface);
  color: var(--tone-fg, var(--slate-fg)); font-size: var(--fs-xs); font-weight: 600; line-height: 1.2; white-space: nowrap;
}
.dl .icon { width: .95rem; height: .95rem; color: var(--tone-solid); }
.dl--strong { background: var(--tone-bg); }
.prio { display: inline-flex; align-items: center; gap: .25rem; min-height: 1.5rem; padding: 0 .45rem; border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.prio .icon { width: .9rem; height: .9rem; }
.prio--URGENT { background: var(--red-solid); color: #fff; }
.prio--HIGH { background: var(--amber-bg); color: var(--amber-fg); }
.prio--NORMAL { background: var(--slate-bg); color: var(--slate-fg); font-weight: 600; }
.tag { display: inline-flex; align-items: center; gap: .3rem; min-height: 1.5rem; padding: 0 .5rem; border-radius: var(--r-xs); background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }

.tone-slate  { --tone-fg: var(--slate-fg);  --tone-bg: var(--slate-bg);  --tone-solid: var(--slate-solid); }
.tone-blue   { --tone-fg: var(--blue-fg);   --tone-bg: var(--blue-bg);   --tone-solid: var(--blue-solid); }
.tone-violet { --tone-fg: var(--violet-fg); --tone-bg: var(--violet-bg); --tone-solid: var(--violet-solid); }
.tone-amber  { --tone-fg: var(--amber-fg);  --tone-bg: var(--amber-bg);  --tone-solid: var(--amber-solid); }
.tone-red    { --tone-fg: var(--red-fg);    --tone-bg: var(--red-bg);    --tone-solid: var(--red-solid); }
.tone-green  { --tone-fg: var(--green-fg);  --tone-bg: var(--green-bg);  --tone-solid: var(--green-solid); }
.tone-teal   { --tone-fg: var(--teal-fg);   --tone-bg: var(--teal-bg);   --tone-solid: var(--teal-solid); }
.tone-rust   { --tone-fg: var(--rust-fg);   --tone-bg: var(--rust-bg);   --tone-solid: var(--rust-solid); }
.tone-grey   { --tone-fg: var(--grey-fg);   --tone-bg: var(--grey-bg);   --tone-solid: var(--grey-solid); }

/* ---------- 8. Thước hạn (signature) ----------
   Dải thời gian từ ngày bắt đầu đến hạn; phần đã trôi qua tô theo tình trạng thời hạn;
   quá hạn: phần vượt hạn kéo dài sau vạch hạn; đã nộp: vạch nộp. */
.ruler { display: grid; gap: .3rem; min-width: 8rem; }
.ruler__track { position: relative; height: .5rem; border-radius: var(--r-pill); background: var(--surface-3); }
.ruler__fill { position: absolute; inset: 0 auto 0 0; border-radius: var(--r-pill); background: var(--tone-solid, var(--blue-solid)); }
.ruler__over { position: absolute; top: 0; bottom: 0; border-radius: 0 var(--r-pill) var(--r-pill) 0; background: var(--red-solid); opacity: .38; }
.ruler__due { position: absolute; top: -.3rem; bottom: -.3rem; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }
.ruler__now { position: absolute; top: 50%; width: .8rem; height: .8rem; margin: -.4rem 0 0 -.4rem; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--tone-solid, var(--blue-solid)); box-shadow: 0 0 0 2px var(--surface); }
.ruler__sub { position: absolute; top: -.3rem; bottom: -.3rem; width: 0; border-left: 2px dashed var(--ink-2); }
.ruler__sub::after { content: ""; position: absolute; top: -.35rem; left: -.32rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--ink-2); }
.ruler__labels { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); line-height: 1.35; }
.ruler__labels > span { white-space: nowrap; }
.ruler__rel { color: var(--tone-fg, var(--ink-2)); font-weight: 600; text-align: center; }
.ruler__end { text-align: right; }
.ruler--compact { min-width: 6.5rem; gap: .25rem; }
.ruler--compact .ruler__track { height: .375rem; }
.ruler--compact .ruler__now { width: .65rem; height: .65rem; margin: -.325rem 0 0 -.325rem; border-width: 2px; }
.ruler--compact .ruler__labels { justify-content: flex-start; column-gap: var(--sp-2); }
.ruler.tone-grey .ruler__fill { opacity: .5; }

/* ---------- 9. Khối bề mặt ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); padding: var(--sp-4) var(--sp-4) 0; }
/* Tiêu đề co lại (xuống dòng) trước khi đẩy nút thao tác xuống hàng riêng trên màn hẹp */
.panel__title { flex: 1 1 8rem; min-width: 0; font-size: var(--fs-md); font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-2); }
.panel__title .count { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink-3); font-size: var(--fs-sm); }
.panel__desc { width: 100%; color: var(--ink-3); font-size: var(--fs-sm); margin-top: -.25rem; }
.panel__body { padding: var(--sp-4); }
.panel__body--flush { padding: var(--sp-3) 0 0; }
.panel__foot { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line-soft); display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: space-between; font-size: var(--fs-sm); }
@media (min-width: 768px) { .panel__head { padding: var(--sp-5) var(--sp-5) 0; } .panel__body { padding: var(--sp-5); } .panel__foot { padding: var(--sp-3) var(--sp-5); } }
.section-gap > * + * { margin-top: var(--sp-5); }

/* Danh sách mô tả (thông tin công việc, hồ sơ) */
.dlist { display: grid; gap: var(--sp-3) var(--sp-5); margin: 0; }
.dlist > div { display: grid; gap: 2px; min-width: 0; align-content: start; }
.dlist dt { font-size: var(--fs-sm); color: var(--ink-3); }
.dlist dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.dlist--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1024px) { .dlist--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.prose { max-width: 70ch; }
.prose p { margin-bottom: var(--sp-3); }
.prose ul { padding-left: 1.25rem; margin-bottom: var(--sp-3); }

/* ---------- 10. Chỉ số (KPI) ----------
   Một dải chia ô bằng đường mảnh, mỗi ô là liên kết tới danh sách chi tiết. */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; container-type: inline-size; }
.kpi { position: relative; display: grid; align-content: start; gap: 2px; padding: var(--sp-3) var(--sp-4); background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0; min-height: 5.25rem; }
a.kpi:hover { background: var(--surface-2); color: var(--ink); }
a.kpi:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; z-index: 1; }
.kpi__label { font-size: var(--fs-sm); color: var(--ink-2); display: flex; align-items: center; gap: var(--sp-1); }
.kpi__label .icon { width: 1rem; height: 1rem; color: var(--tone-solid, var(--ink-3)); }
.kpi__value { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--tone-fg, var(--ink)); }
.kpi__value small { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 2px; }
.kpi__note { font-size: var(--fs-xs); color: var(--ink-3); }
.kpi__go { position: absolute; top: var(--sp-3); right: var(--sp-3); width: 1rem; height: 1rem; color: #9AA8B8; }
a.kpi:hover .kpi__go { color: var(--brand); }
.kpi--alert { background: var(--red-bg); }
a.kpi--alert:hover { background: #F9DCDA; }
.kpi--alert .kpi__note { color: var(--red-fg); }
@media (max-width: 767px) { .kpi--priority { order: -1; } }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .kpi__value { font-size: var(--fs-2xl); } }
@media (min-width: 1600px) { .kpis--8 { grid-template-columns: repeat(8, minmax(0, 1fr)); } }

/* ---------- 11. Bảng dữ liệu ↔ danh sách thẻ ---------- */
.table-wrap { container-type: inline-size; container-name: dtable; min-width: 0; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.table th, .table td { padding: .625rem .75rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.table thead th { background: var(--surface-2); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; border-bottom-color: var(--line); position: sticky; top: 0; }
.table tbody tr:hover { background: #F7FAFD; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-selected, .table tr:has(.row-check:checked) { background: #EEF5FC; }
.table .is-num, .table .c-num { text-align: right; }
.table .c-check { width: 2.75rem; padding-right: 0; }
.table .c-check input { width: 1.1rem; height: 1.1rem; }
.table .c-title a { color: var(--ink); font-weight: 600; text-decoration: none; }
.table .c-title a:hover { color: var(--brand); text-decoration: underline; }
.table .c-title { min-width: 15rem; }
.table .c-title .code { display: block; font-size: var(--fs-xs); color: var(--ink-3); font-weight: 500; white-space: nowrap; }
.table .c-extra, .table .c-prio { white-space: nowrap; }
.table .c-deadline { min-width: 11.5rem; }
.table .c-action { text-align: right; white-space: nowrap; }
.table .c-people { white-space: nowrap; }
.th-sort { display: inline-flex; align-items: center; gap: .25rem; color: inherit; text-decoration: none; min-height: 1.75rem; }
.th-sort:hover { color: var(--brand); }
.th-sort .icon { width: .85rem; height: .85rem; color: #98A6B6; }
.th-sort[aria-sort] .icon, th[aria-sort] .th-sort .icon { color: var(--brand); }
.th-sort--asc .icon { transform: rotate(180deg); }
.person { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.person__name { overflow: hidden; text-overflow: ellipsis; }
.person__more { font-size: var(--fs-xs); color: var(--ink-3); }

/* Màn hẹp: mỗi hàng thành một thẻ (tên, người, hạn, trạng thái, ưu tiên, thao tác chính) */
@container dtable (max-width: 47.99rem) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody { display: block; }
  .table tbody tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "check title prio" "check people people" "check deadline deadline" "check status action";
    gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--line-soft);
  }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tbody td { display: block; padding: 0; border: 0; min-width: 0; }
  .table td.c-check { grid-area: check; width: auto; padding-top: .1rem; }
  .table td.c-title { grid-area: title; font-size: .9375rem; }
  .table td.c-prio { grid-area: prio; text-align: right; }
  .table td.c-people { grid-area: people; white-space: normal; }
  .table td.c-deadline { grid-area: deadline; min-width: 0; }
  .table td.c-status { grid-area: status; display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; }
  .table td.c-action { grid-area: action; align-self: end; }
  .table td.c-extra { grid-column: 2 / -1; font-size: var(--fs-sm); color: var(--ink-2); }
  .table td.c-extra[data-label]::before { content: attr(data-label) ": "; color: var(--ink-3); }
  .table td.c-hide-sm, .table td:empty { display: none; }
  .table td.c-title .code { display: inline; margin-left: var(--sp-1); }
  .table .ruler--compact .ruler__labels { justify-content: space-between; }
}
/* Bảng số liệu thuần (báo cáo): chỉ cuộn ngang trong khung, không đổi thành thẻ */
.table--data { min-width: 36rem; }
.table-wrap--scroll .table { display: table; }

.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); margin: 0 0 var(--sp-2);
  background: var(--brand-tint); border: 1px solid var(--brand-tint-2); border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.bulkbar__count { font-weight: 600; color: var(--blue-fg); margin-right: auto; }
.table-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.select-all { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); min-height: var(--tap); }

/* Phân trang */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line-soft); font-size: var(--fs-sm); color: var(--ink-3); }
.pager__list { list-style: none; display: flex; flex-wrap: wrap; gap: 2px; }
.pager__link { display: inline-grid; place-items: center; min-width: var(--tap); height: var(--tap); padding: 0 var(--sp-2); border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.pager__link:hover { background: var(--surface-3); color: var(--ink); }
.pager__link[aria-current="page"] { background: var(--brand); color: #fff; }
.pager__gap { display: inline-grid; place-items: center; min-width: 1.5rem; height: var(--tap); }
@media (min-width: 1024px) and (pointer: fine) { .pager__link { min-width: 2.25rem; height: 2.25rem; } .pager__gap { height: 2.25rem; } }
@media (max-width: 639px) { .pager__num { display: none; } .pager__list .pager__num[aria-current="page"] { display: inline-grid; } }

/* ---------- 12. Ảnh đại diện chữ cái ---------- */
.avatar { display: inline-grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--av-bg, #DCE7F3); color: var(--av-fg, #1E4C7C); font-size: .75rem; font-weight: 600; letter-spacing: .02em; line-height: 1; user-select: none; }
.avatar--sm { width: 1.5rem; height: 1.5rem; font-size: .625rem; }
.avatar--lg { width: 3.5rem; height: 3.5rem; font-size: 1.125rem; }
.avatar--t0 { --av-bg: #DCE7F3; --av-fg: #1E4C7C; }
.avatar--t1 { --av-bg: #DDF0EC; --av-fg: #155E54; }
.avatar--t2 { --av-bg: #E9E3F7; --av-fg: #4B3490; }
.avatar--t3 { --av-bg: #F6E6D8; --av-fg: #7D3F14; }
.avatar--t4 { --av-bg: #E4EBD9; --av-fg: #3F5A1E; }
.avatar--t5 { --av-bg: #F3DFE6; --av-fg: #7E2647; }
.avatars { display: inline-flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
/* Chồng ít (2px) để chữ viết tắt của ảnh bên cạnh không bị che mất một nửa ("TĐ" đọc thành "TE") */
.avatars .avatar + .avatar { margin-left: -.125rem; }

/* ---------- 13. Dòng thời gian (nhật ký) ---------- */
.timeline { list-style: none; position: relative; }
.timeline__item { position: relative; display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); gap: var(--sp-3); padding-bottom: var(--sp-4); }
.timeline__item::before { content: ""; position: absolute; left: calc(.625rem - 1px); top: 1.25rem; bottom: 0; width: 2px; background: var(--line); }
.timeline__item:last-child::before { display: none; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { width: 1.25rem; height: 1.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--tone-bg, var(--slate-bg)); color: var(--tone-solid, var(--slate-solid)); margin-top: .1rem; }
.timeline__dot .icon { width: .75rem; height: .75rem; stroke-width: 2.6; }
.timeline__head { display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); align-items: baseline; font-size: var(--fs-sm); }
.timeline__actor { font-weight: 600; color: var(--ink); }
.timeline__verb { color: var(--ink-2); }
.timeline__time { color: var(--ink-3); font-size: var(--fs-xs); white-space: nowrap; }
.timeline__detail { margin-top: var(--sp-1); font-size: var(--fs-sm); color: var(--ink-2); }
.timeline__detail--box { padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line-soft); }

/* ---------- 14. Trạng thái: trống / đang tải / lỗi / thành công ---------- */
.state { display: grid; justify-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-8) var(--sp-4); }
.state__icon { color: var(--ink-3); }
.state__icon .icon { width: 2.25rem; height: 2.25rem; stroke-width: 1.5; }
.state__title { font-size: var(--fs-md); font-weight: 600; }
.state__text { color: var(--ink-2); font-size: var(--fs-sm); max-width: 44ch; }
.state__actions { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }
.state--error .state__icon { color: var(--red-solid); }
.state--success .state__icon { color: var(--green-solid); }
.state--compact { padding: var(--sp-5) var(--sp-4); }
.skeleton { display: grid; gap: var(--sp-3); padding: var(--sp-4); }
.skeleton__line { height: .75rem; border-radius: var(--r-pill); background: var(--surface-3); animation: pulse 1.4s ease-in-out infinite; }
.skeleton__line:nth-child(2n) { width: 82%; }
.skeleton__line:nth-child(3n) { width: 64%; }
@keyframes pulse { 50% { opacity: .45; } }
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--brand); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }

/* ---------- 15. Thông báo khối (alert) ---------- */
.alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--tone-solid); background: var(--tone-bg); color: var(--ink); font-size: var(--fs-sm); }
.alert > .icon { color: var(--tone-solid); margin-top: .05rem; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 600; color: var(--tone-fg); }
.alert--info { --tone-fg: var(--blue-fg); --tone-bg: var(--blue-bg); --tone-solid: #8DB6DE; }
.alert--success { --tone-fg: var(--green-fg); --tone-bg: var(--green-bg); --tone-solid: #93C9A6; }
.alert--warning { --tone-fg: var(--amber-fg); --tone-bg: var(--amber-bg); --tone-solid: #E3B46A; }
.alert--danger { --tone-fg: var(--red-fg); --tone-bg: var(--red-bg); --tone-solid: #E39A94; }
.alert--info > .icon { color: var(--blue-solid); }
.alert--success > .icon { color: var(--green-solid); }
.alert--warning > .icon { color: var(--amber-solid); }
.alert--danger > .icon { color: var(--red-solid); }

/* ---------- 16. Hộp thoại xác nhận (dvh; bottom sheet trên điện thoại) ---------- */
.modal {
  width: 100%; max-width: 100%; max-height: calc(100dvh - var(--sp-6)); margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--sh-3); overflow: auto; overscroll-behavior: contain;
}
.modal::backdrop { background: rgba(11, 43, 79, .5); }
.modal[open] { animation: sheet-in 220ms var(--ease); }
.modal__inner { display: grid; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) calc(var(--sp-5) + env(safe-area-inset-bottom)); }
.modal__head { display: flex; gap: var(--sp-3); align-items: flex-start; }
.modal__icon { flex: none; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--blue-bg); color: var(--blue-solid); }
.modal--danger .modal__icon { background: var(--red-bg); color: var(--red-solid); }
.modal__title { font-size: var(--fs-md); font-weight: 600; padding-top: .45rem; }
.modal__text { color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-line; }
.modal__actions { display: flex; flex-direction: column-reverse; gap: var(--sp-2); margin-top: var(--sp-2); }
.modal__actions .btn { width: 100%; }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 640px) {
  .modal { width: min(30rem, calc(100vw - 2rem)); margin: auto; border-radius: var(--r-lg); max-height: calc(100dvh - 4rem); }
  .modal__inner { padding: var(--sp-6); }
  .modal__actions { flex-direction: row; justify-content: flex-end; }
  .modal__actions .btn { width: auto; }
  @keyframes sheet-in { from { transform: scale(.97); opacity: 0; } }
}

/* ---------- 17. Thông báo nổi (toast) ---------- */
.toasts { position: fixed; z-index: var(--z-toast); left: var(--sp-3); right: var(--sp-3); bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-3)); display: grid; gap: var(--sp-2); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--ink); color: #fff; box-shadow: var(--sh-3); font-size: var(--fs-sm); animation: toast-in 240ms var(--ease); }
.toast > .icon { margin-top: .05rem; }
/* Dải cảnh báo cố định (message gắn thẻ "banner"): app.js đưa xuống dưới tiêu đề trang; không JS thì vẫn hiện trong vùng toast */
.notice-banner { pointer-events: auto; box-shadow: var(--sh-2); }
.notice-banner.is-placed { box-shadow: none; margin-bottom: var(--sp-5); }
.notice-banner .alert__body > p + p { margin-top: var(--sp-1); }
.notice-banner__link { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; color: var(--amber-fg); }
.toast--success > .icon { color: #7DD6A0; }
.toast--error > .icon { color: #FF9C94; }
.toast--warning > .icon { color: #F6C16B; }
.toast--info > .icon { color: #8EC3F2; }
.toast__text { flex: 1; padding-top: .1rem; }
.toast__close { margin: -.4rem -.25rem -.4rem 0; color: #C9D6E5; width: 2.25rem; min-height: 2.25rem; }
.toast__close:hover { background: rgba(255,255,255,.1); color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 200ms, transform 200ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@media (min-width: 768px) { .toasts { left: auto; right: var(--sp-6); bottom: var(--sp-6); width: 24rem; } }

/* ---------- 18. Menu thả xuống & thông báo ---------- */
.dropdown { position: relative; }
.dropdown__panel {
  position: absolute; z-index: var(--z-dropdown); top: calc(100% + 6px); right: 0;
  min-width: 15rem; max-width: calc(100vw - 1rem);
  padding: var(--sp-1); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2);
}
.menu { list-style: none; display: grid; }
.menu__item, .menu button.menu__item { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--tap); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; text-align: left; }
.menu__item .icon { color: var(--ink-3); }
.menu__item:hover, .menu__item:focus-visible,
.menu button.menu__item:hover, .menu button.menu__item:focus-visible { background: var(--surface-2); color: var(--ink); outline: 2px solid transparent; }
.menu__item:focus-visible, .menu button.menu__item:focus-visible { box-shadow: var(--focus); }
.menu__item--danger, .menu__item--danger .icon { color: var(--red-fg); }
.menu__sep { height: 1px; background: var(--line-soft); margin: var(--sp-1) 0; }
.menu__head { padding: var(--sp-2) var(--sp-3); display: grid; line-height: 1.35; }
.menu__head strong { font-size: var(--fs-sm); }
.menu__head span { font-size: var(--fs-xs); color: var(--ink-3); }
.account-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--tap); min-width: var(--tap); padding: 0 var(--sp-1); border: 0; background: none; border-radius: var(--r-pill); color: var(--ink); }
.account-btn:hover { background: var(--surface-3); }
.account-btn__name { display: grid; min-width: 0; text-align: left; line-height: 1.2; font-size: var(--fs-sm); font-weight: 600; max-width: 12rem; }
/* Họ tên là phần tử riêng (nút văn bản trần trong lưới không cắt được bằng ellipsis) → tên dài cắt "…" thay vì tràn */
.account-btn__name > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn__role { font-size: var(--fs-xs); font-weight: 400; color: var(--ink-3); }

.notif-panel { width: min(24rem, calc(100vw - 1rem)); max-height: calc(100dvh - var(--topbar-h) - 1.5rem); overflow: auto; overscroll-behavior: contain; padding: 0; }
@media (max-width: 639px) {
  .notif-panel { position: fixed; top: calc(var(--topbar-h) + env(safe-area-inset-top)); left: .5rem; right: .5rem; width: auto; max-height: calc(100dvh - var(--topbar-h) - var(--bottomnav-h) - 2rem); overflow: auto; }
}
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.notif-panel__head h2 { font-size: var(--fs-base); }
.notif-panel__foot { padding: 0 var(--sp-4); border-top: 1px solid var(--line-soft); text-align: center; font-size: var(--fs-sm); }
.notif-panel__foot a { display: flex; align-items: center; justify-content: center; min-height: var(--tap); }
.notif-list { list-style: none; }
.notif { position: relative; }
.notif + .notif { border-top: 1px solid var(--line-soft); }
.notif__btn { display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: var(--sp-3); width: 100%; padding: var(--sp-3) var(--sp-4); border: 0; background: none; text-align: left; color: var(--ink); text-decoration: none; min-height: var(--tap); }
.notif__btn:hover { background: var(--surface-2); color: var(--ink); }
.notif__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--tone-bg, var(--slate-bg)); color: var(--tone-solid, var(--slate-solid)); }
.notif__icon .icon { width: 1rem; height: 1rem; }
.notif__title { font-size: var(--fs-sm); font-weight: 500; display: block; }
.notif__body { font-size: var(--fs-xs); color: var(--ink-2); display: block; margin-top: 2px; }
.notif__time { font-size: var(--fs-xs); color: var(--ink-3); display: block; margin-top: 2px; }
.notif.is-unread .notif__title { font-weight: 700; }
.notif__btn { position: relative; }
.notif.is-unread .notif__btn { padding-right: 2.25rem; }
.notif.is-unread .notif__btn::after { content: ""; position: absolute; right: var(--sp-4); top: 1.1rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--brand); }
.notif-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.notif-row .notif__btn { padding-right: var(--sp-2); }
.notif-row__actions { padding-right: var(--sp-3); }
/* Trang Thông báo (không phải bảng thả xuống): chữ lớn hơn cho người đọc lớn tuổi */
.notif-row .notif__title { font-size: var(--fs-base); }
.notif-row .notif__body { font-size: var(--fs-sm); }

/* ---------- 19. Tệp: danh sách, ô chọn, xem trước, tiến trình ---------- */
.files { list-style: none; display: grid; gap: var(--sp-2); }
.file { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.file__icon { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2); font-size: .625rem; font-weight: 700; }
.file__icon--pdf { background: #FBE4E2; color: #A3271F; }
.file__icon--doc { background: #E1ECF9; color: #1D57A0; }
.file__icon--xls { background: #E0F1E6; color: #1F6B3A; }
.file__icon--ppt { background: #FBE9DF; color: #9A3D12; }
.file__icon--img { background: #EFEAFB; color: #5B3AA8; }
.file__body { min-width: 0; }
.file__name { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.file__name:hover { color: var(--brand); text-decoration: underline; }
.file__meta { font-size: var(--fs-xs); color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); }
.file__actions { display: flex; gap: 2px; }
.file--error { border-color: var(--red-solid); background: var(--red-bg); }
.file--error .file__meta { color: var(--red-fg); font-weight: 500; }

.upload { display: grid; gap: var(--sp-3); }
.upload__drop {
  position: relative; display: grid; justify-items: center; gap: var(--sp-1); padding: var(--sp-5) var(--sp-4);
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); text-align: center; cursor: pointer;
}
.upload__drop:hover, .upload__drop.is-dragover { border-color: var(--brand); background: var(--brand-tint); }
.upload__drop:focus-within { box-shadow: var(--focus); border-color: var(--brand); }
.upload__drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload__drop .icon { color: var(--brand); width: 1.75rem; height: 1.75rem; }
.upload__title { font-weight: 600; font-size: var(--fs-sm); }
.upload__title .btn--link { font-weight: 600; }
.upload__hint { font-size: var(--fs-xs); color: var(--ink-3); overflow-wrap: anywhere; }
.upload__summary { font-size: var(--fs-xs); color: var(--ink-3); }
.progress { display: grid; gap: var(--sp-1); }
.progress__bar { height: .5rem; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress__fill { height: 100%; width: 0; background: var(--brand); border-radius: var(--r-pill); transition: width 120ms linear; }
.progress__label { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-2); }
.progress--error .progress__fill { background: var(--red-solid); }
.meter { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-2); }
.meter .progress__bar { flex: 1; min-width: 3rem; }
.meter .progress__bar, .meter .progress__fill { display: block; }

/* ---------- 20. Thẻ (tabs) ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); padding: 0 var(--sp-3); border: 0; background: none; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--brand); font-weight: 600; }
.tab[aria-selected="true"]::after, .tab[aria-current="page"]::after { content: ""; position: absolute; left: var(--sp-2); right: var(--sp-2); bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }
.tab__count { font-variant-numeric: tabular-nums; min-width: 1.4rem; padding: 0 .4rem; border-radius: var(--r-pill); background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; line-height: 1.4rem; text-align: center; }
.tab[aria-selected="true"] .tab__count, .tab[aria-current="page"] .tab__count { background: var(--brand-tint); color: var(--blue-fg); }
.tab__count--alert { background: var(--red-bg); color: var(--red-fg); }
.tabs--panel { padding: 0 var(--sp-2); }
.tabpanel { padding-top: var(--sp-4); }
.tabpanel:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus); border-radius: var(--r-xs); }

/* ---------- 21. Tiến trình biểu mẫu nhiều bước ---------- */
.steps { list-style: none; display: flex; gap: var(--sp-2); counter-reset: step; margin-bottom: var(--sp-5); }
.step { flex: 1 1 0; min-width: 0; display: grid; gap: var(--sp-2); }
.step__bar { height: .3rem; border-radius: var(--r-pill); background: var(--surface-3); }
.step__label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--ink-3); font-weight: 500; min-width: 0; }
.step__num { display: inline-grid; place-items: center; flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1.5px solid var(--line-strong); font-size: .6875rem; font-weight: 700; background: var(--surface); }
.step__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step--done .step__bar { background: var(--brand); }
.step--done .step__num { background: var(--brand); border-color: var(--brand); color: #fff; }
.step--current .step__bar { background: var(--brand); }
.step--current .step__label { color: var(--ink); font-weight: 600; }
.step--current .step__num { border-color: var(--brand); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
@media (max-width: 639px) { .step:not(.step--current) .step__text { display: none; } .step--current { flex-grow: 3; } }
html.js [data-stepper] [data-step]:not(.is-current) { display: none; }
.step-nav { display: flex; gap: var(--sp-2); align-items: center; }

/* Kiểm tra trước khi giao */
.review-sheet { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.review-sheet__row { display: grid; gap: 2px; padding: var(--sp-3) var(--sp-4); background: var(--surface); }
.review-sheet__row + .review-sheet__row { border-top: 1px solid var(--line-soft); }
.review-sheet__row dt { font-size: var(--fs-xs); color: var(--ink-3); }
.review-sheet__row dd { margin: 0; font-weight: 500; }
.review-sheet__edit { justify-self: start; min-height: 2rem; min-width: var(--tap); justify-content: center; }
.review-sheet__edit { font-size: var(--fs-xs); }
@media (min-width: 640px) { .review-sheet__row { grid-template-columns: 12rem minmax(0, 1fr) auto; align-items: baseline; gap: var(--sp-4); } }
.is-missing { color: var(--red-fg); font-weight: 600; }

/* Chọn người thực hiện, vai trò và hạn từng người (giao việc) */
.people-search { margin-bottom: var(--sp-2); }
/* grid-auto-rows/align-content: hàng cao theo nội dung – tên dài không đè nhau khi khung có max-height và cuộn */
.people-picker { display: grid; grid-auto-rows: max-content; align-content: start; border: 1px solid var(--line); border-radius: var(--r-md); max-height: 18rem; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); }
.person-pick { padding: var(--sp-2) var(--sp-3); align-items: center; }
.person-pick + .person-pick { border-top: 1px solid var(--line-soft); }
.person-pick:has(input:checked) { background: var(--brand-tint); }
.person-pick .check__text { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--sp-3); width: 100%; }
@media (min-width: 640px) { .people-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); } .person-pick + .person-pick { border-top: 0; } .person-pick { border-bottom: 1px solid var(--line-soft); } }
.per-person { list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.per-person__row { display: grid; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3); grid-template-columns: 1fr 1fr; }
.per-person__row + .per-person__row { border-top: 1px solid var(--line-soft); }
.per-person__row .person { grid-column: 1 / -1; font-weight: 600; font-size: var(--fs-sm); }
.per-person__cell { display: grid; gap: 2px; min-width: 0; }
.per-person__lbl { font-size: var(--fs-xs); color: var(--ink-3); }
@media (min-width: 900px) { .per-person__row { grid-template-columns: minmax(0, 1fr) 9rem 14rem; align-items: center; } .per-person__row .person { grid-column: auto; } .per-person__lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.select--sm, .input--sm { min-height: 2.5rem; padding-top: .3rem; padding-bottom: .3rem; font-size: var(--fs-sm); }
.review-note { margin-top: var(--sp-4); }
.review-title { margin-bottom: var(--sp-3); }
.ext-actions .btn { flex: 1 1 auto; }
.composer__kind { width: auto; }
.template-list li { grid-template-columns: auto minmax(0, 1fr) auto; }

/* ---------- 22. Khung nghiệm thu nhanh ---------- */
.review-box { display: grid; gap: var(--sp-4); }
.review-box__sub { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: center; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); font-size: var(--fs-sm); }
.review-box__sub strong { font-weight: 600; }
.review-box__decisions .choice { min-height: 4rem; padding: var(--sp-4); }
.review-box__note { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------- 23. Hành lang hạn 14 ngày (dashboard) ---------- */
.corridor { container-type: inline-size; }
.corridor__scroll { overflow-x: auto; scroll-snap-type: x proximity; overscroll-behavior-x: contain; padding-bottom: var(--sp-1); }
.corridor__grid { display: grid; grid-template-columns: 5.5rem repeat(14, minmax(3.25rem, 1fr)); min-width: 52rem; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.corridor__col { position: relative; display: grid; grid-template-rows: auto 1fr auto; min-width: 0; border-left: 1px solid var(--line-soft); background: var(--surface); text-decoration: none; color: var(--ink); scroll-snap-align: start; }
.corridor__col:first-child { border-left: 0; }
a.corridor__col:hover { background: var(--surface-2); color: var(--ink); }
a.corridor__col:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; z-index: 1; }
.corridor__col--weekend { background: var(--surface-2); }
.corridor__col--past { background: var(--red-bg); }
a.corridor__col--past:hover { background: #F9DCDA; }
.corridor__col--today { box-shadow: inset 0 0 0 2px var(--brand); }
.corridor__day { padding: var(--sp-2) var(--sp-1) var(--sp-1); text-align: center; line-height: 1.2; border-bottom: 1px solid var(--line-soft); }
.corridor__dow { display: block; font-size: var(--fs-xs); color: var(--ink-3); }
.corridor__date { display: block; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.corridor__col--today .corridor__dow { color: var(--brand); font-weight: 600; }
.corridor__col--past .corridor__dow, .corridor__col--past .corridor__date { color: var(--red-fg); }
.corridor__stack { display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 2px; height: 7.5rem; padding: var(--sp-2) .45rem; overflow: hidden; }
.corridor__blk { height: .6rem; border-radius: 2px; background: var(--tone-solid, var(--blue-solid)); flex: none; }
.corridor__blk--more { height: auto; background: none; font-size: var(--fs-xs); color: var(--ink-3); text-align: center; line-height: 1; white-space: nowrap; }
.corridor__count { padding: var(--sp-1) 0 var(--sp-2); text-align: center; font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.corridor__count small { display: block; font-size: .6875rem; font-weight: 500; color: var(--ink-3); }
.corridor__col--past .corridor__count { color: var(--red-fg); }
.corridor__count--zero { color: var(--ink-3); font-weight: 400; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-xs); color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: var(--sp-1); }
.legend__sw { width: .75rem; height: .5rem; border-radius: 2px; background: var(--tone-solid); }
/* Màn hẹp: hành lang chuyển thành danh sách ngày (không cuộn ngang toàn trang) */
@container (max-width: 40rem) {
  .corridor__scroll { overflow: visible; }
  .corridor__grid { min-width: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; gap: 0; }
  .corridor__col { grid-template-rows: none; grid-template-columns: 6.75rem minmax(0, 1fr) 2.5rem; align-items: center; border-left: 0; border-top: 1px solid var(--line-soft); min-height: var(--tap); }
  .corridor__col:first-child { border-top: 0; border-radius: var(--r-sm); }
  .corridor__col--today { border-radius: var(--r-sm); }
  .corridor__day { border: 0; text-align: left; padding: var(--sp-1) var(--sp-2); display: flex; gap: var(--sp-1); align-items: baseline; white-space: nowrap; }
  .corridor__dow, .corridor__date { display: inline; }
  .corridor__dow { font-size: var(--fs-xs); }
  .corridor__stack { flex-direction: row; align-items: center; height: auto; padding: var(--sp-2) 0; flex-wrap: nowrap; }
  .corridor__blk { width: .5rem; height: .875rem; }
  .corridor__count { padding: 0; font-size: var(--fs-base); }
  .corridor__count small { display: none; }
  .corridor__col--empty-sm { display: none; }
}

/* ---------- 24. Danh sách cần chú ý ---------- */
.attn-group + .attn-group { border-top: 1px solid var(--line-soft); }
.attn-group__head { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-1); }
.attn-group__title { font-size: var(--fs-sm); font-weight: 600; }
.attn-group__count { font-variant-numeric: tabular-nums; font-size: var(--fs-xs); font-weight: 700; padding: 0 .45rem; line-height: 1.3rem; border-radius: var(--r-pill); background: var(--tone-bg); color: var(--tone-fg); }
.attn-group__more { margin-left: auto; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; }
.attn-list { list-style: none; }
.attn { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main side" "ruler ruler"; gap: var(--sp-1) var(--sp-3); padding: var(--sp-2) var(--sp-4) var(--sp-3); align-items: center; }
.attn > :first-child { grid-area: main; min-width: 0; }
.attn > .ruler { grid-area: ruler; }
.attn > .attn__side { grid-area: side; }
.attn + .attn { border-top: 1px dashed var(--line-soft); }
.attn__title { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.attn__title:hover { color: var(--brand); text-decoration: underline; }
.attn__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); color: var(--ink-3); }
.attn__side { display: grid; justify-items: end; gap: var(--sp-1); min-width: 7.5rem; }
@media (min-width: 1024px) { .attn { grid-template-columns: minmax(0, 1fr) 11rem auto; grid-template-areas: "main ruler side"; } }
.people-load { list-style: none; }
.people-load li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-3); align-items: center; padding: var(--sp-2) var(--sp-4); min-height: var(--tap); }
.people-load li + li { border-top: 1px solid var(--line-soft); }
.people-load__bar { display: block; height: .375rem; margin-top: .3rem; border-radius: var(--r-pill); background: var(--red-solid); opacity: .75; }
.people-load__num { font-weight: 700; color: var(--red-fg); font-variant-numeric: tabular-nums; text-align: right; line-height: 1.2; }
.people-load__num small { display: block; font-weight: 500; color: var(--ink-3); font-size: var(--fs-xs); }

/* Chỗ đặt biểu đồ (CHARTS sở hữu charts.css/js; ở đây chỉ khung cố định chiều cao) */
.chart-slot { display: grid; grid-template-rows: auto 1fr; gap: var(--sp-2); }
.chart-slot__canvas { position: relative; height: 15rem; border-radius: var(--r-md); border: 1px dashed var(--line-strong); background: var(--surface-2); display: grid; place-items: center; text-align: center; color: var(--ink-3); font-size: var(--fs-sm); padding: var(--sp-4); }
.chart-slot__canvas--sm { height: 12rem; }

/* ---------- 25. Bố cục trang ---------- */
.layout-2col { display: grid; gap: var(--sp-5); }
.dash-gap { margin-top: var(--sp-5); }
.dash-note { margin-top: var(--sp-5); font-size: var(--fs-xs); }
.filters__bar .select { width: auto; min-width: 10rem; flex: 0 1 auto; }
@media (max-width: 639px) { .filters__bar .select { flex: 1 1 8rem; min-width: 0; } .filters__bar .segmented { width: 100%; } .filters__bar .segmented label { flex: 1 1 auto; justify-content: center; } }
.layout-side { display: grid; gap: var(--sp-5); align-items: start; }
@media (min-width: 1024px) {
  .layout-2col { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
  .layout-side { grid-template-columns: minmax(0, 1fr) 20rem; }
  .layout-side__aside { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); }
}
@media (min-width: 1280px) { .layout-side { grid-template-columns: minmax(0, 1fr) 22rem; } }
@media (min-width: 768px) and (max-width: 1023px) { .layout-2col--tablet { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Phần việc từng người */
.parts { list-style: none; }
.part { display: grid; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-4); grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.part + .part { border-top: 1px solid var(--line-soft); }
.part.is-selected { background: #F2F7FC; }
.part__who { display: flex; gap: var(--sp-3); align-items: center; min-width: 0; }
.part__name { font-weight: 600; font-size: var(--fs-sm); display: block; }
.part__role { font-size: var(--fs-xs); color: var(--ink-3); }
.part__states { display: flex; flex-wrap: wrap; gap: var(--sp-1); grid-column: 1 / -1; }
.part .ruler { grid-column: 1 / -1; }
.part__action { justify-self: end; }
/* Bố cục theo bề rộng KHUNG danh sách (container query), không theo màn hình: rail mở rộng từ 1280px (D-04) làm cột
   chính hẹp hơn – nút thao tác ("Nghiệm thu", "…") không được tràn khỏi khung.
   < 34rem: xếp dọc · 34–50rem: người | trạng thái | thao tác, thước hạn dòng dưới · ≥ 50rem: một dòng 4 cột. */
.parts { container-type: inline-size; container-name: parts; }
@container parts (min-width: 34rem) {
  .part { grid-template-columns: minmax(10rem, 1fr) minmax(0, 1.2fr) auto; }
  .part__who { grid-column: 1; grid-row: 1; }
  .part__states { grid-column: 2; grid-row: 1; }
  .part__action { grid-column: 3; grid-row: 1; min-width: 9.5rem; } /* cột thao tác cùng bề rộng → các dòng thẳng cột */
  .part .ruler { grid-column: 1 / -1; grid-row: 2; }
}
@container parts (min-width: 50rem) {
  .part { grid-template-columns: minmax(11rem, 1.1fr) minmax(12rem, 1.2fr) minmax(10rem, 1fr) auto; }
  .part .ruler { grid-column: 3; grid-row: 1; }
  .part__action { grid-column: 4; }
}

/* Trao đổi */
.thread { list-style: none; display: grid; gap: var(--sp-4); }
.msg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); }
.msg__head { display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); align-items: baseline; font-size: var(--fs-sm); }
.msg__author { font-weight: 600; }
.msg__time { font-size: var(--fs-xs); color: var(--ink-3); }
.msg__body { margin-top: var(--sp-1); padding: var(--sp-2) var(--sp-3); border-radius: 0 var(--r-md) var(--r-md) var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); font-size: var(--fs-sm); }
.msg--guidance .msg__body { background: var(--blue-bg); border-color: #C9DDF2; }
.msg--issue .msg__body { background: var(--amber-bg); border-color: #F1D3A1; }
.composer { display: grid; gap: var(--sp-2); }
.composer__bar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: space-between; }

/* ---------- 26. Trang đăng nhập / khung xác thực ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; background: var(--ground); }
.auth__brand { background: var(--rail); color: var(--rail-ink); padding: calc(var(--sp-5) + env(safe-area-inset-top)) var(--sp-5) var(--sp-5); display: flex; align-items: center; gap: var(--sp-3); }
.auth__brand img { width: 3rem; height: 3rem; flex: none; }
.auth__brand-top { display: flex; align-items: center; gap: var(--sp-3); }
.auth__brand-text strong { display: block; color: #fff; font-size: var(--fs-md); }
.auth__brand-text span { font-size: var(--fs-sm); color: var(--rail-ink-2); }
.auth__brand-bottom { display: none; }
.auth__main { display: grid; align-content: start; justify-items: center; padding: var(--sp-6) var(--gutter) calc(var(--sp-8) + env(safe-area-inset-bottom)); }
.auth__card { width: 100%; max-width: 26rem; }
.auth__title { font-size: var(--fs-xl); margin-bottom: var(--sp-1); }
.auth__sub { color: var(--ink-2); font-size: var(--fs-sm); margin-bottom: var(--sp-5); }
.auth__foot { margin-top: var(--sp-6); font-size: var(--fs-xs); color: var(--ink-3); }
.auth .field + .field { margin-top: var(--sp-4); }
.pw-field { position: relative; }
.pw-field input { padding-right: 3rem !important; }
.pw-field__toggle { position: absolute; right: 0; top: 0; height: 100%; width: var(--tap); min-height: 0; }
@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(22rem, 34%) minmax(0, 1fr); }
  .auth__brand { flex-direction: column; align-items: flex-start; justify-content: space-between; padding: var(--sp-10); }
  .auth__brand img { width: 4.5rem; height: 4.5rem; }
  .auth__brand-top { display: grid; gap: var(--sp-5); align-items: start; }
  .auth__brand-text strong { font-size: var(--fs-lg); }
  .auth__brand-bottom { display: grid; gap: var(--sp-8); width: 100%; }
  .auth__lead { max-width: 32ch; font-size: var(--fs-base); color: var(--rail-ink); margin: 0; }
  .auth__main { align-content: center; padding: var(--sp-10); }
}
.auth-sample { display: none; }
@media (min-width: 900px) { .auth-sample { display: block; width: 100%; max-width: 24rem; margin: 0; } }
.auth-sample .ruler__rel { color: #FFD48A; }
.auth-sample .ruler { min-width: 0; }
.auth-sample__cap { font-size: var(--fs-xs); color: var(--rail-ink-2); margin-top: var(--sp-2); }
.auth-sample .ruler__track { background: rgba(255,255,255,.14); }
.auth-sample .ruler__labels { color: var(--rail-ink-2); }
.auth-sample .ruler__due { background: #fff; }
.auth-sample .ruler__now { background: var(--rail); box-shadow: 0 0 0 2px var(--rail); }

/* Trang lỗi */
.error-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6) var(--gutter); background: var(--ground); }
.error-card { width: 100%; max-width: 34rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-8) var(--sp-6); }
.error-card__brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); color: var(--ink-2); font-size: var(--fs-sm); }
.error-card__brand img { width: 2.5rem; height: 2.5rem; }
.error-card__code { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.error-card h1 { font-size: var(--fs-xl); margin: var(--sp-1) 0 var(--sp-3); }
.error-card p { color: var(--ink-2); }
.error-card .cluster { margin-top: var(--sp-5); }

/* Hồ sơ */
.profile-head { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center; }
.profile-head__name { font-size: var(--fs-lg); font-weight: 600; }
.profile-note { margin-top: var(--sp-4); }
.role-list { list-style: none; display: grid; gap: var(--sp-2); }
.role-list li { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: baseline; }

/* Thư viện thành phần /ui/ */
.gallery-note { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--amber-bg); color: var(--amber-fg); font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-5); }
.gallery-sec { scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); }
.gallery-sec + .gallery-sec { margin-top: var(--sp-8); }
.gallery-sec > h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-1); }
.gallery-sec > .gallery-path { font-size: var(--fs-xs); color: var(--ink-3); margin-bottom: var(--sp-3); }
.gallery-toc { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-bottom: var(--sp-6); }
.gallery-row { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); align-items: center; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--sp-2); }
.swatch { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); font-size: var(--fs-xs); }
.swatch__chip { height: 2.5rem; background: var(--sw); }
.swatch__meta { padding: var(--sp-2); display: grid; }
.swatch__meta code { color: var(--ink-3); }
.sw-brand { --sw: var(--brand); } .sw-rail { --sw: var(--rail); } .sw-ground { --sw: var(--ground); } .sw-surface { --sw: var(--surface); }
.sw-ink { --sw: var(--ink); } .sw-ink2 { --sw: var(--ink-2); } .sw-line { --sw: var(--line); } .sw-tint { --sw: var(--brand-tint); }

/* ---------- 26b. Khung: quy tắc hiển thị theo breakpoint (đặt sau thành phần để thắng .btn/.account-btn) ---------- */
.topbar .topbar__menu-btn, .topbar .topbar__create, .topbar .topbar__account-name, .rail .rail__foot { display: none; }
.rail .rail-toggle { border-color: transparent; background: transparent; color: var(--rail-ink-2); }
.rail .rail-toggle:hover { background: var(--rail-2); color: #fff; }
.rail .rail__close { display: inline-flex; color: var(--rail-ink); }
@media (min-width: 640px) { .topbar .topbar__search-btn { display: none; } }
@media (min-width: 768px) {
  .topbar .topbar__menu-btn, .topbar .topbar__create { display: inline-flex; }
  .rail .rail__close { display: none; }
  .rail .rail__foot { display: block; }
}
@media (min-width: 1024px) { .topbar .account-btn__name.topbar__account-name { display: grid; } .topbar svg.topbar__account-name { display: block; } }

/* Nhãn nút thu gọn trên màn rất hẹp: giữ biểu tượng, nhãn đọc bằng trình đọc màn hình */
@media (max-width: 399px) { .btn .btn__label--sm-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }

/* Vùng chạm ≥ 44px trên màn cảm ứng / khung hẹp (chỉ thị thích ứng; bộ kiểm thử QA đo thật) */
@media (pointer: coarse), (max-width: 1023px) {
  .btn--sm, .select--sm, .input--sm, .toast__close, .chip, .btn--link { min-height: var(--tap); }
  /* Tiêu đề cột sắp xếp và liên kết tên trong bảng: đủ 44px cả khi bảng chưa chuyển thành thẻ (tablet cảm ứng) */
  .th-sort { min-height: var(--tap); min-width: var(--tap); }
  .segmented label, .segmented a { min-height: var(--tap); }
  .review-sheet__edit { min-height: var(--tap); }
  .table td.c-title > a:first-child { display: inline-flex; align-items: center; min-height: var(--tap); }
  .table td.c-title > a:first-child + .code { margin-top: -.5rem; }
  .btn--link { display: inline-flex; align-items: center; }
  .toast__close { width: var(--tap); }
}
/* Dòng danh sách bấm được cả dòng: liên kết tiêu đề phủ cả hàng, nút thao tác nằm trên */
.attn { position: relative; }
.attn .attn__title::after { content: ""; position: absolute; inset: 0; }
.attn__side { position: relative; z-index: 1; }
@container dtable (max-width: 47.99rem) {
  .table tbody tr { position: relative; }
  .table td.c-title a::after { content: ""; position: absolute; inset: 0; }
  .table td.c-check, .table td.c-action, .table td.c-people a, .table td.c-status a { position: relative; z-index: 1; }
}

/* ---------- 27. Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- 28. In ấn ---------- */
@media print {
  @page { margin: 14mm 12mm; }
  :root { --ground: #fff; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .rail, .topbar, .bottomnav, .scrim, .toasts, .page-actions, .filters, .bulkbar, .pager, .no-print, .form-actions, .c-check, .skip-link, .composer { display: none !important; }
  .shell { display: block; }
  .shell__main { padding: 0; }
  .panel, .kpis, .table-wrap { border-color: #999; break-inside: avoid; }
  .table thead th { background: #eee; position: static; }
  .table { font-size: 9.5pt; }
  .table-wrap { container-type: normal; }
  a { color: #000; text-decoration: none; }
  .badge, .dl, .prio { border: 1px solid #777; background: #fff !important; color: #000 !important; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
