/* Trang cá nhân · hệ màu Fluent Blue (gói fluent-blue trên PyPI): xanh dương #1677FF làm màu chính,
   nền xám trung tính, thẻ trắng viền mảnh. Mỗi phân hệ một họ màu Ant (cyan, xanh, cam, vàng, tím, hồng)
   cho chip icon, mục đang chọn, đầu thẻ. Chữ trên mọi nền ≥ 4.5:1. Màu chỉ dùng qua token. */
:root {
  /* nền trung tính: thang xám của Fluent Blue */
  --bg: #f5f5f5;
  --fg: #141414;
  --card: #ffffff;
  --muted: #f0f0f0;
  --muted-fg: #595959;
  --line: #e8e8e8;             /* viền thẻ, đường kẻ */
  --border: #d9d9d9;           /* viền ô nhập khi rê chuột, viền đậm hơn */
  --seg: #ffffff;              /* nền tab đang chọn trong dải tab */
  /* nút chính: xanh dương đặc, chữ trắng, một nút mỗi màn */
  --cta: #0e68ea;
  --cta-hover: #0958d9;
  --on-cta: #ffffff;
  /* xanh dương: vạch tiến độ, công tắc, link, mục đang chọn */
  --primary: #1677ff;
  --primary-strong: #0958d9;
  --primary-fill: #bae0ff;
  --primary-fill-hover: #91caff;
  --on-primary: #003eb3;
  --primary-tint: #e6f4ff;
  --accent: #ffe7ba;           /* cam nhạt: số đếm */
  --on-accent: #873800;
  /* họ màu theo phân hệ: tint = nền chip, fill = nền mục đang chọn, ink = chữ/icon (≥ 4.5:1 trên fill) */
  --tint-mint: #e6fffb;   --fill-mint: #b5f5ec;   --ink-mint: #006d75;
  --tint-sky: #e6f4ff;    --fill-sky: #bae0ff;    --ink-sky: #003eb3;
  --tint-peach: #fff7e6;  --fill-peach: #ffe7ba;  --ink-peach: #873800;
  --tint-butter: #fffbe6; --fill-butter: #fff1b8; --ink-butter: #874d00;
  --tint-lilac: #f9f0ff;  --fill-lilac: #efdbff;  --ink-lilac: #531dab;
  --tint-rose: #fff0f6;   --fill-rose: #ffd6e7;   --ink-rose: #9e1068;
  --danger: #cf1322;
  --danger-bg: #fff1f0;
  --ok: #237804;
  --ok-bg: #f6ffed;
  --warn: #9a5c00;
  --warn-bg: #fffbe6;
  --info: #0958d9;
  --info-bg: #e6f4ff;
  /* biểu đồ thành công/lỗi: xanh dương + cam (đã kiểm mù màu), không dùng cặp xanh lá/đỏ */
  --chart-ok: #1677ff;
  --chart-err: #d4380d;
  --focus: #1677ff;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 5%);
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 4px 12px -4px rgb(0 0 0 / 8%);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 4%), 0 18px 40px -16px rgb(0 0 0 / 22%);
  --radius: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --appbar: 60px;
  --subnav: 0px;               /* thanh trang con dưới thanh phân hệ: 45px khi body.has-subnav */
  --bottom-nav: 64px;
  --content: 1240px;
  --pad-x: clamp(16px, 3vw, 32px);
  --pad-top: 24px;
  --pad-bottom: 48px;
  color-scheme: light;
}

/* tối: theo Fluent Blue Dark, nền đen, thẻ #141414, xanh dương dịu hơn, chữ nhấn sáng */
:root[data-theme="dark"] {
  --bg: #000000;
  --fg: #e6e6e6;
  --card: #141414;
  --muted: #1f1f1f;
  --muted-fg: #a6a6a6;
  --line: #303030;
  --border: #424242;
  --seg: #262626;
  --cta: #1668dc;
  --cta-hover: #1a6de4;
  --on-cta: #ffffff;
  --primary: #3c89e8;
  --primary-strong: #69b1ff;
  --primary-fill: #15325b;
  --primary-fill-hover: #15417e;
  --on-primary: #bae0ff;
  --primary-tint: #111a2c;
  --accent: #f8cf8d;
  --on-accent: #442a11;
  --tint-mint: #112123;   --fill-mint: #144848;   --ink-mint: #84e2d8;
  --tint-sky: #111a2c;    --fill-sky: #15325b;    --ink-sky: #8dc5f8;
  --tint-peach: #2b1d11;  --fill-peach: #593815;  --ink-peach: #f8cf8d;
  --tint-butter: #2b2111; --fill-butter: #594214; --ink-butter: #f8df8b;
  --tint-lilac: #1a1325;  --fill-lilac: #301c4d;  --ink-lilac: #cda8f0;
  --tint-rose: #291321;   --fill-rose: #551c3b;   --ink-rose: #f8a8cc;
  --danger: #ff7875;
  --danger-bg: #2c1618;
  --ok: #73d13d;
  --ok-bg: #162312;
  --warn: #ffc53d;
  --warn-bg: #2b2111;
  --info: #69b1ff;
  --info-bg: #111a2c;
  --chart-ok: #3c89e8;
  --chart-err: #e87040;
  --focus: #4096ff;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px -4px rgb(0 0 0 / 40%);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 40%), 0 18px 40px -16px rgb(0 0 0 / 70%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  font: 400 15px/1.55 var(--font);
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; font-family: var(--font-display); }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--primary-strong); text-underline-offset: 3px; }
code, pre, .mono { font-family: var(--mono); font-size: .9em; }
svg { flex-shrink: 0; }
/* icon báo vừa xong việc (vd đã sao chép → dấu tích): tô màu thành công trong lúc hiện */
svg[data-icon] { transition: color .2s var(--ease); }
svg[data-back] { color: var(--ok); }
[hidden] { display: none !important; }
::selection { background: var(--primary-fill); color: var(--fg); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--cta); color: var(--on-cta); padding: 10px 14px; border-radius: var(--radius-sm);
}
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- khung: thanh phân hệ ở đầu trang (máy tính), ở đáy (điện thoại); thanh trang con ngay dưới ---------- */
/* mỗi phân hệ một tông pastel: tint = nền chip, fill = nền mục đang chọn, ink = chữ/icon */
:root { --tone-tint: var(--primary-tint); --tone-fill: var(--primary-fill); --tone-ink: var(--primary-strong); }
.tone-mint   { --tone-tint: var(--tint-mint);   --tone-fill: var(--fill-mint);   --tone-ink: var(--ink-mint); }
.tone-sky    { --tone-tint: var(--tint-sky);    --tone-fill: var(--fill-sky);    --tone-ink: var(--ink-sky); }
.tone-peach  { --tone-tint: var(--tint-peach);  --tone-fill: var(--fill-peach);  --tone-ink: var(--ink-peach); }
.tone-butter { --tone-tint: var(--tint-butter); --tone-fill: var(--fill-butter); --tone-ink: var(--ink-butter); }
.tone-lilac  { --tone-tint: var(--tint-lilac);  --tone-fill: var(--fill-lilac);  --tone-ink: var(--ink-lilac); }
.tone-rose   { --tone-tint: var(--tint-rose);   --tone-fill: var(--fill-rose);   --tone-ink: var(--ink-rose); }
body.has-subnav { --subnav: 45px; }

/* thanh đầu trang trong mờ, nội dung cuộn bên dưới. Lớp mờ nằm ở ::before chứ không ở chính .appbar:
   backdrop-filter trên .appbar sẽ biến nó thành khung chứa của thanh phân hệ position: fixed (điện thoại)
   và kéo thanh đáy lên đầu trang */
.appbar { position: sticky; top: 0; z-index: 40; border-bottom: 1px solid var(--line); }
.appbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
}
/* logo trái, phân hệ giữa, nút phải; mép trái/phải thẳng hàng với nội dung trang */
.appbar-inner {
  max-width: calc(var(--content) + 2 * var(--pad-x)); margin: 0 auto; height: var(--appbar); padding: 0 var(--pad-x);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
}
/* logo là nút mở menu thả (Cài đặt, Đăng nhập); lề âm để logo vẫn thẳng mép với nội dung trang */
.brand-wrap { grid-column: 1; justify-self: start; position: relative; min-width: 0; max-width: calc(100% + 4px); margin-left: -4px; }
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; min-height: 44px;
  padding: 4px 8px 4px 4px; border: 0; background: none; cursor: pointer;
  font: 650 1rem/1.2 var(--font-display); letter-spacing: -.01em; color: var(--fg); text-decoration: none;
  border-radius: var(--radius-sm); touch-action: manipulation; transition: background-color .15s var(--ease);
}
.brand:hover, .brand[aria-expanded="true"], .brand[data-current] { background: var(--muted); }
.brand:disabled { cursor: default; background: none; }
.brand-caret { display: grid; flex: none; color: var(--muted-fg); transition: transform .2s var(--ease); }
.brand[aria-expanded="true"] .brand-caret { transform: rotate(180deg); }
.brand:disabled .brand-caret { display: none; }
/* logo HTL QS: nền trong suốt (không đặt lên ô màu); theme tối dùng bản vòng + tòa nhà trắng */
.brand-mark { display: grid; place-items: center; flex: none; width: 36px; height: 36px; }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-mark .logo-dark, :root[data-theme="dark"] .brand-mark .logo-light { display: none; }
:root[data-theme="dark"] .brand-mark .logo-dark { display: block; }
.brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; min-width: 240px; padding: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop-in .14s var(--ease);
}
.brand-pop[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--fg); cursor: pointer;
  font: inherit; font-size: .95rem; font-weight: 550; text-align: left; text-decoration: none; touch-action: manipulation;
  transition: background-color .15s var(--ease);
}
.menu-item svg { flex: none; color: var(--muted-fg); }
.menu-item:hover, .menu-item:focus-visible { background: var(--muted); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item[aria-current] { font-weight: 650; }
.menu-item[aria-current] svg { color: var(--fg); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
/* đã là quản trị: tên trong Hồ sơ ở chỗ nút Đăng nhập */
.menu-user { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 12px; }
.menu-avatar {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-tint); color: var(--on-primary); font: 700 .85rem/1 var(--font-display);
}
.menu-user-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-user-name { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.menu-user-sub { font-size: .8rem; line-height: 1.35; color: var(--muted-fg); }
.tabbar {
  grid-column: 2; min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar a {
  position: relative; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px 0 6px; flex-shrink: 0;
  border-radius: 999px; white-space: nowrap; color: var(--muted-fg); text-decoration: none; font-size: .92rem; font-weight: 550;
  touch-action: manipulation; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-chip {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 999px;
  color: var(--tone-ink); transition: background-color .15s var(--ease);
}
.nav-chip svg { width: 17px; height: 17px; }
.tabbar a:hover { color: var(--fg); background: var(--muted); }
.tabbar a:focus-visible { outline-offset: -2px; border-radius: 999px; }
/* phân hệ đang mở (cả khi đang ở trang con bên trong): nền tông + chữ đậm + chip đậm hơn, không chỉ dựa vào màu */
.tabbar a[aria-current] { color: var(--tone-ink); background: var(--tone-tint); font-weight: 650; }
.tabbar a[aria-current] .nav-chip { background: var(--tone-fill); }
.tabbar .label-short { display: none; }
.count {
  min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center;
  font-size: .72rem; font-weight: 700; line-height: 18px; background: var(--accent); color: var(--on-accent); font-variant-numeric: tabular-nums;
}
.appbar-tools { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 4px; }

/* thanh trang con của phân hệ đang mở (vd. Tools: Tổng quan · OCR nhanh · Hộp thư scan · Hỏi tài liệu) */
.subbar { border-top: 1px solid var(--line); }
.subbar-inner {
  max-width: calc(var(--content) + 2 * var(--pad-x)); margin: 0 auto; height: 44px; padding: 0 calc(var(--pad-x) - 10px);
  display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.subbar-inner::-webkit-scrollbar { display: none; }
.subbar a {
  position: relative; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; flex-shrink: 0; white-space: nowrap;
  border-radius: var(--radius-sm); color: var(--muted-fg); text-decoration: none; font-size: .88rem; font-weight: 550;
  touch-action: manipulation; transition: background-color .15s var(--ease), color .15s var(--ease);
}
.subbar a > svg { width: 16px; height: 16px; }
.subbar a:hover { color: var(--fg); background: var(--muted); }
.subbar a:focus-visible { outline-offset: -2px; }
.subbar a[aria-current="page"] { color: var(--fg); font-weight: 650; }
.subbar a[aria-current="page"] > svg { color: var(--tone-ink); }
/* gạch chân chạm đáy thanh (thanh cao 44, mục cao 32 nằm giữa) */
.subbar a[aria-current="page"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -6px; height: 2px; border-radius: 2px; background: var(--tone-ink);
}

.main { min-width: 0; padding: var(--pad-top) var(--pad-x) var(--pad-bottom); }
.main:focus { outline: none; }
/* h1 nhận focus bằng code khi đổi trang (để trình đọc màn hình đọc tên trang); không phải ô bấm được nên không vẽ viền */
.main h1[tabindex="-1"]:focus { outline: none; }
.page { max-width: var(--content); margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
/* đầu trang chung (ui.js pageHead): tiêu đề + một dòng mô tả | dải tab của trang | nút. Cao 56px trên máy tính
   nên nội dung mọi trang bắt đầu cùng một mốc; mô tả dài bị cắt một dòng, rê chuột xem đủ */
.page-head { display: flex; align-items: center; gap: 12px 16px; min-height: 56px; flex-wrap: wrap; }
.page-head > :first-child { flex: 1 1 320px; min-width: 0; }
.page-head p { color: var(--muted-fg); margin-top: 2px; font-size: .875rem; line-height: 20px; }
.page-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-tabs, .page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.page-tabs:empty, .page-actions:empty { display: none; }
.page-tabs .tablist { flex: none; }
.tabs-head:empty { display: none; }
/* trang "vừa màn hình": phần .fill giãn hết chỗ còn lại, nội dung cuộn bên trong thay vì cuộn cả trang */
.page.fit { gap: 20px; height: max(540px, calc(100dvh - var(--appbar) - var(--subnav) - 1px - var(--pad-top) - var(--pad-bottom))); }
.page.fit > .fill { flex: 1; min-height: 0; }

/* màn vừa: nhãn ngắn (Tools, CAD, Dữ liệu) để 4 phân hệ không phải cuộn */
@media (max-width: 1199px) {
  .tabbar .label-long { display: none; }
  .tabbar .label-short { display: inline; }
}
@media (max-width: 1023px) {
  .brand-name, .appbar-tools .label { display: none; }
}
@media (max-width: 767px) {
  :root { --appbar: 56px; --pad-top: 20px; --pad-bottom: calc(var(--bottom-nav) + 24px + env(safe-area-inset-bottom)); }
  .appbar-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .appbar-tools { grid-column: 2; }
  .brand-name { display: inline; max-width: min(240px, 58vw); }
  /* thanh phân hệ ở đáy: 4 mục (Cài đặt nằm ở menu logo), icon trong viên thuốc (kiểu Material 3) trên nhãn ngắn */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-width: none;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; overflow: visible;
    background: color-mix(in srgb, var(--card) 88%, transparent); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex-direction: column; justify-content: center; gap: 3px; height: auto; min-height: var(--bottom-nav); padding: 6px 2px;
    border-radius: 0; font-size: .75rem; line-height: 1.15; text-align: center; white-space: normal;
  }
  .tabbar a:hover, .tabbar a[aria-current] { background: none; }
  .nav-chip { width: 52px; height: 30px; }
  .tabbar a:hover .nav-chip { background: var(--muted); }
  .tabbar a[aria-current] .nav-chip { background: var(--tone-fill); }
  .tabbar .label-long { display: none; }
  .tabbar .label-short { display: block; }
  .tabbar .count { position: absolute; top: 4px; left: calc(50% + 10px); }
  .toasts { bottom: calc(var(--bottom-nav) + 12px + env(safe-area-inset-bottom)) !important; }
  .page { gap: 16px; }
  .page-head { min-height: 0; }
  .page-tabs { order: 3; flex: 1 0 100%; }
  .page-tabs .tablist { flex: 0 1 auto; scrollbar-width: none; }
  /* hàng nút sát hơn chút để công tắc + nút + nút icon (Hộp thư scan) vừa một dòng 343px */
  .page-actions { gap: 6px; }
  .page-actions .switch { gap: 8px; }
  .page-actions .btn:not(.btn-icon) { padding: 0 12px; }
  .page-title p { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .tab { min-height: 38px; }
  body.subnav-single { --subnav: 0px; }
  body.subnav-single .subbar { display: none; }
  .page.fit { height: max(460px, calc(100dvh - var(--appbar) - var(--subnav) - 1px - var(--pad-top) - var(--pad-bottom))); }
}

/* ---------- thành phần ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { color: var(--muted-fg); font-size: .9rem; margin-top: 2px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
/* vùng thông báo (aria-live) còn trống: ra khỏi luồng flex để không thêm một khoảng gap dưới đầu trang */
.page > .stack:empty { position: absolute; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }
.muted { color: var(--muted-fg); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.wrap-any { overflow-wrap: anywhere; min-width: 0; }

/* tiêu đề một khối trong trang: chữ + mô tả mờ, nút (nếu có) bên phải */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.section-head p { color: var(--muted-fg); font-size: .9rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); color: var(--fg); box-shadow: var(--shadow-xs);
  font: 600 .9rem/1 var(--font); cursor: pointer; text-decoration: none; touch-action: manipulation; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--muted); border-color: var(--border); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--cta); border-color: var(--cta); color: var(--on-cta); }
.btn-primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .84rem; border-radius: var(--radius-sm); }
.btn-icon { width: 40px; padding: 0; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] svg[data-icon="loader"] { animation: spin 1s linear infinite; }
/* màn cảm ứng: vùng bấm mỗi nút tối thiểu 44×44. Nút nhìn vẫn như cũ, chỉ thêm lớp trong suốt tràn ra quanh nút */
@media (pointer: coarse) {
  .btn { position: relative; }
  .btn::after { content: ""; position: absolute; inset: min(0px, (100% - 44px) / 2); }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .88rem; }
.field .req { color: var(--danger); }
.help { font-size: .82rem; color: var(--muted-fg); }
.error-text { font-size: .84rem; color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
input[type="text"], input[type="url"], input[type="number"], input[type="password"], input[type="search"],
input[type="email"], input[type="tel"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-md); border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: 400 .95rem/1.4 var(--font); box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { resize: vertical; min-height: 84px; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted-fg) 80%, transparent); }
input:hover, select:hover, textarea:hover { border-color: var(--border); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
[aria-invalid="true"] { border-color: var(--danger) !important; }
.input-group { display: flex; gap: 6px; }
.input-group > input, .input-group > select { flex: 1; min-width: 0; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary-strong); cursor: pointer; flex-shrink: 0; }
.check span small { display: block; color: var(--muted-fg); font-size: .82rem; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
.switch .track {
  width: 44px; height: 24px; border-radius: 999px; background: var(--border); position: relative;
  transition: background-color .2s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 25%); transition: transform .2s var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; border: 1px solid transparent;
  font-size: .76rem; font-weight: 600; line-height: 20px; white-space: nowrap; background: var(--muted); color: var(--muted-fg);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.err { background: var(--danger-bg); color: var(--danger); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.run { background: var(--info-bg); color: var(--info); }
.badge.run svg { animation: spin 1s linear infinite; }

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--muted); font-size: .9rem; border: 1px solid var(--line);
}
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert.err { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.info { background: var(--info-bg); color: var(--fg); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert.info > svg { color: var(--info); }
.alert p + p { margin-top: 4px; }

.progress { height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .3s var(--ease); }

/* ---------- tab trong trang: dải phân đoạn (segmented) ---------- */
.tabs { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tabs-head { display: flex; align-items: center; gap: 8px 12px; min-width: 0; }
.tablist {
  display: flex; gap: 2px; flex: 0 1 auto; min-width: 0; max-width: 100%; padding: 3px; overflow-x: auto; scrollbar-width: thin;
  border-radius: var(--radius-md); background: var(--muted); border: 1px solid var(--line);
}
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; flex-shrink: 0;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted-fg); cursor: pointer; white-space: nowrap;
  font: 550 .9rem/1.2 var(--font); touch-action: manipulation;
  transition: background-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.tab > svg { width: 17px; height: 17px; }
.tab:hover { color: var(--fg); }
.tab:focus-visible { outline-offset: -2px; }
.tab[aria-selected="true"] { color: var(--fg); background: var(--seg); font-weight: 650; box-shadow: var(--shadow-xs), 0 0 0 1px var(--line); }
.tab[aria-selected="true"] > svg { color: var(--primary-strong); }
.tab-label { min-width: 0; }
.tab-sub { display: block; margin-top: 2px; font-size: .78rem; font-weight: 400; color: var(--muted-fg); }
.tab-badge {
  min-width: 20px; padding: 0 7px; border-radius: 999px; text-align: center; font-size: .72rem; font-weight: 700;
  line-height: 18px; background: var(--card); color: var(--muted-fg); font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px var(--line);
}
.tab-badge.warn { background: var(--warn-bg); color: var(--warn); box-shadow: none; }
.tab-badge.accent { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.tabpanel { min-width: 0; }
.tabpanel:focus-visible { outline-offset: 4px; }

/* tab dọc: danh sách bên trái, chi tiết bên phải (mục Cài đặt). Bố cục theo chỗ thực có (container query)
   chứ không theo màn hình. Kiểu tab dọc chỉ áp cho dải của chính nó (> .tabs-head), dải tab lồng trong panel giữ dạng ngang */
.page, .tabs.vertical > .tabpanel { container-type: inline-size; }
.tabs.vertical { flex-direction: row; align-items: flex-start; gap: 20px; }
.tabs.vertical > .tabs-head {
  flex-direction: column; align-items: stretch; width: 260px; flex-shrink: 0; gap: 12px;
  position: sticky; top: calc(var(--appbar) + var(--subnav) + 16px); max-height: calc(100dvh - var(--appbar) - var(--subnav) - 32px); overflow-y: auto;
}
.tabs.vertical > .tabs-head .tablist { flex: none; flex-direction: column; gap: 6px; overflow: visible; padding: 0; background: none; border: 0; border-radius: 0; }
.tabs.vertical > .tabs-head .tab {
  width: 100%; justify-content: flex-start; text-align: left; white-space: normal; min-height: 52px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow-xs);
}
.tabs.vertical > .tabs-head .tab:hover { background: var(--muted); }
.tabs.vertical > .tabs-head .tab[aria-selected="true"] {
  background: var(--primary-tint); border-color: color-mix(in srgb, var(--primary) 50%, transparent);
}
.tabs.vertical > .tabs-head .tab .tab-label { flex: 1; }
.tabs.vertical > .tabpanel { flex: 1; }
.tab-sub svg { vertical-align: -2px; }
/* chi tiết engine: ô rộng tối thiểu 300px để ô model + nút không bị ép */
.engine .form-grid { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.engine-tabs > .tabs-head .tablist { flex-wrap: wrap; overflow: visible; }
.engine-tabs .tab { min-height: 44px; padding: 4px 12px; text-align: left; }
.engine-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.engine-add .field { flex: 1 1 240px; }
.engine-add .help { flex-basis: 100%; margin: 0; }

/* mục Cài đặt: cột điều hướng dạng danh sách gọn, mỗi mục một chip tông pastel, mục đang mở tô tông của nó.
   Giữ dạng cột tới cỡ máy tính bảng dọc (thấy đủ các mục), chỉ thành dải ngang ở điện thoại */
.tabs.vertical.nav { gap: 24px; }
.tabs.vertical.nav > .tabs-head { width: 232px; }
.tabs.nav > .tabs-head .tablist { gap: 2px; }
.tabs.nav > .tabs-head .tab:nth-child(6n+1) { --tone-tint: var(--tint-mint);   --tone-fill: var(--fill-mint);   --tone-ink: var(--ink-mint); }
.tabs.nav > .tabs-head .tab:nth-child(6n+2) { --tone-tint: var(--tint-lilac);  --tone-fill: var(--fill-lilac);  --tone-ink: var(--ink-lilac); }
.tabs.nav > .tabs-head .tab:nth-child(6n+3) { --tone-tint: var(--tint-sky);    --tone-fill: var(--fill-sky);    --tone-ink: var(--ink-sky); }
.tabs.nav > .tabs-head .tab:nth-child(6n+4) { --tone-tint: var(--tint-peach);  --tone-fill: var(--fill-peach);  --tone-ink: var(--ink-peach); }
.tabs.nav > .tabs-head .tab:nth-child(6n+5) { --tone-tint: var(--tint-butter); --tone-fill: var(--fill-butter); --tone-ink: var(--ink-butter); }
.tabs.nav > .tabs-head .tab:nth-child(6n+6) { --tone-tint: var(--tint-rose);   --tone-fill: var(--fill-rose);   --tone-ink: var(--ink-rose); }
.tabs.nav > .tabs-head .tab {
  min-height: 46px; padding: 6px 10px; gap: 12px; border-color: transparent; background: none; box-shadow: none;
  color: var(--muted-fg); font-weight: 550;
}
.tabs.nav > .tabs-head .tab > svg {
  width: 30px; height: 30px; padding: 6px; border-radius: var(--radius-sm); background: var(--tone-tint); color: var(--tone-ink);
  transition: background-color .15s var(--ease);
}
.tabs.nav > .tabs-head .tab:hover { background: var(--muted); color: var(--fg); }
.tabs.nav > .tabs-head .tab[aria-selected="true"] {
  background: var(--tone-tint); border-color: transparent; box-shadow: none; color: var(--tone-ink); font-weight: 650;
}
.tabs.nav > .tabs-head .tab[aria-selected="true"] > svg { background: var(--tone-fill); }
@container (max-width: 899px) {
  .tabs.vertical.nav { gap: 20px; }
  .tabs.vertical.nav > .tabs-head { width: 212px; }
}
/* điện thoại: dải mục ngang cuộn được, mục đang mở là viên thuốc tông pastel */
@container (max-width: 679px) {
  .tabs.vertical.nav { flex-direction: column; align-items: stretch; gap: 16px; }
  .tabs.vertical.nav > .tabs-head { width: auto; position: static; max-height: none; overflow: visible; }
  .tabs.nav > .tabs-head .tablist {
    flex-direction: row; overflow-x: auto; gap: 4px; padding: 4px; scrollbar-width: none;
    background: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-md);
  }
  .tabs.nav > .tabs-head .tab { width: auto; flex: 0 0 auto; white-space: nowrap; min-height: 40px; gap: 8px; padding: 0 12px 0 6px; }
  .tabs.nav > .tabs-head .tab > svg { width: 28px; height: 28px; padding: 5px; }
  .tabs.nav > .tabs-head .tab:not([aria-selected="true"]) > svg { background: transparent; }
}

/* ---------- Small & Smart Tools · Tổng quan ---------- */
/* dải trạng thái: một thẻ chia 4 ô bằng đường kẻ */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; overflow: hidden; }
.stats > .stat { padding: 18px 20px; border-left: 1px solid var(--line); min-width: 0; }
.stats > .stat:first-child { border-left: 0; }
.stats > .loading { grid-column: 1 / -1; padding: 18px 20px; }
@container (max-width: 919px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > .stat:nth-child(odd) { border-left: 0; }
  .stats > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@container (max-width: 479px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stats > .stat { border-left: 0; }
  .stats > .stat + .stat { border-top: 1px solid var(--line); }
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.stat-top .badge { margin-left: auto; }
.stat-label { font-size: .86rem; font-weight: 600; color: var(--muted-fg); min-width: 0; }
.stat-icon {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--tone-tint); color: var(--tone-ink);
}
.stat-value { margin-top: 4px; font: 650 1.3rem/1.3 var(--font-display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-detail {
  font-size: .82rem; color: var(--muted-fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* thẻ dẫn tới từng tool: 4 cột, 2 cột, 1 cột theo chỗ thực có (không để thẻ lẻ một mình) */
.tool-grid { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@container (max-width: 979px) { .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 519px) { .tool-grid { grid-template-columns: minmax(0, 1fr); } }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; color: inherit; text-decoration: none; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone-tint) 60%, var(--card)), var(--card) 120px);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.tool-card:hover { border-color: var(--border); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.tool-card:focus-visible { outline-offset: 3px; border-radius: var(--radius); }
.tool-card h3 { font-size: 1rem; font-weight: 650; }
.tool-card p { color: var(--muted-fg); font-size: .88rem; margin-top: 4px; }
.tool-card .stat-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--card); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--line); }
.go {
  position: absolute; top: 20px; right: 20px; color: var(--muted-fg);
  transition: transform .2s var(--ease), color .2s var(--ease);
}
.tool-card:hover .go { color: var(--fg); transform: translateX(3px); }

/* luồng scan */
.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.flow-step {
  flex: 1 1 140px; display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: var(--radius-md);
  background: var(--muted); border: 1px solid var(--line); font-size: .88rem; min-width: 0;
}
.flow-step > svg { color: var(--primary-strong); }
.flow-step b { display: block; font-size: .92rem; }
.flow-step span { color: var(--muted-fg); overflow-wrap: anywhere; }
.flow-arrow { display: grid; place-items: center; color: var(--muted-fg); }
/* hẹp thì xếp dọc, mũi tên chỉ xuống */
@media (max-width: 1023px) {
  .flow { flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .flow-step { flex-basis: auto; }
  .flow-arrow svg { transform: rotate(90deg); }
}

/* kéo thả */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
  padding: 36px 20px; border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--muted);
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.dropzone.drag { background: var(--primary-tint); border-color: var(--primary); }
.dropzone .big-icon { color: var(--primary-strong); }
.dropzone-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* file đã chọn: ảnh nhỏ | tên + cỡ | nút bỏ. Thứ tự là thứ tự trang khi gộp */
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 6px 6px 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card);
}
.file-thumb { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; background: var(--muted); color: var(--muted-fg); display: grid; place-items: center; }
.file-name { font-weight: 500; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted-fg); font-size: .8rem; font-variant-numeric: tabular-nums; }
.merge-box, .export-box { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: var(--radius-sm); background: var(--muted); }
.export-box { gap: 8px; }
.export-box > .help { margin: 0; }
.export-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }

/* chọn định dạng dựng lại: nút bật/tắt dạng viên, màu theo loại file, có dấu tích để không chỉ dựa vào màu */
.fmt-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.fmt {
  --tone-tint: var(--tint-mint); --tone-fill: var(--fill-mint); --tone-ink: var(--ink-mint);
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--fg);
  font-weight: 600; font-size: .9rem; cursor: pointer; user-select: none;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.fmt[data-fmt="docx"] { --tone-tint: var(--tint-sky); --tone-fill: var(--fill-sky); --tone-ink: var(--ink-sky); }
.fmt[data-fmt="pdf"] { --tone-tint: var(--tint-rose); --tone-fill: var(--fill-rose); --tone-ink: var(--ink-rose); }
.fmt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.fmt-tick {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px;
  border: 1.5px solid var(--border); background: var(--card); color: transparent;
}
.fmt:hover { border-color: var(--tone-ink); }
.fmt:has(input:checked) { background: var(--tone-tint); border-color: var(--tone-fill); color: var(--tone-ink); }
.fmt:has(input:checked) .fmt-tick { background: var(--tone-ink); border-color: var(--tone-ink); color: var(--card); }
.fmt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.fmt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.fmt input:disabled { cursor: not-allowed; }

/* ---------- quét từ web (Hộp thư scan) ---------- */
.scan-card .card-head { margin-bottom: 0; align-items: flex-start; }
.scan-card .card-head p { overflow-wrap: anywhere; }
.scan-status { display: flex; align-items: center; gap: 10px; }
.tabular { font-variant-numeric: tabular-nums; }
.scan-opts { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-start; }
.choice { border: 0; margin: 0; padding: 0; min-width: 0; }
.choice > legend { padding: 0; margin-bottom: 8px; }
.choice-check { padding-top: 26px; }
.fmt.pill { padding: 0 16px; --tone-tint: var(--tint-sky); --tone-fill: var(--fill-sky); --tone-ink: var(--ink-sky); }
.scan-actions { display: flex; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; }
.scan-actions .field { flex: 1 1 260px; max-width: 420px; }
.scan-buttons { display: flex; gap: 8px; padding-bottom: 22px; }
.scan-buttons .btn-primary { min-width: 120px; }
.sub-title { margin-top: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 767px) {
  .choice-check { padding-top: 0; }
  .scan-actions .field { max-width: none; }
  .scan-buttons { width: 100%; padding-bottom: 0; }
  .scan-buttons .btn { flex: 1; }
}
@media (max-width: 767px) {
  .dropzone { padding: 24px 16px; gap: 10px; }
  .dropzone-actions .btn { flex: 1 1 140px; }
}

/* danh sách job */
.job-list { display: flex; flex-direction: column; }
.job {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 10px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; border-radius: var(--radius-sm);
  transition: background-color .15s var(--ease);
}
.job:last-child { border-bottom: 0; }
.job:hover { background: var(--muted); }
.job-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--muted); color: var(--muted-fg);
}
.job:hover .job-icon { background: var(--card); }
.job-main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-name { font-weight: 600; overflow-wrap: anywhere; }
.job-meta { font-size: .82rem; color: var(--muted-fg); display: flex; gap: 4px 12px; flex-wrap: wrap; }
.job-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.job .progress { margin-top: 2px; max-width: 360px; }
/* dòng job có nút Dừng (OCR nhanh): nút đứng cạnh link chứ không lồng trong link */
.job-row { display: flex; align-items: center; gap: 8px; padding-right: 10px; border-bottom: 1px solid var(--line); }
.job-row:last-child { border-bottom: 0; }
.job-row > .job { flex: 1; min-width: 0; border-bottom: 0; }
.job-row > .btn { flex: none; }
/* danh sách hẹp (điện thoại, màn nhỏ): nút Dừng xuống dưới, không bóp tên file */
.split-list > .job-list { container-type: inline-size; }
@container (max-width: 520px) {
  .job-row { flex-wrap: wrap; padding-bottom: 12px; }
  .job-row > .job { flex-basis: 100%; padding-bottom: 4px; }
  .job-row > .btn { margin-left: auto; }
}
.empty { text-align: center; padding: 32px 16px; color: var(--muted-fg); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty > svg { width: 44px; height: 44px; padding: 10px; border-radius: var(--radius-md); background: var(--muted); color: var(--muted-fg); }

/* OCR nhanh: form bên trái, danh sách bên phải; mỗi bên cuộn riêng */
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 20px; }
.scroll-y { overflow-y: auto; min-height: 0; }
.split-list { display: flex; flex-direction: column; min-height: 0; }
.split-list > .job-list { flex: 1; margin: 0 -10px; padding: 0 10px; }
@media (max-width: 899px) {
  .page.fit.split-page { height: auto; }
  .split { grid-template-columns: 1fr; grid-template-rows: none; }
  .split .scroll-y { overflow: visible; }
}

/* chi tiết job: đầu trang gọn, phần trang giãn hết màn hình, ảnh và chữ cuộn riêng */
.job-page { gap: 14px; }
.job-head { gap: 10px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; margin-bottom: 2px; font-size: .88rem; text-decoration: none; color: var(--muted-fg); }
.back-link:hover { color: var(--fg); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rerun { flex: 1 1 320px; max-width: 460px; margin-left: auto; }
/* thanh dựng lại Excel/Word/PDF dưới các nút tải */
.export-bar {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 8px 10px 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--muted);
}
.export-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--muted-fg); }
.export-bar .check { align-items: center; min-height: 36px; font-weight: 600; font-size: .9rem; }
.export-bar .check input { margin: 0; }
.export-bar > a { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; }
.export-bar > .btn { margin-left: auto; }
.grow { flex: 1; min-width: 0; }
.job-body { display: flex; flex-direction: column; min-height: 360px; }
.fill-tabs { flex: 1; min-height: 0; gap: 12px; }
.fill-tabs > .tabpanel:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-view { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.page-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-bar .meta { margin-right: auto; color: var(--muted-fg); font-size: .88rem; font-variant-numeric: tabular-nums; }
.page-pair { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 16px; }
.page-pair figure { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: auto; background: var(--muted); }
.page-pair figure a { display: block; cursor: zoom-in; }
.page-pair img { display: block; width: 100%; height: auto; aspect-ratio: 210 / 297; object-fit: contain; background: #fff; }
.page-text {
  margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 .92rem/1.65 var(--font);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; overflow: auto;
}
.page-view > .page-text { flex: 1; min-height: 0; }
.page-pair > .alert { align-self: start; }
/* hẹp: bỏ chế độ vừa màn hình, ảnh trên chữ dưới, cuộn cả trang như bình thường */
@media (max-width: 899px) {
  .page.fit.job-page { height: auto; }
  .page-pair { grid-template-columns: 1fr; grid-template-rows: none; }
  .page-pair figure { overflow: hidden; }
  .rerun { margin-left: 0; max-width: none; }
  .export-bar > .btn { margin-left: 0; flex: 1 1 100%; }
}
@media (max-width: 599px) {
  .page-bar .meta { flex: 1 1 100%; }
}

/* engine trong cài đặt: thẻ thường, không vạch màu cạnh trái; engine gửi ra ngoài có viền đào cả khung (kèm nhãn "Gửi ra …") */
.engine.external { border-color: var(--fill-peach); }
.engine-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details.adv > summary { cursor: pointer; font-weight: 600; font-size: .9rem; padding: 6px 0; color: var(--primary-strong); }
details.adv[open] > summary { margin-bottom: 10px; }
.test-out { font-size: .88rem; }
.test-out pre { margin: 6px 0 0; white-space: pre-wrap; background: var(--muted); padding: 8px 10px; border-radius: var(--radius-sm); }

/* truy cập từ xa: danh sách bước, lệnh chép được, thiết bị đã đăng nhập */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.steps li > div { display: flex; flex-direction: column; gap: 4px; padding-top: 3px; }
.step-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px solid var(--border); color: var(--muted-fg); font: 600 .85rem/1 var(--font); font-variant-numeric: tabular-nums;
}
.steps li.done .step-mark { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.cmd { display: flex; align-items: center; gap: 6px; background: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 6px 6px 6px 12px; }
.cmd code { flex: 1; min-width: 0; font: 400 .82rem/1.5 var(--mono); overflow-wrap: anywhere; }
.cmd code span { display: inline-block; max-width: 100%; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted-fg); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
/* địa chỉ quick tunnel + nút chép: nút giữ sát chữ, chữ dài thì xuống dòng chứ không đẩy nút ra ngoài */
.addr { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.addr a { min-width: 0; font-family: var(--mono); font-size: .84rem; }
pre.log { margin: 0; max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 400 .78rem/1.5 var(--mono); background: var(--muted); padding: 10px 12px; border-radius: var(--radius-sm); }
.session-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.session-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.session-list li:first-child { border-top: 0; padding-top: 0; }
.session-list li > svg { flex: none; margin-top: 2px; color: var(--muted-fg); }
.session-list li > div { flex: 1; min-width: 0; }
.session-list strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* màn đăng nhập khi mở qua tên miền */
.login-wrap { min-height: calc(100dvh - var(--appbar) - var(--pad-top) - var(--pad-bottom)); display: grid; place-items: center; }
.login { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.login-head :is(h1, h2) { font-size: 1.4rem; }
.login-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--radius); background: var(--cta); color: var(--on-cta); }
.login input { font-size: 1rem; min-height: 44px; }
.btn-block { width: 100%; min-height: 44px; }
.login-foot { text-align: center; }
/* hộp đăng nhập nổi (khách bấm Đăng nhập hoặc mở trang cần quyền): nút X góc phải, nền mờ phía sau */
.login-dialog {
  width: min(420px, calc(100vw - 32px)); max-width: none; padding: 0; border: 0;
  background: transparent; color: var(--fg); overflow: visible;
}
.login-dialog[open] { animation: pop-in .18s var(--ease); }
.login-dialog::backdrop { background: rgb(10 10 12 / 55%); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.login-dialog .login { position: relative; width: 100%; }
.login-dialog-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; }
/* điện thoại: chữ trong ô nhập 16px để iOS không tự phóng to khi chạm vào */
@media (max-width: 767px) {
  input[type="text"], input[type="url"], input[type="number"], input[type="password"], input[type="search"],
  input[type="email"], input[type="tel"], select, textarea { font-size: 16px; }
  .login { padding: 24px 18px; }
}

/* chat */
.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-log { flex: 1; min-height: 0; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.chat-tools select { width: auto; flex: 1 1 180px; max-width: 320px; min-width: 0; }
.msg { max-width: min(78ch, 92%); padding: 12px 14px; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--primary-fill); color: var(--on-primary); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--muted); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.err { background: var(--danger-bg); color: var(--danger); }
.sources { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sources .badge { background: var(--card); border: 1px solid var(--line); white-space: normal; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--card); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 200px; }

/* ---------- trang Hồ sơ ---------- */
/* phần đầu: quầng xanh dương mờ ở góc (kiểu thẻ đầu trang Fluent Blue) + lưới chấm nhạt dần */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; gap: 28px; align-items: center; padding: clamp(24px, 4vw, 44px);
}
.hero::before, .hero::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero::before {
  background:
    radial-gradient(520px 260px at 0% 0%, color-mix(in srgb, var(--primary-fill) 80%, transparent), transparent 70%),
    radial-gradient(520px 280px at 100% 0%, color-mix(in srgb, var(--fill-lilac) 55%, transparent), transparent 70%),
    radial-gradient(460px 240px at 75% 130%, color-mix(in srgb, var(--fill-sky) 70%, transparent), transparent 70%);
}
.hero::after {
  background-image: radial-gradient(color-mix(in srgb, var(--fg) 16%, transparent) 1px, transparent 1.2px);
  background-size: 18px 18px;
  -webkit-mask-image: linear-gradient(180deg, #000 10%, transparent 85%); mask-image: linear-gradient(180deg, #000 10%, transparent 85%);
}
.hero-avatar {
  display: grid; place-items: center; flex: none; width: 96px; height: 96px; border-radius: 20px;
  background: var(--card); color: var(--primary-strong); font: 700 2rem/1 var(--font-display); letter-spacing: -.02em;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.hero-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.hero h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.12; }
.hero-headline { font-size: 1.05rem; color: var(--muted-fg); max-width: 62ch; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted-fg); font-size: .92rem; }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.hero-actions:empty { display: none; }
@media (max-width: 599px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 18px; }
  .hero-avatar { width: 72px; height: 72px; border-radius: 16px; font-size: 1.5rem; }
}

/* liên hệ, mạng xã hội: mỗi dòng là một ô bấm cao 56px, icon mang màu của mạng đó (--net) */
.link-list { display: flex; flex-direction: column; gap: 2px; list-style: none; margin: 0; padding: 0; }
.link-row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; margin-inline: -10px; border-radius: var(--radius-md);
  color: inherit; text-decoration: none; transition: background-color .15s var(--ease);
}
a.link-row:hover { background: var(--muted); }
.link-row > svg { flex: none; color: var(--muted-fg); }
.contact-row { display: flex; align-items: center; gap: 4px; }
.contact-row .link-row { flex: 1; min-width: 0; margin-inline-end: 0; }
.net-chip {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: var(--radius-md);
  color: var(--net, var(--ink-sky)); background: color-mix(in srgb, var(--net, var(--ink-sky)) 12%, var(--card));
}
.link-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; overflow-wrap: anywhere; }
.link-text b { font-weight: 620; }
.link-text span { color: var(--muted-fg); font-size: .86rem; }
.contact-row .link-text { flex-direction: column-reverse; }
.net-facebook { --net: #1877f2; }
.net-youtube { --net: #e5141e; }
.net-zalo { --net: #0068ff; }
.net-linkedin { --net: #0a66c2; }
.net-instagram { --net: #d62976; }
.net-telegram { --net: #1d93d2; }
.net-tiktok, .net-x, .net-github { --net: var(--fg); }
.net-web { --net: var(--ink-mint); }
:root[data-theme="dark"] .net-facebook { --net: #4c93f5; }
:root[data-theme="dark"] .net-youtube { --net: #ff4e55; }
:root[data-theme="dark"] .net-zalo { --net: #4d94ff; }
:root[data-theme="dark"] .net-linkedin { --net: #5aa2e6; }
:root[data-theme="dark"] .net-instagram { --net: #f06aa5; }
:root[data-theme="dark"] .net-telegram { --net: #5bb8e8; }
.tone-chip {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--tone-tint); color: var(--tone-ink);
}

.home-cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.section-title svg { color: var(--muted-fg); }
.bio { white-space: pre-line; line-height: 1.7; max-width: 75ch; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 2px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; padding-top: 0; }
.timeline .when { color: var(--muted-fg); font-size: .88rem; font-variant-numeric: tabular-nums; }
.timeline .what { min-width: 0; overflow-wrap: anywhere; }
.timeline .what b { display: block; font-weight: 620; }
.timeline .what span { color: var(--muted-fg); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chips li { padding: 4px 12px; border-radius: 999px; font-size: .86rem; font-weight: 600; background: var(--tone-tint); color: var(--tone-ink); }
.chips li:nth-child(5n+1) { --tone-tint: var(--tint-mint);   --tone-ink: var(--ink-mint); }
.chips li:nth-child(5n+2) { --tone-tint: var(--tint-sky);    --tone-ink: var(--ink-sky); }
.chips li:nth-child(5n+3) { --tone-tint: var(--tint-peach);  --tone-ink: var(--ink-peach); }
.chips li:nth-child(5n+4) { --tone-tint: var(--tint-butter); --tone-ink: var(--ink-butter); }
.chips li:nth-child(5n+5) { --tone-tint: var(--tint-lilac);  --tone-ink: var(--ink-lilac); }
@media (max-width: 899px) { .home-cols { grid-template-columns: 1fr; } }
@media (max-width: 599px) { .timeline li { grid-template-columns: 1fr; } }

/* ---------- danh mục plugin / add-in ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted-fg); font: 600 .86rem/1 var(--font); box-shadow: var(--shadow-xs);
  cursor: pointer; touch-action: manipulation; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.filter-chip:hover { background: var(--muted); color: var(--fg); }
.filter-chip[aria-pressed="true"] { background: var(--cta); border-color: var(--cta); color: var(--on-cta); }
.filter-chip .n {
  min-width: 24px; padding: 0 6px; border-radius: 999px; background: var(--muted); color: var(--muted-fg);
  font-size: .74rem; line-height: 22px; text-align: center; font-variant-numeric: tabular-nums;
}
.filter-chip[aria-pressed="true"] .n { background: color-mix(in srgb, var(--on-cta) 18%, transparent); color: var(--on-cta); }
.catalog { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.cat-card {
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone-tint) 55%, var(--card)), var(--card) 110px);
}
.cat-card .tone-chip { background: var(--card); box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--line); }
.cat-head { display: flex; gap: 12px; align-items: center; }
.cat-head > div { min-width: 0; }
.cat-host { color: var(--muted-fg); font-size: .84rem; margin-top: 2px; }
.cat-card > p { font-size: .92rem; }
.cat-foot {
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.tag { padding: 1px 8px; border-radius: 4px; background: var(--muted); border: 1px solid var(--line); color: var(--muted-fg); font-size: .76rem; font-weight: 600; line-height: 20px; white-space: nowrap; }

/* ---------- định mức xây dựng: kết quả bên trái, chi tiết bên phải, mỗi bên cuộn riêng ---------- */
.norms-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.search-box { position: relative; flex: 1 1 320px; min-width: 0; }
.search-box > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-fg); pointer-events: none; }
.search-box input { padding-left: 40px; min-height: 40px; }
.norms-tools select { width: auto; flex: 0 1 280px; min-width: 0; min-height: 40px; }
.norms-split {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr); gap: 16px;
}
.norms-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.norms-count { padding: 10px 16px 0; }
.norms-count:empty { display: none; }
.norm-hit {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; width: 100%; padding: 10px; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--fg); font: inherit; cursor: pointer; touch-action: manipulation;
  transition: background-color .15s var(--ease);
}
.norm-hit:hover { background: var(--muted); }
.norm-hit[aria-current="true"] { background: var(--tint-butter); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink-butter) 28%, transparent); }
.norm-code { font: 600 .84rem/1.45 var(--mono); color: var(--ink-butter); white-space: nowrap; }
.norm-name { font-size: .9rem; overflow-wrap: anywhere; }
.norm-meta { grid-column: 2; font-size: .8rem; color: var(--muted-fg); }
.norms-more { padding: 10px; font-size: .84rem; color: var(--muted-fg); text-align: center; }
.norm-detail { display: flex; flex-direction: column; gap: 18px; }
.norm-title { display: flex; flex-direction: column; gap: 6px; }
.norm-title h2 { font-size: 1.2rem; overflow-wrap: anywhere; }
.norm-title .norm-code { font-size: 1rem; }
.res-block h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
table.data thead th { background: var(--muted); color: var(--muted-fg); font-size: .78rem; font-weight: 650; white-space: nowrap; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--muted) 60%, transparent); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .qty { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.code { font: 400 .8rem/1.5 var(--mono); color: var(--muted-fg); white-space: nowrap; }
.prose-pre { white-space: pre-line; font-size: .9rem; line-height: 1.65; overflow-wrap: anywhere; }
.sibs { display: flex; flex-wrap: wrap; gap: 6px; }
.sib {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: 500 .8rem/1 var(--mono); cursor: pointer; touch-action: manipulation;
}
.sib:hover { background: var(--muted); }
.sib[aria-current="true"] { background: var(--tint-butter); color: var(--ink-butter); border-color: transparent; font-weight: 700; }
.norms-lookup, .norms-sources { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.norms-pane { scroll-margin-top: calc(var(--appbar) + var(--subnav) + 12px); }
.norms-pane:focus-visible { outline-offset: -2px; }
.norm-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.norm-examples .sib { font-family: var(--font); }
.res-block h3 .muted { font-weight: 500; font-size: .85rem; }
@media (max-width: 899px) {
  .page.fit.norms-page { height: auto; }
  /* minmax(0, …): bảng hao phí rộng cuộn trong .table-wrap, không kéo cả trang tràn ngang */
  .norms-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .norms-split > .norms-results { max-height: 42vh; }
  .norms-split > .norms-pane { overflow: visible; }
}

/* ---------- vật tư & giá: dùng chung bố cục tra cứu với định mức ---------- */
.hit-price { font-weight: 600; color: var(--fg); }
.price-card {
  display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr); gap: 12px 24px; align-items: start;
  padding: 14px 16px; border-radius: var(--radius-md); background: var(--tint-butter);
}
.price-now { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.price-now strong { font-size: 1.35rem; line-height: 1.3; overflow-wrap: anywhere; }
.price-now strong .muted { font-size: .9rem; font-weight: 500; }
.price-edit { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.price-edit input { min-height: 40px; }
.prices-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.mode-set { border: 0; margin: 0; padding: 0; min-width: 0; gap: 8px; }
.mode-set legend { padding: 0; margin-bottom: 4px; font-weight: 600; font-size: .9rem; }
.bad-lines { margin: 4px 0 0; padding-left: 18px; }
table.data td.code a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
table.data td.code a:hover { color: var(--ink-butter); text-decoration-color: currentColor; }
table.data tfoot td { border-top: 1px solid var(--border); border-bottom: 0; background: var(--muted); font-weight: 650; }
table.data tfoot .muted { font-weight: 500; }
.price-note { display: block; font-size: .75rem; color: var(--muted-fg); white-space: normal; }
.cell-code { display: block; font: 400 .78rem/1.4 var(--mono); color: var(--muted-fg); }
.cell-code a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.cell-code a:hover { color: var(--ink-butter); text-decoration-color: currentColor; }
table.data td.qty .unit { font-size: .8rem; color: var(--muted-fg); }
/* bảng có giá: tiêu đề và chữ "chưa có giá" được xuống dòng để 4 cột vừa màn hình điện thoại */
table.data.priced thead th, table.data.priced td.qty.muted { white-space: normal; }
@media (max-width: 599px) { table.data.priced th, table.data.priced td { padding: 8px 6px; } }
.price-hint { display: flex; align-items: flex-start; gap: 6px; }
.price-hint svg { flex: none; margin-top: 2px; }
.norm-cost { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--tint-butter); }
.norm-cost-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.norm-cost-head h3 { display: flex; align-items: center; gap: 8px; }
.norm-cost-head a { color: var(--ink-butter); font-weight: 600; }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px 16px; margin: 0; }
.cost-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cost-grid dt { font-size: .8rem; color: var(--muted-fg); }
.cost-grid dd { margin: 0; font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cost-grid .cost-sum dd { font-size: 1.3rem; color: var(--ink-butter); }
.cost-miss { display: block; font-size: .75rem; font-weight: 500; color: var(--muted-fg); }
@media (max-width: 1099px) { .prices-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 599px) {
  .price-card { grid-template-columns: minmax(0, 1fr); }
  /* 3 tab của trang Vật tư & giá vừa một hàng trên điện thoại */
  .norms-page .tab { padding: 0 10px; }
  .norms-page .tab > svg { display: none; }
}

/* ---------- Dữ liệu ngành (dữ liệu app_tracuu): định mức TT38, cấp phối, vật liệu, chi phí chung ---------- */
.dm-facets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.facet {
  display: inline-flex; align-items: center; max-width: 100%; min-height: 40px; padding-left: 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: .82rem;
}
.facet > span { color: var(--muted-fg); font-weight: 600; white-space: nowrap; }
.facet select {
  width: auto; min-width: 0; max-width: 240px; min-height: 38px; padding: 0 12px 0 8px;
  border: 0; border-radius: 999px; background: transparent; box-shadow: none; cursor: pointer;
}
.facet select:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.facet.on { background: var(--tint-butter); border-color: transparent; }
.facet.on > span, .facet.on select { color: var(--ink-butter); font-weight: 650; }
.dm-count { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dm-count:has(> p:empty):has(> button[hidden]) { display: none; }
.dm-chapters { display: flex; flex-direction: column; gap: 14px; }
.dm-chapters h3 {
  display: flex; justify-content: space-between; gap: 8px; padding: 4px 10px;
  font-size: .76rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-fg);
}
.dm-chap {
  display: grid; grid-template-columns: 4.2em minmax(0, 1fr) auto; align-items: baseline; gap: 10px; width: 100%;
  min-height: 44px; padding: 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--fg);
  font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; transition: background-color .15s var(--ease);
}
.dm-chap:hover { background: var(--muted); }
.dm-n { font-size: .78rem; color: var(--muted-fg); }
.dm-variants {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--radius-md); background: color-mix(in srgb, var(--tint-butter) 40%, var(--card));
}
.dm-variants h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.dm-variants h3 .muted { font-weight: 500; font-size: .85rem; }
.dm-axis { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr); align-items: start; gap: 6px 12px; }
.dm-axis-label { padding-top: 7px; font-size: .82rem; font-weight: 600; color: var(--muted-fg); }
.dm-axis .sib { font-family: var(--font); }
.sib.near { border-style: dashed; border-color: var(--border); }
.dm-bim { margin: 6px 0 0; padding-left: 18px; font-size: .88rem; }
.dm-bim li + li { margin-top: 2px; }
@media (max-width: 599px) {
  .dm-axis { grid-template-columns: minmax(0, 1fr); }
  .dm-axis-label { padding-top: 0; }
}

/* cấp phối: bảng dài cuộn trong khung, dòng tiêu đề đứng yên */
.mix-body { display: flex; flex-direction: column; min-height: 0; }
.mix-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.mix-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--card); }
.mix-wrap thead th { position: sticky; top: 0; z-index: 1; }
.mix-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
table.mix-table td:first-child { min-width: 260px; overflow-wrap: anywhere; }
table.mix-table th .unit { font-weight: 500; }
@media (max-width: 899px) {
  .page.fit.mix-page { height: auto; }
  .mix-wrap { flex: none; max-height: 70dvh; }
}

/* định mức: chọn cấp phối ngay dưới dòng V884, các dòng xi măng, cát, nước tách ra thụt vào với mũi tên */
table.data tr.mix-row td { border-bottom: 0; }
table.data tr.mix-pick td, table.data tbody tr.mix-pick:hover td {
  padding-top: 4px; padding-bottom: 10px; background: color-mix(in srgb, var(--tint-sky) 45%, var(--card)); white-space: normal;
}
/* bảng rộng hơn khung (điện thoại) thì ô chọn vẫn nằm trong phần đang thấy, không cuộn ngang mới thấy hết */
.table-wrap.mix-host { container-type: inline-size; }
.mix-pick-box { display: flex; flex-direction: column; gap: 6px; min-width: 0; position: sticky; left: 12px; max-width: calc(100cqi - 24px); }
.mix-pick-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 10px; }
.mix-pick-field label { font-size: .82rem; font-weight: 650; color: var(--ink-sky); white-space: nowrap; }
.mix-pick-field select { min-width: 0; max-width: 100%; font-size: .88rem; cursor: pointer; }
.mix-info { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; line-height: 1.5; color: var(--muted-fg); overflow-wrap: anywhere; }
.mix-info a { color: var(--ink-sky); font-weight: 600; text-underline-offset: 3px; }
table.data tr.mix-part td { background: color-mix(in srgb, var(--tint-sky) 18%, var(--card)); }
table.data tbody tr.mix-part:hover td { background: color-mix(in srgb, var(--tint-sky) 35%, var(--card)); }
table.data tr.mix-part td:first-child { position: relative; padding-left: 30px; }
.mix-arrow { position: absolute; left: 12px; top: 9px; color: var(--ink-sky); font: 600 .85rem/1.4 var(--font); }
@media (max-width: 599px) {
  .mix-pick-field { grid-template-columns: minmax(0, 1fr); }
  table.data tr.mix-part td:first-child { padding-left: 22px; }
  .mix-arrow { left: 6px; top: 8px; }
  table.data.priced .mix-pick-box { left: 6px; max-width: calc(100cqi - 12px); }
}

/* vật liệu: giá tham khảo, tên gọi khác */
.ref-price { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--tint-butter); }
.ref-price h3 { font-size: .78rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-butter); }
.ref-price strong { font-size: 1.35rem; line-height: 1.3; overflow-wrap: anywhere; }
.ref-price strong .muted { font-size: .9rem; font-weight: 500; }
.ref-price a { color: var(--ink-butter); font-weight: 600; }
.vl-names { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.vl-names .tag { font-weight: 500; font-size: .8rem; white-space: normal; overflow-wrap: anywhere; }

/* chi phí chung, nhà tạm: máy tính bên trái, bảng tỷ lệ bên phải; mỗi bên cuộn riêng trong khung */
.heso-body { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.heso-grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr); align-items: start; gap: 16px;
}
.heso-grid > .card { max-height: 100%; overflow-y: auto; }
.heso-tables:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.heso-grid h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.heso-out .small { overflow-wrap: anywhere; }
table.data.heso-table th, table.data.heso-table td { padding-block: 8px; }
table.heso-table tbody th { min-width: 10em; font-weight: 600; }
table.heso-table tbody th .price-note { display: inline; margin-left: 6px; font-weight: 500; }
table.heso-table tbody tr { cursor: pointer; }
table.data.heso-table tbody tr.sel > * { background: color-mix(in srgb, var(--tint-butter) 50%, transparent); }
table.data.heso-table tbody tr.sel > th { color: var(--ink-butter); }
table.data.heso-table tbody tr td.hit { background: var(--tint-butter); color: var(--ink-butter); font-weight: 700; }
table.heso-table thead th[scope="colgroup"] { text-align: center; }
@media (max-width: 899px) {
  .page.fit.heso-page { height: auto; }
  .heso-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .heso-grid > .card { max-height: none; overflow: visible; }
}

/* ---------- Cài đặt → Hồ sơ: các dòng lặp (liên kết, kinh nghiệm) ---------- */
.repeat-list { display: flex; flex-direction: column; gap: 10px; }
.repeat-row {
  display: grid; gap: 8px 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--muted); grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
}
.repeat-row.cols-3 { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; }
.repeat-row > .btn { min-height: 40px; }
@media (max-width: 699px) {
  .repeat-row, .repeat-row.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .repeat-row > .btn { justify-self: end; }
}

/* ---------- Quản trị · Bảng điều khiển ---------- */
.admin h2[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
.stat-inline { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* biểu đồ 24 giờ rộng hơn thẻ truy cập từ xa; hẹp thì xếp chồng */
.admin-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@container (max-width: 899px) { .admin-top { grid-template-columns: minmax(0, 1fr); } }

.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 168px auto; gap: 6px 8px; }
/* nhãn trục dọc: thò ra nửa dòng trên dưới để số nằm giữa đúng vạch kẻ */
.chart-y {
  grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; margin: -.5em 0;
  font-size: .72rem; line-height: 1; color: var(--muted-fg); text-align: right; font-variant-numeric: tabular-nums;
}
.chart-plot { grid-row: 1; grid-column: 2; position: relative; border-bottom: 1px solid var(--border); }
.chart-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.chart-line.top { top: 0; }
.chart-line.mid { top: 50%; }
.chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
/* cả cột là vùng rê chuột/chạm (to hơn thanh), thanh cao theo % của cột */
.chart-col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; border-radius: 4px 4px 0 0; }
.chart-col[data-hot] { background: var(--muted); }
.seg { flex: none; width: 100%; max-width: 16px; min-height: 2px; }
.seg:first-child { border-radius: 4px 4px 0 0; }
.seg.ok, .swatch.ok { background: var(--chart-ok); }
/* lỗi có sọc chéo: in đen trắng hay mù màu vẫn phân biệt được với phần thành công */
.seg.err, .swatch.err {
  background: repeating-linear-gradient(135deg, var(--chart-err) 0 3px, color-mix(in srgb, var(--chart-err) 55%, var(--card)) 3px 5px);
}
.seg, .swatch { forced-color-adjust: none; }
.chart-axis {
  grid-row: 2; grid-column: 2; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); column-gap: 3px;
  font-size: .72rem; color: var(--muted-fg); font-variant-numeric: tabular-nums;
}
.chart-axis span { grid-row: 1; white-space: nowrap; }
.chart-axis .now { justify-self: end; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; font-size: .8rem; color: var(--muted-fg); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; }
.chart-tip {
  position: absolute; z-index: 5; transform: translateX(-50%); pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: .8rem; font-variant-numeric: tabular-nums;
}
.chart-tip[hidden] { display: none; }
.chart-tip span { display: flex; align-items: center; gap: 6px; color: var(--muted-fg); }
.chart-table > summary { cursor: pointer; width: fit-content; padding: 6px 0; font-weight: 600; font-size: .88rem; color: var(--primary-strong); }
.chart-table[open] > summary { margin-bottom: 8px; }

/* mã truy cập, thiết bị: nút nằm phải; thẻ hẹp thì nút xuống dòng dưới tên */
.admin-list { container-type: inline-size; }
.admin-list li > .row-actions { flex: none; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@container (max-width: 519px) {
  .admin-list li { flex-wrap: wrap; }
  .admin-list li > .row-actions { flex-basis: 100%; justify-content: flex-start; padding-left: 28px; }
}
.admin-log li.is-alert > svg { color: var(--warn); }

/* toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md); background: var(--cta); color: var(--on-cta);
  box-shadow: var(--shadow-lg); animation: toast-in .2s var(--ease);
}
.toast a { color: inherit; font-weight: 600; }
.toast.err { background: var(--danger-bg); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .tool-card:hover { transform: none; }
}
