/* Insight · Camera AI — giao diện "Mẫu 4": kính mờ (glassmorphism) trên nền gradient mềm.
   Chỉ dùng font hệ thống, không CDN. Mọi class/id mà app.js và test dùng được giữ nguyên. */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --bg: #e9edff;
  --text: #1e293b;
  --text-2: #334155;
  --muted: #475569;    /* ≥ 6:1 trên nền kính sáng */
  --muted-2: #4b5a6e;  /* ≥ 4.5:1 trên nền kính sáng */
  --line: rgba(148, 163, 184, .32);
  --line-soft: rgba(255, 255, 255, .75);
  --primary: #2563eb;
  --primary-2: #4f46e5;
  --primary-ink: #1d4ed8;
  --primary-soft: rgba(99, 102, 241, .14);
  --indigo-ink: #4338ca;
  --grad: linear-gradient(135deg, #4f46e5, #2563eb);
  --grad-green: linear-gradient(135deg, #10b981, #059669);
  --grad-bar: linear-gradient(90deg, #6366f1, #06b6d4);
  --ok: #047857; --ok-soft: rgba(16, 185, 129, .16); --green-soft: rgba(16, 185, 129, .16);
  --warn: #92400e; --warn-soft: rgba(245, 158, 11, .2);
  --danger: #b91c1c; --red-soft: rgba(239, 68, 68, .14);
  --info: #1d4ed8; --info-soft: rgba(59, 130, 246, .16);
  --violet: #6d28d9; --violet-soft: rgba(139, 92, 246, .16);
  --cyan: #0e7490; --cyan-soft: rgba(6, 182, 212, .16);
  --orange: #c2410c; --orange-soft: rgba(249, 115, 22, .16);
  --gray-soft: rgba(100, 116, 139, .16);
  --empty: rgba(99, 102, 241, .16);
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .8);
  --glass-border: rgba(255, 255, 255, .82);
  --field-bg: rgba(255, 255, 255, .62);
  --field-border: rgba(255, 255, 255, .92);
  --radius: 20px; --radius-md: 14px; --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(31, 38, 135, .10), inset 0 1px 0 rgba(255, 255, 255, .85);
  --shadow-sm: 0 4px 14px rgba(31, 38, 135, .08);
  --shadow-primary: 0 8px 20px rgba(37, 99, 235, .3);
  --ring: #2563eb;
  --blur: blur(22px) saturate(170%);
  --side-w: 248px;
  --card: var(--glass);
  --tree-line: rgba(99, 102, 241, .4); --row-h: 2.5rem;
  --chev: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  --i-note: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V9Z'/><path d='M15 3v4a2 2 0 0 0 2 2h4'/><path d='M8 13h8'/><path d='M8 17h5'/></svg>");
}
/* Trình duyệt không hỗ trợ backdrop-filter: panel đặc hơn để chữ vẫn đọc được. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255, 255, 255, .9); --glass-strong: rgba(255, 255, 255, .95); --field-bg: rgba(255, 255, 255, .85); }
}

* { box-sizing: border-box; }
/* Nền: gradient mềm + các đốm màu (vẽ bằng radial-gradient, không cần filter blur). Đặt trên <html> để nền lan ra
   toàn bộ canvas, cao bằng cả trang chứ không chỉ một khung nhìn (ảnh chụp cả trang không còn phần trắng ở dưới).
   Các đốm bám mép trên/dưới của trang theo ô cao 100vh; gradient chính trải suốt chiều cao trang. */
html {
  -webkit-text-size-adjust: 100%; scroll-padding-top: 5.5rem; scroll-padding-bottom: 6rem;
  min-height: 100%; background-color: var(--bg);
  /* SPEC-06 2.2 (04/11/2026): nền xám rất nhạt, không còn vệt màu */
  background: linear-gradient(180deg, #f8f9fa 0%, #f1f3f5 100%) fixed, var(--bg);
}
body {
  margin: 0; min-height: 100vh; background: transparent; color: var(--text);
  font: 14px/1.5 var(--font);
}
[hidden] { display: none !important; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 800; margin-bottom: .75rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.empty { padding: .5rem 0; margin: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}
svg.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.ic-sm { width: 15px; height: 15px; }
svg.ic-xs { width: 12px; height: 12px; stroke-width: 2.5; }

/* Ô nhập */
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%; padding: .5rem .7rem; border: 1px solid var(--field-border); border-radius: 11px; background: var(--field-bg);
  color: var(--text); transition: box-shadow .18s, border-color .18s, background .18s;
}
input::placeholder, textarea::placeholder { color: #5b6b80; opacity: 1; }
input:focus, textarea:focus, select:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); background: rgba(255, 255, 255, .92); }
input:disabled, select:disabled { color: var(--muted); background: rgba(255, 255, 255, .35); }
textarea { resize: vertical; min-height: 2.4rem; line-height: 1.5; }
select:not([multiple]) {
  appearance: none; -webkit-appearance: none; padding-right: 1.9rem; cursor: pointer;
  background-image: var(--chev); background-repeat: no-repeat; background-position: right .6rem center;
}

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap; min-height: 38px;
  padding: .3rem .9rem; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .62);
  color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .18s, transform .18s, box-shadow .18s;
}
.btn:hover { background: rgba(255, 255, 255, .94); text-decoration: none; box-shadow: var(--shadow-sm); }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--shadow-primary); }
.btn.primary:hover { box-shadow: 0 10px 26px rgba(37, 99, 235, .42); }
@media (hover: hover) { .btn.primary:hover { transform: translateY(-1px); } }
.btn.small { min-height: 32px; padding: .15rem .7rem; font-size: .86rem; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn.danger-text { color: var(--danger); }
.icon {
  width: 2rem; height: 2rem; border: 1px solid transparent; background: transparent; border-radius: 9px; flex: none;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted-2); transition: background .18s, color .18s;
}
.icon:hover:not(:disabled) { background: rgba(255, 255, 255, .95); border-color: rgba(255, 255, 255, .9); color: var(--text); box-shadow: var(--shadow-sm); }
.icon:disabled { opacity: .3; cursor: default; }
.icon.danger:hover { color: var(--danger); background: var(--red-soft); border-color: transparent; }
.linklike { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; }

/* Khung trang: thanh bên trái (kính) + nội dung */
body { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: 20px; padding: 20px; align-items: start; }
.topbar {
  position: sticky; top: 20px; z-index: 10; height: calc(100vh - 40px); display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; overflow: auto; overscroll-behavior: contain;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 16px; color: var(--text); font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand-mark {
  flex: none; width: 40px; height: 40px; border-radius: 14px; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #2563eb 60%, #06b6d4); box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-logo { flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: contain; background: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand span.sub, .login-card h1 span { display: block; color: var(--muted-2); font-weight: 500; font-size: 12px; }
.topbar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; }
.topbar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; color: var(--text-2); font-weight: 500;
  transition: background .18s, color .18s;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .62); text-decoration: none; color: var(--text); }
.topbar nav a.on { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(79, 70, 229, .35); }
.nav-ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-sep { margin: 10px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.user-card {
  margin-top: auto; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center;
  padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(255, 255, 255, .85);
}
.avatar {
  grid-row: 1 / 3; width: 36px; height: 36px; border-radius: 12px; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; background: linear-gradient(135deg, #f472b6, #f97316); flex: none;
}
.avatar:empty { background: var(--grad); }
.topbar .who { display: block; font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { margin: 0; line-height: 1.2; }
.logout .linklike { font-size: 12px; color: var(--muted-2); }
.logout .linklike:hover { color: var(--primary-ink); text-decoration: underline; }
.container { max-width: none; margin: 0; padding: 0; min-width: 0; }
/* Thu gọn thanh bên (chỉ > 1100px): cột icon 76px, tooltip = title do JS gắn; badge thành chấm nhỏ ở góc icon */
/* v21.4: logo + nút thu gọn chung một hàng (.side-head); ≤1100px hàng này "trong suốt" (display: contents) như trước */
.side-head { display: contents; }
.side-toggle { display: none; }
@media (min-width: 1101px) {
  .side-head { display: flex; align-items: center; gap: 4px; padding-bottom: 16px; }
  .side-head > .brand { flex: 1 1 auto; min-width: 0; padding-bottom: 6px; }
  body { transition: grid-template-columns .22s ease; }
  .topbar { overflow-x: hidden; }
  .side-toggle {
    display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; margin: 0; border: 0; border-radius: 10px;
    background: transparent; color: var(--muted-2); cursor: pointer; transition: background .18s, color .18s;
  }
  .side-toggle:hover { background: rgba(255, 255, 255, .8); color: var(--text); }
  .side-toggle svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
  .topbar nav a { position: relative; white-space: nowrap; }
  .nav-label { overflow: hidden; text-overflow: ellipsis; }
  html.side-collapsed { --side-w: 76px; }
  html.side-collapsed .topbar { padding-left: 13px; padding-right: 13px; }
  /* collapsed rail: no ≡ button — the logo itself expands the sidebar (JS gives it role=button + tooltip) */
  html.side-collapsed .side-toggle { display: none; }
  html.side-collapsed .side-head { padding-bottom: 10px; }
  html.side-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  html.side-collapsed .brand[role="button"] { cursor: pointer; }
  html.side-collapsed .brand-logo { width: 36px; height: 36px; }
  html.side-collapsed .brand-text, html.side-collapsed .nav-label, html.side-collapsed .nav-sep,
  html.side-collapsed .topbar .who, html.side-collapsed .logout { display: none; }
  html.side-collapsed .topbar nav a { justify-content: center; padding: 11px 0; }
  html.side-collapsed .nav-badge { position: absolute; top: 3px; right: 5px; margin: 0; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
  html.side-collapsed .user-card { grid-template-columns: 1fr; justify-items: center; padding: 8px 0; }
  html.side-collapsed .avatar { grid-row: auto; }
}
.page-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 16px 22px; margin-bottom: 16px;
}
.page-head > div:first-child { min-width: 0; }
.page-head p { margin: .2rem 0 0; font-size: 13px; }
.inline-form { display: flex; gap: .5rem; min-width: min(100%, 340px); }
.card { padding: 18px 22px; margin-bottom: 16px; }
.card h3 { margin-bottom: 12px; }
/* Mọi panel kính dùng chung một kiểu. */
.card, .topbar, .page-head, .filters, .kpi, .tabs, .pkg-tabs-row, .tree > li.section, .tree > li.add-stage-form, .login-card, .save-bar, .feature-filter {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius); box-shadow: var(--shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}

/* Số liệu tổng quan (trang danh sách) */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; display: flex; align-items: center; gap: 12px; min-width: 0; transition: transform .2s; }
@media (hover: hover) { .kpi:hover { transform: translateY(-2px); } }
.kpi > div { min-width: 0; }
.k-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none; background: var(--grad); }
.k-ic.b { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.k-ic.c { background: var(--grad-green); }
.k-ic.d { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.kpi .v { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .t { display: inline-block; margin-top: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.t.up { background: var(--ok-soft); color: var(--ok); }
.t.flat { background: var(--gray-soft); color: var(--muted); }
.t.warn { background: var(--warn-soft); color: var(--warn); }

/* Tiến độ: thanh chia đoạn (mỗi đoạn một giai đoạn, bấm được) */
.pct { font-weight: 800; font-size: 1.2rem; color: var(--indigo-ink); font-variant-numeric: tabular-nums; }
.pct.full { color: var(--ok); }
.pkg-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.pkg-top h2 { overflow-wrap: break-word; word-break: normal; }
.card-actions { display: flex; gap: .1rem; }
.segbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.seg { height: 7px; border-radius: 999px; background: var(--empty); display: block; }
.seg.done { background: var(--grad-bar); }
a.seg:hover { outline: 2px solid rgba(37, 99, 235, .4); outline-offset: 1px; }

/* Giai đoạn còn trống */
.report { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.report .card { margin: 0; display: flex; flex-direction: column; gap: .75rem; }
.empty-steps { margin: 0; padding-left: 1.1rem; }
.empty-steps li { margin: .2rem 0; }
.ok { color: var(--ok); margin: 0; font-weight: 600; }
.stage-summary { list-style: none; margin: 0; padding: 0; }
.stage-summary li { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-top: 1px solid var(--line-soft); }
.stage-summary li:first-child { border-top: 0; }
.stage-n {
  flex: none; width: 1.7rem; height: 1.7rem; border-radius: 9px; background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700;
}
.stage-t { flex: 1; min-width: 0; }
.stage-c { flex: none; color: var(--muted); font-size: .9rem; }
.stage-c.ok { color: var(--ok); }

/* Trang gói: đường dẫn, đầu trang, tab */
.crumbs { margin-bottom: 10px; font-size: 13px; color: var(--muted-2); }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--primary-ink); }
.pkg-head { align-items: center; flex-wrap: nowrap; padding: 14px 24px 12px; gap: 16px; }
.pkg-title { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "tags" "sum"; gap: 10px 24px; align-items: start; }
.head-badges { display: contents; }
.title-input {
  grid-area: name; width: 100%; font-size: 26px; font-weight: 800; letter-spacing: -.02em; border-color: transparent; background: transparent;
  padding: .15rem .5rem; margin-left: -.5rem; box-shadow: none;
}
.title-input:hover { border-color: var(--line); background: rgba(255, 255, 255, .6); }
.title-input:focus { background: rgba(255, 255, 255, .92); }
.head-tags { grid-area: tags; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.head-summary { grid-area: sum; margin: 0; color: var(--text-2); max-width: 760px; font-size: 13.5px; }
.head-prices { grid-area: prices; display: grid; gap: 10px; align-self: center; }
.head-price {
  display: block; min-width: 200px; padding: 12px 16px; border-radius: 16px; background: rgba(255, 255, 255, .55);
  border: 1px solid rgba(255, 255, 255, .9); color: var(--muted-2); font-size: 12px;
}
.tile-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted-2); }
.head-price .price { display: block; color: var(--text); font-weight: 800; font-size: 20px; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.head-price .price.none { color: var(--muted); font-weight: 700; }
.head-price .price .muted.small { font-size: 12px; font-weight: 600; letter-spacing: 0; }
.head-price .price .price-src { display: block; font-weight: 500; }
.pkg-head .pct {
  position: relative; z-index: 0; flex: none; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; font-weight: 800; color: var(--indigo-ink); box-shadow: 0 10px 24px rgba(79, 70, 229, .2);
  background: conic-gradient(#4f46e5 calc(var(--p, 0) * 1%), rgba(99, 102, 241, .15) 0);
}
.pkg-head .pct::before { content: ''; position: absolute; inset: 11px; border-radius: 50%; background: rgba(255, 255, 255, .88); z-index: -1; }
.pkg-head .pct.full { color: var(--ok); background: conic-gradient(#10b981 calc(var(--p, 0) * 1%), rgba(16, 185, 129, .15) 0); box-shadow: 0 10px 24px rgba(16, 185, 129, .25); }
.sec-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.sec-chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .7rem .25rem .3rem; border-radius: 999px;
  background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .9); color: var(--muted); font-size: .85rem; font-weight: 500;
  transition: background .18s, color .18s;
}
.sec-chip:hover { text-decoration: none; background: rgba(255, 255, 255, .95); color: var(--text); }
.sec-chip .dot {
  display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%;
  background: var(--gray-soft); color: var(--muted); font-size: .75rem; font-weight: 700;
}
.sec-chip.done { color: var(--ok); }
.sec-chip.done .dot { background: var(--grad-green); color: #fff; }
.tree-tools { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.tree-tools .spacer { flex: 1; }
.save-status { font-size: .85rem; }
.save-status.error { color: var(--danger); }
.pkg-tabs-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; position: sticky; top: 20px; z-index: 5; }
.pkg-tabs-row .tabs { flex: 1 1 auto; min-width: 0; margin-bottom: 0; position: static; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding-left: 0; padding-right: 0; }
.pkg-tl-tools { display: inline-flex; align-items: center; gap: 2px; flex: none; padding: 4px; border-radius: 14px; background: inherit; }
.pkg-tl-tool { position: relative; width: 2.25rem; height: 2.25rem; color: var(--muted-2); }
.pkg-tl-tool.on { color: var(--primary, #2563eb); background: rgba(37, 99, 235, .12); border-color: rgba(37, 99, 235, .2); }
.pkg-tl-tool-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px rgba(255,255,255,.9); }

/* v21.95 — tabs sit inside package header (under tags); no separate tabs card */
.pkg-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pkg-head .pkg-tabs-row {
  margin: 2px 0 0;
  padding: 0;
  position: static;
  top: auto;
  z-index: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 0;
}
.pkg-head .pkg-tabs-row .tabs { padding-left: 0; padding-right: 0; }
.pkg-head .pkg-tl-tools { background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .9); }

.tabs { display: flex; align-items: center; gap: 6px; padding: 8px; margin-bottom: 16px; flex-wrap: wrap; position: sticky; top: 20px; z-index: 5; border-radius: 16px; }
.tabs .tab {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 13px; border: 0; margin: 0;
  color: var(--text-2); font-weight: 600; transition: background .18s, color .18s, box-shadow .18s;
}
.tabs .tab:hover { color: var(--text); text-decoration: none; background: rgba(255, 255, 255, .62); }
.tabs .tab.on { color: #fff; background: var(--grad); box-shadow: var(--shadow-primary); }
.tab-count { display: inline-block; margin-left: .1rem; font-size: 11px; font-weight: 700; background: var(--primary-soft); border-radius: 999px; padding: 1px 7px; color: var(--indigo-ink); }
.tabs .tab.on .tab-count { background: rgba(255, 255, 255, .25); color: #fff; }
.flow-tabs { margin-top: 0; }
.flow-tabs .tab .muted.small { color: inherit; opacity: .75; }
.tab-body > h3 { margin: 1.1rem 0 .6rem; font-size: 1.05rem; }
.page-sub { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .9rem; }
.page-sub p { margin: 0; max-width: 46rem; }

/* Cây quy trình */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree > li.section { border-left: 4px solid rgba(99, 102, 241, .4); border-radius: 16px; padding: .6rem .9rem .7rem; margin-bottom: 12px; scroll-margin-top: 5.5rem; }
.tree > li.section.filled { border-left-color: #10b981; }
.tree li.item > .node-row, .tree li.item > .hint, .tree li.item > .node-body { background: rgba(255, 255, 255, .5); }
.tree li.item { margin: .4rem 0; }
.tree li.item > .node-row { border-radius: 12px 12px 0 0; padding: .1rem .4rem; border: 1px solid rgba(255, 255, 255, .9); border-bottom: 0; }
.tree li.item > .hint { margin: 0; padding: 0 .4rem .3rem 2.6rem; border-left: 1px solid rgba(255, 255, 255, .9); border-right: 1px solid rgba(255, 255, 255, .9); }
.tree li.item > .node-body { border-radius: 0 0 12px 12px; padding: 0 .6rem .15rem 2.2rem; border: 1px solid rgba(255, 255, 255, .9); border-top: 0; }
.tree li.item > .node-body .node-note { background: rgba(255, 255, 255, .8); }
.tree li.item .sec-num { width: auto; min-width: 1.9rem; padding: 0 .45rem; border-radius: 999px; font-size: .78rem; background: var(--primary-soft); color: var(--indigo-ink); box-shadow: none; }
.tree li.item.filled > .node-row .sec-num { background: var(--ok-soft); color: var(--ok); }
.sec-title { font-weight: 700; }
h4.sec-title { font-size: .97rem; }
.std { margin: -.4rem 0 .75rem; font-size: .85rem; }
.small { margin: 0; }
.tree ul.children { padding-left: .55rem; }
.tree ul.children ul.children { padding-left: 1.5rem; }
.tree ul.children > li { position: relative; padding-left: 1.1rem; }
.tree ul.children > li::before {
  content: ''; position: absolute; left: 0; top: 0; width: .9rem; height: calc(var(--row-h) / 2);
  border-left: 2px solid var(--tree-line); border-bottom: 2px solid var(--tree-line); border-bottom-left-radius: 8px;
}
.tree ul.children > li::after { content: ''; position: absolute; left: 0; top: calc(var(--row-h) / 2); bottom: 0; border-left: 2px solid var(--tree-line); }
.tree ul.children > li:last-child::after { display: none; }
.tree li.add-li::before { border-style: dashed; }
.tree li.closed > ul.children { display: none; }
.node-row { display: flex; align-items: center; gap: .3rem; min-height: var(--row-h); border-radius: 10px; transition: background .15s; }
/* Branch rows light up under the pointer / keyboard focus / while their menu is open, so the actions read as part of the row. */
li:not(.section) > .node-row:focus-within, li.menu-open:not(.section) > .node-row { background: rgba(255, 255, 255, .55); }
@media (hover: hover) { li:not(.section) > .node-row:hover { background: rgba(255, 255, 255, .55); } }
.twisty {
  flex: none; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin: 0 .075rem; padding: 0;
  border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .6); border-radius: 8px; color: var(--indigo-ink);
  cursor: pointer; font-size: 1rem; font-weight: 700; line-height: 1; font-family: var(--mono); transition: background .18s;
}
@media (hover: hover) { .twisty:hover:not(:disabled) { background: #fff; box-shadow: var(--shadow-sm); } }
.twisty.none { visibility: hidden; cursor: default; }
/* Leaf branches get a small dot where the connector ends (sections keep their number tile instead). */
.twisty.none::before { content: ''; visibility: visible; width: 6px; height: 6px; border-radius: 50%; background: var(--tree-line); }
li.section > .node-row > .twisty.none::before, li.add-li > .node-row > .twisty.none::before { display: none; }
.sec-head { display: flex; align-items: center; gap: .55rem; flex: 1; min-width: 0; }
.sec-num {
  flex: none; display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 10px;
  background: var(--grad); color: #fff; font-weight: 800; font-size: .82rem; box-shadow: 0 4px 12px rgba(79, 70, 229, .25);
}
li.filled > .node-row .sec-num { background: var(--grad-green); box-shadow: 0 4px 12px rgba(16, 185, 129, .3); }
.sec-title { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.hint { margin: -.2rem 0 .3rem 2.1rem; font-size: .85rem; }
.node-title { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; padding: .3rem .5rem; border-radius: 8px; box-shadow: none; }
@media (hover: hover) { .node-title:hover { border-color: rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .6); } }
.node-title:focus { background: rgba(255, 255, 255, .92); }
li.d1 > .node-row .node-title { font-weight: 600; }
li.d2 > .node-row .node-title, li.d3 > .node-row .node-title, li.d4 > .node-row .node-title { font-weight: 500; color: var(--text-2); }
.node-title-wrap { display: flex; align-items: center; gap: .1rem; flex: 1; min-width: 0; }
.node-title-text { font: inherit; color: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; white-space: normal; line-height: 1.3; }
@media (hover: hover) { .node-title-text:hover { border-color: transparent; background: var(--primary-soft); } }
.node-title-input { border: 1px solid #93c5fd; background: #fff; font: inherit; color: inherit; box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); }
.icon.rename { flex: none; width: 1.6rem; height: 1.6rem; opacity: .7; }
.icon.rename:hover, .node-title-wrap.editing .icon.rename, .node-row:focus-within .icon.rename { opacity: 1; }
.node-title-wrap.editing .icon.rename { background: var(--primary-soft); }
.count { flex: none; font-size: .76rem; font-weight: 500; color: var(--muted); background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .9); border-radius: 999px; padding: .05rem .5rem; white-space: nowrap; }
.count:empty { display: none; }

/* Hàng: chỉ 2 nút luôn hiện — "Ghi chú" và menu "⋯"; nhánh tự do chỉ hiện khi rê chuột/focus (luôn hiện trên màn cảm ứng) */
.node-actions { display: flex; align-items: center; gap: .15rem; flex: none; margin-left: auto; }
.node-actions .icon { width: 1.9rem; height: 1.9rem; }
.btn-note {
  display: inline-flex; align-items: center; gap: .3rem; height: 1.9rem; padding: 0 .5rem 0 .45rem; border: 1px solid transparent; background: transparent;
  color: var(--muted-2); border-radius: 9px; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .18s, color .18s, box-shadow .18s;
}
.btn-note:hover { background: rgba(255, 255, 255, .95); border-color: rgba(255, 255, 255, .9); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-note[aria-expanded="true"] { background: var(--primary-soft); color: var(--indigo-ink); }
.btn-note .tg { transition: transform .18s; }
.btn-note[aria-expanded="true"] .tg { transform: rotate(180deg); }
.menu-btn[aria-expanded="true"] { background: var(--primary-soft); color: var(--indigo-ink); border-color: transparent; }
.btn-add {
  border: 1px dashed rgba(99, 102, 241, .5); background: rgba(255, 255, 255, .35); color: var(--primary-ink); border-radius: 8px;
  padding: .15rem .55rem; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; margin-right: .2rem; transition: background .18s;
}
.btn-add:hover { border-color: var(--primary); background: var(--primary-soft); }
@media (hover: hover) {
  li:not(.section) > .node-row .node-actions, .node-row .icon.rename { opacity: 0; transition: opacity .12s; }
  li:not(.section) > .node-row:hover .node-actions,
  li:not(.section) > .node-row:focus-within .node-actions,
  li.menu-open > .node-row .node-actions,
  li.note-open > .node-row .node-actions,
  li.add-li > .node-row .node-actions,
  .node-row:hover .icon.rename, .node-row:focus-within .icon.rename, .node-title-wrap.editing .icon.rename { opacity: 1; }
}
@media (hover: none) {
  .node-actions .icon, .btn-note { min-height: 2.25rem; }
  .menu-item { min-height: 2.5rem; }
}

/* Menu "⋯" của một hàng (lớp trên cùng qua popover; vị trí tính từ nút) */
.node-menu {
  position: fixed; inset: auto; margin: 0; z-index: 70; min-width: 13rem; padding: .3rem; border: 1px solid var(--glass-border); border-radius: 14px;
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: 0 14px 40px rgba(31, 38, 135, .22);
  color: var(--text); overflow: visible;
}
.node-menu[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 2.1rem; padding: .3rem .65rem; border: 0; border-radius: 9px; background: transparent;
  color: var(--text-2); font: inherit; font-size: .88rem; font-weight: 500; text-align: left; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s;
}
.menu-item .ic { color: var(--muted-2); }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--primary-soft); color: var(--text); }
.menu-item:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.menu-item:hover:not(:disabled) .ic { color: var(--indigo-ink); }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.menu-item.danger:hover:not(:disabled) { background: var(--red-soft); color: var(--danger); }
.menu-item.danger:hover:not(:disabled) .ic { color: var(--danger); }
.menu-sep { height: 1px; margin: .25rem .4rem; background: var(--line); }
.node-body { padding-left: 1.8rem; }
.node-note {
  font-size: .9rem; padding: .5rem .65rem; margin: .1rem 0 .35rem; background: rgba(255, 255, 255, .7); resize: vertical; min-height: 2.3rem;
  line-height: 1.45; border-radius: 10px;
}
li.section > .node-body .node-note { background: rgba(255, 255, 255, .75); }
.node-images { margin: .25rem 0 .5rem; }
.node-images.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; max-width: 900px; }
.node-images.single .thumb { width: min(360px, 100%); }
.thumb { margin: 0; border: 1px solid rgba(255, 255, 255, .9); border-radius: 12px; overflow: hidden; background: rgba(255, 255, 255, .7); box-shadow: var(--shadow-sm); }
.thumb-open { display: block; width: 100%; padding: 0; border: 0; background: rgba(241, 245, 249, .9); aspect-ratio: 4 / 3; cursor: zoom-in; }
.thumb-open:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-missing { display: grid; place-items: center; color: var(--muted); font-size: .85rem; cursor: default; }
.thumb figcaption { display: flex; align-items: center; gap: .2rem; padding: .3rem; }
.thumb figcaption input { padding: .25rem .5rem; font-size: .82rem; border-radius: 8px; }
.thumb .icon { width: 1.7rem; height: 1.7rem; }
.paste-hint { font-size: .78rem; margin: 0 0 .3rem; }

/* Xem ảnh lớn */
.lightbox {
  position: fixed; inset: 0; z-index: 95; background: rgba(15, 23, 42, .82); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center; padding: 3rem 3.5rem;
}
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.lb-img { max-width: 100%; max-height: calc(100vh - 8rem); object-fit: contain; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.lb-cap { color: #e5e7eb; font-size: .9rem; text-align: center; }
.lb-close, .lb-nav {
  position: absolute; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; border-radius: 999px;
  width: 2.6rem; height: 2.6rem; font-size: 1.4rem; line-height: 1; transition: background .18s;
}
.lb-close { top: .8rem; right: .8rem; font-size: 1.1rem; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 2rem; }
.lb-prev { left: .6rem; }
.lb-next { right: .6rem; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .3); }

/* Lịch sử */
.history-tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.history-tools select { width: auto; min-width: 11rem; }
.history-tools input[type=date] { width: auto; padding: .4rem .6rem; }
.history-tools .date-range { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); }
ul.history { list-style: none; margin: 0 0 16px; padding: 0; }
ul.history > li { padding: .75rem 1.2rem; border-bottom: 1px solid var(--line-soft); }
ul.history > li:last-child { border-bottom: 0; }
.h-main { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.h-act { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .1rem .55rem; background: var(--gray-soft); color: var(--muted); }
.h-act.create { background: var(--ok-soft); color: var(--ok); }
.h-act.delete { background: var(--red-soft); color: var(--danger); }
.h-act.update { background: var(--info-soft); color: var(--info); }
.h-act.restore { background: var(--ok-soft); color: var(--ok); }
.h-act.reorder { background: var(--violet-soft); color: var(--violet); }
.h-type { font-weight: 700; font-size: .9rem; color: var(--text-2); }
.h-desc { overflow-wrap: anywhere; }
.h-meta { font-size: .8rem; margin-top: .15rem; }
.h-src { font-style: italic; }
ul.history details summary { cursor: pointer; font-size: .78rem; }
ul.history pre { font-size: .75rem; background: rgba(255, 255, 255, .6); padding: .6rem; border-radius: 10px; overflow: auto; max-height: 320px; }
.deleted-box h3 { margin-bottom: .4rem; }
.deleted-list { list-style: none; margin: 0; padding: 0; }
.deleted-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .4rem 0; border-top: 1px solid var(--line-soft); }
.deleted-list li:first-child { border-top: 0; }

/* v5: sửa cấu trúc giai đoạn/mục; nút ghi chú; xem trước ghi chú */
.tree:not(.editing) .struct-only { display: none !important; }
.struct-title { font-weight: 700; font-size: 1.05rem; color: var(--text); }
li.item .struct-title { font-size: .97rem; }
.tree.editing > li.section { border-left-style: dashed; }
li.add-stage { list-style: none; margin: .25rem 0 1rem; }
.tree > li.add-stage-form { border: 1px dashed rgba(99, 102, 241, .5); border-radius: 16px; padding: .35rem .6rem; margin-bottom: 12px; }
.template > li.section { border-left-color: rgba(37, 99, 235, .6); }
.edit-toggle.primary { color: #fff; }
.node-row:has(> .note-preview:not([hidden])) { flex-wrap: wrap; }
.note-preview {
  order: 10; flex: 1 1 100%; min-width: 0; margin: -.35rem 0 .2rem; padding: 0 .5rem 0 2.25rem; font-size: .85rem;
  color: var(--muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-preview::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: .35rem; vertical-align: -1px; background: currentColor; opacity: .8;
  -webkit-mask: var(--i-note) center / contain no-repeat; mask: var(--i-note) center / contain no-repeat;
}
.note-preview:hover { color: var(--text); }
li.section > .node-row > .note-preview { padding-left: 4.4rem; }
.tree li.item > .node-row > .note-preview { margin: -.3rem 0 .25rem; padding-left: 4.1rem; }
.note-badge {
  display: inline-flex; align-items: center; gap: .3rem; flex: none; font-size: .75rem; font-weight: 600; color: var(--warn); background: var(--warn-soft);
  border: 1px solid rgba(245, 158, 11, .3); border-radius: 999px; padding: .05rem .5rem; white-space: nowrap;
}
.note-badge[hidden] { display: none; }
.note-wrap .hint { margin: .2rem 0 .2rem; }

/* Thanh lưu nổi */
.save-bar {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; display: flex; align-items: center; gap: .7rem;
  background: var(--glass-strong); border-radius: 16px; box-shadow: 0 14px 40px rgba(31, 38, 135, .22); padding: 8px 8px 8px 16px;
}
.save-bar .save-status { font-size: .85rem; color: var(--ok); font-weight: 600; white-space: nowrap; }
.save-bar[data-state="dirty"] .save-status, .save-bar[data-state="saving"] .save-status { color: var(--warn); }
.save-bar[data-state="error"] .save-status { color: var(--danger); }
.save-bar[data-state="saved"] .save-status::before { content: '✓ '; }
.save-bar[data-state="dirty"] .save-status::before { content: '● '; }
.save-btn { border-radius: 12px; padding: .3rem 1rem; font-weight: 700; }
.save-btn:disabled { opacity: .7; cursor: progress; }
#view:has(.save-bar) { padding-bottom: 5rem; }

/* Thông báo */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(30, 41, 59, .94); color: #fff;
  padding: .6rem 1.1rem; border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, .3); z-index: 100; font-size: .92rem; font-weight: 500;
  max-width: min(90vw, 560px); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.toast.error { background: rgba(185, 28, 28, .95); }

/* Đăng nhập */
.login-body { display: grid; grid-template-columns: 1fr; gap: 0; place-items: center; padding: 20px; min-height: 100vh; }
.login-card { width: 100%; max-width: 400px; padding: 32px 30px 26px; border-radius: 24px; }
.login-mark { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 14px; }
.login-mark svg { width: 26px; height: 26px; }
.login-card h1 { font-size: 1.4rem; }
.login-card h1 span { font-size: .9rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); }
.login-card label input { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 14px; padding: .6rem .8rem; }
.login-card .btn { margin-top: .3rem; min-height: 42px; font-size: 14.5px; }
.alert { background: var(--red-soft); color: var(--danger); border: 1px solid rgba(239, 68, 68, .25); border-radius: 12px; padding: .6rem .8rem; margin-top: .9rem; font-size: .9rem; font-weight: 500; }
.login-note { margin: 1rem 0 0; text-align: center; }

/* ===================== v6: nhãn, bảng, danh sách gói, form ===================== */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; border-radius: 999px; padding: .12rem .6rem;
  background: var(--gray-soft); color: var(--muted); white-space: nowrap; vertical-align: middle; line-height: 1.4;
}
.badge.seg-dan_dung { background: var(--cyan-soft); color: var(--cyan); }
.badge.seg-chuyen_dung { background: var(--primary-soft); color: var(--indigo-ink); }
.badge.st-y_tuong { background: var(--gray-soft); color: var(--muted); }
.badge.st-nghien_cuu { background: var(--info-soft); color: var(--info); }
.badge.st-prototype { background: var(--violet-soft); color: var(--violet); }
.badge.st-dang_phat_trien { background: var(--warn-soft); color: var(--warn); }
.badge.st-ban_duoc { background: var(--ok-soft); color: var(--ok); }
.badge.st-loai { background: var(--red-soft); color: var(--danger); text-decoration: line-through; }
.badge.flow { background: rgba(255, 255, 255, .6); border: 1px solid rgba(255, 255, 255, .9); color: var(--muted); font-weight: 500; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.locked { background: var(--red-soft); color: var(--danger); }
.code {
  display: inline-block; font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .04em; background: var(--primary-soft);
  border-radius: 7px; padding: .05rem .45rem; margin-right: .4rem; color: var(--indigo-ink); vertical-align: middle;
}

/* Chấm mức AI: xanh / vàng / đỏ; xám khi chưa đánh giá */
.ai-dot { display: inline-flex; align-items: center; gap: .45rem; vertical-align: middle; font-size: .86rem; font-weight: 600; white-space: nowrap; }
.ai-dot::before { content: ''; display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: #94a3b8; flex: none; box-shadow: 0 0 0 3px rgba(148, 163, 184, .25); }
.ai-dot.green::before { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .22); }
.ai-dot.yellow::before { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .25); }
.ai-dot.red::before { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .22); }
.ai-dot.green { color: var(--ok); }
.ai-dot.yellow { color: var(--warn); }
.ai-dot.red { color: var(--danger); }
.ai-dot.none { color: var(--muted-2); font-weight: 500; }
.ai-dot .ai-label { font-size: inherit; }
.ai-table tr.ai-green td.col-level { background: rgba(16, 185, 129, .12); }
.ai-table tr.ai-yellow td.col-level { background: rgba(245, 158, 11, .14); }
.ai-table tr.ai-red td.col-level { background: rgba(239, 68, 68, .12); }
.ai-table td.col-level { white-space: nowrap; }
.ai-table td.col-level select { display: inline-block; width: auto; margin-left: .3rem; }
.ai-summary { display: flex; flex-direction: column; gap: .4rem; }
.ai-summary p { margin: 0; }

/* Bảng */
.table-card { padding: 0; overflow-x: auto; }
.table-card.has-foot { overflow: hidden; display: flex; flex-direction: column; }
.tscroll { overflow-x: auto; min-width: 0; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.tbl th, .tbl td { padding: .55rem .75rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
.tbl th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); font-weight: 700; background: rgba(255, 255, 255, .45);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .45); }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl input, .tbl select { padding: .3rem .5rem; font-size: .88rem; border-color: transparent; background: transparent; min-width: 5rem; border-radius: 8px; box-shadow: none; }
.tbl select { padding-right: 1.6rem; background-position: right .4rem center; }
.tbl input:hover, .tbl select:hover { border-color: rgba(255, 255, 255, .95); background-color: rgba(255, 255, 255, .7); }
.tbl input:focus, .tbl select:focus { border-color: #93c5fd; background-color: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.tbl input.money { width: 8.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.tbl input.qty { width: 4.5rem; text-align: right; }
.tbl input.short { width: 6rem; min-width: 4rem; }
.tbl tfoot td { background: rgba(255, 255, 255, .4); }
.tbl tfoot tr.total td { border-top: 2px solid rgba(99, 102, 241, .35); font-size: .95rem; background: rgba(255, 255, 255, .55); }
.tbl tfoot tr.sub td { color: var(--indigo-ink); font-weight: 600; font-size: .82rem; border-bottom: 0; background: rgba(99, 102, 241, .07); }
.tbl tr.add-row td { background: rgba(255, 255, 255, .3); border-top: 1px dashed rgba(99, 102, 241, .4); }
.tbl tr.add-row input, .tbl tr.add-row select { border-color: var(--field-border); background-color: var(--field-bg); }
.tbl tr.mine td { background: var(--primary-soft); }
.tbl th.mine, .tbl td.mine { background: rgba(99, 102, 241, .08); }
.tbl .card-actions { display: inline-flex; }
.tbl td .pct.small { font-size: .8rem; font-weight: 600; color: var(--muted); min-width: 2.2rem; text-align: right; }
.users-table tr.locked td { color: var(--muted); }
.bom-table td:nth-child(2) { min-width: 12rem; }
.bom-table td:nth-child(3), .bom-table td:nth-child(8) { min-width: 9rem; }

/* Danh sách gói */
.pkg-table .col-name { min-width: 16rem; }
.pkg-table .name-cell { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.pkg-table .pkg-link { font-weight: 700; color: var(--text); font-size: .95rem; }
.pkg-table .pkg-link:hover { color: var(--primary-ink); }
.pkg-table tr.d0 td { background: rgba(255, 255, 255, .3); }
.pkg-table tr.d1 td { background: rgba(255, 255, 255, .06); }
.pkg-table tbody tr:hover td { background: rgba(255, 255, 255, .55); }
.pkg-table tr.d1 .name-cell { padding-left: 1.7rem; position: relative; }
.pkg-table tr.d1 .pkg-link { font-weight: 500; }
.pkg-table .child-mark {
  position: absolute; left: .55rem; top: -.9rem; width: .9rem; height: 1.7rem; color: transparent; font-size: 0; user-select: none;
  border-left: 2px solid rgba(99, 102, 241, .35); border-bottom: 2px solid rgba(99, 102, 241, .35); border-radius: 0 0 0 8px;
}
.pkg-table .name-cell > .code { order: 1; margin-right: 0; }
.pkg-table .name-cell > .muted.small { order: 2; }
.pkg-table .summary { flex-basis: 100%; margin-top: .1rem; max-width: 36rem; font-size: .8rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pkg-table tr.d1 .summary { padding-left: 1.7rem; }
.pkg-table tr.dim td { opacity: .55; }
.pkg-table .col-price { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.pkg-table .col-price .price .muted.small { font-weight: 500; }
.pkg-table .col-price .price-src { display: block; font-weight: 500; }
.pkg-table .col-progress { min-width: 10rem; }
.pkg-table .col-actions { white-space: nowrap; text-align: right; }
.pkg-table .col-stt { width: 3rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.pkg-table .col-code { white-space: nowrap; }
.pkg-table .name-cell > .code { order: 0; }
/* Row action buttons: visible, coloured by intent (light theme) */
.pkg-table .row-btn { width: 36px; height: 36px; border-color: var(--line); background: rgba(255, 255, 255, .7); color: var(--primary-ink); }
.pkg-table .row-btn .ic { width: 18px; height: 18px; }
.pkg-table .card-actions { gap: .3rem; }
.pkg-table .row-btn.act-up, .pkg-table .row-btn.act-down { color: var(--info); background: var(--info-soft); border-color: transparent; }
.pkg-table .row-btn.act-star { color: #b45309; background: var(--warn-soft); border-color: transparent; }
.pkg-table .row-btn.act-add { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pkg-table .row-btn.act-del { color: var(--danger); background: var(--red-soft); border-color: transparent; }
.pkg-table .row-btn:hover:not(:disabled) { box-shadow: var(--shadow-sm); filter: brightness(.95); }
.pkg-table .row-btn:disabled { opacity: .35; }
.progress-cell { display: flex; align-items: center; gap: .5rem; }
.progress-cell .segbar { flex: 1; min-width: 5rem; }
.price.none { color: var(--muted); font-weight: 500; }
.price-src { white-space: nowrap; }
.price-multi { white-space: normal; }
.price-term { white-space: nowrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 16px; padding: 12px 16px; border-radius: 16px; }
.filters select, .filters input { width: auto; min-width: 9rem; padding: .45rem .7rem; min-height: 38px; }
.filters select { padding-right: 1.9rem; }
.filters input[type=search] { min-width: 15rem; }
.add-pkg { display: grid; grid-template-columns: 1.6fr .7fr 1fr 1fr 1.3fr auto; gap: .45rem; min-width: min(100%, 720px); }
.add-pkg input.short { min-width: 4rem; }
.legend { margin: .5rem 0 0; }
.legend .ai-dot { margin: 0 .1rem; }

/* Chân bảng: số dòng/trang + phân trang, luôn là một hàng riêng dưới bảng */
.list-foot {
  display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; padding: 10px 16px; font-size: .86rem; color: var(--muted);
  border-top: 1px solid var(--glass-border); background: rgba(255, 255, 255, .45);
}
.list-foot .per { display: inline-flex; align-items: center; gap: .5rem; font-weight: 500; white-space: nowrap; }
.list-foot .per select { width: auto; min-height: 34px; padding: .25rem 1.8rem .25rem .7rem; border-radius: 10px; font-weight: 600; }
.pager { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.pager button {
  min-width: 34px; height: 34px; padding: 0 .5rem; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .55);
  font-weight: 600; color: var(--text-2); cursor: pointer; display: inline-grid; place-items: center; transition: background .18s;
}
.pager button:hover:not(:disabled) { background: #fff; }
.pager button.cur, .pager button.cur:hover { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 14px rgba(37, 99, 235, .3); }
.pager button:disabled { opacity: .4; cursor: default; }

/* Form */
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.two-col > * { min-width: 0; }
.form-card .field { margin-bottom: .8rem; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-label { font-size: .75rem; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .9rem; margin-bottom: .5rem; }
.form-grid .field { margin-bottom: .25rem; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .5rem 1rem; margin: 0; font-size: .92rem; align-items: baseline; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv dd .muted.small { font-weight: 500; }
.price-summary h3 { margin-bottom: .6rem; }
.price-summary dd:first-of-type { color: var(--indigo-ink); font-size: 1.05rem; font-weight: 800; }
.finance dd.margin { color: var(--ok); font-weight: 800; }
.bom-total { font-size: 1.05rem; color: var(--indigo-ink); }
.inline-form input.short { min-width: 5rem; max-width: 8rem; }
.add-offer { display: grid; grid-template-columns: 1.4fr 1fr 1fr .8fr .8fr .6fr 1fr auto; gap: .45rem; padding: .7rem; border-top: 1px dashed rgba(99, 102, 241, .4); background: rgba(255, 255, 255, .3); }
.add-offer input, .add-offer select { padding: .35rem .55rem; font-size: .88rem; }
.add-user { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr auto; gap: .45rem; }

/* Đồng bộ Sheet */
.sync-status p { margin: .2rem 0; }
.sync-status.warn { border-left: 4px solid #f59e0b; }
.sync-status code { font-size: .85rem; background: rgba(255, 255, 255, .6); padding: 0 .35rem; border-radius: 6px; font-family: var(--mono); }
.conflict-count { color: var(--danger); font-weight: 700; }
.badge.kind-cell { background: var(--warn-soft); color: var(--warn); }
.badge.kind-invalid { background: var(--red-soft); color: var(--danger); }
.badge.kind-row_deleted_sheet, .badge.kind-row_deleted_app { background: var(--violet-soft); color: var(--violet); }
.badge.run-done { background: var(--ok-soft); color: var(--ok); }
.badge.run-error { background: var(--red-soft); color: var(--danger); }
.badge.run-running { background: var(--info-soft); color: var(--info); }
.conflicts-table td.val { max-width: 22rem; overflow-wrap: anywhere; font-size: .88rem; }
.conflicts-table pre { font-size: .72rem; max-height: 10rem; overflow: auto; background: rgba(255, 255, 255, .6); padding: .3rem; border-radius: 8px; }
.btn-col { display: flex; flex-direction: column; gap: .3rem; }
.runs-table td.msg { max-width: 28rem; overflow-wrap: anywhere; }

/* v7: mức quan trọng / nhánh của tính năng — chip gọn (rộng theo giá trị), <select> thật nằm phủ lên chip */
.feat-fields { display: inline-flex; gap: .3rem; flex: none; margin-left: .2rem; }
.chip-sel {
  position: relative; display: inline-flex; align-items: center; gap: .25rem; height: 1.45rem; padding: 0 .45rem 0 .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; line-height: 1; white-space: nowrap; border: 1px solid transparent; background-color: var(--gray-soft); color: var(--text-2);
  cursor: pointer; transition: box-shadow .18s, background-color .18s;
}
.chip-sel:hover { box-shadow: 0 4px 12px rgba(31, 38, 135, .15); }
.chip-sel:has(> .feat-sel:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.chip-sel .chip-caret { width: 11px; height: 11px; stroke-width: 2.5; opacity: .8; }
.chip-sel .feat-sel {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; border-radius: inherit; opacity: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; background: none; box-shadow: none;
}
.chip-sel.importance-none, .chip-sel.branch-none { color: var(--muted); background-color: rgba(255, 255, 255, .45); border: 1px dashed rgba(100, 116, 139, .5); font-weight: 500; }
.chip-sel.importance-cuc_ky_quan_trong, .badge.imp-cuc_ky_quan_trong { background-color: var(--red-soft); color: var(--danger); border-color: transparent; }
.chip-sel.importance-quan_trong, .badge.imp-quan_trong { background-color: var(--orange-soft); color: var(--orange); border-color: transparent; }
.chip-sel.importance-phu_tro, .badge.imp-phu_tro { background-color: var(--gray-soft); color: var(--muted); border-color: transparent; }
.chip-sel.branch-thuat_toan, .badge.br-thuat_toan { background-color: var(--info-soft); color: var(--info); border-color: transparent; }
.chip-sel.branch-ai, .badge.br-ai { background-color: var(--violet-soft); color: var(--violet); border-color: transparent; }
.chip-sel.branch-ket_hop, .badge.br-ket_hop { background-color: var(--cyan-soft); color: var(--cyan); border-color: transparent; }
.tree li.feat-hide { display: none !important; }
.feature-filter { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .75rem; padding: .5rem .8rem; border-radius: 14px; }
.feature-filter select { width: auto; padding: .3rem 1.8rem .3rem .6rem; font-size: .85rem; }
.legend-feat .badge { font-weight: 500; }

/* Điều hướng trên điện thoại: nút ≡ mở ngăn kéo (nav + thẻ người dùng); desktop/tablet giữ bố cục cũ nhờ display: contents */
.nav-toggle, .nav-close { display: none; }
.nav-panel { display: contents; }
.nav-backdrop { position: fixed; inset: 0; z-index: 85; background: rgba(15, 23, 42, .45); }

/* Hàng cây: cụm thông tin phụ (chip, ghi chú, số ảnh, số nhánh gập) — trên desktop nằm chung hàng như cũ */
.node-meta { display: contents; }
.note-chip { display: none; }
.add-reveal { display: none; }

/* Bottom sheet (điện thoại): mọi thao tác của một hàng cây, mục tiêu chạm ≥ 44px */
.sheet-layer { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; background: rgba(15, 23, 42, .45); animation: sheet-fade .18s ease-out; }
.sheet {
  width: 100%; max-width: 560px; max-height: min(88vh, 88dvh); overflow: auto; overscroll-behavior: contain; outline: none;
  padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: var(--glass-strong);
  border: 1px solid var(--glass-border); border-bottom: 0; box-shadow: 0 -16px 48px rgba(31, 38, 135, .28);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-handle { width: 40px; height: 4px; margin: 4px auto 10px; border-radius: 999px; background: rgba(100, 116, 139, .45); }
.sheet-head { margin: 0 4px 8px; }
.sheet-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.sheet-title { margin: 2px 0 0; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sheet-field { margin: 2px 0 6px; }
.sheet-field-label { display: block; margin: 6px 4px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); }
.sheet-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet-opt {
  flex: 1 1 auto; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .6);
  color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, box-shadow .15s;
}
.sheet-opt.on { box-shadow: inset 0 0 0 2px currentColor; border-color: transparent; }
.sheet-opt.on.imp-cuc_ky_quan_trong { background: var(--red-soft); color: var(--danger); }
.sheet-opt.on.imp-quan_trong { background: var(--orange-soft); color: var(--orange); }
.sheet-opt.on.imp-phu_tro { background: var(--gray-soft); color: var(--muted); }
.sheet-opt.on.br-thuat_toan { background: var(--info-soft); color: var(--info); }
.sheet-opt.on.br-ai { background: var(--violet-soft); color: var(--violet); }
.sheet-opt.on.br-ket_hop { background: var(--cyan-soft); color: var(--cyan); }
.sheet-sep { height: 1px; margin: 6px 2px; background: var(--line); }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 10px; border: 0; border-radius: 12px; background: transparent;
  color: var(--text); font: inherit; font-size: 15px; font-weight: 500; text-align: left; cursor: pointer; transition: background .12s;
}
.sheet-item .ic { color: var(--muted-2); }
.sheet-item:active, .sheet-item:focus-visible { background: var(--primary-soft); }
.sheet-item:disabled { opacity: .4; cursor: default; }
.sheet-item.danger, .sheet-item.danger .ic { color: var(--danger); }
.sheet-close { width: 100%; min-height: 48px; margin-top: 6px; }
html.sheet-open, html.nav-open { overflow: hidden; }
@keyframes sheet-up { from { transform: translateY(32px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }

/* Giảm chuyển động theo cài đặt hệ thống */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn.primary:hover, .kpi:hover { transform: none; }
}

/* ===================== Màn hình hẹp ===================== */
@media (max-width: 1100px) {
  body { display: block; padding: 0; }
  html { scroll-padding-top: 7.5rem; }
  .topbar {
    position: sticky; top: 0; height: auto; border-radius: 0; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: .4rem .8rem; padding: .55rem .9rem .5rem; border-width: 0 0 1px; background: var(--glass-strong); box-shadow: 0 6px 24px rgba(31, 38, 135, .1);
  }
  .brand { padding: 0; font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand span.sub { display: none; }
  .topbar nav { order: 3; flex: 1 1 100%; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: .25rem; padding-bottom: .15rem; scrollbar-width: thin; }
  .topbar nav a { flex: none; padding: .4rem .7rem; font-size: .88rem; border-radius: 999px; white-space: nowrap; }
  .nav-sep { display: none; }
  .user-card { order: 2; margin: 0 0 0 auto; padding: .15rem .3rem; background: transparent; border: 0; column-gap: .5rem; }
  .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
  .topbar .who { max-width: 9rem; font-size: 12.5px; }
  .container { padding: 14px 12px; }
  .tabs { top: 0; border-radius: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pkg-title { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "tags" "sum" "prices"; }
  .head-prices { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .pkg-head { flex-wrap: wrap; }
  .pkg-head .pct { width: 84px; height: 84px; font-size: 17px; }
  .pkg-head .pct::before { inset: 9px; }
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .add-pkg, .add-offer, .add-user { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
/* ===================== Điện thoại (≤ 640px): mobile-first cho 360–430px ===================== */
@media (max-width: 640px) {
  :root { --blur: blur(10px) saturate(150%); --glass: rgba(255, 255, 255, .74); --glass-strong: rgba(255, 255, 255, .9); --row-h: 2.75rem; --mob-head: 52px; }
  /* Kính nhẹ hơn: chỉ lớp nổi (thanh tab, thanh Lưu, sheet, ngăn kéo) còn làm mờ nền; thẻ nội dung dùng nền đặc hơn */
  .card, .page-head, .filters, .kpi, .tree > li.section, .tree > li.add-stage-form, .login-card, .feature-filter, .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; }
  html { scroll-padding-top: 3.6rem; }
  html, body { overflow-x: clip; }
  body { font-size: 15px; }
  h1, .title-input { font-size: 1.2rem; }
  .container { min-width: 0; max-width: 100%; }
  h3 { font-size: .95rem; }
  /* Ô nhập 16px để iOS không tự phóng to khi focus; cao ≥ 44px */
  #view input:not([type=file]), #view select, #view textarea, .login-card input { font-size: 16px; min-height: 44px; }
  .chip-sel .feat-sel { min-height: 0; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
  .icon { width: 44px; height: 44px; }
  .container { padding: 10px 10px 0; }
  .page-head, .card, .filters { padding: 12px; border-radius: 14px; margin-bottom: 10px; }
  .page-head { display: block; }
  .page-head p { font-size: 12.5px; }

  /* Đầu trang gọn: logo + nút ≡; nav và thẻ người dùng chuyển vào ngăn kéo bên trái */
  .topbar {
    position: static; display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; height: var(--mob-head); padding: 0 6px 0 12px;
    border-width: 0 0 1px; border-radius: 0; box-shadow: none; background: rgba(255, 255, 255, .55); overflow: visible;
  }
  .brand { padding: 0; gap: 10px; font-size: 16px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; }
  .brand-logo { width: 32px; height: 32px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand span.sub { display: none; }
  .nav-toggle { display: inline-grid; place-items: center; margin-left: auto; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer; }
  .nav-toggle:active { background: var(--primary-soft); }
  .nav-toggle svg { width: 22px; height: 22px; }
  .nav-panel {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 90; width: min(84vw, 320px); display: flex; flex-direction: column; gap: 2px;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: var(--glass-strong); border-right: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(31, 38, 135, .3); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; overflow: auto; overscroll-behavior: contain;
  }
  html.nav-open .nav-panel { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav-close { display: inline-grid; align-self: flex-end; width: 44px; height: 44px; margin-bottom: 2px; }
  .topbar nav { flex: 1; order: 0; flex-direction: column; flex-wrap: nowrap; gap: 2px; overflow: visible; padding: 0; }
  .topbar nav a { display: flex; flex: none; min-height: 48px; padding: 10px 12px; border-radius: 12px; font-size: 15px; white-space: normal; }
  .nav-sep { display: block; margin: 12px 12px 4px; }
  .user-card { order: 0; margin: auto 0 0; padding: 10px; background: rgba(255, 255, 255, .55); border: 1px solid var(--glass-border); column-gap: 10px; }
  .avatar { width: 36px; height: 36px; border-radius: 12px; font-size: 13px; }
  .topbar .who { max-width: none; font-size: 13px; }
  .logout .linklike { font-size: 13px; padding: 6px 0; }

  /* Danh sách gói: form thêm gói gập sau nút "+ Thêm gói"; bộ lọc: ô tìm trước, 3 select thành 2 hàng; thẻ số liệu gọn */
  .add-reveal { display: inline-flex; width: 100%; margin-top: 10px; }
  .page-head .add-pkg { display: none; }
  .page-head.adding .add-pkg { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
  .kpi { padding: 10px; gap: 8px; flex-wrap: nowrap; min-width: 0; }
  .k-ic { width: 34px; height: 34px; border-radius: 10px; }
  .k-ic svg { width: 16px; height: 16px; }
  .kpi .v { font-size: 18px; }
  .kpi .l { font-size: 11.5px; }
  .kpi .t { font-size: 10.5px; margin-top: 3px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .filters { gap: 6px; padding: 8px 10px; }
  .filters input[type=search] { order: -1; flex: 1 1 100%; min-width: 0; }
  .filters select { flex: 1 1 45%; min-width: 0; padding: .4rem 1.6rem .4rem .6rem; }
  .filters .btn { flex: 1 1 100%; }
  .legend { font-size: .8rem; }
  .list-foot { padding: 8px 10px; gap: 6px 10px; }
  .pager { margin-left: 0; width: 100%; justify-content: center; }
  .pager button { min-width: 40px; height: 40px; }

  /* Bảng → thẻ xếp chồng: mỗi dòng một thẻ, mỗi ô có nhãn cột (data-label, do app.js gắn) phía trên giá trị */
  .table-card, .table-card.has-foot, .tscroll { overflow: visible; }
  .tbl { display: block; font-size: .92rem; }
  .tbl thead { display: none; }
  .tbl tbody, .tbl tfoot { display: block; }
  .tbl tr { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl td, .tbl th { display: block; flex: 1 1 100%; min-width: 0; padding: 2px 0; border: 0; background: transparent; }
  .tbl tbody tr:hover td, .pkg-table tbody tr:hover td, .pkg-table tr.d0 td, .pkg-table tr.d1 td, .tbl tr.mine td, .tbl td.mine, .tbl tfoot td, .tbl tr.add-row td { background: transparent; border-top: 0; }
  .tbl td:empty { display: none; }
  .tbl td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; margin-bottom: 1px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2);
  }
  .tbl td.num { text-align: left; }
  .tbl input, .tbl select { width: 100%; min-width: 0; border-color: var(--field-border); background-color: var(--field-bg); }
  .tbl select:not([multiple]) { background-image: var(--chev); background-repeat: no-repeat; background-position: right .6rem center; padding-right: 1.9rem; } /* mũi tên lại hiện: select trong bảng không còn giống ô nhập */
  .tbl input.money, .tbl input.qty, .tbl input.short { width: 100%; text-align: left; }
  .tbl .card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .tbl td:has(> .card-actions), .tbl td:has(> .icon), .tbl td:has(> .btn-col) { display: flex; justify-content: flex-end; }
  .tbl .card-actions .icon, .tbl td > .icon { width: 44px; height: 44px; background: rgba(255, 255, 255, .55); border-color: rgba(255, 255, 255, .9); }
  .tbl tr.add-row { background: rgba(255, 255, 255, .3); border-top: 1px dashed rgba(99, 102, 241, .4); }
  .tbl tr.add-row::before { content: 'Thêm dòng'; flex: 1 1 100%; font-size: .82rem; font-weight: 700; color: var(--indigo-ink); }
  .tbl tr.add-row td:has(> button) { flex: 1 1 100%; }
  .tbl tr.add-row button[type=submit] { width: 100%; min-height: 44px; }
  .tbl tfoot tr:not(.add-row) { justify-content: space-between; align-items: baseline; gap: 4px 12px; background: rgba(255, 255, 255, .35); }
  .tbl tfoot tr:not(.add-row) td { flex: 0 1 auto; }
  .tbl tfoot tr:not(.add-row) td::before { display: none; }
  .tbl tfoot tr.total { border-top: 2px solid rgba(99, 102, 241, .35); }
  .tbl tr.mine { background: var(--primary-soft); }
  /* Ô ngắn đi theo cặp trên một hàng (giá, số lượng, đơn vị, ngày, trạng thái) */
  .tbl td[data-label="Giá bán đứt"], .tbl td[data-label="Thuê bao/tháng"], .tbl td[data-label="Giá/tháng"], .tbl td[data-label="Đơn vị"], .tbl td[data-label="Ngày báo giá"],
  .tbl td[data-label="SL"], .tbl td[data-label="Giá tham khảo"], .tbl td[data-label="Thành tiền"], .tbl td[data-label="Giá vốn BOM"], .tbl td[data-label="Trạng thái"], .tbl td[data-label="Tạo lúc"] { flex: 1 1 40%; }
  .pkg-table .col-name { min-width: 0; }
  .pkg-table td.col-stt::before, .pkg-table td.col-name::before, .pkg-table td.col-code::before, .pkg-table td.col-seg::before, .pkg-table td.col-status::before, .pkg-table td.col-ai::before { display: none; }
  .pkg-table .col-stt { flex: 0 0 auto; width: auto; text-align: left; font-weight: 700; }
  .pkg-table .col-stt::after { content: '.'; }
  .pkg-table .col-name { flex: 1 1 60%; }
  .pkg-table .col-code, .pkg-table .col-seg, .pkg-table .col-status { flex: 0 1 auto; }
  .pkg-table .row-btn { width: 44px; height: 44px; }
  .pkg-table .col-price { flex: 1 1 45%; white-space: normal; font-size: .88rem; }
  .pkg-table .col-progress { flex: 1 1 100%; min-width: 0; }
  .pkg-table .col-actions { text-align: right; }
  .pkg-table tr.d1 { margin-left: 12px; padding-left: 10px; border-left: 2px solid rgba(99, 102, 241, .35); }
  .pkg-table tr.d1 .name-cell, .pkg-table tr.d1 .summary { padding-left: 0; }
  .pkg-table .child-mark { display: none; }
  .pkg-table .summary { max-width: none; }
  /* Mỗi gói một thẻ riêng (chỉ mobile ≤640px; desktop giữ bảng) */
  .table-card:has(> .tscroll > .pkg-table), .table-card:has(> .pkg-table) {
    background: transparent; border: 0; box-shadow: none; padding: 0;
  }
  .table-card:has(> .tscroll > .pkg-table) .tscroll { padding: 0; }
  .pkg-table tbody { display: flex; flex-direction: column; gap: 12px; }
  .pkg-table tbody tr.pkg-row {
    background: rgba(255, 255, 255, .92); border: 1px solid var(--glass-border); border-radius: 12px;
    box-shadow: var(--shadow-sm); padding: 12px; border-bottom: 0; gap: 4px 10px;
  }
  .pkg-table tbody tr.pkg-row:last-child { border-bottom: 0; }
  .pkg-table tbody tr.pkg-row.d1 { background: rgba(255, 255, 255, .88); }
  .table-card.has-foot:has(.pkg-table) > .list-foot {
    margin-top: 12px; background: rgba(255, 255, 255, .74); border: 1px solid var(--glass-border);
    border-radius: 12px; box-shadow: var(--shadow-sm);
  }
  .bom-table td:nth-child(2), .bom-table td:nth-child(3), .bom-table td:nth-child(8) { min-width: 0; }
  .ai-table td.col-level { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; white-space: normal; }
  .ai-table td.col-level::before { flex: 1 1 100%; }
  .ai-table td.col-level select { flex: 1; width: auto; margin: 0; }
  .ai-table tr.ai-green td.col-level, .ai-table tr.ai-yellow td.col-level, .ai-table tr.ai-red td.col-level { background: transparent; }
  .conflicts-table td.val { max-width: none; }
  .runs-table td.msg { max-width: none; }

  /* Form */
  .inline-form { width: 100%; flex-direction: column; min-width: 0; }
  .inline-form input.short { max-width: none; }
  .page-sub { display: block; }
  .page-sub p { margin-bottom: 8px; }
  .add-pkg, .add-offer, .add-user { grid-template-columns: 1fr; gap: 8px; }
  .add-offer { padding: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: minmax(0, 1fr) auto; gap: .4rem .6rem; font-size: .9rem; }
  .history-tools { gap: 6px; }
  .history-tools select, .history-tools .btn, .history-tools .date-range { width: 100%; }
  .history-tools .date-range input { flex: 1; }
  .deleted-list li { flex-wrap: wrap; gap: .4rem; }
  ul.history > li { padding: 10px 12px; }
  .report { grid-template-columns: 1fr; gap: 10px; }

  /* Trang gói: đầu trang gọn, vòng % nhỏ cạnh tên, 2 ô giá cạnh nhau; tab thành pill cuộn ngang, dính mép trên */
  .crumbs { margin-bottom: 6px; font-size: 12.5px; }
  .pkg-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: start; padding: 12px; }
  .pkg-title { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "tags" "sum" "prices"; gap: 6px; }
  .title-input { padding: .1rem .3rem; margin-left: -.3rem; min-height: 40px; }
  .head-tags { gap: 6px; font-size: .82rem; }
  .head-summary { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .head-prices { grid-template-columns: 1fr 1fr; gap: 6px; }
  .head-price { min-width: 0; padding: 8px 10px; border-radius: 12px; }
  .head-price .price { font-size: 15px; }
  .tile-label { font-size: 10.5px; }
  .pkg-head .pct { width: 56px; height: 56px; font-size: 14px; box-shadow: none; }
  .pkg-head .pct::before { inset: 6px; }
  .tabs {
    position: sticky; top: 0; z-index: 5; flex-wrap: nowrap; gap: 4px; padding: 6px 10px; margin: 0 -10px 10px; border-radius: 0; border-width: 0 0 1px;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; scroll-padding: 0 10px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: none; min-height: 40px; padding: 0 14px; font-size: .9rem; scroll-snap-align: start; }
  .tabs::after { content: ''; position: sticky; right: -10px; flex: none; width: 28px; margin-left: -28px; align-self: stretch; pointer-events: none; background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--glass) 70%); }
  .flow-tabs { position: static; }
  .std { margin: 0 0 8px; font-size: .82rem; }
  .sec-nav { gap: 6px; margin-bottom: 8px; }
  .sec-chip { padding: 4px; min-width: 36px; min-height: 36px; justify-content: center; }
  .sec-chip .dot { width: 1.6rem; height: 1.6rem; }
  .sec-chip .label { display: none; }
  .tree-tools { gap: 6px; margin-bottom: 8px; }
  .tree-tools .spacer { display: none; }
  .tree-tools .btn { flex: 1 1 auto; padding: .3rem .6rem; font-size: .85rem; }
  .tree-tools .edit-toggle { flex: 1 1 100%; }
  .feature-filter { padding: 8px; gap: 6px; margin-bottom: 8px; }
  .feature-filter > .small, .legend-feat { display: none; }
  .feature-filter select { flex: 1 1 100%; min-width: 0; }
  .feat-count { flex: 1 1 100%; }

  /* Cây yêu cầu: mỗi hàng = 1 dòng tiêu đề (…) + 1 nút ⋯; chip chỉ hiện khi có giá trị; thụt lề ~12px/cấp, guide 1px */
  .tree > li.section { padding: 6px 6px 8px; border-left-width: 3px; border-radius: 14px; margin-bottom: 10px; scroll-margin-top: 3.6rem; }
  .tree li.item { margin: 4px 0; }
  .tree li.item > .node-row { padding: 0 2px; border-radius: 10px 10px 0 0; }
  .tree li.item > .node-body { padding: 0 6px 2px; }
  .tree li.item > .hint { padding: 0 6px 4px; }
  .tree ul.children { padding-left: 0; }
  .tree ul.children ul.children { padding-left: 2px; }
  .tree ul.children > li { padding-left: 11px; }
  .tree ul.children > li::before { width: 8px; height: calc(var(--row-h) / 2); border-width: 0 0 1px 1px; border-bottom-left-radius: 6px; }
  .tree ul.children > li::after { border-left-width: 1px; }
  .node-row { gap: 2px; flex-wrap: wrap; min-height: var(--row-h); }
  .node-row > .twisty { position: relative; width: 32px; height: 32px; margin: 0; font-size: 1.05rem; }
  .twisty::after { content: ''; position: absolute; inset: -6px; }
  .node-row .node-title-wrap, li.section > .node-row .sec-head { flex: 1 1 calc(100% - 84px); min-width: 0; order: 1; }
  .node-title { padding: .25rem .3rem; }
  .node-title-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
  .node-title-wrap .icon.rename { display: none; }
  .node-title-text:hover, .node-title:hover { background: transparent; border-color: transparent; } /* không giữ màu hover sau khi chạm */
  .sec-head { gap: 6px; }
  .sec-num { width: 1.7rem; height: 1.7rem; font-size: .76rem; border-radius: 8px; box-shadow: none; }
  .tree li.item .sec-num { min-width: 1.7rem; }
  .sec-title, .struct-title, li.item .struct-title { font-size: .98rem; }
  .node-actions { order: 2; margin-left: auto; gap: 0; opacity: 1 !important; }
  .node-actions .btn-note { display: none; }
  .node-actions .icon { width: 44px; height: 44px; border-radius: 10px; }
  .node-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; order: 3; flex: 1 1 100%; min-width: 0; margin: -4px 0 6px 36px; }
  .node-meta:not(:has(.chip-sel:not(.importance-none):not(.branch-none):not(.ai_level-none), .note-chip:not([hidden]), .note-badge:not([hidden]), .count:not(:empty))) { display: none; }
  .node-meta .feat-fields { display: contents; }
  .chip-sel.importance-none, .chip-sel.branch-none, .chip-sel.ai_level-none { display: none; }
  .chip-sel, .note-badge, .note-chip, .count { min-height: 28px; height: auto; font-size: .74rem; }
  .chip-sel { padding: 0 8px 0 10px; }
  .note-chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .9); border-radius: 999px; background: rgba(255, 255, 255, .6); color: var(--muted-2); font: inherit; font-size: .74rem; font-weight: 600; cursor: pointer; }
  .note-chip .ic { width: 12px; height: 12px; }
  .node-row > .note-preview { display: none !important; }
  .node-row .count { order: 0; }
  .node-body { padding-left: 2px; }
  .hint { margin-left: 2px; }
  .paste-hint { display: none; }
  .node-note { font-size: 16px; }
  .btn-add { margin-right: 2px; padding: .25rem .6rem; min-height: 40px; }
  .node-images.gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .thumb .icon { width: 40px; height: 40px; }
  .lightbox { padding: 3.5rem .5rem; }
  .lb-nav { top: auto; bottom: .8rem; transform: none; }

  /* Thanh Lưu dính mép dưới, rộng hết màn; nội dung chừa chỗ để dòng cuối không bị che; toast nằm trên thanh */
  .save-bar { left: 0; right: 0; bottom: 0; justify-content: space-between; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) 14px; border-radius: 16px 16px 0 0; border-bottom: 0; box-shadow: 0 -10px 30px rgba(31, 38, 135, .18); }
  .save-btn { min-height: 44px; padding: .3rem 1.2rem; }
  #view:has(.save-bar) { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .toast { bottom: 16px; }
  #view:has(.save-bar) ~ .toast { bottom: calc(5rem + env(safe-area-inset-bottom)); }

  /* Đăng nhập */
  .login-body { padding: 16px; min-height: 100svh; }
  .login-card { padding: 24px 20px 20px; border-radius: 20px; }
  .login-card .btn { min-height: 48px; }
}

/* ===================== v8: quy trình 7 bước, checklist, Kỹ thuật, thư viện giải thuật, khảo sát ===================== */
/* Quyết định Kỹ thuật cạnh trạng thái gói */
.badge.dec-lam_tiep { background: var(--ok-soft); color: var(--ok); }
.badge.dec-dung { background: var(--red-soft); color: var(--danger); }
.badge.dec-none { background: var(--gray-soft); color: var(--muted); border: 1px dashed rgba(100, 116, 139, .5); }
.col-status .badge + .badge, .head-tags .badge + .badge { margin-left: .1rem; }
.pkg-table .col-status { white-space: nowrap; }
/* Chip Mức AI trên tính năng (B2) */
.chip-sel.ai_level-none { color: var(--muted); background-color: rgba(255, 255, 255, .45); border: 1px dashed rgba(100, 116, 139, .5); font-weight: 500; }
.chip-sel.ai_level-co_san { background-color: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-sel.ai_level-can_lam_them { background-color: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-sel.ai_level-khong_lam_duoc { background-color: var(--red-soft); color: var(--danger); border-color: transparent; }

/* Stepper 7 bước */
.step-nav { margin-bottom: 1rem; }
.step-chip { padding-right: .55rem; }
.step-chip .step-pct { font-size: .72rem; font-weight: 700; opacity: .75; font-variant-numeric: tabular-nums; }
.step-chip.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-primary); }
.step-chip.on .dot { background: rgba(255, 255, 255, .25); color: #fff; }
.step-chip.on:hover { background: var(--grad); color: #fff; }
.step-chip.legacy { border-style: dashed; }
.step-panel { scroll-margin-top: 5.5rem; }
.step-head { display: flex; align-items: flex-start; gap: .8rem; margin: 0 0 .8rem; }
.step-head .sec-num { margin-top: .1rem; }
.step-head .step-title { flex: 1; min-width: 0; }
.step-head h3 { margin: 0; font-size: 1.1rem; }
.step-head p { margin: .15rem 0 0; max-width: 60rem; }
.step-count { flex: none; font-size: .78rem; font-weight: 700; color: var(--indigo-ink); background: var(--primary-soft); border-radius: 999px; padding: .2rem .7rem; white-space: nowrap; }
.step-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.step-main { min-width: 0; }
.step-side { position: sticky; top: 90px; }
.step-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.step-tools .spacer { flex: 1; }
.quick-add { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: .4rem; }
.step-form .field { margin-bottom: .9rem; }
.step-form .field:last-child { margin-bottom: 0; }
.empty-step { border-left: 4px solid rgba(99, 102, 241, .4); }
.empty-step p { margin: 0; }
.sec-num.legacy { background: var(--gray-soft); color: var(--muted); box-shadow: none; }
.legacy-panel .tree > li.section { border-left-style: dashed; }
.convert-box { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 12px; border-left: 4px solid rgba(99, 102, 241, .5); }
.convert-box > div { min-width: 0; flex: 1; }
.convert-box p { margin: .2rem 0 0; max-width: 60rem; }

/* Checklist */
.checklist .cl-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; margin-bottom: .2rem; }
.checklist .cl-head h3 { margin: 0; }
.cl-pct { font-weight: 800; color: var(--indigo-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cl-bar { height: 6px; border-radius: 999px; background: var(--empty); overflow: hidden; margin: .45rem 0 .7rem; }
.cl-bar i { display: block; height: 100%; width: 0; background: var(--grad-bar); border-radius: inherit; transition: width .3s; }
.checklist.all-done .cl-bar i { background: var(--grad-green); }
.checklist.all-done .cl-pct { color: var(--ok); }
.cl-list { list-style: none; margin: 0; padding: 0; }
.cl-item { display: flex; align-items: flex-start; gap: .5rem; padding: .4rem 0; border-top: 1px solid var(--line-soft); }
.cl-item:first-child { border-top: 0; }
.cl-check { flex: none; display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-top: .05rem; }
.cl-check input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--primary); cursor: pointer; }
.cl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.cl-title { text-align: left; padding: .15rem .3rem; margin: 0 -.3rem; line-height: 1.4; cursor: text; border-radius: 6px; font: inherit; overflow-wrap: anywhere; }
.cl-title:hover { background: var(--primary-soft); }
.cl-item.done .cl-title { color: var(--muted); text-decoration: line-through; }
.cl-input { padding: .2rem .45rem; font-size: .92rem; }
.cl-meta { font-size: .76rem; }
.cl-actions { display: flex; gap: .05rem; flex: none; opacity: 0; transition: opacity .12s; }
.cl-item:hover .cl-actions, .cl-item:focus-within .cl-actions { opacity: 1; }
@media (hover: none) { .cl-actions { opacity: 1; } }
.cl-actions .icon { width: 1.6rem; height: 1.6rem; }
.cl-add { display: flex; gap: .4rem; margin-top: .6rem; }
.cl-add input { flex: 1; min-width: 0; padding: .4rem .6rem; }
.cl-restore { display: inline-block; margin-top: .5rem; color: var(--muted); font-size: .8rem; }
.cl-restore:hover { color: var(--primary-ink); text-decoration: underline; }
.cl-static { margin: .4rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.cl-static li { margin: .15rem 0; }
.v8-defaults { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 12px; }
.step-default { margin: 0; }
.step-default .sec-head { margin-bottom: .3rem; }
.step-default p { margin: 0; }

/* B1: danh sách thiết bị; B7: ref link */
.chip-list { list-style: none; margin: 0 0 .4rem; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip-item { display: inline-flex; align-items: center; gap: .15rem; padding: .15rem .25rem .15rem .65rem; border-radius: 999px; background: rgba(255, 255, 255, .62); border: 1px solid rgba(255, 255, 255, .9); font-size: .86rem; font-weight: 500; }
.chip-item .icon { width: 1.4rem; height: 1.4rem; }
.chip-add { display: flex; gap: .4rem; }
.chip-add input { flex: 1; min-width: 0; }
.links-card { margin: 0; }
.links-table td.link-actions { white-space: nowrap; }
.links-table td.link-actions a { margin-right: .3rem; }

/* B4: mô tả tính năng */
.spec-list { display: flex; flex-direction: column; gap: 12px; }
.spec-card { margin: 0; }
.spec-card.d1 { margin-left: 1.4rem; }
.spec-card.d2, .spec-card.d3 { margin-left: 2.8rem; }
.spec-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.spec-head h4 { margin: 0; font-size: 1rem; }
.spec-tags { display: inline-flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.spec-note { margin: -.2rem 0 .6rem; white-space: pre-line; max-width: 70rem; }

/* B5 / B6: bảng màn hình */
.board-summary { margin: 0 0 .6rem; }
.screen-group { margin-bottom: 14px; }
.screen-platform { margin: 0 0 .5rem; font-size: 1rem; }
.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.screen-card { margin: 0; padding: 12px 14px; }
.screen-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.screen-card.platform { border-left: 4px solid rgba(99, 102, 241, .5); }
.screen-head h4 { margin: 0 0 .5rem; font-size: .95rem; overflow-wrap: anywhere; }
.screen-path { display: block; min-height: 1.1em; font-size: .76rem; }
.screen-link { display: flex; gap: .4rem; margin-bottom: .5rem; }
.screen-link input { flex: 1; min-width: 0; font-size: .84rem; padding: .35rem .5rem; }
.screen-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.screen-images .thumb-open { aspect-ratio: 4 / 3; }
.add-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 104px; border: 1px dashed rgba(99, 102, 241, .5); background: rgba(255, 255, 255, .35); color: var(--primary-ink); font-size: .8rem; font-weight: 600; cursor: pointer; border-radius: 12px; box-shadow: none; }
.add-thumb:hover { background: var(--primary-soft); }

/* Tab Kỹ thuật */
.kt-top { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kt-top > .card { margin-bottom: 16px; }
.kt-section h3 { display: flex; align-items: center; gap: .6rem; }
.kt-section h3 .sec-num { width: 1.7rem; height: 1.7rem; font-size: .78rem; }
.kt-section .two-col { grid-template-columns: 1fr 1fr; }
.hw-row { margin: .4rem 0 .6rem; }
.hw-choice { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.hw-opt { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .85rem .35rem .6rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .55); cursor: pointer; font-weight: 600; font-size: .88rem; transition: background .18s; }
.hw-opt:hover { background: rgba(255, 255, 255, .95); }
.hw-opt.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-primary); }
.hw-opt input { width: auto; margin: 0; accent-color: var(--primary); }
.hw-opt.on input { accent-color: #fff; }
.decision-card .field { margin: .4rem 0 .2rem; }
.decision-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }
.btn.go { background: var(--grad-green); border-color: transparent; color: #fff; box-shadow: 0 8px 20px rgba(16, 185, 129, .3); }
.btn.stop { color: var(--danger); border-color: rgba(239, 68, 68, .35); }
.btn.stop:hover { background: var(--red-soft); }
.decision-info { margin: .2rem 0 .4rem; line-height: 1.5; }
.steps-wrap { margin: .6rem 0 1rem; }
.steps-summary { margin: 0 0 .6rem; }
.feature-steps { margin-bottom: 12px; padding: 12px 14px; }
.feature-steps .spec-head { margin-bottom: .3rem; }
.steps-table td:nth-child(2) { min-width: 13rem; }
.steps-table td:nth-child(5) { min-width: 9rem; }
.steps-table td.col-algo { min-width: 17rem; }
.steps-table td.col-algo select { max-width: 20rem; }
.steps-table select.level { width: auto; }
.tbl select.level.br-ai { color: var(--violet); font-weight: 600; }
.tbl select.level.br-thuat_toan { color: var(--info); font-weight: 600; }
.steps-table tr.br-ai td:first-child { box-shadow: inset 3px 0 0 #8b5cf6; }
.steps-table tr.br-thuat_toan td:first-child { box-shadow: inset 3px 0 0 #3b82f6; }
.badge.st-algo { margin-left: .3rem; }
.badge.st-algo.green { background: var(--ok-soft); color: var(--ok); }
.badge.st-algo.yellow { background: var(--warn-soft); color: var(--warn); }
.badge.st-algo.red { background: var(--red-soft); color: var(--danger); }
.card.inner { margin: 0; background: rgba(255, 255, 255, .4); box-shadow: none; }

/* Thư viện giải thuật */
.algo-table td.col-name { min-width: 12rem; }
.algo-table td.col-desc { min-width: 15rem; }
.algo-table td.col-level select { min-width: 8rem; }
.algo-table textarea, .items-table textarea { padding: .3rem .5rem; font-size: .86rem; border-color: transparent; background: transparent; min-height: 2.2rem; border-radius: 8px; box-shadow: none; }
.algo-table textarea:hover, .items-table textarea:hover { border-color: rgba(255, 255, 255, .95); background: rgba(255, 255, 255, .7); }
.algo-table textarea:focus, .items-table textarea:focus { border-color: #93c5fd; background: #fff; }
.algo-table tr.algo-green td.col-level { background: rgba(16, 185, 129, .12); }
.algo-table tr.algo-yellow td.col-level { background: rgba(245, 158, 11, .14); }
.algo-table tr.algo-red td.col-level { background: rgba(239, 68, 68, .12); }
.algo-table td.col-level { white-space: nowrap; }
.algo-table td.col-level select { display: inline-block; width: auto; margin-left: .3rem; }
.nowrap { white-space: nowrap; }

/* Khảo sát khách */
.add-survey { max-width: 64rem; }
.add-survey-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.add-survey textarea { margin-bottom: .6rem; }
.badge.sv-moi { background: var(--gray-soft); color: var(--muted); }
.badge.sv-dang_khop { background: var(--info-soft); color: var(--info); }
.badge.sv-da_bao_gia { background: var(--ok-soft); color: var(--ok); }
.badge.sv-dong { background: var(--gray-soft); color: var(--muted); text-decoration: line-through; }
.survey-head { align-items: flex-start; }
.survey-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .4rem; }
.survey-title .title-input { margin-left: -.5rem; }
.survey-title p { margin: 0; }
.survey-meta { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.survey-meta input { max-width: 28rem; }
.survey-meta select { width: auto; }
.survey-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.flow-strip { list-style: none; display: flex; gap: .5rem; flex-wrap: wrap; margin: 0 0 16px; padding: 0; counter-reset: none; }
.flow-strip li { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .85rem .3rem .35rem; border-radius: 999px; background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .9); font-size: .86rem; font-weight: 500; color: var(--muted); }
.flow-strip li .dot { display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; border-radius: 50%; background: var(--gray-soft); color: var(--muted); font-size: .75rem; font-weight: 700; }
.flow-strip li.done { color: var(--ok); }
.flow-strip li.done .dot { background: var(--grad-green); color: #fff; }
.items-table td.col-content { min-width: 12rem; }
.items-table td.col-pkg { min-width: 11rem; }
.items-table td.col-pkg select { min-width: 10rem; max-width: 13rem; }
.items-table select.level { min-width: 6.5rem; }
.items-table input.qty { width: 3.4rem; min-width: 3.4rem; }
.items-table td:nth-child(5) input, .items-table td:nth-child(8) input { min-width: 5rem; }
.items-table td:last-child { white-space: nowrap; }
.items-table td:last-child .card-actions { display: inline-flex; align-items: center; gap: .15rem; }
.items-table td.col-pkg a { display: block; margin-top: .1rem; }
.items-table tr.m-dap_ung td:first-child { box-shadow: inset 3px 0 0 #10b981; }
.items-table tr.m-thieu td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.tbl select.level.m-dap_ung { color: var(--ok); font-weight: 600; }
.tbl select.level.m-thieu { color: var(--warn); font-weight: 600; }
.tbl select.level.f-lam_duoc { color: var(--ok); font-weight: 600; }
.tbl select.level.f-khong_lam_duoc { color: var(--danger); font-weight: 600; }
.suggest-row td { background: rgba(99, 102, 241, .06); border-bottom: 1px solid var(--line-soft); padding-top: .2rem; }
.chip-suggest { display: inline-flex; align-items: center; gap: .2rem; margin: .15rem .3rem .15rem 0; padding: .2rem .65rem; border-radius: 999px; border: 1px solid rgba(99, 102, 241, .4); background: rgba(255, 255, 255, .7); color: var(--primary-ink); font-size: .82rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.chip-suggest:hover { background: var(--primary-soft); }
.items-add { display: flex; gap: .5rem; align-items: flex-start; padding: .7rem; border-top: 1px dashed rgba(99, 102, 241, .4); background: rgba(255, 255, 255, .3); }
.items-add textarea { flex: 1; min-height: 2.6rem; }
.quote-box .cl-head { margin-bottom: .3rem; }
.quote-box .cl-head h3 { margin: 0; }
.quote-table tfoot tr.total td { font-size: 1rem; }
.quote-table td:first-child, .quote-table.print td:nth-child(2) { min-width: 14rem; }
.quote-table td.num, .quote-table th.num { white-space: normal; }
.quote-table .price-term { white-space: nowrap; }
.req-counts { white-space: nowrap; }

/* Bản báo giá để in */
.quote-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.quote-sheet { background: #fff; color: #111827; max-width: 1100px; margin: 0 auto; padding: 32px 36px; border-radius: 12px; box-shadow: var(--shadow); overflow-x: auto; }
.quote-table.print { font-size: .86rem; }
.quote-table.print td, .quote-table.print th { padding: .45rem .5rem; }
.quote-table.print th { white-space: normal; }
.quote-table.print .price-term { white-space: normal; }
.quote-table.print td:first-child { width: 2rem; }
.quote-head { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 2px solid #4f46e5; }
.quote-brand { font-weight: 800; color: #4f46e5; letter-spacing: .06em; text-transform: uppercase; font-size: .8rem; }
.quote-head h1 { font-size: 1.9rem; letter-spacing: .03em; margin: .1rem 0; }
.quote-head p { margin: 0; }
.quote-customer { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .25rem 1rem; margin: 0; align-content: start; font-size: .92rem; min-width: 16rem; }
.quote-customer dt { color: #64748b; }
.quote-customer dd { margin: 0; font-weight: 600; }
.quote-table.print th { background: #f1f5f9; color: #334155; }
.quote-table.print td, .quote-table.print th { border-bottom: 1px solid #e2e8f0; }
.quote-table.print tbody tr:hover td { background: transparent; }
.quote-table.print tfoot td { background: #f8fafc; }
.quote-unpriced, .quote-note { margin-top: 18px; }
.quote-unpriced h3, .quote-note h3 { font-size: .95rem; margin-bottom: .3rem; }
.quote-unpriced ul { margin: 0; padding-left: 1.2rem; }
.quote-note p { white-space: pre-line; margin: 0; }
.quote-foot { margin-top: 24px; padding-top: 10px; border-top: 1px solid #e2e8f0; }
@media print {
  html { background: #fff !important; }
  body { display: block; padding: 0; font-size: 12px; }
  .topbar, .no-print, .save-bar, .toast { display: none !important; }
  .container { padding: 0; }
  .quote-sheet { box-shadow: none; border-radius: 0; max-width: none; padding: 0; }
  .quote-table .tbl th, .quote-table .tbl td, .tbl th, .tbl td { padding: .3rem .45rem; }
  a { color: inherit; }
}

@media (max-width: 1100px) {
  .step-grid { grid-template-columns: 1fr; }
  .step-side { position: static; }
  .kt-top { grid-template-columns: 1fr; }
  .kt-section .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .spec-grid, .add-survey-grid, .screen-grid { grid-template-columns: 1fr; }
  .spec-card.d1, .spec-card.d2, .spec-card.d3 { margin-left: .6rem; }
  .step-head { flex-wrap: wrap; }
  .items-add { flex-direction: column; }
  .quote-sheet { padding: 16px; }
}

/* ===================== Điện thoại (≤ 640px): màn hình v8 — stepper, checklist gập + sheet, Kỹ thuật, thư viện, khảo sát, báo giá ===================== */
/* Desktop: nút gập checklist, nút ⋯ của mục checklist và nút chuyển bước không hiện (stepper luôn trong tầm nhìn) */
.cl-toggle, .cl-more, .step-pager { display: none; }
.sheet-opt.on.ai-co_san { background: var(--ok-soft); color: var(--ok); }
.sheet-opt.on.ai-can_lam_them { background: var(--warn-soft); color: var(--warn); }
.sheet-opt.on.ai-khong_lam_duoc { background: var(--red-soft); color: var(--danger); }
@media (max-width: 640px) {
  /* Stepper 7 bước: ô 44px (số/✓ + %), nhãn ẩn; cuộn ngang khi có thêm "Quy trình cũ" */
  .step-nav { flex-wrap: nowrap; gap: 4px; margin: 0 0 8px; overflow-x: auto; scrollbar-width: none; }
  .step-nav::-webkit-scrollbar { display: none; }
  .step-chip { flex: 1 0 44px; flex-direction: column; justify-content: center; gap: 2px; min-width: 44px; min-height: 50px; padding: 5px 2px; border-radius: 12px; }
  .step-chip .dot { width: 1.5rem; height: 1.5rem; font-size: .74rem; }
  .step-chip .step-pct { font-size: 10px; line-height: 1; }
  .step-head { flex-wrap: nowrap; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
  .step-head .sec-num { margin-top: 0; }
  .step-head h3 { font-size: 1rem; }
  .step-head p { font-size: 12.5px; }
  .step-count { margin-top: 2px; padding: .15rem .5rem; font-size: .7rem; }
  .step-panel { scroll-margin-top: 3.6rem; }
  /* Checklist (gập) trước nội dung của bước, rồi nút chuyển bước */
  .step-grid { gap: 0; }
  .step-side { order: -1; position: static; }
  .step-tools { gap: 6px; margin-bottom: 8px; }
  .step-tools > .muted, .step-tools .spacer { display: none; }
  .step-tools .btn { flex: 1 1 auto; min-height: 44px; }
  .step-tools .btn.primary { flex: 1 1 100%; }
  .quick-add { gap: 6px; margin-bottom: 8px; }
  .quick-add > .muted { flex: 1 1 100%; }
  .quick-add .btn { flex: 1 1 auto; min-height: 44px; }
  .step-form .field { margin-bottom: 12px; }
  .chip-list { gap: 6px; }
  .chip-item { min-height: 36px; padding: 2px 2px 2px 12px; font-size: .9rem; }
  .chip-item .icon { width: 36px; height: 36px; }
  .chip-add .btn { min-height: 44px; }
  .spec-list { gap: 10px; }
  .spec-card.d1 { margin-left: 8px; }
  .spec-card.d2, .spec-card.d3 { margin-left: 16px; }
  .spec-head { gap: 6px; margin-bottom: 8px; }
  .spec-grid { gap: 10px; }
  .screen-group { margin-bottom: 10px; }
  .screen-grid { gap: 10px; }
  .screen-card { padding: 12px; }
  .screen-link .btn { min-height: 44px; }
  .screen-images { gap: 6px; }
  .add-thumb { min-height: 88px; }
  .thumb figcaption input { min-height: 40px; }
  .links-table td.link-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: normal; }
  .links-table td.link-actions a { display: inline-flex; align-items: center; min-height: 44px; margin: 0; padding: 0 10px; font-size: .9rem; font-weight: 600; }
  .tbl.links-table tr.add-row::before { content: 'Thêm link'; }
  .step-pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
  .step-pager .btn, .step-pager .spacer { flex: 1 1 0; min-width: 0; min-height: 48px; }
  .step-pager .btn { white-space: normal; text-align: center; line-height: 1.2; }
  .v8-defaults { grid-template-columns: 1fr; gap: 10px; }
  .convert-box { padding: 12px; gap: 8px; }
  .convert-box .btn { width: 100%; min-height: 44px; }

  /* Checklist: đầu thẻ chạm để mở / gập (mặc định gập, % vẫn thấy), ô tick 44px, chạm tên = tick, ⋯ mở sheet (sửa / lên / xuống / xóa) */
  .checklist { padding: 10px 12px; }
  .checklist .cl-head { align-items: center; gap: 8px; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .checklist .cl-head h3 { flex: 1; min-width: 0; font-size: .95rem; }
  .cl-pct { font-size: .9rem; }
  .cl-toggle { display: inline-grid; flex: none; width: 40px; height: 40px; margin: -4px -8px -4px 0; border-radius: 10px; }
  .cl-toggle .ic { transition: transform .2s; transform: rotate(180deg); }
  .checklist.collapsed .cl-toggle .ic { transform: none; }
  .cl-bar { margin: 8px 0 6px; }
  .checklist.collapsed .cl-bar { margin-bottom: 0; }
  .checklist.collapsed .cl-list, .checklist.collapsed .cl-add, .checklist.collapsed .cl-restore { display: none; }
  .cl-item { align-items: center; gap: 4px; padding: 0; }
  .cl-check { width: 44px; height: 44px; margin: 0 0 0 -10px; }
  .cl-check input { width: 22px; height: 22px; }
  .cl-text { gap: 0; }
  .cl-title { display: flex; align-items: center; min-height: 44px; margin: 0; padding: .3rem .2rem; font-size: 15px; }
  .cl-input { min-height: 44px; }
  .cl-meta { margin-top: -4px; padding-bottom: 4px; }
  .cl-actions { display: none; }
  .cl-more { display: inline-grid; flex: none; width: 44px; height: 44px; margin-right: -8px; border-radius: 10px; }
  .cl-add { gap: 6px; margin-top: 8px; }
  .cl-add .btn { min-height: 44px; }
  .cl-restore { display: inline-flex; align-items: center; min-height: 36px; margin-top: 2px; }
  .cl-static { padding-left: 1.1rem; }

  /* Kỹ thuật: checklist (gập) rồi Go / No-go; "▶ Làm tiếp" và "■ Dừng" chia đôi một hàng, 48px */
  .kt-top { display: flex; flex-direction: column; align-items: stretch; }
  .kt-top > .card { margin-bottom: 10px; }
  .decision-actions { gap: 8px; margin-top: 8px; }
  .decision-actions .btn { flex: 1 1 40%; min-height: 48px; font-size: 15px; }
  .decision-actions .linklike { flex: 1 1 100%; min-height: 44px; }
  .kt-section { padding: 12px; }
  .kt-section h3 { font-size: .95rem; }
  .kt-section .two-col { gap: 10px; }
  .hw-row { margin: 6px 0 10px; }
  .hw-choice { gap: 6px; }
  .hw-opt { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .steps-wrap { margin: 8px 0 10px; }
  .feature-steps { padding: 8px 8px 6px; margin-bottom: 10px; }
  .feature-steps .tbl tr { padding: 8px 6px; }
  .steps-table tr.br-ai, .steps-table tr.br-thuat_toan { border-left: 3px solid #8b5cf6; }
  .steps-table tr.br-thuat_toan { border-left-color: #3b82f6; }
  .steps-table tr.br-ai td:first-child, .steps-table tr.br-thuat_toan td:first-child { box-shadow: none; }
  .tbl.steps-table td.num:first-child { display: none; }
  .steps-table td:nth-child(2), .steps-table td:nth-child(5), .steps-table td.col-algo { min-width: 0; }
  .steps-table td.col-algo select { max-width: none; }
  .steps-table td.col-algo .badge { display: inline-block; margin: 4px 0 0; }
  .steps-table select.level { width: 100%; }
  .tbl.steps-table tr.add-row::before { content: 'Thêm bước'; }
  .card.inner { padding: 10px 12px; }

  /* Thư viện giải thuật: mỗi giải thuật một thẻ; ô mô tả có viền rõ (không còn hiện khi rê chuột) */
  .tbl textarea { width: 100%; min-width: 0; }
  .algo-table textarea, .items-table textarea { min-height: 44px; font-size: 16px; border-color: var(--field-border); background: var(--field-bg); }
  .algo-table td.col-name, .algo-table td.col-desc { min-width: 0; }
  .algo-table td.col-level { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; white-space: normal; }
  .algo-table td.col-level::before { flex: 1 1 100%; }
  .algo-table td.col-level select { flex: 1; width: auto; min-width: 0; margin: 0; }
  .algo-table tr.algo-green td.col-level, .algo-table tr.algo-yellow td.col-level, .algo-table tr.algo-red td.col-level { background: transparent; }
  .algo-table td.nowrap { white-space: normal; }
  .algo-table td[data-label="Nhánh"], .algo-table td[data-label="Dùng trong"] { flex: 1 1 40%; }
  .tbl.algo-table tr.add-row::before { content: 'Thêm giải thuật'; }

  /* Khảo sát khách: form tạo, danh sách thẻ, trang khảo sát (đầu trang gọn, 2 nút), bảng yêu cầu thành thẻ, báo giá */
  .add-survey { padding: 12px; }
  .add-survey h3 { font-size: .95rem; }
  .add-survey .btn { width: 100%; min-height: 48px; }
  .surveys-table .req-counts { white-space: normal; }
  .surveys-table td[data-label="Liên hệ"], .surveys-table td[data-label="Trạng thái"], .surveys-table td[data-label="Báo giá bán đứt"] { flex: 1 1 40%; }
  .surveys-table .card-actions .btn { min-height: 44px; }
  .survey-head { grid-template-columns: minmax(0, 1fr); }
  .survey-title { gap: 6px; }
  .survey-title .title-input { margin-left: -.3rem; }
  .survey-meta { gap: 6px; }
  .survey-meta input { flex: 1 1 100%; max-width: none; }
  .survey-meta select { width: 100%; }
  .survey-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .survey-actions .btn { min-height: 44px; padding: .3rem .6rem; }
  .flow-strip { gap: 6px; margin-bottom: 10px; }
  .flow-strip li { flex: 1 1 100%; padding: 6px 10px 6px 6px; font-size: .84rem; white-space: normal; }
  .items-card { margin-bottom: 10px; }
  .items-table td.col-content, .items-table td.col-pkg { min-width: 0; }
  .tbl.items-table td:first-child { flex: 1 1 100%; padding: 2px 0 0; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--indigo-ink); }
  .tbl.items-table td:first-child::before { content: 'Yêu cầu'; display: inline; margin-right: 4px; color: inherit; }
  .tbl.items-table td.col-content::before { display: none; }
  .items-table td[data-label="Khớp"], .items-table td[data-label="Làm được?"], .items-table td[data-label="SL"] { flex: 1 1 40%; }
  .items-table select.level, .items-table td.col-pkg select { width: 100%; min-width: 0; max-width: none; }
  .items-table input.qty { width: 100%; min-width: 0; text-align: left; }
  .items-table td:nth-child(5) input, .items-table td:nth-child(8) input { min-width: 0; }
  .items-table td.col-pkg a { display: inline-flex; align-items: center; min-height: 36px; margin-top: 2px; }
  .items-table td:last-child { white-space: normal; }
  .items-table td:last-child .card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .items-table td:last-child .card-actions .btn { min-height: 44px; }
  .items-table tr.m-dap_ung td:first-child, .items-table tr.m-thieu td:first-child { box-shadow: none; }
  .items-table tr.m-dap_ung { border-left: 3px solid #10b981; }
  .items-table tr.m-thieu { border-left: 3px solid #f59e0b; }
  .suggest-row td { padding: 4px 0 6px; border-bottom: 0; background: transparent; }
  .chip-suggest { min-height: 40px; margin: 3px 6px 3px 0; padding: 4px 12px; white-space: normal; text-align: left; }
  .items-add { padding: 10px; gap: 8px; }
  .items-add .btn { min-height: 44px; }
  .quote-box .cl-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
  .quote-box .cl-head .btn { min-height: 40px; }
  .quote-table td:first-child, .quote-table.print td:nth-child(2) { min-width: 0; }
  .quote-table td.num { text-align: left; }
  .quote-table td[data-label="SL"], .quote-table td[data-label="Bán đứt"], .quote-table td[data-label="Thuê bao/tháng"], .quote-table td[data-label="Thành tiền"], .quote-table td[data-label="Thuê bao × SL"],
  .quote-table td[data-label="Đơn giá bán đứt"], .quote-table td[data-label="Thuê bao / tháng"], .quote-table td[data-label="Thành tiền bán đứt"], .quote-table td[data-label="Thuê bao / tháng × SL"] { flex: 1 1 40%; }
  .quote-table tfoot tr.total td { font-size: .95rem; }

  /* Bản báo giá: 2 nút ngang hàng, tờ báo giá sát mép, bảng thành thẻ (khi in vẫn là bảng) */
  .quote-tools { gap: 6px; margin-bottom: 10px; }
  .quote-tools .btn { flex: 1 1 40%; min-height: 44px; }
  .quote-tools > .muted { order: 3; flex: 1 1 100%; font-size: 12px; }
  .quote-sheet { padding: 14px 12px 12px; border-radius: 14px; overflow: visible; }
  .quote-head { gap: 10px; margin-bottom: 12px; padding-bottom: 10px; }
  .quote-head h1 { font-size: 1.4rem; }
  .quote-customer { width: 100%; min-width: 0; }
  .quote-table.print { font-size: .9rem; }
  .quote-table.print td { border: 0; }
  .quote-table.print tbody tr { border-bottom: 1px solid #e2e8f0; }
  .quote-table.print tfoot td { background: transparent; }
  .tbl.quote-table.print td:first-child { flex: 1 1 100%; width: auto; padding: 2px 0 0; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #64748b; }
  .tbl.quote-table.print td:first-child::before { content: 'Hạng mục'; display: inline; margin-right: 4px; color: inherit; }
  .tbl.quote-table.print td[data-label="Hạng mục"]::before { display: none; }
  .quote-unpriced, .quote-note { margin-top: 12px; }
}

/* ===================== Bảng đọc như sheet: B2 / B3 (tên | các ý), B1 / B4 / B7 (mục | nội dung) ===================== */
/* B2 / B3: mỗi tính năng / nền tảng một dòng, các ý của nó ở cột phải, đọc theo dấu chấm đầu dòng như cột Mô tả của sheet. */
.tree.layout-table { --name-col: minmax(11rem, 26%); }
.tree.layout-table > li.section { padding: .6rem .9rem .55rem; }
.tree.layout-table .thead, .ftable-head {
  display: grid; grid-template-columns: var(--name-col, minmax(11rem, 26%)) minmax(0, 1fr); column-gap: 1.25rem;
  margin: .45rem 0 0; padding: .45rem .6rem; border-radius: 10px; background: rgba(255, 255, 255, .5);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2);
}
.tree.layout-table ul.children, .tree.layout-table ul.children ul.children { padding-left: 0; }
.tree.layout-table ul.children > li { padding-left: 0; }
.tree.layout-table ul.children > li::before, .tree.layout-table ul.children > li::after { display: none; }
.tree.layout-table li.trow {
  display: grid; grid-template-columns: var(--name-col) minmax(0, 1fr); column-gap: 1.25rem; align-items: start;
  grid-template-areas: "name items" "name add" "body body"; padding: .5rem .6rem .55rem; border-top: 1px solid var(--line); border-radius: 0;
}
.tree.layout-table li.trow:first-child { border-top: 0; }
.tree.layout-table li.trow > .node-row { grid-area: name; align-items: flex-start; flex-wrap: wrap; min-height: 0; padding-top: .05rem; }
.tree.layout-table li.trow > .node-body { grid-area: body; padding-left: 0; }
.tree.layout-table li.trow > ul.children { grid-area: items; min-width: 0; }
.tree.layout-table li.trow > .add-item { grid-area: add; justify-self: start; }
.tree.layout-table li.trow:not(.closed) > .node-row > .twisty { display: none; }
.tree.layout-table li.trow.closed > ul.children { display: none; }
.tree.layout-table li.trow.closed > .add-item, .tree.layout-table li.trow.adding > .add-item { display: none; }
.tree.layout-table li.trow > .node-row .node-title-wrap { flex: 1 1 8rem; }
.tree.layout-table li.trow > .node-row .node-title { font-weight: 700; font-size: .97rem; color: var(--text); padding: .2rem .4rem; }
.tree.layout-table li.trow > .node-row > .node-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; order: 3; flex: 1 1 100%; padding: 0 .4rem .15rem; }
.tree.layout-table li.trow > .node-row > .note-preview { padding-left: .4rem; margin: 0 0 .1rem; }
/* Ý trong cột phải: chấm đầu dòng, chữ xuống dòng đầy đủ (không cắt), thao tác hiện khi trỏ / focus vào ý đó. */
.tree.layout-table li.titem > .node-row { min-height: 1.95rem; align-items: flex-start; gap: .1rem; border-radius: 8px; }
.tree.layout-table li.titem > .node-row > .twisty { width: 1.15rem; height: 1.15rem; margin: .4rem .15rem 0 .05rem; font-size: .8rem; border-radius: 6px; }
.tree.layout-table li.titem > .node-row > .twisty.none { border-color: transparent; background: transparent; }
.tree.layout-table li.titem > .node-row > .twisty.none::before { width: 6px; height: 6px; background: rgba(79, 70, 229, .55); }
.tree.layout-table li.titem.d3 > .node-row > .twisty.none::before, .tree.layout-table li.titem.d4 > .node-row > .twisty.none::before { width: 5px; height: 5px; background: transparent; border: 1.5px solid rgba(79, 70, 229, .55); }
.tree.layout-table li.titem .node-title-text { font-weight: 400; color: var(--text); line-height: 1.5; padding: .2rem .35rem; white-space: normal; }
.tree.layout-table li.titem.d3 .node-title-text, .tree.layout-table li.titem.d4 .node-title-text { color: var(--text-2); font-size: .93rem; }
.tree.layout-table li.titem > ul.children { margin: 0 0 .1rem .62rem; padding-left: .7rem; border-left: 1px solid rgba(99, 102, 241, .22); }
.tree.layout-table li.titem > .node-row > .node-meta .feat-fields { display: contents; }
.item-quick { display: inline-flex; gap: .05rem; }
.item-quick .icon, .tree.layout-table li.titem .node-actions .icon { width: 1.75rem; height: 1.75rem; }
.tree.layout-table li.titem .node-actions { align-self: center; }
/* Nhãn mức quan trọng / nhánh / mức AI: nhỏ, chỉ hiện khi đã chọn; trỏ chuột hoặc focus vào dòng thì hiện ô trống để chọn. */
.tree.layout-table .chip-sel { height: 1.3rem; padding: 0 .4rem 0 .55rem; font-size: .7rem; }
.tree.layout-table .chip-sel.importance-none, .tree.layout-table .chip-sel.branch-none, .tree.layout-table .chip-sel.ai_level-none { display: none; }
/* the pickers of a row (feature / platform) show while it is pointed at or focused; an item sets its tags from its ⋯ menu */
.tree.layout-table li.trow > .node-row:focus-within .chip-sel.importance-none, .tree.layout-table li.trow > .node-row:focus-within .chip-sel.branch-none, .tree.layout-table li.trow > .node-row:focus-within .chip-sel.ai_level-none { display: inline-flex; }
.tree.layout-table li.trow > .node-row .feat-fields { display: contents; }
@media (hover: hover) {
  .tree.layout-table li.trow > .node-row:hover .chip-sel.importance-none, .tree.layout-table li.trow > .node-row:hover .chip-sel.branch-none, .tree.layout-table li.trow > .node-row:hover .chip-sel.ai_level-none { display: inline-flex; }
  .tree.layout-table li.trow:hover > .add-item { opacity: 1; }
}
/* the line of tags under a name takes no room while there is nothing to show (no tag set, no note, row not pointed at) */
.tree.layout-table li.trow > .node-row:not(:hover):not(:focus-within) > .node-meta:not(:has(.chip-sel:not(.importance-none):not(.branch-none):not(.ai_level-none), .note-chip:not([hidden]), .note-badge:not([hidden]), .count:not(:empty))) { display: none; }
.add-item {
  display: inline-flex; align-items: center; gap: .3rem; margin: .2rem 0 0 .1rem; padding: .15rem .55rem; min-height: 1.8rem;
  border: 1px dashed rgba(99, 102, 241, .45); border-radius: 8px; background: transparent; color: var(--primary-ink);
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; opacity: .8; transition: background .15s, opacity .15s, border-color .15s;
}
.add-item:hover, .add-item:focus-visible { opacity: 1; background: var(--primary-soft); border-style: solid; }
.tree.layout-table li.add-li > .node-row { padding: .1rem 0; }
.tree.layout-table li.add-li .node-title { font-size: .92rem; }
.tree.layout-table li.feat-hide { display: none !important; }
.tree.feat-filtering li.feat-context > .node-row { opacity: .55; }

/* B1 / B4 / B7: bảng hai cột — tên mục bên trái, nội dung (danh sách ý sửa từng dòng) bên phải. */
.ftable { padding: .5rem .9rem .6rem; }
.ftable-head { margin: 0 0 .1rem; }
.frow { display: grid; grid-template-columns: minmax(11rem, 26%) minmax(0, 1fr); column-gap: 1.25rem; padding: .7rem .6rem; border-top: 1px solid var(--line); }
.ftable-head + .frow { border-top: 0; }
.frow-label { display: flex; flex-direction: column; gap: .2rem; min-width: 0; padding-top: .2rem; }
.frow-name { font-weight: 700; font-size: .95rem; color: var(--text); line-height: 1.35; margin: 0; }
.frow-hint { line-height: 1.4; }
.frow-value { min-width: 0; }
.ftable .links-card { margin: 0; padding: 0; background: transparent; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }

/* Danh sách ý của một ô (public/bullets.js): mỗi dòng một ý, lồng theo cấp như sheet; bấm chữ để sửa ngay tại chỗ. */
.bl { list-style: none; margin: 0; padding: 0; }
.bl .bl { margin: 0 0 .1rem .62rem; padding-left: .7rem; border-left: 1px solid rgba(99, 102, 241, .22); }
.bl-row { display: flex; align-items: flex-start; gap: .15rem; min-height: 1.95rem; border-radius: 8px; transition: background .15s; }
.bl-row:focus-within, .bl-item.editing > .bl-row { background: rgba(255, 255, 255, .55); }
@media (hover: hover) { .bl-row:hover { background: rgba(255, 255, 255, .55); } }
.bl-dot { flex: none; width: 6px; height: 6px; margin: .78rem .45rem 0 .3rem; border-radius: 50%; background: rgba(79, 70, 229, .55); }
.bl-item.d1 > .bl-row > .bl-dot { width: 5px; height: 5px; background: transparent; border: 1.5px solid rgba(79, 70, 229, .55); }
.bl-item.d2 > .bl-row > .bl-dot, .bl-item.d3 > .bl-row > .bl-dot { width: 7px; height: 1.5px; border-radius: 1px; margin-top: .86rem; }
.bl-text {
  flex: 1; min-width: 0; padding: .2rem .35rem; border: 0; border-radius: 6px; background: transparent; color: var(--text);
  font: inherit; font-size: .93rem; line-height: 1.5; text-align: left; white-space: normal; overflow-wrap: anywhere; cursor: text;
}
.bl-item.d1 > .bl-row > .bl-text, .bl-item.d2 > .bl-row > .bl-text, .bl-item.d3 > .bl-row > .bl-text { color: var(--text-2); }
.bl-item.has-kids > .bl-row > .bl-text, .bl-head > .bl-row > .bl-text { font-weight: 600; }
@media (hover: hover) { .bl-text:hover { background: var(--primary-soft); } }
.bl-input { flex: 1; min-width: 0; padding: .2rem .4rem; font-size: .93rem; line-height: 1.5; border: 1px solid #93c5fd; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); border-radius: 6px; }
.bl-actions { display: inline-flex; flex: none; gap: .05rem; align-self: center; }
.bl-actions .icon { width: 1.75rem; height: 1.75rem; }
.bl-more { display: none; }
@media (hover: hover) {
  .bl-actions { opacity: 0; transition: opacity .12s; }
  .bl-row:hover > .bl-actions, .bl-row:focus-within > .bl-actions { opacity: 1; }
}
.bl-empty { margin: .25rem .3rem .35rem; }
.bl-add { display: flex; gap: .4rem; align-items: center; margin: .35rem 0 0; }
.bl-add input { flex: 1; min-width: 0; padding: .3rem .6rem; font-size: .9rem; border-style: dashed; border-color: rgba(99, 102, 241, .35); background: rgba(255, 255, 255, .35); }
.bl-add input:focus { border-style: solid; }
.bl-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: .15rem; }
.bl-foot .add-item { margin: 0; }
.list-editor.raw .bl-add-btn { display: none; }
.bl-raw-toggle { margin-left: auto; }
.bl-bulk { margin-top: .4rem; }
.bl-bulk > summary { cursor: pointer; color: var(--primary-ink); font-weight: 600; }
.bl-bulk-ta { width: 100%; margin-top: .4rem; }
.bl-bulk-act { margin-top: .3rem; }
.bl-raw-toggle { color: var(--primary-ink); font-weight: 600; }
.bl-raw-toggle:hover { text-decoration: underline; }
.list-editor.raw > .bl, .list-editor.raw > .bl-empty, .list-editor.raw > .bl-add { display: none !important; }
.bl-raw { margin-top: .2rem; font-size: .9rem; line-height: 1.5; font-family: var(--font); }

/* B4: Quy trình rồi Use case (mỗi khối hết bề ngang cột phải, câu dài không bị bẻ vụn); tính năng con gập dưới tính năng cha */
.spec-table .frow, .spec-table .ftable-head { grid-template-columns: minmax(9rem, 19%) minmax(0, 1fr); }
.spec-cells { display: grid; grid-template-columns: minmax(0, 1fr); gap: .55rem; }
.spec-block + .spec-block { padding-top: .45rem; border-top: 1px dashed var(--line); }
.spec-block-title { margin: 0 0 .2rem; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); }
.spec-row .frow-label .spec-tags { display: flex; flex-wrap: wrap; gap: .25rem; }
.spec-row .frow-label .spec-tags:empty { display: none; }
.spec-subs { margin-top: .55rem; border-radius: 10px; background: rgba(255, 255, 255, .35); padding: .3rem .6rem; }
.spec-subs > summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--text-2); padding: .2rem 0; }
.spec-sub { padding: .5rem 0 .4rem; border-top: 1px solid var(--line); }
.spec-sub.d2 { margin-left: .8rem; }
.spec-sub.d3 { margin-left: 1.6rem; }
.spec-sub-name { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.steps-more { margin-top: .3rem; }
.steps-more > summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-2); padding: .4rem .2rem; }

/* Có chuột: thao tác của một ý nổi ở mép phải khi trỏ / focus, không chiếm chỗ của chữ (chữ dùng hết bề ngang cột). */
@media (hover: hover) and (min-width: 641px) {
  .tree.layout-table li.titem > .node-row, .bl-row { position: relative; }
  .tree.layout-table li.titem > .node-row > .node-actions, .bl-actions {
    position: absolute; right: .15rem; top: .12rem; z-index: 2; padding: 1px 2px; border-radius: 9px; margin: 0;
    background: rgba(255, 255, 255, .95); box-shadow: var(--shadow-sm);
  }
  /* a row's name uses the whole name column too: its buttons float at the top right of the cell */
  .tree.layout-table li.trow > .node-row { position: relative; }
  .tree.layout-table li.trow > .node-row > .node-actions {
    position: absolute; right: 0; top: 0; z-index: 2; padding: 1px 2px; border-radius: 9px; margin: 0;
    background: rgba(255, 255, 255, .95); box-shadow: var(--shadow-sm);
  }
}
/* a folded row is one line: name and how many items it holds */
.tree.layout-table li.trow.closed > .node-row { align-items: center; }
.tree.layout-table li.trow.closed > .node-row > .node-meta { flex: 0 1 auto; order: 2; padding: 0; }
.tree.layout-table li.trow.closed > .node-row .node-title-wrap { flex: 0 1 auto; }
.tree.layout-table li:not(.section) .btn-note .lbl, .tree.layout-table li:not(.section) .btn-note .tg { display: none; }
.tree.layout-table li:not(.section) .btn-note { width: 1.75rem; height: 1.75rem; padding: 0; justify-content: center; }
.tree.layout-table li.trow > .node-row .node-actions .icon { width: 1.75rem; height: 1.75rem; }
/* while an item is renamed its input takes the whole line */
.tree.layout-table .node-row:has(> .node-title-wrap.editing) > .node-actions, .tree.layout-table .node-row:has(> .node-title-wrap.editing) > .node-meta { display: none; }
.tree.layout-table li.section.closed > .thead { display: none; }
/* tag pickers inside the ⋯ menu of a table row / item (desktop) */
.node-menu .menu-field { padding: .15rem .35rem .3rem; }
.node-menu .menu-field .sheet-field-label { margin: .2rem .1rem .25rem; font-size: 10.5px; }
.node-menu .menu-field .sheet-opts { gap: 4px; }
.node-menu .menu-field .sheet-opt { min-height: 28px; padding: 0 .55rem; font-size: .78rem; border-radius: 8px; }
.node-menu .menu-field .sheet-opt:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
@media (hover: none) {
  .add-item { opacity: 1; }
}
/* Điện thoại: tên ở trên, các ý ở dưới; mỗi ý ≥ 44px; ↑ ↓ ✕ nằm trong ⋯ (bottom sheet) */
@media (max-width: 640px) {
  .tree.layout-table > li.section { padding: 6px 6px 8px; }
  .tree.layout-table .thead, .ftable-head { display: none; }
  .tree.layout-table li.trow { display: block; padding: 8px 2px 10px; }
  .tree.layout-table li.trow > .node-row > .node-meta { margin: -2px 0 2px 4px; padding: 0; }
  .tree.layout-table li.trow > ul.children { margin: 2px 0 0 8px; padding-left: 8px; border-left: 2px solid rgba(99, 102, 241, .22); }
  .tree.layout-table li.trow .node-title-text, .tree.layout-table li.titem .node-title-text { white-space: normal; overflow: visible; text-overflow: clip; }
  .tree.layout-table li.titem > .node-row { min-height: 44px; flex-wrap: nowrap; align-items: center; }
  .tree.layout-table li.titem > .node-row > .twisty { width: 32px; height: 32px; margin: 6px 0 0; align-self: flex-start; }
  .tree.layout-table li.titem > .node-row > .twisty.none { width: 14px; }
  .tree.layout-table li.titem > .node-row .node-title-wrap { flex: 1 1 auto; }
  .tree.layout-table li.titem > .node-row > .node-meta { display: none; }
  .tree.layout-table li.titem > .node-row > .node-actions { align-self: center; }
  .tree.layout-table .item-quick { display: none; }
  .tree.layout-table li.titem .node-title-text { font-size: 15px; }
  .add-item { min-height: 44px; margin: 6px 0 0 8px; padding: 0 14px; font-size: .88rem; opacity: 1; }
  .ftable { padding: 4px 10px 8px; }
  .frow { display: block; padding: 10px 2px 12px; }
  .frow-label { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 4px; padding: 0; }
  .frow-name { font-size: 1rem; }
  .bl-row { min-height: 44px; align-items: center; }
  /* the bullet lines up with the first line of a long item (and with the middle of a one-line row) */
  .bl-dot { align-self: flex-start; margin-top: 19px; }
  .bl-item.d1 > .bl-row > .bl-dot { margin-top: 19px; }
  .bl-item.d2 > .bl-row > .bl-dot, .bl-item.d3 > .bl-row > .bl-dot { margin-top: 21px; }
  .bl-text { font-size: 15px; padding: 6px 4px; }
  .bl-actions { display: none; }
  .bl-more { display: inline-grid; width: 44px; height: 44px; }
  .bl-add input { font-size: 16px; }
  .bl-add .btn { min-height: 44px; }
  .bl-foot .linklike { min-height: 44px; padding: 0 4px; }
  .spec-cells { gap: 10px; }
  .spec-subs { padding: 4px 8px; }
  .spec-subs > summary { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
  .spec-sub.d2, .spec-sub.d3 { margin-left: 6px; }
  .steps-more > summary { min-height: 44px; display: flex; align-items: center; }
}

/* ===================== Đối thủ (v9): hồ sơ đối thủ — hub, đầu trang, ma trận sửa tại chỗ, sản phẩm, giải pháp, so sánh, khoảng trống ===================== */
.dt-section { margin: 18px 0 10px; font-size: 1.05rem; }
.dt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 8px; }
.dt-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); transition: transform .2s, box-shadow .2s; }
.dt-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 14px 36px rgba(31, 38, 135, .14); }
.dt-card h3 { margin: 0; font-size: 1.15rem; }
.dt-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dt-card-sub { margin: 0; }
.dt-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.dt-stat b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.dt-status { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-open { align-self: flex-start; margin-top: auto; }
.dt-profile-link { display: inline-block; margin-top: 2px; }
.dt-head { display: flex; flex-direction: column; gap: 8px; }
.dt-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.dt-title h1 { margin: 0; }
.dt-site { font-weight: 600; }
.dt-product { margin: 0; color: var(--text-2); }
.dt-intro { margin: 0; max-width: 960px; }
.kpis.dt-kpis { margin: 8px 0 0; }
/* Nhãn màu: trạng thái ma trận, nhóm, ai làm, kết quả so sánh, độ tin cậy, đã sửa */
.badge.mx-co_san, .badge.vd-co, .badge.conf-ok { background: var(--ok-soft); color: var(--ok); }
.badge.mx-can_lam_them, .badge.vd-mot_phan, .badge.conf-warn, .badge.warn-note { background: var(--warn-soft); color: var(--warn); }
.badge.mx-chua_co, .badge.vd-khong, .badge.conf-danger { background: var(--red-soft); color: var(--danger); }
.badge.vd-khong_ro, .badge.conf-gray, .badge.mk-khong_ro { background: var(--gray-soft); color: var(--muted); }
.badge.grp-thiet_bi { background: var(--cyan-soft); color: var(--cyan); }
.badge.grp-phan_mem { background: var(--violet-soft); color: var(--violet); }
.badge.mk-tu_lam { background: var(--ok-soft); color: var(--ok); }
.badge.mk-hang_khac { background: var(--info-soft); color: var(--info); }
.badge.edited { background: var(--primary-soft); color: var(--indigo-ink); align-self: flex-start; cursor: help; }
/* Tóm tắt: 3 ô trạng thái (bấm để lọc) + chip giai đoạn */
.dt-summary-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 10px; }
.dt-summary-head h3, .dt-summary-head p { margin: 0; }
.dt-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.dt-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; border: 2px solid transparent; border-radius: 14px;
  cursor: pointer; text-align: left; font: inherit; transition: box-shadow .18s, transform .18s, border-color .18s;
}
.dt-tile-n { font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dt-tile-l { font-size: 12.5px; font-weight: 600; }
.dt-tile.mx-co_san { background: var(--ok-soft); color: var(--ok); }
.dt-tile.mx-can_lam_them { background: var(--warn-soft); color: var(--warn); }
.dt-tile.mx-chua_co { background: var(--red-soft); color: var(--danger); }
.dt-tile:hover { box-shadow: var(--shadow-sm); }
.dt-tile[aria-pressed="true"] { border-color: currentColor; box-shadow: var(--shadow-sm); }
.dt-phases { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-count {
  display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 3px 11px; border-radius: 999px; font: inherit; font-size: 12.5px; color: var(--muted);
  background: rgba(255, 255, 255, .65); border: 1px solid rgba(255, 255, 255, .9); cursor: default; transition: background .18s, color .18s;
}
.chip-count b { color: var(--text); font-variant-numeric: tabular-nums; }
button.chip-count { cursor: pointer; }
button.chip-count:hover { background: rgba(255, 255, 255, .95); color: var(--text); }
.chip-count.on { background: var(--primary-soft); color: var(--indigo-ink); border-color: transparent; }
.chip-count.on b { color: var(--indigo-ink); }
.dt-filters .dt-count { margin-left: auto; white-space: nowrap; }
/* Ô sản phẩm: ảnh thu nhỏ (khung cố định, lazy) + tên + hãng · giá */
.dt-prod { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.dt-prod-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dt-name { font-weight: 600; overflow-wrap: anywhere; }
.dt-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.dt-thumb { margin: 0; flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dt-thumb-open { display: block; width: 56px; height: 56px; padding: 0; border: 1px solid rgba(255, 255, 255, .92); border-radius: 10px; background: rgba(255, 255, 255, .78); overflow: hidden; cursor: zoom-in; }
.dt-thumb-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dt-thumb.xs .dt-thumb-open { width: 36px; height: 36px; border-radius: 8px; }
.dt-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dt-thumb figcaption { font-size: 10.5px; line-height: 1.2; }
.dt-thumb-open.none { background: var(--gray-soft); border-color: transparent; cursor: default; }
/* Ma trận thay thế: ô sửa tại chỗ (textarea tự cao theo nội dung), trạng thái tô màu, viền trái theo trạng thái */
.matrix-table { table-layout: fixed; }
.matrix-table th:nth-child(1) { width: 21%; }
.matrix-table th:nth-child(2) { width: 18%; }
.matrix-table th:nth-child(3) { width: 15%; }
.matrix-table th:nth-child(4) { width: 16%; }
.matrix-table th:nth-child(5) { width: 8%; }
.matrix-table th:nth-child(6) { width: 11%; }
.matrix-table th:nth-child(7) { width: 11%; }
.matrix-table th, .products-table th, .compare-table th { white-space: normal; }
.matrix-table td, .products-table td, .compare-table td { vertical-align: top; overflow-wrap: anywhere; }
.tbl textarea {
  width: 100%; min-width: 7rem; padding: .3rem .5rem; font: inherit; font-size: .88rem; line-height: 1.4; border: 1px solid transparent; border-radius: 8px; background: transparent;
  resize: vertical; min-height: 2.6rem; max-height: 12rem; field-sizing: content; box-shadow: none; transition: box-shadow .18s, border-color .18s, background .18s;
}
.tbl textarea:hover { border-color: rgba(255, 255, 255, .95); background: rgba(255, 255, 255, .7); }
.tbl textarea:focus { border-color: #93c5fd; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); outline: none; }
.matrix-table select.level { width: 100%; min-width: 0; padding-left: .4rem; font-size: .84rem; font-weight: 600; }
.matrix-table select.level.mx-co_san { background-color: var(--ok-soft); color: var(--ok); }
.matrix-table select.level.mx-can_lam_them { background-color: var(--warn-soft); color: var(--warn); }
.matrix-table select.level.mx-chua_co { background-color: var(--red-soft); color: var(--danger); }
.matrix-table select.level.pr-cao { color: var(--ok); }
.matrix-table select.level.pr-thap { color: var(--muted); }
.matrix-table select.level.ph-khong_lam { color: var(--muted); }
.matrix-table tr.st-co_san td:first-child { box-shadow: inset 3px 0 0 #10b981; }
.matrix-table tr.st-can_lam_them td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.matrix-table tr.st-chua_co td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
.matrix-table tr.edited td { background: rgba(99, 102, 241, .05); }
.matrix-table .dt-sub { margin-top: 4px; line-height: 1.35; }
.matrix-table .dt-link-row { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.matrix-table input.dt-url { font-size: .8rem; min-width: 5rem; }
/* Sản phẩm: 8 cột vừa màn hình (cột cố định, chữ xuống dòng thay vì cuộn ngang), dòng nhóm, mô tả gập */
.products-table { table-layout: fixed; }
.products-table th:nth-child(1) { width: 20%; }
.products-table th:nth-child(2) { width: 10%; }
.products-table th:nth-child(3) { width: 13%; }
.products-table th:nth-child(4) { width: 12%; }
.products-table th:nth-child(5) { width: 15%; }
.products-table th:nth-child(6) { width: 8%; }
.products-table th:nth-child(7) { width: 12%; }
.products-table th:nth-child(8) { width: 10%; }
.products-table td { overflow-wrap: anywhere; }
.products-table tr.grp td { background: rgba(99, 102, 241, .08); font-weight: 700; color: var(--indigo-ink); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.products-table td.col-price { white-space: normal; font-variant-numeric: tabular-nums; }
.dt-desc summary { cursor: pointer; color: var(--muted-2); font-size: .88rem; }
.dt-desc[open] summary { margin-bottom: 4px; }
.dt-desc p { margin: 0; font-size: .88rem; line-height: 1.45; }
/* Giải pháp: thẻ, hai nhóm Thiết bị / Phần mềm, mỗi sản phẩm một dòng */
.dt-sol { padding: 14px 18px; }
.dt-sol-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.dt-sol-head h3 { margin: 0; font-size: 1rem; }
.dt-sol-sum { margin: 6px 0 0; }
.dt-modules { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip-mod { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .7); border: 1px solid rgba(255, 255, 255, .9); color: var(--muted); font-family: var(--mono); }
.dt-sol-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-top: 10px; }
.dt-sol-group h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.dt-sol-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dt-sol-item { display: flex; align-items: center; gap: 8px; font-size: .9rem; min-height: 36px; }
.dt-sol-text { min-width: 0; }
/* So sánh với gói */
.compare-table th:nth-child(1) { width: 14%; }
.compare-table th:nth-child(3) { width: 11%; }
.compare-table tr.vd-co td:first-child { box-shadow: inset 3px 0 0 #10b981; }
.compare-table tr.vd-mot_phan td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }
.compare-table tr.vd-khong td:first-child { box-shadow: inset 3px 0 0 #ef4444; }
/* Khoảng trống */
.dt-gaps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dt-gap h3 { margin-bottom: 8px; }
.dt-gap ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 6px; }
.dt-gap-ho_co { border-left: 4px solid #f59e0b; }
.dt-gap-minh_co { border-left: 4px solid #10b981; }
/* Lịch sử sửa ma trận */
.dt-hist-sec h3 { margin: 18px 0 4px; }
.dt-hist-sec > p { margin: 0 0 8px; }
/* Sản phẩm: tính năng chính dưới tên (gập được) */
.dt-prod-links { display: flex; flex-wrap: wrap; gap: 0 4px; }
.dt-feats { margin-top: 4px; font-size: .84rem; }
.dt-feats summary { cursor: pointer; color: var(--indigo-ink); font-weight: 600; font-size: .8rem; }
.dt-feat-list { margin: 3px 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.dt-feat-list li { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.dt-feat-more { display: inline-block; margin-top: 2px; }
/* Cây thư mục (v10) */
.dt-tree-card { padding: 10px 16px; }
ul.dt-tree { list-style: none; margin: 0; padding: 0; }
ul.dt-tree ul.dt-tree { margin-left: 14px; padding-left: 12px; border-left: 1px solid var(--tree-line); }
.dt-tn { margin: 0; }
.dt-tn > details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 3px 6px; border-radius: 8px; }
.dt-tn > details > summary::-webkit-details-marker { display: none; }
.dt-tn > details > summary::before { content: ''; flex: none; width: 10px; height: 10px; border-right: 2px solid var(--muted-2); border-bottom: 2px solid var(--muted-2); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
.dt-tn > details[open] > summary::before { transform: rotate(45deg); margin-top: -3px; }
.dt-tn > details > summary:hover { background: rgba(255, 255, 255, .6); }
.dt-tn.leaf { display: flex; align-items: center; min-height: 30px; padding: 2px 6px 2px 26px; border-radius: 8px; }
.dt-tn.leaf:hover { background: rgba(255, 255, 255, .5); }
.dt-tn-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.dt-tn-title { font-weight: 600; }
.dt-tn.leaf .dt-tn-title { font-weight: 500; }
.dt-tn-title.prod { color: var(--primary-ink); }
.dt-tn-count { font-size: 11px; font-weight: 700; background: var(--primary-soft); color: var(--indigo-ink); border-radius: 999px; padding: 1px 7px; }
.dt-tn-n { white-space: nowrap; }
.dt-tn-note { font-style: italic; }
/* Chi tiết sản phẩm (v10) */
.dt-detail-head .dt-title h1 { font-size: 1.35rem; }
.dt-detail-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.dt-detail-short { margin: 0; color: var(--text-2); max-width: 960px; }
.dt-detail-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.dt-detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 16px; align-items: start; }
.dt-detail-side { display: flex; flex-direction: column; gap: 16px; }
.dt-detail-side .card { margin-bottom: 0; }
.dt-detail-sec h3 { margin-bottom: 10px; }
.dt-gallery { display: flex; flex-direction: column; gap: 10px; }
.dt-gal-main { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 1px solid rgba(255, 255, 255, .92); border-radius: 14px; background: rgba(255, 255, 255, .8); overflow: hidden; cursor: zoom-in; }
.dt-gal-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dt-gal-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.dt-gal-thumb { width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 10px; background: rgba(255, 255, 255, .8); overflow: hidden; cursor: pointer; }
.dt-gal-thumb.on { border-color: var(--primary); }
.dt-gal-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dt-gal-empty { display: grid; place-items: center; min-height: 160px; border-radius: 14px; background: var(--gray-soft); }
.dt-kv-list { display: flex; flex-direction: column; gap: 8px; font-size: .92rem; margin-bottom: 8px; }
.dt-kv-list .tile-label { display: block; margin-bottom: 2px; }
.dt-links { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 4px; }
.dt-features .dt-fsec { margin-bottom: 12px; }
.dt-features h4 { margin: 0 0 4px; font-size: .95rem; color: var(--indigo-ink); }
.dt-features .lv2 h4 { font-size: .88rem; color: var(--text-2); margin-left: 8px; }
.dt-features ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 3px; }
.dt-features p { margin: 4px 0; color: var(--text-2); }
.dt-spec { margin-bottom: 14px; overflow-x: auto; }
.dt-spec h4 { margin: 0 0 6px; }
.spec-table td.col-key { font-weight: 600; width: 30%; }
.spec-table td { vertical-align: top; overflow-wrap: anywhere; }
.dt-desc-full summary { cursor: pointer; font-weight: 600; }
.dt-desc-full p { margin: 8px 0 0; color: var(--text-2); line-height: 1.55; }
/* v13: hồ sơ nghiên cứu từ web / Facebook — các thẻ dưới đầu trang (chỉ thẻ có nội dung), bảng khách hàng kèm link nguồn, lưới ảnh giao diện */
.dt-profile-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; align-items: start; }
.dt-profile-cards .card { margin-bottom: 0; min-width: 0; }
.dt-pcard h3 { margin: 0 0 10px; }
.dt-pcard.dt-customers, .dt-pcard.dt-ui, .dt-pcard.dt-sources { grid-column: 1 / -1; }
.dt-pcard-sub { margin: -4px 0 10px; }
.dt-pre { margin: 0; white-space: pre-line; line-height: 1.5; overflow-wrap: anywhere; }
.dt-plist { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.dt-nf { font-style: italic; }
.dt-kv-v { overflow-wrap: anywhere; line-height: 1.45; }
.dt-summary { margin: 0; max-width: 960px; color: var(--text-2); }
.dt-ctable { overflow-x: auto; }
.customers-table td { vertical-align: top; overflow-wrap: anywhere; }
.customers-table th.col-idx, .customers-table td.col-idx { width: 2.5rem; color: var(--muted); }
.customers-table td.col-src { white-space: normal; }
.dt-cname { font-weight: 600; }
.dt-ui-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.dt-ui-item { margin: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dt-ui-open { display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 1px solid rgba(255, 255, 255, .92); border-radius: 12px; background: rgba(255, 255, 255, .8); overflow: hidden; cursor: zoom-in; }
.dt-ui-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.dt-ui-open img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dt-ui-item figcaption { font-size: 12px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .dt-card, .dt-tile, .chip-count { transition: none; } .dt-card:hover { transform: none; } }

/* ===================== v11: ô sửa được (một class chung + token), ẩn bước / mục trống, vai trò ===================== */
:root {
  --ed-bg: rgba(255, 255, 255, .55); --ed-border: rgba(99, 102, 241, .32); --ed-hover-bg: rgba(255, 255, 255, .96); --ed-hover-border: rgba(99, 102, 241, .6);
  --ed-ring: rgba(37, 99, 235, .22);
  --i-pencil: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/><path d='m15 5 4 4'/></svg>");
}
/* Ô nhập sửa tại chỗ: viền nhẹ + nền mờ + bút chì bên phải khi nghỉ; sáng lên khi rê; vòng focus rõ; select có chevron. */
input.ed, textarea.ed {
  background-color: var(--ed-bg); background-image: var(--i-pencil); background-repeat: no-repeat; background-position: right .45rem center; background-size: 12px 12px;
  border: 1px solid var(--ed-border); border-radius: 8px; padding-right: 1.6rem; cursor: text; box-shadow: none; transition: border-color .18s, background-color .18s, box-shadow .18s;
}
textarea.ed { background-position: right .45rem top .55rem; }
select.ed {
  background-color: var(--ed-bg); background-image: var(--chev); background-repeat: no-repeat; background-position: right .55rem center; border: 1px solid var(--ed-border); border-radius: 8px;
  padding-right: 1.7rem; cursor: pointer; box-shadow: none; transition: border-color .18s, background-color .18s, box-shadow .18s;
}
input.ed:hover, textarea.ed:hover, select.ed:hover { background-color: var(--ed-hover-bg); border-color: var(--ed-hover-border); }
input.ed:focus, textarea.ed:focus, select.ed:focus { outline: none; background-color: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ed-ring); }
input.ed:focus, textarea.ed:focus { background-image: none; padding-right: .5rem; }
input.title-input.ed { background-size: 14px 14px; padding-right: 1.8rem; }
/* Chữ bấm để sửa (ý, tên nhánh, mục checklist): con trỏ text, bút chì mờ, rõ khi rê. */
.ed-text { cursor: text; border-radius: 6px; }
.ed-text::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 5px; vertical-align: -1px; background: var(--i-pencil) center / contain no-repeat; opacity: .45; }
@media (hover: hover) { .ed-text:hover { background: rgba(99, 102, 241, .1); } .ed-text:hover::after { opacity: 1; } }
.ed-text:focus-visible::after { opacity: 1; }
/* Bước / giai đoạn / mục chưa có nội dung: ẩn cho tới khi bật "Hiện … trống" (nút đang mở và cây đang sửa cấu trúc vẫn hiện). */
html:not(.show-empty) .is-empty:not(.on) { display: none !important; }
html:not(.show-empty) .tree.editing > li.is-empty { display: list-item !important; }
.step-chip.next:not(.on) { border-style: dashed; color: var(--muted); }
.empty-toggle { margin-left: auto; white-space: nowrap; }
.sec-nav .empty-toggle { align-self: center; }
.std .empty-toggle { margin: 0; padding: 0; min-height: 0; font: inherit; color: var(--primary-ink); white-space: normal; }
.std .empty-toggle[aria-pressed="true"] { color: var(--muted); }
.ftable-head .empty-toggle { grid-column: 2; justify-self: end; }
.ftable-head:has(.empty-toggle) { align-items: center; }
.admin-only h3 { margin-bottom: 6px; }
/* Vai trò khách: không thấy mục Hệ thống (Thành viên, Đồng bộ Sheet); Lịch sử vẫn còn. */
html.role-guest [data-nav=members], html.role-guest [data-nav=sync], html.role-guest .nav-sep { display: none !important; }
.badge.role-admin { background: var(--primary-soft); color: var(--indigo-ink); }
.badge.role-guest { background: var(--gray-soft); color: var(--muted); }
.users-table select.level.role-guest { color: var(--muted); }

/* Điện thoại (≤ 640px): thẻ xếp chồng, ô nhập đủ 44px, không tràn ngang */
@media (max-width: 640px) {
  input.ed, textarea.ed, select.ed { border-color: var(--ed-border); background-color: var(--ed-bg); }
  .ed-text::after { opacity: .6; }
  .sec-nav .empty-toggle { flex: 1 1 100%; margin-left: 0; min-height: 40px; }
  .ftable-head .empty-toggle { grid-column: 1 / -1; justify-self: stretch; min-height: 40px; }
  .std .empty-toggle { min-height: 0; }
  .dt-cards { grid-template-columns: 1fr; gap: 10px; }
  .dt-card { padding: 12px; }
  .dt-section { margin: 12px 0 8px; }
  .dt-title h1 { font-size: 1.2rem; }
  .kpis.dt-kpis { grid-template-columns: 1fr 1fr; }
  .dt-kpis .kpi .t { white-space: normal; }
  .products-table, .matrix-table { table-layout: auto; }
  .dt-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .dt-tile { padding: 8px; min-height: 44px; gap: 0; }
  .dt-tile-n { font-size: 18px; }
  .dt-tile-l { font-size: 10.5px; }
  .dt-filters .dt-count { margin-left: 0; flex: 1 1 100%; white-space: normal; }
  .dt-filters select { flex: 1 1 45%; }
  .dt-thumb-open { width: 48px; height: 48px; }
  .matrix-table td, .products-table td, .compare-table td, .projects-table td { min-width: 0; }
  .tbl.matrix-table td.col-prod::before, .tbl.products-table td.col-prod::before { display: none; }
  .matrix-table td[data-label="Ưu tiên"], .matrix-table td[data-label="Giai đoạn"] { flex: 1 1 40%; }
  .tbl textarea { min-height: 44px; font-size: 16px; border-color: var(--field-border); background: var(--field-bg); }
  .matrix-table select.level { font-size: 16px; }
  .matrix-table .dt-link-row { flex-wrap: wrap; }
  .matrix-table input.dt-url { font-size: 14px; }
  .tbl.products-table tr.grp { padding: 6px 12px; background: rgba(99, 102, 241, .08); }
  .tbl.products-table tr.grp td { font-size: .8rem; }
  .products-table td.col-price { flex: 1 1 40%; }
  .compare-table td.col-group, .compare-table td.col-verdict { flex: 1 1 40%; }
  .dt-profile-cards { grid-template-columns: 1fr; gap: 10px; }
  .dt-pcard { padding: 12px; }
  .dt-ui-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .customers-table td.col-idx { display: none; }
  .dt-sol { padding: 12px; }
  .dt-sol-groups { grid-template-columns: 1fr; gap: 8px; }
  .dt-sol-item { min-height: 44px; }
  .dt-gaps { grid-template-columns: 1fr; gap: 10px; }
  .dt-hist-sec h3 { margin-top: 12px; }
  /* v10: cây thư mục, chi tiết sản phẩm, tính năng chính */
  .dt-feats summary { min-height: 32px; display: flex; align-items: center; }
  .dt-tree-card { padding: 6px 8px; }
  ul.dt-tree ul.dt-tree { margin-left: 6px; padding-left: 8px; }
  .dt-tn > details > summary { min-height: 44px; align-items: flex-start; padding-top: 10px; }
  .dt-tn > details > summary::before { margin-top: 6px; }
  .dt-tn > details > summary .dt-tn-n { margin-left: auto; padding-top: 2px; }
  .dt-tn.leaf { min-height: 40px; padding-left: 18px; }
  .dt-tn-line { font-size: .92rem; }
  .dt-detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .dt-detail-side { gap: 10px; }
  .dt-detail-head .dt-title h1 { font-size: 1.15rem; }
  .dt-detail-links .btn { flex: 1 1 100%; }
  .dt-gal-thumb { width: 56px; height: 56px; }
  .dt-spec { overflow: visible; }
  .tbl.spec-table td.col-key { width: auto; }
  .tbl.spec-table td:first-child::before { display: none; }
}

/* ===================== v12: Timeline Chấm công (tab Timeline), Nhắc việc, badge menu ===================== */
/* v22: 3 trạng thái — Hoàn thành xanh, Đang làm vàng hổ phách, trống xám (chip / thẻ / ô chọn nhạt, thanh gantt đậm); trễ hạn đỏ. */
:root { --tl-done: #b6d7a8; --tl-doing: #ffe599; --tl-none: #e5e7eb; --tl-bar-done: #16a34a; --tl-bar-doing: #f59e0b; --tl-bar-none: #9ca3af; }
.badge.tl-st, .tl-tile, select.tl-st { border: 1px solid rgba(15, 23, 42, .12); }
.badge.tl-st-done, .tl-tile.tl-st-done, select.tl-st-done { background-color: var(--tl-done); color: #1f4d2b; }
.badge.tl-st-doing, .tl-tile.tl-st-doing, select.tl-st-doing { background-color: var(--tl-doing); color: #6b4e00; }
.badge.tl-st-none, .tl-tile.tl-st-none, select.tl-st-none { background-color: var(--tl-none); color: #475569; border-style: dashed; }
.badge.tl-late { background: repeating-linear-gradient(45deg, #dc2626 0 4px, #f87171 4px 8px); color: #fff; }
.tl-drag-hint { flex: 1 1 100%; }
.tl-head .dt-summary-head { margin-bottom: 8px; }
.tl-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.tl-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; border-radius: 12px; cursor: pointer; text-align: left; font: inherit;
  transition: box-shadow .18s, border-color .18s;
}
.tl-tile:hover { box-shadow: var(--shadow-sm); }
.tl-tile[aria-pressed="true"] { border-color: currentColor; box-shadow: 0 0 0 2px rgba(37, 99, 235, .25); }
.tl-tile-n { font-size: 22px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tl-tile-l { font-size: 12px; font-weight: 600; }
.tl-due-line { margin: 0 0 6px; }
.tl-due-line .tl-overdue { color: var(--danger); }
.tl-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Bảng: nhóm Chức năng làm dòng tiêu đề; ô sửa tại chỗ; cột Lịch là lưới ngày */
.tl-table { table-layout: fixed; }
.tl-table { --tl-day: 40px; --tl-days: 31; width: 100%; min-width: calc(794px + var(--tl-days) * var(--tl-day)); }
.tl-table th:nth-child(1) { width: 160px; }
.tl-table th:nth-child(2) { width: 140px; }
.tl-table th:nth-child(3) { width: 132px; }
.tl-table th:nth-child(4), .tl-table th:nth-child(5) { width: 128px; }
.tl-table th:nth-child(7) { width: 102px; }
.tl-table td.col-owner input { text-overflow: ellipsis; }

/* Assignee tag picker (Timeline Nhân sự + step/pipeline) */
.owner-tags { display: flex; flex-direction: column; gap: 4px; min-width: 0; width: 100%; }
.owner-tags-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 1.4rem; align-items: center; }
.owner-tag {
  display: inline-flex; align-items: center; gap: 2px;
  max-width: 100%; padding: 1px 6px 1px 8px; border-radius: 999px;
  border: 1px solid rgba(99, 102, 241, .28); background: rgba(99, 102, 241, .10);
  color: var(--indigo-ink, #3730a3); font: inherit; font-size: .78rem; font-weight: 650;
  cursor: pointer; line-height: 1.35;
}
.owner-tag.is-role { background: rgba(14, 165, 233, .12); border-color: rgba(14, 165, 233, .35); color: #0369a1; }
.owner-tag:hover:not(:disabled) { filter: brightness(.97); }
.owner-tag:disabled { cursor: default; opacity: .95; }
.owner-tag-x { font-weight: 700; opacity: .55; margin-left: 2px; }
.owner-tags-add { min-width: 0; }
.owner-tags-select {
  width: 100%; min-width: 0; max-width: 100%;
  padding: .2rem .35rem; font: inherit; font-size: .78rem;
  border: 1px dashed rgba(100, 116, 139, .55); border-radius: 8px;
  background: rgba(255,255,255,.7); color: var(--muted-2, #64748b);
}
.owner-tags.is-disabled .owner-tags-select { display: none; }
.owner-tags-compact { gap: 2px; }
.owner-tags-compact .owner-tag { font-size: .74rem; padding: 0 5px 0 7px; }
.tl-table td.col-owner .owner-tags { margin: -2px 0; }
.tl-table td.col-owner input { text-overflow: ellipsis; } /* legacy */
.step-meta .owner-tags, .task-meta-fields .owner-tags { min-width: 140px; }

.tl-table td.col-note textarea { min-height: 0; resize: vertical; }
.tl-table td.col-status select { padding-right: 1.6rem; text-overflow: clip; }
.tl-table td.col-task { overflow-wrap: break-word; word-break: normal; white-space: normal; }
.tl-table td.col-gantt, .tl-table th.col-gantt { padding-left: 0; padding-right: 0; }
.tl-table th { white-space: normal; vertical-align: bottom; }
.tl-table td { vertical-align: top; overflow-wrap: anywhere; }
.tl-table tr.grp td { background: rgba(99, 102, 241, .08); font-weight: 700; color: var(--indigo-ink); font-size: .84rem; }
.tl-table tr.grp td .muted { font-weight: 500; }
.tl-table tr.tl-row.tl-st-done td:first-child { box-shadow: inset 3px 0 0 #7cb86a; }
.tl-table tr.tl-row.tl-st-doing td:first-child { box-shadow: inset 3px 0 0 #e0b400; }
.tl-table tr.edited td { background: rgba(99, 102, 241, .05); }
.tl-table tr.overdue td.col-date:nth-child(5) { background: rgba(239, 68, 68, .07); }
.tl-title { font-weight: 600; }
.tl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.tl-code {
  font: inherit; font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .03em; color: var(--indigo-ink); background: var(--primary-soft);
  border: 1px solid transparent; border-radius: 7px; padding: .05rem .45rem; cursor: help; line-height: 1.5;
}
.tl-code:hover, .tl-code.on { background: rgba(99, 102, 241, .28); border-color: rgba(99, 102, 241, .5); }
.tl-code.nodesc { background: var(--gray-soft); color: var(--muted); }
.tl-code-desc { margin-top: 4px; padding: 4px 8px; border-left: 2px solid rgba(99, 102, 241, .5); background: rgba(255, 255, 255, .6); border-radius: 0 8px 8px 0; }
.tl-table select.level { width: 100%; min-width: 0; padding-left: .45rem; font-size: .84rem; font-weight: 600; }
.tl-table input[type=date] { width: 100%; min-width: 0; padding: .3rem .25rem; font-size: .84rem; font-variant-numeric: tabular-nums; }
.tl-sub { margin-top: 2px; }
.tl-due { display: inline-block; margin-top: 3px; font-size: .74rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.tl-due-overdue, .badge.tl-due-overdue { background: var(--red-soft); color: var(--danger); }
.tl-due-today, .badge.tl-due-today { background: var(--warn-soft); color: var(--warn); }
.tl-due-soon, .badge.tl-due-soon { background: var(--info-soft); color: var(--info); }
/* Lưới ngày (gantt): một cột mỗi ngày (≥34px), cuối tuần tô nhạt, vạch xanh "Hôm nay"; thanh vuông góc bo 3px, viền cùng màu nền theo trạng thái, phần trễ hạn tô đỏ sọc */
.tl-axis, .tl-gantt { display: grid; gap: 0; }
.tl-axis { position: relative; margin-top: 16px; }
.tl-axis-day { display: flex; flex-direction: column; align-items: center; padding: 2px 0; font-size: .64rem; line-height: 1.2; color: var(--muted-2); text-transform: none; letter-spacing: 0; border-left: 1px solid rgba(148, 163, 184, .22); }
.tl-axis-day b { font-size: .7rem; font-weight: 700; }
.tl-axis-day small { font-size: .62rem; font-weight: 500; }
.tl-axis-day.we { background: rgba(148, 163, 184, .16); color: #64748b; }
.tl-axis-day.today { color: #1d4ed8; background: rgba(37, 99, 235, .12); }
.tl-today-label { position: absolute; top: -15px; transform: translateX(-50%); padding: 0 6px; border-radius: 999px; background: #2563eb; color: #fff; font-size: .62rem; font-weight: 700; line-height: 14px; white-space: nowrap; z-index: 2; }
.tl-today-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #2563eb; z-index: 3; pointer-events: none; }
.tl-axis .tl-today-line { top: 0; }
.tl-gantt { position: relative; min-height: 30px; background: transparent; width: 100%; }
.tl-day { grid-row: 1; min-height: 30px; border-left: 1px solid rgba(148, 163, 184, .22); }
.tl-day.we { background: rgba(148, 163, 184, .16); }
.tl-day.today { background: rgba(37, 99, 235, .08); }
.tl-bar { --bar: var(--tl-bar-none); grid-row: 1; align-self: center; box-sizing: border-box; height: 14px; border-radius: 3px; margin: 0 1px; position: relative; z-index: 1; background: var(--bar); border: 1px solid var(--bar); }
.tl-bar.tl-st-done { --bar: var(--tl-bar-done); }
.tl-bar.tl-st-doing { --bar: var(--tl-bar-doing); }
.tl-bar-late { grid-row: 1; align-self: center; box-sizing: border-box; height: 14px; margin: 0 1px 0 0; border-radius: 0 3px 3px 0; z-index: 1; border: 1px solid #dc2626; background: repeating-linear-gradient(45deg, #dc2626 0 4px, #fca5a5 4px 8px); }
/* v22: kéo trên gantt (chỉ người được sửa): thân thanh = dời cả hai ngày, hai đầu = đổi bắt đầu / hạn; nhãn ngày nổi khi kéo */
.tl-bar.can-drag { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.tl-bar-h { position: absolute; top: -4px; bottom: -4px; width: 8px; cursor: ew-resize; z-index: 2; }
.tl-bar-h.start { left: -3px; }
.tl-bar-h.due { right: -3px; }
.tl-bar.can-drag:hover .tl-bar-h::after { content: ''; position: absolute; top: 4px; bottom: 4px; left: 3px; width: 2px; border-radius: 1px; background: rgba(255, 255, 255, .9); }
.tl-bar.dragging { cursor: grabbing; z-index: 4; box-shadow: 0 2px 8px rgba(15, 23, 42, .35); }
.tl-bar.drag-start, .tl-bar.drag-due { cursor: ew-resize; }
.tl-gantt.dragging { cursor: grabbing; }
.tl-gantt.dragging .tl-bar-late { opacity: .25; }
.tl-drag-tip { position: absolute; top: 50%; transform: translate(-50%, -50%); z-index: 5; padding: 0 6px; border-radius: 3px; background: #0f172a; color: #fff; font-size: .66rem; font-weight: 700; line-height: 16px; white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
/* Quyết định, mã việc */
.tl-decisions h4 { margin: 12px 0 6px; font-size: .9rem; color: var(--indigo-ink); }
.tl-plain, .tl-open { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 6px; }
.tl-plain { list-style: none; padding-left: 0; }
.tl-plain li { padding-left: 10px; border-left: 3px solid rgba(99, 102, 241, .35); }
.tl-codes > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.tl-codes > summary::-webkit-details-marker { display: none; }
.tl-codes > summary h3 { margin: 0; }
.tl-codes[open] > summary { margin-bottom: 10px; }
.tl-code-sec h4 { margin: 10px 0 4px; font-size: .9rem; }
.tl-code-table td.col-code { width: 11rem; white-space: nowrap; }
/* Nhắc việc */
.tl-reminders { display: flex; flex-direction: column; gap: 0; }
.tl-rem-sec h3 { display: flex; align-items: center; gap: 8px; }
.tl-rem-sec h3 .badge { font-size: .86rem; padding: .2rem .7rem; }
.tl-rem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl-rem-item { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 4px 14px; padding: 10px 4px; border-top: 1px solid var(--line-soft); align-items: start; }
.tl-rem-when { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.tl-rem-when b { font-size: 1rem; }
.tl-rem-overdue .tl-rem-when b { color: var(--danger); }
.tl-rem-today .tl-rem-when b { color: var(--warn); }
.tl-rem-title { font-weight: 700; color: var(--text); font-size: .98rem; }
.tl-rem-title:hover { color: var(--primary-ink); }
.tl-rem-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
/* Badge số việc cần nhắc trên menu (và trên nút ≡ ở điện thoại) */
.nav-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: auto; padding: 0 6px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11.5px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.topbar nav a.on .nav-badge { background: #fff; color: var(--danger); }
.nav-toggle { position: relative; }
.nav-toggle .toggle-badge { position: absolute; top: 2px; right: 2px; margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; }

/* Điện thoại: thẻ xếp chồng, ô nhập 44px, lưới ngày đủ rộng, ô ngày đi theo cặp */
@media (max-width: 640px) {
  .tl-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .tl-tile { padding: 8px; min-height: 44px; }
  .tl-tile-n { font-size: 18px; }
  .tl-tile-l { font-size: 10.5px; }
  .tl-table { table-layout: auto; width: auto; min-width: 0; }
  .tl-table td.col-task::before { display: none; }
  .tl-table td.col-owner, .tl-table td.col-status { flex: 1 1 45%; }
  .tl-table td.col-date { flex: 1 1 45%; }
  .tl-table td.col-gantt { flex: 1 1 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tl-gantt { width: calc(var(--tl-days) * var(--tl-day)); }
  .tl-table td.col-gantt::before { display: none; }
  .tl-table select.level, .tl-table input[type=date] { font-size: 16px; min-height: 44px; }
  .tl-rem-item { grid-template-columns: 1fr; gap: 2px; }
  .tl-rem-when { flex-direction: row; align-items: baseline; gap: 8px; }
  .tl-code { min-height: 28px; padding: 2px 8px; }
  .tl-filters .dt-count { flex: 1 1 100%; }
}

/* ---- v14: tiến độ theo checklist (trạng thái bước, trễ hạn), gói mẫu, người phụ trách / hạn ---- */
.seg.doing { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.seg.late { box-shadow: 0 0 0 2px rgba(239, 68, 68, .85); }
.seg-legend { display: inline-flex; align-items: center; gap: .3rem; vertical-align: middle; }
.seg-legend .seg { display: inline-block; width: 1.2rem; height: 7px; margin: 0 .1rem; }
.badge.stp { font-weight: 600; }
.badge.stp-chua_lam { background: var(--gray-soft); color: var(--muted); }
.badge.stp-dang_lam { background: var(--warn-soft); color: var(--warn); }
.badge.stp-xong { background: var(--ok-soft); color: var(--ok); }
.badge.late, .badge.stp.late { background: var(--red-soft); color: var(--danger); border: 1px solid rgba(239, 68, 68, .45); }
.badge.tpl { background: var(--violet-soft); color: var(--violet); }
button.badge.tpl-btn { cursor: pointer; font: inherit; font-size: .78rem; line-height: 1.3; }
button.badge.tpl-off { background: rgba(255, 255, 255, .6); border: 1px dashed rgba(100, 116, 139, .55); color: var(--muted); font-weight: 500; }
button.badge.tpl-btn:hover { filter: brightness(.96); }
.late-text { color: var(--danger); font-weight: 600; }
.status-summary { display: inline-flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.head-steps { display: inline-flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.head-steps:empty { display: none; }
.progress-late { margin-top: .2rem; }
.col-progress.has-late .pct.small { color: var(--danger); }
.pkg-table .tpl-toggle { color: var(--violet); }
.templates { margin-top: 16px; }
.templates-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.templates-head h2 { margin: 0; font-size: 1.1rem; }
.templates-head p { margin: 0; flex: 1 1 24rem; }
.tpl-table .col-name { min-width: 16rem; }
.tpl-table .name-cell { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.tpl-table .pkg-link { font-weight: 700; color: var(--text); }
.tpl-table .col-progress { min-width: 10rem; }
.tpl-table .col-actions { white-space: nowrap; text-align: right; }
.tpl-table .card-actions { display: inline-flex; gap: .35rem; align-items: center; }
/* Người phụ trách / hạn của một bước (kiểu ô sửa `ed` dùng chung) */
.step-meta { display: flex; align-items: center; gap: .6rem .9rem; flex-wrap: wrap; margin: -.2rem 0 .9rem; padding: .5rem .75rem; border-radius: 12px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(255, 255, 255, .9); }
.step-meta.late { border-color: rgba(239, 68, 68, .45); background: rgba(254, 226, 226, .45); }
.step-meta-field { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.step-meta-label { font-weight: 600; }
.step-meta input.ed { padding: .25rem .5rem; font-size: .9rem; min-height: 2rem; }
.step-meta input.step-assignee { width: 11rem; }
.step-meta input.step-deadline { width: 10.5rem; }
.step-late { font-size: .85rem; font-weight: 700; color: var(--danger); }
.step-head.late .sec-num { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 4px 12px rgba(239, 68, 68, .35); }
.step-head h3 .badge { vertical-align: middle; margin-left: .25rem; }
.sec-chip.doing { color: var(--warn); }
.sec-chip.doing .dot { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }
.sec-chip.late { border-color: rgba(239, 68, 68, .6); box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .35); }
.sec-chip.late .dot { outline: 2px solid rgba(239, 68, 68, .8); outline-offset: 1px; }
/* Thẻ checklist từng giai đoạn của quy trình cũ */
.stage-cards { margin: 0 0 18px; }
.stage-cards-title, .tree-title { margin: 0 0 .6rem; font-size: 1rem; }
.stage-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr)); gap: 12px; align-items: start; }
.stage-card { padding: 14px 16px; }
.stage-card.late { border-left: 4px solid rgba(239, 68, 68, .7); }
.stage-card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.stage-card-head h4 { margin: 0; flex: 1; min-width: 0; font-size: 1rem; }
.stage-card .step-meta { margin: 0 0 .6rem; }
.stage-card .checklist { padding: 0; box-shadow: none; background: transparent; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.stage-card .cl-head h3 { font-size: .9rem; }
li.late > .node-row .sec-num { outline: 2px solid rgba(239, 68, 68, .8); outline-offset: 1px; }
.empty-steps li .badge { vertical-align: middle; }
@media (max-width: 640px) {
  .step-meta { gap: .4rem .6rem; padding: .45rem .6rem; }
  .step-meta-field { flex: 1 1 45%; }
  .step-meta input.step-assignee, .step-meta input.step-deadline { width: 100%; flex: 1; }
  .stage-cards-grid { grid-template-columns: 1fr; gap: 8px; }
  .stage-card { padding: 10px 12px; }
  .templates-head p { flex-basis: 100%; }
  .tpl-table .col-progress { flex: 1 1 100%; min-width: 0; }
  .tpl-table .col-actions { text-align: right; }
  .tpl-table td:nth-child(2), .tpl-table td:nth-child(3) { flex: 0 1 auto; }
  .status-summary .badge { font-size: .7rem; }
}
.step-title-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.step-title-row h3 { margin: 0; }

/* ===== v15: quy trình vòng đời của gói — timeline hộp lớn trên tab Tổng quan (app.js lifecycleSection) =====
   Màu theo CẤP, không theo nhóm: mọi nhóm chính một màu (--lc-group), mọi mục con một màu nhạt hơn (--lc-item).
   Mỗi cột một nhóm; hai nhóm cùng cột xếp dọc = song song (Dev trên, Mkt + Sales dưới); mũi tên giữa các cột ở ngang
   đầu hộp. Khung .lifecycle cuộn ngang khi hẹp (điện thoại), trang không tràn. */
:root { --lc-group: rgba(99, 102, 241, .18); --lc-group-border: rgba(99, 102, 241, .42); --lc-item: rgba(255, 255, 255, .78); --lc-item-border: rgba(255, 255, 255, .95); --lc-arrow: rgba(79, 70, 229, .6); }
.lifecycle-card { padding-bottom: 10px; }
.lifecycle-head { display: flex; align-items: baseline; gap: .3rem 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.lifecycle-head h3, .lifecycle-head p { margin: 0; }
.lifecycle {
  overflow-x: auto; overflow-y: hidden; padding: 4px 2px 12px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; border-radius: 12px;
  scroll-snap-type: x proximity; scroll-padding-inline: 10px; overscroll-behavior-x: contain;
}
.lifecycle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.lc-track { display: flex; align-items: flex-start; width: max-content; min-width: 100%; }
.lc-col { flex: 1 1 0; min-width: 9.5rem; display: flex; flex-direction: column; gap: 6px; }
.lc-arrow { flex: none; width: 1.75rem; height: 3.2rem; position: relative; }
.lc-arrow::before { content: ''; position: absolute; left: 3px; right: 8px; top: 1.55rem; height: 2px; background: var(--lc-arrow); }
.lc-arrow::after { content: ''; position: absolute; right: 2px; top: calc(1.55rem - 5px); border: 6px solid transparent; border-left: 8px solid var(--lc-arrow); border-right: 0; }
.lc-group { background: var(--lc-group); border: 1px solid var(--lc-group-border); border-radius: 16px; padding: 6px 8px 8px; }
.lc-group-head {
  display: flex; align-items: center; gap: .45rem; width: 100%; min-height: 2.4rem; padding: .2rem .3rem; border: 0; border-radius: 10px;
  background: transparent; color: var(--indigo-ink); font: inherit; font-weight: 800; font-size: 1rem; line-height: 1.25; text-align: left; cursor: pointer;
}
.lc-group-head:hover { background: rgba(255, 255, 255, .35); }
.lc-group-head:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.lc-group-name {
  flex: 1; min-width: 0; overflow-wrap: break-word; word-break: normal; hyphens: none;
  /* keep title readable — badges/chevron stay flex:none beside it */
}
.lc-count { flex: none; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .62); color: var(--indigo-ink); font-variant-numeric: tabular-nums; }
.lc-group-head .lc-chev { width: 16px; height: 16px; flex: none; transition: transform .18s; }
.lc-group.collapsed .lc-chev { transform: rotate(-90deg); }
.lc-group.collapsed .lc-items { display: none; }
.lc-items { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.lc-item { background: var(--lc-item); border: 1px solid var(--lc-item-border); border-radius: 10px; padding: .4rem .6rem; font-size: .9rem; line-height: 1.35; color: var(--text); overflow-wrap: break-word; word-break: normal; }
.lc-parallel-tag { align-self: center; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .lc-group-head .lc-chev { transition: none; } }
/* Phone / narrow tablet: fixed readable column width + horizontal snap scroll (desktop flex unchanged above). */
@media (max-width: 900px) {
  .lifecycle { scroll-snap-type: x mandatory; }
  .lc-col {
    flex: 0 0 240px;
    min-width: 240px;
    max-width: min(260px, 82vw);
    width: 240px;
    scroll-snap-align: start;
  }
  .lc-arrow { width: 1.35rem; }
  .lc-group { padding: 8px 10px 10px; }
  .lc-group-head {
    min-height: 44px; align-items: flex-start; gap: .35rem;
    flex-wrap: nowrap;
  }
  .lc-group-name {
    overflow-wrap: break-word; word-break: normal; hyphens: none;
    line-height: 1.3; padding-top: .15rem;
  }
  .lc-item { font-size: .92rem; }
  .lc-item { flex-wrap: nowrap; align-items: flex-start; }
  .lc-item .lc-item-btn {
    flex: 1 1 auto; min-width: 0; align-items: flex-start;
    padding: .45rem .35rem .45rem .55rem;
  }
  .lc-item-name, .lc-item-text .lc-item-name {
    overflow-wrap: break-word; word-break: normal; hyphens: none;
  }
  .lc-item-menu {
    opacity: 1; /* touch: always visible so it never jumps onto the status icon */
    align-self: center;
    margin-top: .15rem;
  }
  .lc-toggle { align-self: center; padding: .35rem .4rem .35rem 0; }
  .pkg-name-row { flex-wrap: wrap; gap: 8px; }
  .pkg-name-row .title-input {
    flex: 1 1 100%; min-width: 0; overflow-wrap: break-word; word-break: normal;
  }
  .pkg-edit-btn, .pkg-refresh-btn { flex: none; }
}

/* ---- v16: hộp thoại dùng chung (modal) — đầu và chân cố định, chỉ phần thân cuộn. Desktop 85vw × 80vh, điện thoại
   (≤ 480px) 95vw × 95vh. Dùng cho: hộp Clone nội dung, chi tiết mục vòng đời, popup "BA & Tiêu chí", hộp xác nhận (.modal-sm). ---- */
.modal-layer { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(15, 23, 42, .45); animation: sheet-fade .18s ease-out; }
.modal {
  position: relative;
  display: flex; flex-direction: column; width: 85vw; height: 80vh; max-width: none; min-width: min(600px, 100%); outline: none; overflow: hidden;
  background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: 20px; box-shadow: 0 24px 64px rgba(31, 38, 135, .3);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: modal-in .2s cubic-bezier(.2, .8, .2, 1);
}
.modal.modal-sm { width: min(540px, 95vw); height: auto; max-height: 70vh; }
.modal-head { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .5); }
.modal-head-row { display: flex; align-items: flex-start; gap: .6rem; }
.modal-head-text { flex: 1; min-width: 0; }
.modal-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); }
.modal-title { margin: 0; font-size: 1.08rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.modal-sub { margin: .15rem 0 0; font-size: .85rem; color: var(--muted); }
.modal-close { flex: none; }
.modal-tabs { display: flex; gap: 6px; flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding-bottom: 2px; }
.modal-tab { flex: none; white-space: nowrap; min-height: 34px; padding: .25rem 1rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .55); font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; }
.modal-tab:hover { background: rgba(255, 255, 255, .85); }
.modal-tab.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-primary); }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px; -webkit-overflow-scrolling: touch; }
.modal-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3; width: 42px; height: 72px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .94); color: var(--indigo-ink); font-size: 1.6rem; line-height: 1;
  cursor: pointer; box-shadow: 0 8px 24px rgba(31, 38, 135, .18);
}
.modal-nav.prev { left: 10px; }
.modal-nav.next { right: 10px; }
.modal-nav:hover:not(:disabled) { background: #fff; }
.modal-nav:disabled { opacity: .35; cursor: default; }
.modal-nav:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
/* v18: the arrows name the item they lead to — a label beside the arrow on hover / keyboard focus. */
.modal-nav-tip {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 4; max-width: min(320px, 40vw); padding: .35rem .65rem; border-radius: 10px;
  background: rgba(30, 41, 59, .94); color: #fff; font-size: .82rem; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.modal-nav.prev .modal-nav-tip { left: calc(100% + 8px); }
.modal-nav.next .modal-nav-tip { right: calc(100% + 8px); }
.modal-nav:hover:not(:disabled) .modal-nav-tip, .modal-nav:focus-visible:not(:disabled) .modal-nav-tip { opacity: 1; }
.modal-layer.swap, .modal-layer.swap .modal { animation: none; } /* ‹ › swap the content in place — no fade / pop-in */
.modal-has-nav .modal-body { padding-left: 60px; padding-right: 60px; }
/* v21.15: the arrows live in .modal-navbar. Desktop: no box of its own (display: contents), the arrows stay edge buttons over the panel.
   Phones (≤ 768px): a slim bar between the body and the footer, so nothing is covered; the body keeps its normal padding. */
.modal-navbar { display: contents; }
@media (max-width: 768px) {
  .modal-navbar { display: flex; flex: none; order: 2; gap: .5rem; padding: 6px 14px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .5); }
  .modal-has-nav .modal-foot { order: 3; }
  .modal-has-nav .modal-body { padding-left: 14px; padding-right: 14px; }
  .modal-navbar .modal-nav { position: static; transform: none; flex: 1 1 0; width: auto; height: 40px; border-radius: 12px; box-shadow: none; font-size: 1.4rem; }
  .modal-navbar .modal-nav-tip { display: none; }
}
.lc-dt-sec { margin: 0 0 1rem; }
.lc-dt-sec h4 { margin: 0 0 .4rem; font-size: .95rem; }
.lc-dt-info { display: grid; gap: .35rem; }
.lc-dt-row { display: grid; grid-template-columns: 7.5rem 1fr; gap: .4rem; align-items: baseline; }
.lc-dt-k { color: var(--muted); font-size: .85rem; }
.lc-offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.lc-offer { display: flex; flex-direction: column; gap: .35rem; padding: .5rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .55); }
.lc-offer img, .lc-offer-ph { width: 100%; height: 110px; object-fit: contain; background: rgba(255, 255, 255, .8); border-radius: 8px; }
.lc-offer-ph { display: flex; align-items: center; justify-content: center; }
.lc-dt-prices { margin: 0; padding-left: 1.1rem; }
.lc-dt-add { margin-top: .6rem; }
.lc-dt-actions { margin: .4rem 0 0; }
.modal-body > .card:last-child { margin-bottom: 0; }
.modal-foot { flex: none; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255, 255, 255, .5); }
.modal-foot .spacer { flex: 1; }
.modal-status { font-size: .85rem; font-weight: 600; color: var(--ok); }
.modal-status[data-state="dirty"], .modal-status[data-state="saving"] { color: var(--warn); }
.modal-status[data-state="error"] { color: var(--danger); }
.modal-status[data-state="saved"]::before { content: '✓ '; }
.modal-status[data-state="dirty"]::before { content: '● '; }
.modal-text { margin: 0 0 .6rem; line-height: 1.55; }
.btn.danger-btn { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 8px 20px rgba(239, 68, 68, .3); }
html.modal-open { overflow: hidden; }
@keyframes modal-in { from { transform: translateY(14px) scale(.985); opacity: .5; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .modal, .modal-layer { animation: none; } }
@media (max-width: 768px) {
  .modal-layer { padding: 0; }
  .modal { min-width: 0; border-radius: 18px; }
  .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
  .modal-body { padding: 12px 14px; }
  .modal-body .two-col { grid-template-columns: 1fr; }
  .modal-body .form-grid { grid-template-columns: 1fr; }
  /* v17.1: the footer stays one row on a phone — compact buttons, status as a dot, "Xong · ai · lúc nào" left to the body */
  .modal-foot { flex-wrap: nowrap; gap: .4rem; }
  .modal-foot .btn { flex: none; padding: .45rem .65rem; font-size: .85rem; white-space: nowrap; }
  .modal-foot .modal-status { flex: none; font-size: 0; }
  .modal-foot .modal-status::before { font-size: .95rem; }
  .modal-foot .lc-done-meta { display: none; }
}
/* v17.1: read-only (view) mode of the lifecycle popups */
.modal.is-view .modal-body input, .modal.is-view .modal-body textarea, .modal.is-view .modal-body select { cursor: default; }
.modal.is-view .modal-body textarea.ed { background: rgba(255, 255, 255, .35); }
/* v21.19: list-editor chrome only after Sửa — hide add / paste / raw-text / per-item action buttons in view mode */
.modal.is-view .bl-add-btn,
.modal.is-view .bl-add,
.modal.is-view .bl-bulk,
.modal.is-view .bl-raw-toggle,
.modal.is-view .bl-actions,
.modal.is-view .bl-more,
.modal.is-view .list-editor.raw .bl-raw { display: none !important; }
.modal.is-view .bl-text { cursor: default; }
.modal.is-view .bl-text:hover { background: transparent; }
.list-editor.is-view .bl-add-btn,
.list-editor.is-view .bl-add,
.list-editor.is-view .bl-bulk,
.list-editor.is-view .bl-raw-toggle,
.list-editor.is-view .bl-actions,
.list-editor.is-view .bl-more { display: none !important; }

/* v21.19: template item CRUD on the lifecycle pipeline cards */
.lc-item { position: relative; }
.lc-item-menu {
  flex: none; width: 1.75rem; height: 1.75rem; margin-right: .15rem; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .12s, background .12s;
}
.lc-item:hover .lc-item-menu, .lc-item:focus-within .lc-item-menu, .lc-item-menu:focus { opacity: 1; }
.lc-item-menu:hover, .lc-item-menu:focus-visible { background: rgba(99, 102, 241, .12); color: var(--primary-ink); }
.lc-item-menu .ic { width: 1rem; height: 1rem; }
.lc-add-item {
  display: flex; align-items: center; gap: .35rem; width: 100%; margin: .25rem 0 0; padding: .35rem .55rem;
  border: 1px dashed rgba(99, 102, 241, .35); border-radius: 8px; background: rgba(255, 255, 255, .35);
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--primary-ink); cursor: pointer;
}
.lc-add-item:hover { background: var(--primary-soft); border-style: solid; }
.lc-add-form { display: flex; gap: .35rem; align-items: center; margin: .25rem 0 0; }
.lc-add-form input { flex: 1; min-width: 0; padding: .3rem .55rem; font-size: .85rem; border-style: dashed; }
.lc-rename-input { width: 100%; padding: .25rem .4rem; font: inherit; font-size: .9rem; border: 1px solid #93c5fd; border-radius: 6px; }

/* ---- v16: mục vòng đời có trạng thái — nút cả dòng, dấu tích cuối dòng: Chưa làm (vòng xám, không tích), Đang làm (vòng +
   tích viền, không tô), Xong (vòng tô xanh, tích trắng); đầu nhóm đếm xong/tổng. ---- */
.lc-item { padding: 0; }
.lc-item-btn {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 2.4rem; padding: .4rem .5rem .4rem .6rem; border: 0; border-radius: inherit;
  background: transparent; font: inherit; font-size: .9rem; line-height: 1.35; color: var(--text); text-align: left; cursor: pointer; transition: background .15s;
}
.lc-item-btn:hover { background: rgba(255, 255, 255, .6); }
.lc-item-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.lc-item-name { flex: 1; min-width: 0; overflow-wrap: break-word; word-break: normal; hyphens: none; }
.lc-check { flex: none; width: 20px; height: 20px; }
.lc-check circle { fill: none; stroke: rgba(100, 116, 139, .5); stroke-width: 1.6; }
.lc-check path { fill: none; stroke: transparent; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.lc-check .lc-half { fill: transparent; stroke: none; }
.lc-item.st-dang_lam .lc-check circle { stroke: #d97706; stroke-width: 1.8; }
.lc-item.st-dang_lam .lc-check .lc-half { fill: #f59e0b; }
.lc-item.st-xong .lc-check circle { fill: #059669; stroke: #059669; }
.lc-item.st-xong .lc-check path:not(.lc-half) { stroke: #fff; }
.lc-item.st-xong .lc-item-name { color: var(--ok); font-weight: 600; }
.lc-legend { display: flex; gap: .4rem 1rem; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); margin: 0; }
.lc-legend .lc-item { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .45rem; font-size: .8rem; }
.lc-legend .lc-check { width: 16px; height: 16px; }
.lc-summary { font-variant-numeric: tabular-nums; }
.lc-item-detail textarea { min-height: 14rem; width: 100%; }
.lc-item-detail .hint { margin: .5rem 0 0; }
.lc-done-meta { font-size: .85rem; color: var(--ok); font-weight: 600; }
.btn.done-toggle[aria-pressed="true"] { background: var(--ok-soft); color: var(--ok); border-color: rgba(16, 185, 129, .4); }
.lc-ba-note { margin: 0 0 .8rem; }
.lc-ba-pane { display: flex; flex-direction: column; gap: .5rem; min-height: 100%; }
.lc-ba-text { flex: 1 1 auto; width: 100%; min-height: 260px; resize: none; line-height: 1.55; }
.lc-ba-updated { flex: none; margin: 0; }
.pkg-name-row { grid-area: name; display: flex; align-items: center; gap: 10px; min-width: 0; }
.pkg-name-row .title-input { flex: 1; min-width: 0; }
.pkg-edit-btn, .pkg-refresh-btn { flex: none; }
.pkg-edit { margin: 0 0 14px; }
.pkg-edit[hidden] { display: none; }
.pkg-edit h3 { margin: 0 0 .6rem; }
.pkg-edit textarea { width: 100%; }
.pkg-edit-actions { display: flex; gap: .6rem; margin-top: .8rem; }
.h-act.clone { background: var(--cyan-soft); color: var(--cyan); }

/* ---- v16: hộp Clone nội dung ---- */
.pkg-tools { display: inline-flex; gap: .4rem; align-items: center; margin-left: auto; }
.clone-form { display: grid; gap: 14px; }
.clone-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; align-items: start; }
.clone-grid .field select, .clone-grid .field input { width: 100%; }
.radio-row { display: flex; gap: .4rem 1.1rem; flex-wrap: wrap; align-items: center; }
.radio-row label { display: inline-flex; gap: .35rem; align-items: center; cursor: pointer; }
.radio-row input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--primary); }
.clone-sections { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.clone-sections label { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem .65rem; border-radius: 12px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(255, 255, 255, .9); cursor: pointer; }
.clone-sections label:hover { background: rgba(255, 255, 255, .8); }
.clone-sections input { width: 1.1rem; height: 1.1rem; margin: .15rem 0 0; accent-color: var(--primary); flex: none; }
.clone-sec-label { font-weight: 600; }
.clone-sec-counts { display: block; font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.clone-sec-counts .n-copy { color: var(--ok); font-weight: 700; }
.clone-sec-counts .n-replace { color: var(--danger); font-weight: 700; }
.clone-preview { border-radius: 14px; background: rgba(255, 255, 255, .5); border: 1px solid rgba(255, 255, 255, .9); padding: 10px 14px; }
.clone-preview h4 { margin: 0 0 .4rem; font-size: .95rem; }
.clone-preview table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.clone-preview th, .clone-preview td { text-align: left; padding: .3rem .4rem; border-top: 1px solid var(--line-soft); vertical-align: top; }
.clone-preview thead th { border-top: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); }
.clone-preview .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clone-preview tfoot td { font-weight: 800; }
.clone-overwrite { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem .75rem; border-radius: 12px; background: var(--red-soft); border: 1px solid rgba(239, 68, 68, .35); }
.clone-overwrite input { width: 1.1rem; height: 1.1rem; margin: .15rem 0 0; accent-color: var(--danger); flex: none; }
.clone-overwrite b { color: var(--danger); }
.clone-note { margin: 0; font-size: .85rem; color: var(--muted); }
@media (max-width: 768px) {
  .clone-grid { grid-template-columns: 1fr; }
  .pkg-tools { margin-left: 0; }
}

/* v18: deadline chip on a pipeline sub-item (red when overdue and not Xong) + start / deadline / owner row in the item popup. */
.lc-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; }
.lc-item-dates { font-size: .75rem; line-height: 1.2; color: var(--muted, #6b7280); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lc-item-text .lc-item-name { flex: none; max-width: 100%; overflow-wrap: break-word; }
.lc-plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .6rem; margin-bottom: .6rem; }

@media (max-width: 480px) {
  .modal { width: 95vw; height: 95vh; }
  .modal.modal-sm { width: 95vw; height: auto; max-height: 95vh; }
}

/* ---- v19: popup "Mô hình & công nghệ" — sơ đồ SVG lấp đầy thân popup (public/diagram-editor.js) ---- */
.lc-mohinh-popup .modal-body, .lc-mohinh-popup.modal-has-nav .modal-body { padding: 0; overflow: hidden; display: flex; }
.dg-wrap {
  --dg-door: #059669; --dg-door-bg: #d1fae5; --dg-lan: #2563eb; --dg-lan-bg: #dbeafe; --dg-cloud: #7c3aed; --dg-cloud-bg: #ede9fe; --dg-other: #475569; --dg-other-bg: #e2e8f0;
  position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; background: rgba(255, 255, 255, .35);
  display: flex; flex-direction: column;
}
/* v21: AntV X6 canvas (public/vendor/x6). Toolbar = its own row; the stage below holds the canvas, legend, drawer and pickers,
   so the options drawer slides in under the toolbar instead of covering it. */
.dg-stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; }
.dg-stage > .dg-svg { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; user-select: none; -webkit-user-select: none; overflow: hidden; }
.dg-stage > .dg-svg:active { cursor: grabbing; }
/* v21.4: one row — tiers | edit tools (edit mode; the hint shrinks / hides, full text in the tooltip) | zoom */
.dg-tools { position: relative; z-index: 5; flex: none; padding: 8px 16px; display: flex; flex-wrap: nowrap; gap: .4rem; align-items: center; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .55); }
.dg-tools > .dg-tiers { order: 1; }
.dg-tools > .dg-edit-tools { order: 2; flex: 1 1 auto; }
.dg-tools > .dg-zoom { order: 3; }
.dg-edit-tools { display: flex; flex-wrap: nowrap; flex: 0 1 auto; max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: thin; gap: .4rem; align-items: center; padding: .25rem .4rem; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line); }
.dg-edit-tools[hidden] { display: none; }
.dg-edit-tools > * { flex: none; white-space: nowrap; }
.dg-zoom { display: flex; flex: none; gap: .3rem; margin-left: auto; padding: .25rem .4rem; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line); }
.dg-sel { width: auto; max-width: 9rem; font: inherit; font-size: .85rem; padding: .2rem .4rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.dg-legend { position: absolute; left: 60px; bottom: 10px; z-index: 3; display: flex; gap: .35rem; flex-wrap: wrap; pointer-events: none; }
.dg-chip { font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; border: 1px solid currentColor; }
.dg-chip.g-door, .dg-node.g-door { color: var(--dg-door); --bg: var(--dg-door-bg); }
.dg-chip.g-lan, .dg-node.g-lan { color: var(--dg-lan); --bg: var(--dg-lan-bg); }
.dg-chip.g-cloud, .dg-node.g-cloud { color: var(--dg-cloud); --bg: var(--dg-cloud-bg); }
.dg-chip.g-other, .dg-node.g-other { color: var(--dg-other); --bg: var(--dg-other-bg); }
.dg-chip { background: rgba(255, 255, 255, .85); }
.dg-node { cursor: pointer; }
.is-edit .dg-node { cursor: move; }
.dg-box { fill: #fff; stroke: currentColor; stroke-width: 1.6; filter: drop-shadow(0 3px 6px rgba(31, 38, 135, .12)); }
.dg-node.is-box .dg-box { stroke-width: 2.6; }
.dg-node.sel .dg-box { stroke-width: 3; stroke-dasharray: 6 3; }
.dg-icon-bg { fill: var(--bg); }
.dg-icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dg-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.dg-tiers { display: inline-flex; flex: none; gap: 2px; padding: .2rem; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line); }
.dg-tier-btn.active { background: var(--primary); color: #fff; }
/* Every part of a node (box, label, icon) is part of the click target: handlers live on the node <g>. A blanket
   `pointer-events: none` on the label made the rect the hit target, so a real click on the text "hit" the rect. */
.dg-node > * { pointer-events: all; }
.dg-node > .dg-badge, .dg-node > .dg-badge-n { pointer-events: none; }
.dg-handle { fill: currentColor; stroke: #fff; stroke-width: 2; cursor: crosshair; opacity: .55; }
.dg-handle:hover, .dg-node:hover .dg-handle { opacity: 1; }
.is-view .dg-handle { display: none; }
.dg-line { fill: none; stroke: #64748b; stroke-width: 1.8; }
.dg-line.temp { stroke: var(--primary); stroke-dasharray: 5 4; }
.dg-hit { fill: none; stroke: transparent; stroke-width: 14; }
.dg-edge.sel .dg-line { stroke: var(--primary); stroke-width: 3; }
.is-edit .dg-edge { cursor: pointer; }
.dg-arrow-head { fill: #64748b; }
.dg-elabel { font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: #f1f5ff; stroke-width: 4px; pointer-events: none; }
/* edit mode: a link label can be dragged along its line; the selected link shows X6 tools (segments, bend points, arrowheads) */
.is-edit .dg-elabel { pointer-events: all; cursor: move; }
.dg-wrap .x6-edge-tool-segment, .dg-wrap .x6-edge-tool-vertex, .dg-wrap .dg-arrowhead { filter: drop-shadow(0 1px 2px rgba(15, 23, 42, .35)); }
.dg-rename { position: absolute; z-index: 5; transform: translate(-50%, -50%); width: 180px; font: inherit; padding: .3rem .5rem; border-radius: 8px; border: 2px solid var(--primary); background: #fff; }
.dg-panel {
  position: absolute; z-index: 4; top: 0; right: 0; bottom: 0; width: min(380px, 100%); display: flex; flex-direction: column;
  background: #fff; opacity: 1; -webkit-backdrop-filter: none; backdrop-filter: none; border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(31, 38, 135, .16);
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s;
}
.dg-panel.open { transform: translateX(0); visibility: visible; transition: transform .25s ease, visibility 0s; }
@media (prefers-reduced-motion: reduce) { .dg-panel { transition: none; } }
.dg-panel-head { flex: none; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.dg-panel-head h4 { flex: 1; margin: 0; font-size: .95rem; }
.dg-panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: .6rem .8rem; display: grid; gap: .6rem; align-content: start; }
.dg-dev { padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .6); display: grid; gap: .35rem; }
.dg-dev h5 { margin: 0; font-size: .92rem; }
.dg-dev ul { margin: 0; padding-left: 1.1rem; font-size: .88rem; }
.dg-dev-name, .dg-comp { display: flex; gap: .3rem; }
.dg-dev input[type=text] { flex: 1; min-width: 0; font: inherit; font-size: .88rem; padding: .25rem .45rem; border-radius: 8px; border: 1px solid var(--ed-border, var(--line)); background: #fff; }
.dg-comps { display: grid; gap: .25rem; }
@media (max-width: 480px) {
  .dg-tools { padding: 6px 8px; gap: .3rem; }
  .dg-tiers .btn.small, .dg-zoom .btn.small { min-height: 28px; padding: .1rem .4rem; font-size: .8rem; }
  .dg-zoom { gap: .1rem; padding: .15rem .2rem; }
  .dg-legend { left: 8px; }
  .dg-icon-picker { left: 8px; }
  .dg-panel { width: min(380px, 92%); }
}

/* v21 — box catalog in the drawer of the Box chấm công node (light product cards; full width on phones) */
.dg-panel.wide { width: min(460px, 100%); }
.bx-cat { gap: .7rem; }
.bx-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
.bx-filter { display: grid; gap: .15rem; font-size: .75rem; color: var(--muted); }
.bx-filter select, .bx-form input[type=text], .bx-form input[type=url], .bx-form select, .bx-form textarea {
  width: 100%; box-sizing: border-box; min-width: 0; font: inherit; font-size: .86rem; padding: .3rem .45rem; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff; color: var(--text);
}
.bx-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 30px; }
.bx-group { display: grid; gap: .6rem; }
.bx-group-title { margin: .2rem 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.bx-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: .7rem; padding: .65rem; border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.bx-media { position: relative; display: grid; align-content: start; gap: .3rem; }
.bx-media img { width: 112px; height: 112px; object-fit: contain; border-radius: 10px; background: #f8fafc; border: 1px solid #eef2f7; }
.bx-ph { width: 112px; height: 112px; box-sizing: border-box; display: grid; place-items: center; align-content: center; gap: .35rem; border-radius: 10px; border: 1px dashed #cbd5e1; background: #f8fafc; color: var(--muted); }
.bx-ph-box { width: 40px; height: 34px; border: 2px solid #94a3b8; border-radius: 6px; background: linear-gradient(#e2e8f0 0 30%, transparent 30%); }
.bx-3d-host { width: 112px; height: 112px; border-radius: 10px; overflow: hidden; background: #f1f5f9; }
.bx-media .bx-3d { justify-self: stretch; }
.bx-info { display: grid; gap: .3rem; align-content: start; min-width: 0; }
.bx-title { display: flex; align-items: flex-start; gap: .4rem; }
.bx-title h5 { flex: 1; margin: 0; font-size: .95rem; line-height: 1.3; color: var(--text); }
.bx-status { flex: none; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; }
.bx-status.s-tested { color: var(--ok); background: var(--ok-soft); }
.bx-status.s-testing { color: var(--warn); background: var(--warn-soft); }
.bx-status.s-untested { color: var(--muted); background: var(--gray-soft); }
.bx-brand { margin: 0; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.bx-self { font-size: .7rem; font-weight: 600; color: var(--violet); background: var(--violet-soft); padding: .05rem .4rem; border-radius: 999px; }
.bx-chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.bx-chip { font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; background: #eff6ff; color: var(--primary-ink); border: 1px solid #dbeafe; }
.bx-note { margin: 0; font-size: .82rem; color: var(--text-2); white-space: pre-line; }
.bx-src { font-size: .8rem; color: var(--primary-ink); word-break: break-all; }
.bx-parts { font-size: .82rem; }
.bx-parts summary { cursor: pointer; font-weight: 600; color: var(--text-2); }
.bx-parts ul { margin: .3rem 0 0; padding-left: 1.1rem; display: grid; gap: .1rem; }
.bx-acts { display: flex; gap: .35rem; flex-wrap: wrap; }
.bx-form { display: grid; gap: .45rem; padding: .7rem; border: 1px solid #bfdbfe; border-radius: 14px; background: #f8fbff; }
.bx-form h5 { margin: 0; font-size: .92rem; }
.bx-frow { display: grid; gap: .15rem; font-size: .78rem; color: var(--muted); }
.bx-feats { margin: 0; padding: .35rem .5rem .5rem; border: 1px solid #e2e8f0; border-radius: 10px; display: grid; gap: .35rem; }
.bx-feats legend { font-size: .78rem; color: var(--muted); padding: 0 .2rem; }
.bx-fchks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem .75rem; }
.bx-fchk { display: flex; align-items: center; gap: .4rem; min-width: 0; min-height: 24px; margin: 0; font-size: .84rem; line-height: 1.2; color: var(--text); cursor: pointer; }
.bx-fchk input[type=checkbox] { flex: none; width: 16px; height: 16px; margin: 0; padding: 0; }
.bx-fchk > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bx-fchk.bx-self-row { width: fit-content; max-width: 100%; }
.bx-form-img { display: flex; align-items: center; gap: .5rem; }
.bx-form-img img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid #e2e8f0; }
/* v24: shared device cards (any diagram node, device manager) */
.bx-head-acts { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.bx-link { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; padding: .5rem; border: 1px solid #bfdbfe; border-radius: 12px; background: #f8fbff; }
.bx-link select { flex: 1; min-width: 0; font: inherit; font-size: .85rem; padding: .3rem .4rem; border: 1px solid #cbd5e1; border-radius: 8px; }
.bx-kind { font-size: .7rem; font-weight: 600; color: var(--text-2); background: var(--gray-soft); padding: .05rem .4rem; border-radius: 999px; }
.bx-qty { flex: none; font-size: .78rem; font-weight: 600; color: var(--muted); }
.bx-thumbs { display: flex; gap: .25rem; flex-wrap: wrap; }
.bx-thumb { padding: 0; border: 1px solid #e2e8f0; border-radius: 6px; background: #f8fafc; cursor: zoom-in; }
.bx-thumb img { display: block; width: 36px; height: 36px; object-fit: cover; border-radius: 5px; }
.bx-parts ul:has(.bx-part) { list-style: none; padding-left: 0; gap: .2rem; }
.bx-part { display: flex; align-items: center; gap: .35rem; width: 100%; padding: .15rem .3rem; border: 0; border-radius: 6px; background: none; font: inherit; text-align: left; color: var(--text); cursor: pointer; }
.bx-part:hover, .bx-part[aria-expanded=true] { background: #f1f5f9; }
.bx-part-img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; flex: none; }
.bx-card.bx-child { grid-template-columns: 64px minmax(0, 1fr); gap: .5rem; padding: .45rem; margin: .2rem 0 .35rem; box-shadow: none; }
.bx-child .bx-media img, .bx-child .bx-ph, .bx-child .bx-3d-host { width: 64px; height: 64px; }
.bx-child .bx-ph-box { width: 26px; height: 22px; }
.bx-single { padding: 0; }
.dm-group { display: grid; gap: 6px; margin-bottom: 10px; }
.dm-group-title { margin: 4px 0 0; padding-left: 8px; border-left: 3px solid var(--zc, #94a3b8); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
.dm-tiles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dm-tile { border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .55); }
.dm-tile.on { border-color: transparent; background: #fff; box-shadow: 0 0 0 2px var(--ring), var(--shadow-primary, 0 2px 8px rgba(59, 130, 246, .25)); }
.dm-pick { width: 100%; min-width: 0; display: flex; align-items: center; gap: .55rem; padding: 6px 8px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: inherit; border-radius: 12px; }
.dm-pick:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.dm-txt { flex: 1; min-width: 0; display: grid; gap: 1px; }
.dm-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-used { flex: none; min-width: 1.4rem; height: 1.4rem; padding: 0 5px; border-radius: 999px; background: #e2e8f0; color: #64748b; font-size: .72rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.dm-used.on { background: #dbeafe; color: #1d4ed8; }

@media (max-width: 480px) {
  .dg-panel.wide { width: 100%; }
  .bx-bar { grid-template-columns: 1fr 1fr; }
  .bx-card { grid-template-columns: 84px minmax(0, 1fr); }
  .bx-media img, .bx-ph, .bx-3d-host { width: 84px; height: 84px; }
}

.dg-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dg-edit-tools > .dg-hint { flex: 1 1 0; }
/* v19.1: zones — tinted frames behind the nodes; only the title band is grabbable (edit mode) */
.dg-zone-box { stroke-width: 1.5; pointer-events: none; }
.dg-zone-head { fill: transparent; pointer-events: none; }
.is-edit .dg-zone-head { pointer-events: all; cursor: move; }
.dg-zone-title { font-size: 14px; font-weight: 700; pointer-events: none; }
.dg-zone.sel .dg-zone-box, .dg-zone.drop .dg-zone-box { stroke-width: 2.4; stroke-dasharray: 8 4; }
.dg-zone.drop .dg-zone-box { fill-opacity: .18; }
/* zone.style 'dashed': dashed frame on its own tint (fill = zone colour); selected → shorter dashes */
.dg-zone.dashed .dg-zone-box { stroke-width: 1.8; stroke-dasharray: 9 5; fill-opacity: .12; }
.dg-zone.dashed.sel .dg-zone-box { stroke-width: 2.4; stroke-dasharray: 3 3; }
/* X6 Transform resize handles of the selected zone */
.dg-wrap .x6-widget-transform { border-color: var(--primary); }
.dg-wrap .x6-widget-transform-resize { border-color: var(--primary); border-radius: 3px; }
.dg-badge { fill: var(--primary); stroke: #fff; stroke-width: 2; pointer-events: none; }
.dg-badge-n { fill: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.dg-opt-img { width: 100%; max-height: 140px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.dg-opt-price { margin: 0; font-weight: 600; font-size: .88rem; }
.dg-opt-note { margin: 0; white-space: pre-wrap; }
.dg-dev textarea.dg-note { width: 100%; box-sizing: border-box; font: inherit; font-size: .88rem; padding: .25rem .45rem; border-radius: 8px; border: 1px solid var(--ed-border, var(--line)); background: #fff; resize: vertical; }

/* ---- v20: popup "Thiết bị" — master-detail (danh sách thiết bị bên trái, chi tiết bên phải), ảnh / 3D. Desktop 85vw × 80vh
   (như .modal), ≤ 768px 95% và danh sách nằm trên, chi tiết nằm dưới. ---- */
.modal.dev-popup .modal-body { padding-left: 60px; padding-right: 60px; }
.dev-md { display: grid; grid-template-columns: minmax(230px, 320px) minmax(0, 1fr); gap: 12px 16px; align-items: start; }
.dm-filterbar { grid-column: 1 / -1; padding: 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(248, 250, 252, .9); }
.dm-filter-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; min-width: 0; }
.dm-filter-row .dm-search { flex: 1 1 140px; min-width: 110px; }
.dm-filter-row .dm-group-filter { flex: 0 1 140px; min-width: 110px; }
.dm-filter-count { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dm-filter-clear { flex: none; }
/* v21.83 — thống kê add-on trên Phân tích › Thiết bị */
.dm-addon-stats { grid-column: 1 / -1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.dm-stats-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.dm-stats-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dm-stat { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 10px; background: rgba(248,250,252,.95); border: 1px solid var(--line); min-width: 0; }
.dm-stat-k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.dm-stat-v { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.dm-stats-brands { overflow-x: auto; }
.dm-brand-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.dm-brand-table th, .dm-brand-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.dm-brand-table th { color: var(--muted); font-weight: 600; }
.dm-brand-table td.num, .dm-brand-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.bx-buy { flex: none; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; margin-left: 4px; }
.bx-buy.s-purchased { color: var(--ok); background: var(--ok-soft); }
.bx-buy.s-not_purchased { color: var(--muted); background: var(--gray-soft); }
@media (max-width: 900px) {
  .dm-stats-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .dm-addon-stats { grid-column: 1; }
}

.dm-tagbox { position: relative; display: flex; align-items: center; flex: 1 1 150px; min-width: 120px; }
.dm-tagbox-field { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 3px 6px; min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: text; }
.dm-tagbox.open .dm-tagbox-field { border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(59, 130, 246, .15); }
.dm-tag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 2px 1px 8px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: .75rem; font-weight: 600; max-width: 100%; }
.dm-tag-lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-tag-x { border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; line-height: 1; padding: 2px 6px; border-radius: 999px; }
.dm-tag-x:hover { background: rgba(29, 78, 216, .12); }
.dm-tag-input { flex: 1; min-width: 5rem; border: 0; outline: none; background: transparent; font: inherit; font-size: .85rem; padding: 2px 0; }
.dm-tag-menu { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; margin: 0; padding: 4px; list-style: none; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .12); }
.dm-tag-opt { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.dm-tag-opt:hover, .dm-tag-opt.on { background: #eff6ff; }
.dm-tag-opt-n { flex: none; }
.dm-tag-empty { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.dev-list-col { position: sticky; top: 0; display: flex; flex-direction: column; gap: .5rem; max-height: calc(80vh - 190px); overflow-y: auto; padding-right: 2px; }
.dev-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.dev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dev-row { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .55); }
.dev-row.on { border-color: transparent; background: #fff; box-shadow: 0 0 0 2px var(--ring), var(--shadow-primary, 0 2px 8px rgba(59, 130, 246, .25)); }
.dev-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: .55rem; padding: 6px 8px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: inherit; border-radius: 12px; }
.dev-pick:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.dev-thumb { flex: none; width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: rgba(148, 163, 184, .22); }
.dev-ico { display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 800; color: var(--muted); }
.dev-ico .ic { width: 20px; height: 20px; }
.dev-name { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.dev-qty { flex: none; font-size: .8rem; color: var(--muted); }
.dev-row-tools { flex: none; display: flex; padding-right: 4px; }
.dev-row-tools .icon { width: 28px; height: 28px; }
.dev-add { align-self: flex-start; }
.dev-empty { padding: .6rem; border: 1px dashed var(--line); border-radius: 12px; }
.dev-legacy { margin-top: .6rem; padding: .5rem; border-radius: 10px; background: rgba(255, 255, 255, .6); white-space: pre-wrap; color: var(--text-2, inherit); }
.dev-detail-col { min-width: 0; display: flex; flex-direction: column; gap: .8rem; }
.dev-detail-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.dev-detail-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.dev-detail-title h4 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.dev-chip { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--grad); color: #fff; }
.dev-chip.alt { background: rgba(100, 116, 139, .16); color: var(--text-2, #334155); }
.dev-toggle { display: flex; gap: 4px; }
.dev3d-wrap { position: relative; }
.dev3d { width: 100%; height: clamp(220px, 42vh, 460px); border-radius: 14px; border: 1px solid var(--line); background: radial-gradient(circle at 50% 35%, #fff, rgba(203, 213, 225, .55)); overflow: hidden; touch-action: none; }
.dev3d-canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.dev3d-canvas:active { cursor: grabbing; }
.dev3d-badge { position: absolute; top: 10px; left: 10px; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: rgba(250, 204, 21, .9); color: #422006; }
.dev3d-badge[hidden], .dev3d-hint[hidden] { display: none; }
.dev3d-tip, .dev3d-hint { margin: .3rem 0 0; }
.dev3d-msg { padding: 1rem; margin: 0; }
.dev-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.dev-shot { position: relative; }
.dev-shot-btn { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: zoom-in; }
.dev-shot img { display: block; width: 100%; height: 130px; object-fit: contain; }
.dev-shot-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; background: rgba(255, 255, 255, .92); }
.dev-noimg { padding: 1.2rem; text-align: center; border: 1px dashed var(--line); border-radius: 12px; }
.dev-media-tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dev-val { white-space: pre-wrap; overflow-wrap: anywhere; }
.dev-form { display: flex; flex-direction: column; gap: .6rem; }
.dev-form-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .6rem; }
.dev-form input.ed, .dev-form textarea.ed, .dev-form select.ed { width: 100%; }
@media (max-width: 768px) {
  .modal.dev-popup { width: 95vw; height: 95vh; }
  .modal.dev-popup .modal-body { padding-left: 14px; padding-right: 14px; }
  .dev-md { grid-template-columns: 1fr; gap: 12px; }
  .dm-filterbar { grid-column: 1; }
  .dm-filter-row { flex-wrap: wrap; }
  .dm-tagbox { flex: 1 1 45%; }
  .dev-list-col { position: static; max-height: 34vh; }
  .dev3d { height: clamp(200px, 36vh, 320px); }
}

/* undo / redo, icon picker, zone resize handles */
.dg-edit-tools button:disabled { opacity: .4; cursor: default; }
.dg-icon-picker { position: absolute; z-index: 6; top: 8px; left: 60px; width: min(380px, calc(100% - 16px)); max-height: 60%; display: flex; flex-direction: column; border-radius: 14px; background: var(--glass-strong, #fff); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(31, 38, 135, .2); }
.dg-icon-picker[hidden] { display: none; }
.dg-icon-search { flex: 1; min-width: 0; font: inherit; padding: .3rem .5rem; border-radius: 8px; border: 1px solid var(--line); }
.dg-icon-grid { flex: 1; min-height: 0; overflow-y: auto; padding: .5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: .25rem; }
.dg-icon-item { display: grid; place-items: center; height: 40px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.dg-icon-item:hover, .dg-icon-item:focus-visible { background: var(--bg, #e2e8f0); border-color: var(--primary); }
.dg-icon-info { margin: 0; padding: .3rem .6rem; }
/* PC: compact controls on the one row (sideways scroll only as a last resort); tighter still up to 1400px (1280 / 1366 wide) */
@media (min-width: 701px) {
  .dg-edit-tools { flex-wrap: nowrap; overflow-x: auto; gap: .25rem; }
  .dg-edit-tools .btn.small, .dg-tiers .btn.small, .dg-zoom .btn.small { min-height: 28px; padding: .1rem .5rem; font-size: .8rem; }
  .dg-edit-tools [data-act=dg-undo], .dg-edit-tools [data-act=dg-redo] { min-width: 28px; padding: .1rem .35rem; }
  .dg-edit-tools .dg-sel { max-width: 6.5rem; font-size: .8rem; padding: .1rem .3rem; }
}
@media (min-width: 701px) and (max-width: 1400px) {
  .dg-tools { padding: 6px 10px; gap: .3rem; }
  .dg-edit-tools { gap: .15rem; padding: .2rem .3rem; }
  .dg-zoom { gap: .15rem; padding: .2rem .3rem; }
  .dg-edit-tools .btn.small, .dg-tiers .btn.small, .dg-zoom .btn.small { padding: .1rem .35rem; }
  .dg-edit-tools .dg-sel { max-width: 5.5rem; }
}
/* phone / tablet: the edit tools take their own row under tiers + zoom and scroll sideways */
@media (max-width: 1199px) {
  .dg-tools { flex-wrap: wrap; }
  .dg-tools > .dg-edit-tools { order: 3; flex: 1 0 100%; max-width: 100%; }
  .dg-edit-tools > .dg-hint { display: none; }
}

/* v21.10: pipeline items work like tasks — done circle toggle, compact start → end dates, alarm when overdue / due today. */
.lc-item { display: flex; flex-wrap: wrap; align-items: center; }
.lc-item .lc-item-btn { flex: 1 1 0; width: auto; min-width: 0; }
.lc-toggle { flex: none; display: inline-flex; align-items: center; justify-content: center; padding: .3rem .5rem .3rem 0; margin: 0; border: 0; background: transparent; line-height: 0; }
button.lc-toggle { cursor: pointer; }
button.lc-toggle:hover .lc-check circle { stroke: var(--primary); }
button.lc-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; border-radius: 50%; }
.lc-due-badge { flex: none; font-size: .7rem; line-height: 1; padding: .2rem .4rem; border-radius: 999px; background: rgba(220, 38, 38, .16); color: #b91c1c; font-weight: 700; white-space: nowrap; }
.lc-due-badge.today { background: rgba(245, 158, 11, .2); color: #b45309; }
.lc-due-badge[hidden] { display: none; }
.lc-item.overdue { border-color: #dc2626; background: rgba(254, 226, 226, .85); }
.lc-item.due-today { border-color: #f59e0b; background: rgba(254, 243, 199, .7); }
.lc-late-count { flex: none; font-size: .72rem; font-weight: 700; padding: .1rem .4rem; border-radius: 999px; background: rgba(220, 38, 38, .16); color: #b91c1c; }
.lc-late-count[hidden] { display: none; }
.lc-dates-sep::before { content: '→'; }

/* v22: modes per package — "Số mode" + names in the create form, the modes list of the header Sửa form */
.mode-pick { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.mode-pick .mode-count { width: 4.2rem; }
.mode-names { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.mode-names .mode-name { width: 8.5rem; }
.mode-edit { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.mode-list { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: .3rem; }
.mode-row { display: flex; align-items: center; gap: .3rem; }
.mode-row .mode-name { width: 14rem; max-width: 60vw; }
.mode-row .mode-key { min-width: 4.5rem; font-family: ui-monospace, monospace; }
.add-pkg .mode-pick { grid-column: 1 / -1; order: 9; }

/* v22: popup Tính năng — "Kế thừa từ <mode trước>" (chỉ xem, thu gọn) above the editor */
.lc-inherit { margin: 0 0 .6rem; border: 1px dashed var(--border, #cbd5e1); border-radius: 6px; padding: .3rem .6rem; font-size: .85rem; color: var(--muted); }
.lc-inherit summary { cursor: pointer; font-weight: 600; }
.lc-inherit-mode { margin-top: .4rem; }
.lc-inherit ul { margin: .2rem 0 0; padding-left: 1.1rem; }
.lc-inherit-group { font-weight: 600; list-style: none; margin-left: -1.1rem; }

/* ===================== v23: bảng có tiêu đề + dòng nhóm dính khi cuộn (dùng lại được) ==============   .sticky-scroll = vùng cuộn (cả ngang lẫn dọc, cao tối đa = màn hình trừ thanh dính phía trên, --sticky-top do app.js đo);
   .sticky-table = bảng trong đó: thead dính ở đầu vùng cuộn, tr.grp dính ngay dưới (--sticky-head-h), nhóm sau đẩy nhóm
   trước lên (--grp-shift, app.js stickyTable). Nền đặc để chữ bên dưới không lộ qua. Điện thoại: bảng thành thẻ, trang
   tự cuộn — dòng nhóm dính dưới thanh tab, mỗi nhóm một <tbody> nên nhóm sau đẩy nhóm trước. */
:root { --sticky-bg: #f8f9fd; --grp-tint: rgba(99, 102, 241, .1); }
.sticky-scroll { overflow: auto; max-height: calc(100vh - var(--sticky-top, 0px) - 24px); max-height: calc(100dvh - var(--sticky-top, 0px) - 24px); overscroll-behavior-x: contain; }
.sticky-table thead th { position: sticky; top: 0; z-index: 6; background: var(--sticky-bg); }
.sticky-table tr.grp > td, .sticky-table tr.grp:hover > td { position: sticky; top: calc(var(--sticky-head-h, 0px) + var(--grp-shift, 0px)); z-index: 5; background: linear-gradient(var(--grp-tint), var(--grp-tint)), var(--sticky-bg); }
.sticky-table tr.grp .grp-label { position: sticky; left: .75rem; display: inline-block; }
/* Cuộn bằng cả trang (không có vùng cuộn dọc riêng): tiêu đề / dòng nhóm dời bằng transform xuống ngay dưới thanh dính (app.js stickyTable) */
.sticky-page { overflow-x: auto; overscroll-behavior-x: contain; }
.sticky-page .sticky-table thead th { position: relative; z-index: 6; background: var(--sticky-bg); transform: translateY(var(--head-shift, 0px)); box-shadow: 0 1px 0 rgba(148, 163, 184, .4); }
.sticky-page .sticky-table tr.grp > td, .sticky-page .sticky-table tr.grp:hover > td { position: relative; top: auto; z-index: 5; transform: translateY(var(--grp-shift, 0px)); background: linear-gradient(var(--grp-tint), var(--grp-tint)), var(--sticky-bg); }
@media (max-width: 640px) {
  .sticky-page { overflow: visible; }
  .sticky-page .sticky-table tr.grp > td, .sticky-page .sticky-table tr.grp:hover > td { position: static; transform: none; background: transparent; }
  .sticky-scroll { max-height: none; overflow: visible; }
  .sticky-table tr.grp > td { position: static; background: transparent; }
  .sticky-table tr.grp { position: sticky; top: var(--sticky-top, 0px); z-index: 5; background: linear-gradient(var(--grp-tint), var(--grp-tint)), var(--sticky-bg); }
  .sticky-table tr.grp .grp-label { position: static; }
}

/* v21.93 — Timeline: vùng cuộn sticky-scroll (max-height viewport) → thanh kéo ngang luôn ở đáy khung nhìn;
   cột Chi tiết sticky-left; thead/ngày sticky-top; chừa chỗ nút Lưu cố định. */
.tl-card.sticky-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  min-width: 0;
  max-width: 100%;
  /* mặc định .sticky-scroll đã trừ --sticky-top; thêm chừa đáy cho thanh cuộn khỏi nút Lưu */
  max-height: calc(100vh - var(--sticky-top, 0px) - 24px);
  max-height: calc(100dvh - var(--sticky-top, 0px) - 24px);
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}
#view:has(.save-bar) .tl-card.sticky-scroll {
  max-height: calc(100vh - var(--sticky-top, 0px) - 5.5rem);
  max-height: calc(100dvh - var(--sticky-top, 0px) - 5.5rem);
}
.tl-card.sticky-scroll .tl-table thead th:first-child,
.tl-card.sticky-scroll .tl-table tbody td.col-task {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--sticky-bg);
  box-shadow: 1px 0 0 rgba(148, 163, 184, .45);
}
.tl-card.sticky-scroll .tl-table thead th:first-child {
  top: 0; /* sticky top + left góc */
  z-index: 8; /* above other sticky thead cells + body sticky col */
}
.tl-card.sticky-scroll .tl-table tbody tr.tl-row:hover td.col-task {
  background: var(--sticky-bg);
}
.tl-card.sticky-scroll .tl-table tbody tr.edited td.col-task {
  background: color-mix(in srgb, rgba(99, 102, 241, .08) 100%, var(--sticky-bg));
  background: linear-gradient(rgba(99, 102, 241, .05), rgba(99, 102, 241, .05)), var(--sticky-bg);
}
.tl-card.sticky-scroll .tl-table tbody tr.tl-row.tl-st-done td.col-task {
  box-shadow: inset 3px 0 0 #7cb86a, 1px 0 0 rgba(148, 163, 184, .45);
}
.tl-card.sticky-scroll .tl-table tbody tr.tl-row.tl-st-doing td.col-task {
  box-shadow: inset 3px 0 0 #e0b400, 1px 0 0 rgba(148, 163, 184, .45);
}
/* Group label already sticky-left; keep opaque while H-scrolling */
.tl-card.sticky-scroll .tl-table tr.grp .grp-label {
  position: sticky;
  left: .75rem;
  z-index: 3;
  background: linear-gradient(var(--grp-tint), var(--grp-tint)), var(--sticky-bg);
  padding-right: .35rem;
}
/* Desktop: never let a wide timeline leak page-level H-scroll */
html { overflow-x: clip; }

@media (max-width: 640px) {
  /* Điện thoại: trả về cuộn trang (đã có rule .sticky-scroll { max-height:none } ở trên) */
  #view:has(.save-bar) .tl-card.sticky-scroll {
    max-height: none;
  }
}

/* v21.95 — Timeline: chỉ cột Lịch cuộn ngang (1/2 bề rộng vùng lịch cũ); trái + Ghi chú đứng yên;
   thanh kéo ngang luôn ở đáy card (ngoài vùng cuộn dọc); Hôm nay kéo vào giữa lúc mở. */
.tl-card.tl-freeze-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  padding-bottom: 0;
  max-width: 100%;
  min-width: 0;
}
.tl-freeze-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  max-height: none !important; /* height comes from flex parent */
}
.tl-freeze-body .tl-table.tl-freeze { width: auto; max-width: 100%; }
.tl-table.tl-freeze {
  min-width: 0 !important;
  width: auto;
  max-width: 100%;
  table-layout: fixed;
}
.tl-table.tl-freeze th:nth-child(1),
.tl-table.tl-freeze td.col-task { width: var(--tl-task-w, 280px); min-width: 0; max-width: var(--tl-task-w, 280px); }
.tl-table.tl-freeze th:nth-child(2),
.tl-table.tl-freeze td:nth-child(2) { width: 140px; min-width: 140px; max-width: 140px; }
.tl-table.tl-freeze th:nth-child(3),
.tl-table.tl-freeze td:nth-child(3) { width: 132px; min-width: 132px; max-width: 132px; }
.tl-table.tl-freeze th:nth-child(4),
.tl-table.tl-freeze td:nth-child(4),
.tl-table.tl-freeze th:nth-child(5),
.tl-table.tl-freeze td:nth-child(5) { width: 128px; min-width: 128px; max-width: 128px; }
.tl-table.tl-freeze th:nth-child(7),
.tl-table.tl-freeze td.col-note {
  width: var(--tl-note-w, 60px);
  min-width: 0;
  max-width: var(--tl-note-w, 60px);
  overflow: hidden;
}
.tl-table.tl-freeze th.col-gantt,
.tl-table.tl-freeze td.col-gantt {
  width: var(--tl-cal-w, 280px);
  max-width: var(--tl-cal-w, 280px);
  min-width: 0 !important;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  vertical-align: top;
}
.tl-cal-label { display: none !important; } /* v22.00: drop Lịch strip above axis */
.tl-cal-view {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  min-height: 2.4rem;
  contain: layout paint;
}
.tl-table.tl-freeze .tl-cal-view > .tl-axis,
.tl-table.tl-freeze .tl-cal-view > .tl-gantt {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--tl-days) * var(--tl-day, 34px));
  min-width: calc(var(--tl-days) * var(--tl-day, 34px));
  max-width: none;
  transform: translateX(calc(-1 * var(--tl-cal-x, 0px)));
  will-change: transform;
}
.tl-table.tl-freeze thead .tl-cal-view { min-height: 3.1rem; }
.tl-table.tl-freeze td.col-gantt .tl-cal-view { min-height: 2.2rem; height: 100%; }
.tl-cal-hbar {
  flex: none;
  z-index: 9;
  height: 14px;
  margin-left: var(--tl-left-w, 0px);
  width: var(--tl-cal-w, 280px);
  max-width: var(--tl-cal-w, 280px);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--sticky-bg, #f8f9fd);
  border-top: 1px solid rgba(148, 163, 184, .45);
  scrollbar-width: thin;
  box-shadow: 0 -1px 0 rgba(148, 163, 184, .25);
}
.tl-cal-hbar-inner { height: 1px; pointer-events: none; }
/* Keep Chi tiết sticky-left rules harmless under overflow-x:hidden; drop whole-table H intent */
.tl-freeze-card .tl-table thead th:first-child,
.tl-freeze-card .tl-table tbody td.col-task {
  position: sticky;
  left: auto;
  top: auto;
  box-shadow: none;
  background: var(--sticky-bg);
}
.tl-freeze-card .tl-table thead th:first-child {
  /* keep corner sticky-top from .sticky-table thead th */
  position: sticky;
  top: 0;
  z-index: 8;
}
.tl-freeze-card .tl-table tbody tr.tl-row.tl-st-done td.col-task {
  box-shadow: inset 3px 0 0 #7cb86a;
}
.tl-freeze-card .tl-table tbody tr.tl-row.tl-st-doing td.col-task {
  box-shadow: inset 3px 0 0 #e0b400;
}
@media (max-width: 640px) {
  .tl-table.tl-freeze th.col-gantt,
  .tl-table.tl-freeze td.col-gantt { max-width: none; width: auto; }
  .tl-cal-hbar { display: none; }
  .tl-table.tl-freeze .tl-axis,
  .tl-table.tl-freeze .tl-gantt { transform: none; width: calc(var(--tl-days) * var(--tl-day, 34px)); }
  .tl-cal-view { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}



/* ---- v25: popup "Chi phí / giá vốn / ROI" — tab theo mode, nhóm chi phí, mỗi dòng: tên · SL · đơn giá · thành tiền (khoảng VND).
   Desktop 85vw × 80vh như popup Thiết bị; ≤ 768px 95% và mỗi dòng thành một thẻ (số liệu xuống dòng dưới tên). ---- */
.modal.cost-popup .modal-body { padding-left: 48px; padding-right: 48px; background: #f8fafc; }
.cost-pop { display: flex; flex-direction: column; gap: .8rem; color: var(--text); }
.cost-sheet { display: flex; flex-direction: column; gap: .7rem; }
.cost-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: .3rem .8rem; padding: .7rem .9rem; border-radius: 12px; background: #fff; border: 1px solid #c7d2fe; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.cost-total-v { font-size: 1.2rem; color: var(--primary-ink); font-variant-numeric: tabular-nums; }
.cost-head, .cost-item { display: grid; grid-template-columns: minmax(0, 1fr) 4rem 12rem 12rem auto; gap: .3rem .8rem; align-items: center; }
.cost-head { padding: 0 .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: .72rem; }
.cost-head span:nth-child(n+2), .cost-qty, .cost-unit, .cost-line { text-align: right; font-variant-numeric: tabular-nums; }
.cost-group { display: flex; flex-direction: column; gap: .35rem; }
.cost-group-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.cost-group-title { margin: 0; padding-left: 8px; border-left: 3px solid #6366f1; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); }
.cost-group[data-group=nhan-dien] .cost-group-title { border-left-color: #0891b2; }
.cost-group[data-group=dieu-khien] .cost-group-title { border-left-color: #d97706; }
.cost-group[data-group=quan-ly] .cost-group-title { border-left-color: #db2777; }
.cost-group[data-group=theo-doi] .cost-group-title { border-left-color: #dc2626; }
.cost-gtotal { font-weight: 600; font-size: .88rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cost-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cost-item { padding: .5rem .75rem; border-radius: 10px; background: #fff; border: 1px solid #e2e8f0; }
.cost-item.no-price .cost-unit { color: var(--muted); font-style: italic; }
.cost-item.editing { display: block; border-color: #a5b4fc; }
.cost-name { display: flex; flex-direction: column; gap: .1rem; min-width: 0; overflow-wrap: anywhere; }
.cost-src a { color: var(--primary-ink); }
.cost-line { font-weight: 600; }
.cost-tools { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.cost-empty { margin: 0; padding: .45rem .75rem; border: 1px dashed #cbd5e1; border-radius: 10px; background: #fff; }
.cost-add { align-self: flex-start; }
.cost-form { display: flex; flex-direction: column; gap: .5rem; padding: .6rem .75rem; border-radius: 10px; background: #fff; border: 1px solid #a5b4fc; }
.cost-item.editing .cost-form { padding: 0; border: 0; }
.cost-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; }
.cost-form input.ed, .cost-form textarea.ed { width: 100%; box-sizing: border-box; background: #fff; }
.cost-form-acts { display: flex; gap: .4rem; }
.cost-note-field textarea { width: 100%; box-sizing: border-box; }
@media (max-width: 900px) {
  .cost-head { display: none; }
  .cost-item { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "name name name" "qty unit line" "tools tools tools"; }
  .cost-name { grid-area: name; }
  .cost-qty { grid-area: qty; text-align: left; }
  .cost-unit { grid-area: unit; }
  .cost-line { grid-area: line; }
  .cost-tools { grid-area: tools; justify-content: flex-start; }
}
@media (max-width: 768px) {
  .modal.cost-popup { width: 95vw; height: 95vh; }
  .modal.cost-popup .modal-body { padding-left: 12px; padding-right: 12px; }
}

/* v26 — alternative boxes on one node: only the default counts, the others are dimmed */
.cost-alt { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem .6rem; }
.cost-alt-pick { white-space: nowrap; display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; color: var(--primary-ink); cursor: pointer; min-height: 28px; }
.cost-alt-static { cursor: default; }
.cost-alt-tag { font-style: italic; color: var(--muted); }
.cost-item.cost-alt-off { opacity: .6; background: #f8fafc; border-style: dashed; }
.cost-item.cost-alt-off .cost-line { text-decoration: line-through; }

/* v27 — component palette of the Mô hình editor (edit mode): left sidebar on desktop, bottom sheet on phones (≤ 700px); the canvas shrinks
   beside / above it so nothing is covered. Link colours by type (edge.type). */
.dg-node.is-main .dg-box { stroke-width: 2.6; }
.dg-edge[data-type=door]:not(.sel) .dg-line { stroke: #2e8b6a; }
.dg-edge[data-type=lan]:not(.sel) .dg-line { stroke: #3b6fd8; }
.dg-edge[data-type=cloud]:not(.sel) .dg-line { stroke: #8b5cf6; }
.dg-edge[data-type=other]:not(.sel) .dg-line { stroke: #94a3b8; }
.dg-pal { position: absolute; z-index: 4; left: 0; top: 0; bottom: 0; width: 232px; display: flex; flex-direction: column; min-height: 0; background: var(--glass-strong, #fff); border-right: 1px solid var(--line); }
.dg-pal[hidden] { display: none; }
.dg-stage.pal-open > .dg-svg { left: 232px; width: calc(100% - 232px); }
.dg-stage.pal-open > .dg-legend, .dg-stage.pal-open > .dg-icon-picker { left: 244px; }
.dg-pal-head { flex: none; display: flex; align-items: center; gap: .4rem; padding: .5rem .6rem .3rem; }
.dg-pal-head strong { flex: 1; font-size: .9rem; }
.dg-pal-search { flex: none; box-sizing: border-box; width: calc(100% - 1.2rem); margin: 0 .6rem .4rem; font: inherit; font-size: .85rem; padding: .3rem .5rem; border-radius: 8px; border: 1px solid var(--line); min-width: 0; }
.dg-pal-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 .6rem .6rem; display: grid; gap: .5rem; align-content: start; }
.dg-pal-group { display: grid; gap: .25rem; }
.dg-pal-group h5 { margin: .2rem 0 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2, #475569); }
.dg-pal-item { display: flex; align-items: center; gap: .45rem; min-width: 0; padding: .3rem .45rem; border: 1.5px solid #1d9e75; border-radius: 10px; background: #fff; color: var(--text); font: inherit; font-size: .82rem; font-weight: 600; text-align: left; cursor: grab; touch-action: manipulation; }
.dg-pal-item.net { border-color: #8b5cf6; }
.dg-pal-item.k-person { border-color: var(--dg-other, #475569); }
.dg-pal-item.k-zone { border: 2px dashed var(--tc, #475569); color: var(--tc, #475569); background: color-mix(in srgb, var(--tc, #475569) 8%, #fff); }
.dg-pal-item:hover, .dg-pal-item:focus-visible { box-shadow: 0 0 0 2px var(--ring, #93c5fd); outline: none; }
.dg-pal-ic { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #e1f5ee; color: #0f6e56; }
.dg-pal-item.net .dg-pal-ic { background: #ede9fe; color: #6d28d9; }
.dg-pal-item.k-zone .dg-pal-ic { background: transparent; color: inherit; }
.dg-pal-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-pal-empty { margin: .4rem 0; }
.dg-pal-fab { position: absolute; z-index: 3; left: 8px; bottom: 44px; box-shadow: 0 2px 8px rgba(31, 38, 135, .18); }
.dg-pal-fab[hidden] { display: none; }
.is-edit .dg-legend .dg-chip { pointer-events: auto; cursor: pointer; font: inherit; font-size: .75rem; font-weight: 600; }
.dg-legend .dg-chip.on { background: currentColor; }
.dg-legend .dg-chip.on { color: #fff; }
.is-edit .dg-legend .dg-chip.on.g-door { background: #2e8b6a; border-color: #2e8b6a; }
.is-edit .dg-legend .dg-chip.on.g-lan { background: #3b6fd8; border-color: #3b6fd8; }
.is-edit .dg-legend .dg-chip.on.g-cloud { background: #8b5cf6; border-color: #8b5cf6; }
.is-edit .dg-legend .dg-chip.on.g-other { background: #94a3b8; border-color: #94a3b8; }
.dg-legend .dg-chip:focus-visible { outline: 2px solid var(--ring, #93c5fd); outline-offset: 1px; }
@media (max-width: 700px) {
  .dg-pal { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 46%; border-right: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgba(31, 38, 135, .12); }
  .dg-stage.pal-open > .dg-svg { left: 0; width: 100%; height: 54%; }
  .dg-stage.pal-open > .dg-legend { display: none; }
  .dg-stage.pal-open > .dg-icon-picker { left: 8px; }
  .dg-pal-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
  .dg-pal-group { display: contents; }
  .dg-pal-group h5 { grid-column: 1 / -1; }
  .dg-pal-item { min-height: 40px; }
}

/* v27 — "Quản lý component" dialog (admin) */
.tpl-mgr { display: grid; gap: .6rem; padding: .8rem 1rem; }
.tpl-row { display: grid; grid-template-columns: 28px minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: .4rem; align-items: center; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, .6); }
.tpl-row.off { opacity: .55; }
.tpl-row .tpl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tpl-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem .7rem; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tpl-form label { display: grid; gap: .15rem; font-size: .8rem; color: var(--text-2, #475569); min-width: 0; }
.tpl-form input, .tpl-form select { font: inherit; font-size: .88rem; padding: .3rem .45rem; border-radius: 8px; border: 1px solid var(--line); min-width: 0; }
.tpl-form .full { grid-column: 1 / -1; }
.tpl-form .tpl-checks { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
@media (max-width: 700px) {
  .tpl-row { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .tpl-row .tpl-cat { display: none; }
  .tpl-form { grid-template-columns: minmax(0, 1fr); }
}

.lc-item.lc-important { background: rgba(34, 197, 94, .22); border-color: rgba(22, 163, 74, .55); }
/* v21.24 — Sản phẩm popup: aligned catalog | package headers; right list by device kind */
.cost-split { display: grid; grid-template-columns: minmax(15rem, 40%) 1fr; gap: .85rem; align-items: start; }
.cost-right { display: flex; flex-direction: column; gap: .55rem; min-width: 0; background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:.6rem; max-height:min(68vh,640px); overflow:auto; }
.cost-catalog-head, .cost-sheet-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .55rem;
  min-height: 44px; box-sizing: border-box;
  padding-bottom: .45rem; margin-bottom: .15rem;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.cost-catalog-head { position: sticky; top: 0; z-index: 2; }
/* v21.29: builder head is NOT sticky — sticky + taller 2-row head overlapped Tổng chi phí */
.cost-sheet-head.cost-builder-head { position: static; z-index: auto; }
.cost-mode-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; flex: 0 1 auto; min-width: 0; }
.cost-mode-tab { font: inherit; font-size: .88rem; font-weight: 600; padding: .35rem .85rem; border-radius: 999px; border: 1px solid #86efac; background: #f0fdf4; color: #166534; cursor: pointer; min-height: 36px; }
.cost-mode-tab:hover, .cost-mode-tab:focus-visible { outline: 2px solid #4ade80; outline-offset: 1px; }
.cost-mode-tab.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.cost-mode-add { font: inherit; font-size: 1.15rem; font-weight: 700; line-height: 1; width: 36px; height: 36px; padding: 0; border-radius: 10px; border: 1px dashed #86efac; background: #f0fdf4; color: #166534; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.cost-mode-add:hover, .cost-mode-add:focus-visible { outline: 2px solid #4ade80; outline-offset: 1px; background: #dcfce7; }
.cost-mode-add:disabled { opacity: .45; cursor: not-allowed; }
.cost-catalog { background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:.6rem; max-height:min(68vh,640px); overflow:auto; display:flex; flex-direction:column; gap:.55rem; }
.cost-catalog-head .cost-catalog-search { flex:1 1 8rem; min-width:0; }
.cost-group .cost-cat-group-title, .cost-group-title.cost-cat-group-title {
  margin: .15rem 0 0; padding: .2rem .45rem; border-left: 3px solid #6366f1; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); background: #f1f5f9; border-radius: 0 6px 6px 0;
}
.cost-group[data-group=box] .cost-cat-group-title { border-left-color: #0891b2; }
.cost-group[data-group=dau-doc] .cost-cat-group-title { border-left-color: #0d9488; }
.cost-group[data-group=server] .cost-cat-group-title { border-left-color: #db2777; }
.cost-group[data-group=chot] .cost-cat-group-title, .cost-group[data-group=khoa] .cost-cat-group-title, .cost-group[data-group=nut] .cost-cat-group-title { border-left-color: #d97706; }
.cost-group[data-group=camera] .cost-cat-group-title { border-left-color: #dc2626; }
.cost-cat-group { display:flex; flex-direction:column; gap:.4rem; }
.cost-cat-group-title { margin: .15rem 0 0; padding: .2rem .45rem; border-left: 3px solid #6366f1; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); background: #f1f5f9; border-radius: 0 6px 6px 0; }
.cost-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .45rem; }
.cost-cat-tile { display:flex; flex-direction:column; gap:.3rem; padding:.4rem; border:1px solid #e2e8f0; border-radius:10px; background:#fafafa; min-width:0; }
.cost-cat-tile.is-pick { cursor:grab; touch-action:manipulation; }
.cost-cat-tile.is-pick:hover, .cost-cat-tile.is-pick:focus-visible { border-color:#22c55e; box-shadow:0 0 0 2px rgba(34,197,94,.25); outline:none; }
.cost-cat-img, .cost-cat-ph { width:100%; aspect-ratio:1; object-fit:contain; border-radius:8px; background:#eef2ff; display:grid; place-items:center; color:#6366f1; }
.cost-cat-img { display:block; }
.cost-cat-ph .ic { width:1.6rem; height:1.6rem; }
.cost-cat-meta { display:flex; flex-direction:column; gap:.1rem; min-width:0; }
.cost-cat-name { font-size:.78rem; font-weight:600; line-height:1.25; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.cost-cat-price { font-size:.72rem; color:var(--primary-ink); font-variant-numeric:tabular-nums; font-weight:600; }
.cost-drop { border:2px dashed #a5b4fc; border-radius:12px; padding:1rem; text-align:center; }
.cost-drop.over { border-color:#22c55e; background:rgba(34,197,94,.1); }
@media(max-width:720px){
  .cost-split{grid-template-columns:1fr}
  /* Package list first on phones so the total sits above the nav bar; catalog below. */
  .cost-right{order:-1; max-height:min(48vh,420px)}
  .cost-catalog{max-height:min(38vh,320px)}
  .cost-cat-grid{grid-template-columns:repeat(auto-fill,minmax(6.5rem,1fr))}
}

/* ---- v21.23 / v30: tasklist in generic lifecycle Nội dung popup ---- */
.task-list-wrap { display: flex; flex-direction: column; gap: .55rem; }
.task-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.task-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .55rem .7rem; align-items: start; padding: .55rem .7rem; border-radius: 10px; background: #fff; border: 1px solid #e2e8f0; }
.task-item.editing { grid-template-columns: auto minmax(0, 1fr) auto; border-color: #a5b4fc; }
.task-status { font: inherit; font-size: .72rem; font-weight: 700; padding: .25rem .55rem; border-radius: 999px; border: 1px solid transparent; min-height: 28px; white-space: nowrap; cursor: default; }
.task-status:not(:disabled) { cursor: pointer; }
.task-status:not(:disabled):hover, .task-status:not(:disabled):focus-visible { outline: 2px solid var(--ring, #93c5fd); outline-offset: 1px; }
.task-status.st-chua_lam { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.task-status.st-dang_lam { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.task-status.st-xong { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.task-body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.task-title { font-size: .92rem; overflow-wrap: anywhere; }
.task-meta { overflow-wrap: anywhere; }
.task-fields { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }
.task-meta-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .4rem; }
.task-add { align-self: flex-start; }
.task-empty { margin: 0; padding: .5rem .7rem; border: 1px dashed #cbd5e1; border-radius: 10px; background: #fff; }
.task-backup { margin-top: .2rem; }
.task-backup-pre { margin: .35rem 0 0; padding: .55rem .7rem; max-height: 10rem; overflow: auto; font-size: .78rem; white-space: pre-wrap; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
@media (max-width: 720px) {
  .task-item.editing { grid-template-columns: minmax(0, 1fr); }
  .task-item.editing .task-del { justify-self: start; }
}


/* View toggle: thumbnail tiles vs compact grid/table (both catalog + package list) */
.cost-view-toggle { display: inline-flex; gap: 2px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 2px; background: #f8fafc; }
.cost-view-btn { display: grid; place-items: center; width: 32px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: #64748b; cursor: pointer; padding: 0; }
.cost-view-btn.on { background: #fff; color: #166534; box-shadow: 0 1px 2px rgba(15,23,42,.08); }
.cost-view-btn:hover, .cost-view-btn:focus-visible { outline: 2px solid #86efac; outline-offset: 0; }
.cost-catalog-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .55rem; }
.cost-catalog-head .cost-catalog-search { flex: 1 1 8rem; min-width: 0; }
.cost-cat-table { display: flex; flex-direction: column; gap: 2px; }
.cost-cat-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: .4rem; align-items: center; padding: .35rem .45rem; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; min-width: 0; }
.cost-cat-row.is-pick { cursor: grab; touch-action: manipulation; }
.cost-cat-row.is-pick:hover, .cost-cat-row.is-pick:focus-visible { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.2); outline: none; }
.cost-cat-row-ph { width: 28px; height: 28px; border-radius: 6px; background: #eef2ff; display: grid; place-items: center; overflow: hidden; color: #6366f1; }
.cost-cat-row-ph img { width: 100%; height: 100%; object-fit: cover; }
.cost-sheet-toolbar { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; }
.cost-sheet-toolbar .cost-total { flex: 1 1 14rem; }
.cost-sheet { display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.cost-right .cost-sheet { flex: 1 1 auto; }
.cost-item.view-thumb { grid-template-columns: 48px minmax(0, 1fr) 4rem 12rem 12rem auto; }
.cost-item-thumb { width: 48px; height: 48px; border-radius: 8px; background: #eef2ff; display: grid; place-items: center; overflow: hidden; color: #6366f1; }
.cost-item-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cost-sheet[data-view=thumb] .cost-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem; }
.cost-sheet[data-view=thumb] .cost-item.view-thumb { grid-template-columns: 1fr; justify-items: start; }
.cost-sheet[data-view=thumb] .cost-item-thumb { width: 100%; aspect-ratio: 1; height: auto; }
.cost-sheet[data-view=thumb] .cost-qty, .cost-sheet[data-view=thumb] .cost-unit, .cost-sheet[data-view=thumb] .cost-line { text-align: left; }
@media (max-width: 900px) {
  .cost-item.view-thumb { grid-template-columns: 40px auto minmax(0, 1fr); grid-template-areas: "thumb name name" "thumb qty unit" "line line line" "tools tools tools"; }
  .cost-item.view-thumb .cost-item-thumb { grid-area: thumb; }
  .cost-item.view-thumb .cost-name { grid-area: name; }
}
.lc-rename-input { flex: 1; min-width: 0; font: inherit; font-weight: 600; padding: .25rem .45rem; border: 1px solid #a5b4fc; border-radius: 8px; background: #fff; }
.lc-item:has(.lc-rename-input) .lc-item-btn[hidden] { display: none; }

/* v21.25 — package tiles match catalog tile size; qty stepper + remove */
.cost-pkg-grid { margin-top: .25rem; }
.cost-pkg-tile { position: relative; }
.cost-pkg-tile .cost-pkg-rm {
  position: absolute; top: 4px; right: 4px; z-index: 2;
  width: 22px; height: 22px; border-radius: 999px; border: 1px solid #fecaca;
  background: #fff; color: #b91c1c; font-size: 14px; font-weight: 700; line-height: 1;
  display: grid; place-items: center; padding: 0; cursor: pointer;
}
.cost-pkg-tile .cost-pkg-rm:hover, .cost-pkg-rm:focus-visible { background: #fef2f2; outline: 2px solid #fca5a5; outline-offset: 1px; }
.cost-pkg-rm.inline { width: 28px; height: 28px; border-radius: 8px; border: 1px solid #fecaca; background: #fff; color: #b91c1c; font-weight: 700; cursor: pointer; }
.cost-pkg-qty { display: inline-flex; align-items: center; gap: 2px; margin-top: 2px; }
.cost-pkg-qty-btn {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff;
  color: #334155; font-size: 14px; font-weight: 700; line-height: 1; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.cost-pkg-qty-btn:hover, .cost-pkg-qty-btn:focus-visible { border-color: #86efac; outline: 2px solid #86efac; outline-offset: 0; }
.cost-pkg-qty-v { font-size: .72rem; font-weight: 600; min-width: 1.6rem; text-align: center; font-variant-numeric: tabular-nums; }
.cost-pkg-tile.no-price .cost-cat-price, .cost-pkg-row.no-price .cost-cat-price { color: var(--muted); font-style: italic; }
.cost-pkg-table .cost-cat-row { grid-template-columns: 28px minmax(0, 1fr) auto auto auto; }
.cost-sheet .cost-drop { margin: .35rem 0; min-height: 4.5rem; display: grid; place-items: center; color: #64748b; font-size: .9rem; }
.cost-sheet .cost-drop.has-items { place-items: stretch; justify-items: stretch; text-align: left; align-content: start; }
.cost-pkg-tile.editing, .cost-pkg-row.editing { grid-column: 1 / -1; display: block; border-color: #a5b4fc; background: #fff; padding: .55rem; }


/* v21.28 — sample product builder: header align + product CRUD, flow tiles, preview */
/* v21.29 — mode tabs on their own row (no overlap with Tổng chi phí); Preview no longer covers view toggles */
.cost-sheet-head.cost-builder-head {
  display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch;
  gap: .45rem; min-height: 0; position: relative; z-index: 2;
  background: #fff; padding-bottom: .15rem;
}
.cost-builder-head-stack {
  display: flex; flex-direction: column; flex-wrap: nowrap; align-items: stretch;
  gap: .45rem; width: 100%;
}
.cost-builder-bar {
  display:flex; flex-wrap:nowrap; gap:.4rem .5rem; align-items:center; width:100%;
  min-height:36px; position: relative; z-index: 1;
}
.cost-builder-bar [data-act=prod-back] { flex:0 0 auto; white-space:nowrap; }
.cost-builder-bar .cost-prod-name-wrap { flex:1 1 auto; min-width:0; max-width:100%; }
.cost-builder-bar .view-toggle, .cost-builder-bar [data-view-toggle] { flex:0 0 auto; }
@media (max-width: 1280px) {
  .cost-builder-bar { flex-wrap: wrap; }
  .cost-builder-modes { margin-top: 0; }
}

.cost-builder-modes {
  display:flex; flex-wrap:wrap; align-items:center; gap:.35rem .45rem; width:100%;
  position: relative; z-index: 0; clear: both;
}
.cost-builder-modes .cost-mode-tabs { flex: 0 1 auto; min-width: 0; display:inline-flex; flex-wrap:wrap; gap:.3rem; }
.cost-warn { color:#b45309 !important; background:#fffbeb; padding:.1rem .4rem; border-radius:6px; font-weight:700; }
.cost-save-warn { color:#92400e; background:#fffbeb; border:1px solid #fcd34d; border-radius:8px; padding:.45rem .65rem; margin:.25rem 0 .5rem; }

.cost-prod-sel { min-width:10rem; max-width:15rem; height:36px; box-sizing:border-box; }
.cost-prod-name-wrap { display:inline-flex; align-items:center; gap:.2rem; flex:1 1 9rem; min-width:7rem; }
.cost-prod-name { flex:1 1 auto; min-width:0; height:36px; box-sizing:border-box; font-weight:650; }
.cost-prod-actions { display:inline-flex; align-items:center; gap:.25rem; flex:0 0 auto; }
.cost-prod-add, .cost-prod-rename, .cost-prod-del {
  width:36px; height:36px; padding:0; display:grid; place-items:center; border-radius:10px; flex:0 0 auto;
}
.cost-prod-add { border:1px dashed #86efac; background:#f0fdf4; color:#166534; }
.cost-prod-add:hover, .cost-prod-add:focus-visible { outline:2px solid #4ade80; outline-offset:1px; background:#dcfce7; }
.cost-prod-rename { border:1px solid #e2e8f0; background:#fff; color:#334155; }
.cost-prod-rename:hover, .cost-prod-rename:focus-visible { border-color:#a5b4fc; outline:2px solid #a5b4fc; outline-offset:1px; color:#1d4ed8; }
.cost-prod-del { border:1px solid #fecaca; background:#fff; color:#b91c1c; }
.cost-prod-del:hover, .cost-prod-del:focus-visible { background:#fef2f2; outline:2px solid #fca5a5; outline-offset:1px; }
.cost-preview-btn { background:#0f172a; color:#fff; border-color:#0f172a; height:36px; flex:0 0 auto; position:static; }
.cost-preview-btn:hover, .cost-preview-btn:focus-visible { filter:brightness(1.08); }
/* no permanent tooltip/pseudo overlay on the preview control */
.cost-preview-btn::before, .cost-preview-btn::after { content: none !important; }
.cost-drop-full { min-height:10rem; position:relative; margin:.45rem 0; width:100%; box-sizing:border-box; }
.cost-drop-full.has-items { min-height:6rem; }
.cost-drop-hint { position:absolute; top:.4rem; right:.55rem; font-size:.68rem; color:#818cf8; background:#eef2ff; padding:.12rem .4rem; border-radius:999px; z-index:1; }
.cost-drop-empty { margin:1.5rem auto; text-align:center; color:#64748b; }
/* start-aligned, fill full width up to the right edge (not centered) */
.cost-pkg-flow {
  display:grid; grid-template-columns:repeat(auto-fill, minmax(7.4rem, 1fr)); gap:.5rem;
  align-content:start; justify-content:start; width:100%; padding:.85rem .15rem .15rem; box-sizing:border-box;
}
.cost-pkg-flow .cost-pkg-tile { width:auto; min-width:0; }
.cost-pkg-kind {
  font-size:.62rem; font-weight:700; letter-spacing:.03em; text-transform:uppercase;
  color:#1d4ed8; background:#eff6ff; border-radius:4px; padding:.1rem .3rem; align-self:flex-start;
}
.cost-pkg-move {
  margin-top:.15rem; border:1px solid #e2e8f0; background:#fff; border-radius:6px; font-size:.65rem;
  color:#475569; padding:.15rem .3rem; cursor:pointer; width:100%;
}
.cost-pkg-move:hover { border-color:#86efac; background:#f0fdf4; color:#166534; }
.cost-bucket { text-align:left; }
.cost-bucket-head {
  display:flex; justify-content:space-between; align-items:baseline; gap:.5rem;
  padding:.15rem .1rem .35rem; border-bottom:1px solid #e2e8f0; margin-bottom:.15rem;
}
.cost-bucket-title { font-size:.85rem; color:#0f172a; }
.cost-bucket-total { font-size:.78rem; color:#334155; font-weight:650; }
.cost-bucket[data-bucket=core] { border-color:#86efac; background:rgba(240,253,244,.45); }
.cost-bucket[data-bucket=addons] { border-color:#a5b4fc; }

/* Preview: large nested dialog so X6 has room; sits above the builder modal */
.modal-layer:has(.prod-preview-popup) { z-index: 88; }
.modal.prod-preview-popup {
  width: min(96vw, 1180px); height: min(92vh, 780px); max-width: none;
}
.prod-preview-popup .modal-body { padding:0; overflow:hidden; display:flex; flex:1 1 auto; min-height:0; }
.prod-preview-wrap { display:grid; grid-template-columns:1fr minmax(12rem,16rem); flex:1; min-height:0; width:100%; }
.prod-preview-host { min-height:0; height:100%; background:#f1f5f9; position:relative; }
.prod-preview-host .dg-root, .prod-preview-host > div { height:100%; min-height:min(70vh,640px); }
.prod-preview-legend { border-left:1px solid #e2e8f0; padding:.75rem; background:#fff; font-size:.82rem; overflow:auto; }
.prod-preview-legend ul { margin:.4rem 0; padding-left:1.1rem; }
.prod-preview-legend li { margin:.2rem 0; }
@media (max-width: 768px) {
  .prod-preview-wrap { grid-template-columns:1fr; }
  .prod-preview-legend { border-left:0; border-top:1px solid #e2e8f0; max-height:30vh; }
  .modal.prod-preview-popup { width:95vw; height:95vh; }
}


/* v21.30 — package list + diagram slots + pricing */
.cost-empty-list { border:2px dashed #cbd5e1; border-radius:14px; padding:2rem 1.2rem; text-align:center; color:#64748b; background:#f8fafc; }
.cost-empty-list strong { display:block; color:#0f172a; font-size:1rem; margin-bottom:.35rem; }
.cost-mode-pick { display:flex; flex-direction:column; gap:.5rem; margin-top:.5rem; }
.cost-mode-pick-btn { width:100%; justify-content:flex-start; text-align:left; }
.cost-mode-pick-btn.on { box-shadow:0 0 0 2px #2563eb55; }

.cost-pkg-list { display:flex; flex-direction:column; gap:.55rem; }
.cost-pkg-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.55rem; align-items:center; padding:.75rem .9rem; border:1px solid #e2e8f0; border-radius:12px; background:#fff; }
.cost-pkg-row-acts { display:flex; gap:.35rem; }
.cost-slot-sec { margin:.35rem 0; }
.cost-slot-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(8.5rem,1fr)); gap:.55rem; padding:.35rem 0 .15rem; }
.cost-slot { position:relative; border:1.5px dashed #94a3b8; border-radius:10px; padding:.65rem .55rem; min-height:6.5rem; background:#fff; display:flex; flex-direction:column; gap:.2rem; }
.cost-slot.filled { border-style:solid; border-color:#86efac; background:#f0fdf4; }
.cost-slot.over { border-color:#22c55e; background:rgba(34,197,94,.12); }
.cost-slot-tag { align-self:flex-start; font-size:.62rem; font-weight:800; letter-spacing:.03em; text-transform:uppercase; padding:.1rem .35rem; border-radius:4px; }
.cost-slot-tag.req { background:#ecfdf5; color:#047857; }
.cost-slot-tag.add { background:#eff6ff; color:#1d4ed8; }
.cost-slot-lab { font-size:.78rem; font-weight:700; }
.cost-slot-dev { font-size:.72rem; font-weight:650; }
.cost-slot-price { font-size:.7rem; color:#166534; font-weight:650; }
.cost-slot-hint { margin-top:auto; }
.cost-pricing { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.65rem; border:1px solid #e2e8f0; border-radius:12px; padding:.75rem .85rem; background:#fff; margin-top:.35rem; }
.cost-pricing label { display:flex; flex-direction:column; gap:.25rem; min-width:0; }
.cost-price-val { font-size:.95rem; font-weight:750; padding:.45rem .55rem; border:1px solid #e2e8f0; border-radius:8px; background:#f8fafc; }
.cost-price-val.pos { color:#047857; }
.cost-price-val.neg { color:#b91c1c; }
.cost-sale-input { font-weight:700; border-color:#93c5fd !important; }
@media (max-width:720px){
  .cost-pricing { grid-template-columns:1fr 1fr; }
}


/* v21.31 — global right-side device info drawer (click device anywhere) */
.di-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .28); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.di-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 96vw); display: flex; flex-direction: column;
  background: #fff; border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(31, 38, 135, .22);
  transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s;
}
.di-drawer.open { transform: translateX(0); visibility: visible; transition: transform .22s ease, visibility 0s; }
@media (prefers-reduced-motion: reduce) { .di-drawer { transition: none; } }
.di-head { flex: none; }
.di-body { flex: 1; min-height: 0; overflow-y: auto; }
.di-body .bx-card { grid-template-columns: 1fr; }
.di-body .bx-media img, .di-body .bx-ph { width: 100%; height: 180px; }
.bx-price { margin: .15rem 0 0; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--text); }
.bx-onky { display: inline-block; margin-left: .35rem; padding: .05rem .4rem; border-radius: 999px; background: #ede9fe; color: #5b21b6; font-size: .72rem; font-weight: 700; }
.cost-cat-tile.is-info, .cost-cat-row.is-info, .cost-slot.filled.is-info { cursor: pointer; }
.cost-cat-tile.is-info:hover, .cost-cat-row.is-info:hover { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }


/* v34 — lifecycle item attachments */
.lc-attach { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border, #e5e7eb); }
.lc-attach-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.lc-attach-head .field-label { margin: 0; }
.lc-attach-head .btn { margin-left: auto; }
.lc-attach-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.lc-attach-item { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; background: #fff; }
.lc-attach-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; background: #f3f4f6; }
.lc-attach-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; background: #f3f4f6; font-size: 10px; font-weight: 700; color: #6b7280; flex: 0 0 auto; }
.lc-attach-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.lc-attach-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-attach-acts { display: flex; gap: .3rem; flex: 0 0 auto; }
.lc-attach-empty { margin: .25rem 0 .5rem; }
.lc-item-steps {
  flex: none; font-size: .72rem; font-weight: 600; padding: .05rem .35rem; border-radius: 999px;
  background: var(--empty, #e5e7eb); color: var(--muted, #6b7280); white-space: nowrap;
}
.lc-item-steps.partial { background: #fef3c7; color: #92400e; }
.lc-item-steps.done { background: #d1fae5; color: #065f46; }
.lc-steps { margin-top: 1rem; padding-top: .75rem; border-top: 1px solid var(--border, #e5e7eb); }
/* v21.40 — checklist as the item's main content (Đóng gói & cài đặt): no secondary divider */
.lc-steps-main { margin-top: 0; padding-top: 0; border-top: 0; }
.lc-donggoi-popup .lc-steps-main { margin-bottom: .75rem; }
.lc-donggoi-popup .lc-plan { margin-top: .5rem; }
.lc-steps-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .55rem; flex-wrap: wrap; }
.lc-steps-head .field-label { margin: 0; }
.lc-steps-prog { margin-left: auto; font-variant-numeric: tabular-nums; }
.lc-steps.all-done .lc-steps-prog { color: var(--ok, #059669); font-weight: 600; }
.lc-steps-sec { margin-bottom: .85rem; }
.lc-steps-sec-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .25rem; }
.lc-steps-sec-name { margin: 0; font-size: .92rem; font-weight: 600; }
.lc-steps-list { list-style: none; margin: 0; padding: 0; }
.lc-steps-item { display: flex; align-items: flex-start; gap: .45rem; padding: .35rem 0; border-top: 1px solid var(--line-soft, #f3f4f6); }
.lc-steps-item:first-child { border-top: 0; }
.lc-steps-check { flex: none; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; margin-top: .05rem; }
.lc-steps-check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--primary); cursor: pointer; }
.lc-steps-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.lc-steps-title { font-size: .9rem; overflow-wrap: anywhere; }
.lc-steps-item.done .lc-steps-title { color: var(--muted); text-decoration: line-through; }
.lc-steps-meta { font-size: .75rem; }
.lc-steps-acts { display: flex; gap: .15rem; opacity: 0; flex: none; }
.lc-steps-item:hover .lc-steps-acts, .lc-steps-item:focus-within .lc-steps-acts { opacity: 1; }
.lc-steps-add { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; align-items: center; }
.lc-steps-add-sec { width: 10rem; max-width: 40%; }
.lc-steps-add-title { flex: 1; min-width: 10rem; }

.lc-steps-empty { margin: .2rem 0 .4rem; }

/* v21.67 — Sơ đồ quy trình (Quy trình popup): bước nối mũi tên, checklist, mô tả ẩn mặc định */
.lc-flow { margin: .25rem 0 .75rem; }
.lc-flow-head { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .65rem; flex-wrap: wrap; }
.lc-flow-head .field-label { margin: 0; }
.lc-flow-prog { margin-left: auto; font-variant-numeric: tabular-nums; }
.lc-flow.all-done .lc-flow-prog { color: var(--ok, #059669); font-weight: 600; }
.lc-flow-body { display: flex; flex-direction: column; gap: 0; }
.lc-flow-step-wrap { display: flex; flex-direction: column; align-items: stretch; }
.lc-flow-step {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: .7rem .85rem .75rem;
  background: var(--card, #fff);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.lc-flow-step.partial { border-color: #93c5fd; background: #f8fbff; }
.lc-flow-step.done { border-color: #86efac; background: #f0fdf4; }
.lc-flow-step-head { display: flex; align-items: flex-start; gap: .65rem; margin-bottom: .45rem; }
.lc-flow-num {
  flex: none; width: 1.75rem; height: 1.75rem; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--primary, #2563eb); color: #fff; font-size: .8rem; font-weight: 700;
}
.lc-flow-step.done .lc-flow-num { background: var(--ok, #059669); }
.lc-flow-step-meta { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.lc-flow-step-name { margin: 0; font-size: .95rem; font-weight: 650; }
.lc-flow-step-prog { margin-left: auto; font-variant-numeric: tabular-nums; }
.lc-flow-checks { list-style: none; margin: 0; padding: 0 0 0 .15rem; }
.lc-flow-check { padding: .22rem 0; }
.lc-flow-check-lab { display: flex; align-items: flex-start; gap: .45rem; cursor: pointer; font-size: .9rem; }
.lc-flow-check-lab input { margin: .15rem 0 0; width: 1.05rem; height: 1.05rem; accent-color: var(--primary); flex: none; }
.lc-flow-check.done span { color: var(--muted); text-decoration: line-through; }
.lc-flow-detail { margin-top: .45rem; border-top: 1px dashed var(--line-soft, #e5e7eb); padding-top: .35rem; }
.lc-flow-detail > summary {
  cursor: pointer; color: var(--muted); font-size: .82rem; font-weight: 600;
  list-style: none; user-select: none;
}
.lc-flow-detail > summary::-webkit-details-marker { display: none; }
.lc-flow-detail > summary::before { content: '▸ '; }
.lc-flow-detail[open] > summary::before { content: '▾ '; }
.lc-flow-detail-body {
  margin-top: .35rem; font-size: .86rem; line-height: 1.45; color: var(--text, #1f2937);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.lc-flow-arrow {
  text-align: center; color: var(--primary, #2563eb); font-size: 1.1rem; line-height: 1.2;
  padding: .15rem 0; opacity: .75; user-select: none;
}
.lc-flow-add { margin-top: .55rem; }
.lc-note-collapse {
  margin: .85rem 0 .4rem; border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px; padding: .45rem .7rem .55rem; background: var(--card, #fff);
}
.lc-note-collapse > summary {
  cursor: pointer; list-style: none; user-select: none; font-weight: 600;
}
.lc-note-collapse > summary::-webkit-details-marker { display: none; }
.lc-note-collapse > summary::before { content: '▸ '; color: var(--muted); }
.lc-note-collapse[open] > summary::before { content: '▾ '; }
.lc-note-collapse-body { margin-top: .45rem; }
.lc-note-collapse-body .lc-content { width: 100%; min-height: 8rem; }
.lc-quytrinh-popup .lc-flow { margin-top: .15rem; }



/* v21.32 — node.required badge / panel */
.dg-req-mark { font-size: 9px; font-weight: 800; letter-spacing: .02em; fill: #047857; pointer-events: none; }
.dg-node.req-addons.req-set .dg-req-mark { fill: #1d4ed8; }
.dg-node.req-core.req-set .dg-box { stroke: #059669; }
.dg-node.req-addons.req-set .dg-box { stroke: #3b82f6; stroke-dasharray: 5 3; }
.dg-req-row { display:flex; flex-direction:column; gap:.35rem; margin-bottom:.75rem; padding:.65rem .7rem; border:1px solid #e2e8f0; border-radius:10px; background:#f8fafc; }
.dg-req-lab { display:flex; flex-direction:column; gap:.25rem; font-size:.78rem; font-weight:600; color:#334155; }
.dg-req-sel { max-width:100%; }


/* v35: Timeline view toggle Theo kế hoạch / Theo tính năng */
.tl-head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between; }
.tl-head-row h3 { margin: 0; }
.tl-view-toggle { display: inline-flex; border: 1px solid var(--border, #d0d5dd); border-radius: 999px; overflow: hidden; background: var(--card, #fff); }
.tl-view-btn { appearance: none; border: 0; background: transparent; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted, #667085); }
.tl-view-btn.on { background: var(--accent, #2563eb); color: #fff; font-weight: 600; }
.tl-view-btn:not(.on):hover { background: rgba(37, 99, 235, 0.08); color: var(--text, #101828); }


/* v21.38 — Wireframe tab (iframe embeds + Claude fallback) */
.wf-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between; margin-bottom: 10px; }
.wf-head h3 { margin: 0; }
.wf-side-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; justify-content: space-between; }
.wf-tabs-main { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.wf-tab-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.wf-tab-btn { appearance: none; border: 1px solid var(--border, #d0d5dd); background: var(--card, #fff); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted, #667085); }
.wf-tab-btn.on { background: var(--accent, #2563eb); color: #fff; border-color: var(--accent, #2563eb); font-weight: 600; }
.wf-tab-btn:not(.on):hover { background: rgba(37, 99, 235, 0.08); color: var(--text, #101828); }
.wf-tab-add { appearance: none; border: 1px dashed var(--border, #d0d5dd); background: transparent; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted, #667085); }
.wf-tab-add:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.wf-frame-wrap { border: 1px solid var(--border, #e5e7eb); border-radius: 12px; overflow: hidden; background: #fff; }
.wf-frame-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb); background: #f8fafc; }
.wf-iframe { display: block; width: 100%; height: min(70vh, 720px); border: 0; background: #f1f5f9; }
.wf-fallback { text-align: center; padding: 2rem 1.25rem; max-width: 520px; margin: 0 auto; }
.wf-fallback-ico { font-size: 2rem; line-height: 1; margin-bottom: .5rem; color: #64748b; }
.wf-fallback h3 { margin: 0 0 .5rem; }
.wf-url { word-break: break-all; color: #475569; margin: .75rem 0 1rem; }
.wf-fallback-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.wf-empty { padding: 1.5rem; text-align: center; }
.wf-note { margin-top: 12px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: #b91c1c; border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }

/* v21.42 — Wireframe pipeline popup */
.lc-wireframe-popup .wf-popup-body { min-height: 0; }
.lc-wireframe-popup .wf-iframe { min-height: 55vh; }
.lc-wireframe-popup .wf-fallback { margin-top: .5rem; }


/* v21.49 — Tính năng: cột theo mode; full chiều cao popup, scroll trong cột */
.modal.lc-feat-board-popup .modal-body {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0;
  overflow: hidden;
  padding-top: 10px; padding-bottom: 10px;
}
.modal.lc-feat-board-popup {
  width: 96vw;
  max-width: 96vw;
  height: min(94vh, 920px);
  max-height: 94vh;
  display: flex; flex-direction: column;
}
.lc-feat-board {
  display: grid;
  gap: 12px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  width: 100%;
}
/* Nhỏ (1) / Cơ bản (2): center columns with a sensible width */
.lc-feat-board.cols-1 {
  grid-template-columns: minmax(280px, 560px);
  justify-content: center;
}
.lc-feat-board.cols-2 {
  grid-template-columns: repeat(2, minmax(280px, 560px));
  justify-content: center;
}
/* Nâng cao (3+): stretch to fill popup */
.lc-feat-board.cols-3 {
  grid-template-columns: repeat(var(--feat-cols, 3), minmax(0, 1fr));
  justify-content: stretch;
}
.lc-feat-col {
  display: flex; flex-direction: column;
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #f8fafc; overflow: hidden; min-width: 0;
  min-height: 0; height: 100%;
}
.lc-feat-col-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; color: #fff; font-weight: 700; font-size: 13px;
  flex: none;
}
.lc-feat-col-head.tone-box { background: #0f766e; }
.lc-feat-col-head.tone-pc { background: #1d4ed8; }
.lc-feat-col-head.tone-app { background: #c2410c; }
.lc-feat-col-head.tone-server { background: #7e22ce; }
.lc-feat-col-meta { font-weight: 500; font-size: 11px; opacity: .9; }
.lc-feat-col-body {
  padding: 8px; overflow: auto; flex: 1 1 auto; min-height: 0;
  background: #fff; max-height: none;
}
.lc-feat-wf .bl-group > .bl-row { background: #f8fafc; border-radius: 6px; padding: 4px 6px; }
.lc-feat-wf .bl-collapse {
  width: 1.4rem; border: 0; background: transparent; cursor: pointer;
  color: #64748b; font-size: 10px; padding: 0;
}
.lc-feat-wf .bl-group-count {
  background: #e2e8f0; color: #334155; font-size: 10px;
  padding: 1px 7px; border-radius: 10px; margin-left: 4px;
}
.lc-feat-wf .bl-group-summary { padding: 2px 18px 6px; }
.lc-feat-wf .bl-add-group-btn { margin-left: 6px; }
.lc-feat-wf .bl-map-node {
  max-width: 9.5rem; margin-left: .25rem; font-size: 11px;
  padding: 1px 4px; border-radius: 6px; border: 1px solid #e5e7eb;
  background: #fff; color: #374151;
}
@media (max-width: 900px) {
  .lc-feat-board.cols-1,
  .lc-feat-board.cols-2,
  .lc-feat-board.cols-3 { grid-template-columns: minmax(0, 1fr); justify-content: stretch; }
}

.lc-feat-wf .bl-map-node:disabled { opacity: .7; background: #f9fafb; }
.lc-feat-wf .bl-map-chip {
  display: inline-flex; align-items: center; max-width: 9.5rem;
  margin-left: .25rem; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* v21.63 — Tính năng: + ↑ ↓ × inline left of sơ đồ; reserve space; never absolute-overlap */
.lc-feat-wf .bl-row {
  flex-wrap: nowrap;
  align-items: center;
  gap: .25rem .35rem;
}
.lc-feat-wf .bl-text { flex: 1 1 auto; min-width: 0; }
.lc-feat-wf .bl-map-node,
.lc-feat-wf .bl-map-chip { flex: 0 0 auto; margin-left: 0; }
.lc-feat-wf .bl-actions {
  position: static !important;
  right: auto !important;
  top: auto !important;
  z-index: auto !important;
  flex: 0 0 auto;
  min-width: 6.75rem;
  justify-content: flex-end;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0;
  align-self: center;
}
/* keep hover fade but space always reserved (opacity, not display/position) */
@media (hover: hover) and (min-width: 641px) {
  .lc-feat-wf .bl-actions { opacity: 0.35; }
  .lc-feat-wf .bl-row:hover > .bl-actions,
  .lc-feat-wf .bl-row:focus-within > .bl-actions { opacity: 1; }
}

/* v21.44 — Native wireframe viewer (screens + hotspots) */
.wf-tab-count { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.25); font-size: 11px; }
.wf-tab-btn:not(.on) .wf-tab-count { background: #e2e8f0; color: #475569; }
.wf-native { display: grid; grid-template-columns: 200px 1fr; gap: 0; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; overflow: hidden; background: #fff; min-height: 480px; }
.wf-native-side { border-right: 1px solid var(--border, #e5e7eb); background: #f8fafc; padding: 8px; overflow: auto; max-height: min(70vh, 720px); }
.wf-side-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #8b93a7; }
.wf-native-screen { display: block; width: 100%; text-align: left; appearance: none; border: 0; background: transparent; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer; color: var(--muted, #667085); margin-bottom: 2px; }
.wf-native-screen.on { background: var(--accent, #2563eb); color: #fff; font-weight: 600; }
.wf-native-screen:not(.on):hover { background: rgba(37,99,235,.08); color: var(--text, #101828); }
.wf-native-main { display: flex; flex-direction: column; min-width: 0; }
.wf-native-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb); background: #f8fafc; }
.wf-native-stage { position: relative; flex: 1; background: #f1f5f9; min-height: 420px; }
.wf-native-frame { display: block; width: 100%; height: 100%; border: 0; background: #fff; pointer-events: auto; }
.wf-screen-viewport { position: relative; flex: 1; min-height: 420px; overflow: hidden; background: #e8ecf3; cursor: grab; touch-action: none; }
.wf-screen-viewport.panning { cursor: grabbing; }
.wf-screen-world { position: absolute; left: 0; top: 0; background: #fff; border-radius: 8px; box-shadow: 0 8px 28px rgba(14,26,58,.12); overflow: hidden; will-change: transform; }
.wf-screen-world .wf-hotspot-layer { position: absolute; inset: 0; }
.wf-native-board .wf-native-main .wf-board-viewport,
.wf-board-viewport { cursor: grab; }
.wf-board-viewport.panning { cursor: grabbing; }
.wf-hotspot-layer { position: absolute; inset: 0; }
.wf-hotspot-layer { display: none !important; }
.wf-hotspot { position: absolute; border: 1.5px solid rgba(37,99,235,.55); background: rgba(37,99,235,.12); border-radius: 4px; cursor: pointer; padding: 0; font: 11px/1 sans-serif; color: transparent; }
.wf-hotspot:hover { background: rgba(37,99,235,.28); border-color: #2563eb; }
.wf-native-loading { padding: 2rem; text-align: center; }
@media (max-width: 800px) {
  .wf-native { grid-template-columns: 1fr; }
  .wf-native-side { max-height: 160px; border-right: 0; border-bottom: 1px solid var(--border, #e5e7eb); }
}

/* v21.44 — Overview board (all screens map) */
.wf-native-bar-left, .wf-native-bar-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wf-board-jump { font-weight: 600; }
.wf-native-board .wf-native-main { min-height: 520px; }
.wf-board-viewport {
  position: relative; flex: 1; overflow: hidden; background:
    #e8eef5 radial-gradient(circle at 1px 1px, rgba(100,116,139,.25) 1px, transparent 0) 0 0 / 20px 20px;
  cursor: grab; min-height: min(65vh, 640px); touch-action: none;
}
.wf-board-viewport.panning { cursor: grabbing; }
.wf-board-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.wf-board-edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.wf-board-edge { fill: none; stroke: #94a3b8; stroke-width: 1.6; opacity: .55; }
.wf-board-edge.global { stroke: #cbd5e1; stroke-width: 1; opacity: .18; }
.wf-board-edge.hi { stroke: #2563eb; stroke-width: 2.4; opacity: .95; }
.wf-board-nodes { position: absolute; inset: 0; }
.wf-board-sec {
  position: absolute; font: 700 13px/1.2 system-ui, sans-serif; color: #334155;
  letter-spacing: .02em; text-transform: uppercase; pointer-events: none;
}
.wf-board-thumb {
  position: absolute; appearance: none; border: 1.5px solid #cbd5e1; border-radius: 10px;
  background: #fff; padding: 0; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(15,23,42,.08);
  display: flex; flex-direction: column; text-align: left; transition: box-shadow .15s, border-color .15s, opacity .15s;
}
.wf-board-thumb:hover, .wf-board-thumb.hi { border-color: #2563eb; box-shadow: 0 4px 14px rgba(37,99,235,.25); z-index: 2; }
.wf-board-thumb.dim { opacity: .35; }
.wf-board-thumb-img { display: block; width: 100%; height: 105px; object-fit: cover; object-position: top left; background: #f1f5f9; pointer-events: none; }
.wf-board-thumb-ph { height: 105px; display: grid; place-items: center; padding: 8px; font-size: 11px; text-align: center; background: linear-gradient(180deg,#e8ecf1,#f8fafc); color:#475569; border-bottom:1px dashed #cbd5e1; }
.wf-board-thumb-cap {
  display: block; padding: 3px 6px; font: 600 10px/1.3 system-ui, sans-serif; color: #334155;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid #e2e8f0; background: #f8fafc;
}
.wf-board-title { font-weight: 600; font-size: 13px; }
.wf-board-zoom { min-width: 3.2em; text-align: center; }


/* v21.54 — package tab panels: keep mounted, toggle hidden (no full re-render) */
.pkg-panels { display: block; min-width: 0; }
.pkg-panels > .tab-body[hidden] { display: none !important; }

/* Wireframe pipeline popup = full Wireframe tab content */
.modal.lc-wireframe-popup {
  width: 96vw;
  height: 94vh;
  max-width: 96vw;
  max-height: 94vh;
  display: flex; flex-direction: column;
}
.modal.lc-wireframe-popup .modal-body {
  flex: 1 1 auto; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 8px 10px 0;
}
.modal.lc-wireframe-popup.modal-has-nav .modal-body { padding-left: 52px; padding-right: 52px; }
.modal.lc-wireframe-popup .modal-head { padding: 10px 14px 6px; }
.modal.lc-wireframe-popup .wf-popup-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.modal.lc-wireframe-popup .wf-popup-body > .wf-tabs { flex: 0 0 auto; }
.modal.lc-wireframe-popup .wf-popup-body > .wf-native {
  flex: 1 1 auto; min-height: 0; height: auto;
  border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0;
}
.modal.lc-wireframe-popup .wf-native-side {
  max-height: none; height: 100%; overflow: auto;
}
.modal.lc-wireframe-popup .wf-native-main { min-height: 0; height: 100%; }
.modal.lc-wireframe-popup .wf-board-viewport,
.modal.lc-wireframe-popup .wf-screen-viewport {
  min-height: 0; flex: 1 1 auto;
}
.modal.lc-wireframe-popup .wf-native-board .wf-native-main { min-height: 0; }

/* v21.62 — persistent stage host: side stays, main swaps screen/board without tearing shell */
.wf-stage-host {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.wf-stage-host > .wf-native-main {
  flex: 1 1 auto; min-height: 0; height: 100%;
  display: flex; flex-direction: column;
}
.wf-native-frame[hidden] { display: none !important; }

/* v21.64 — Pilot › Khách thử nghiệm */
.modal.lc-pilot-popup {
  width: min(96vw, 1280px);
  max-width: 96vw;
  height: min(92vh, 860px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.modal.lc-pilot-popup .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}
.modal.lc-pilot-popup.modal-has-nav .modal-body { padding-left: 52px; padding-right: 52px; }
.modal.lc-pilot-popup .modal-head { padding: 10px 14px 6px; }

.pilot-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.pilot-side {
  border-right: 1px solid var(--border, #e5e7eb);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pilot-side-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.pilot-list {
  flex: 1 1 auto;
  overflow: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pilot-card {
  text-align: left;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .12s, box-shadow .12s;
}
.pilot-card:hover { border-color: #94a3b8; }
.pilot-card.on {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
  background: #eff6ff;
}
.pilot-card-name { font-weight: 600; font-size: 14px; }
.pilot-card-meta { font-size: 12px; line-height: 1.35; }
.pilot-pill {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  color: #1d4ed8;
  background: #dbeafe;
  border-radius: 999px;
  padding: 2px 8px;
  width: fit-content;
}

.pilot-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}
.pilot-main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
  border-bottom: 1px solid #eef2f7;
}
.pilot-main-title h3 { margin: 0 0 4px; font-size: 18px; }
.pilot-main-title p { margin: 0; max-width: 52ch; }
.pilot-main-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.pilot-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  border-bottom: 1px solid #eef2f7;
}
.pilot-tab {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
}
.pilot-tab:hover { color: #0f172a; }
.pilot-tab.on { color: #1d4ed8; border-bottom-color: #2563eb; font-weight: 600; }
.pilot-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 20px;
}
.pilot-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  border: 1px solid #fed7aa;
}
.pilot-node-list { display: flex; flex-direction: column; gap: 6px; }
.pilot-node-row {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  row-gap: 4px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.pilot-node-row.on { background: #f0fdf4; border-color: #bbf7d0; }
.pilot-node-row.cust { background: #fff7ed; border-color: #fed7aa; }
.pilot-node-row.is-group {
  background: #eef2ff;
  border-color: #c7d2fe;
  margin-top: 4px;
}
.pilot-node-row.is-group .pilot-node-label { font-weight: 700; }
.pilot-node-row > input[type="checkbox"],
.pilot-check input[type="checkbox"] {
  width: 1.1rem !important;
  height: 1.1rem;
  min-width: 1.1rem;
  max-width: 1.1rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  box-shadow: none;
  accent-color: var(--primary, #2563eb);
  justify-self: center;
  flex: none;
}
.pilot-check { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; grid-column: 1 / 3; }
.pilot-node-row > .pilot-check { grid-column: 1 / 3; }
.pilot-node-row > .pilot-device-sel { grid-column: 3; width: auto; min-width: 140px; max-width: 220px; }
.pilot-node-row > .pilot-tag { justify-self: end; }
.pilot-node-label { font-size: 13px; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.pilot-tag {
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.pilot-tag.auto { background: #dbeafe; color: #1d4ed8; }
.pilot-tag.miss { background: #ffedd5; color: #c2410c; }
.pilot-device-sel {
  margin-left: auto;
  min-width: 160px;
  max-width: 240px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

/* Sơ đồ rows: checkbox+label | tag | device select */
.pilot-node-row:has(> .pilot-device-sel) {
  grid-template-columns: minmax(0, 1fr) auto minmax(140px, 220px);
}
.pilot-node-row:has(> .pilot-device-sel) > .pilot-check { grid-column: 1; }
.pilot-node-row:has(> .pilot-device-sel) > .pilot-tag { grid-column: 2; }
.pilot-node-row:has(> .pilot-device-sel) > .pilot-device-sel { grid-column: 3; width: 100%; max-width: none; }

.pilot-add-node { margin-top: 12px; }

@media (max-width: 800px) {
  .pilot-layout { grid-template-columns: 1fr; }
  .pilot-side { max-height: 220px; border-right: 0; border-bottom: 1px solid #e5e7eb; }
}

/* v21.68 — video attachments: inline HTML5 player (Windows / Linux guides, reusable) */
.lc-attach-videos { display: flex; flex-direction: column; gap: .85rem; margin: .35rem 0 .75rem; }
.lc-attach-video { margin: 0; padding: .55rem .65rem .7rem; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; background: #fafafa; }
.lc-attach-video-cap { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .45rem; }
.lc-attach-video-cap b { font-size: .95rem; }
.lc-attach-video-cap .lc-attach-acts { margin-left: auto; }
.lc-attach-player { display: block; width: 100%; max-height: 420px; border-radius: 8px; background: #111; }

/* v21.70 — Hướng dẫn cài đặt (markdown guide) */
.lc-guide-popup .modal-body { overflow: auto; -webkit-overflow-scrolling: touch; }
.lc-guide {
  padding: 12px 16px 24px;
  max-width: 820px;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text, #1f2937);
  word-break: normal;
  overflow-wrap: anywhere;
}
.lc-guide-h { margin: 1.25em 0 .5em; line-height: 1.3; scroll-margin-top: 12px; }
.lc-guide h1.lc-guide-h { font-size: 1.35rem; }
.lc-guide h2.lc-guide-h { font-size: 1.15rem; border-bottom: 1px solid var(--border, #e5e7eb); padding-bottom: .25em; }
.lc-guide h3.lc-guide-h { font-size: 1.02rem; }
.lc-guide-p { margin: .55em 0; }
.lc-guide-ul, .lc-guide-ol { margin: .4em 0 .7em; padding-left: 1.35em; }
.lc-guide-ul li, .lc-guide-ol li { margin: .25em 0; }
.lc-guide-hr { border: 0; border-top: 1px solid var(--border, #e5e7eb); margin: 1.2em 0; }
.lc-guide-quote {
  margin: .7em 0; padding: .55em .8em; border-left: 3px solid #3b82f6;
  background: #f8fafc; border-radius: 0 8px 8px 0; color: #334155;
}
.lc-guide-pre {
  margin: .7em 0; padding: .65em .8em; background: #0f172a; color: #e2e8f0;
  border-radius: 8px; overflow-x: auto; font-size: .88em;
}
.lc-guide-pre code { background: none; padding: 0; color: inherit; }
.lc-guide code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em; background: #f1f5f9; padding: .1em .35em; border-radius: 4px;
}
.lc-guide-img {
  display: block; width: 100%; height: auto; max-width: 100%;
  margin: .65em 0 1em; border-radius: 8px; border: 1px solid var(--border, #e5e7eb);
  background: #f8fafc;
}
.lc-guide-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .7em 0 1em; }
.lc-guide-table { width: 100%; border-collapse: collapse; font-size: .92em; min-width: 280px; }
.lc-guide-table th, .lc-guide-table td {
  border: 1px solid var(--border, #e5e7eb); padding: .45em .55em; text-align: left; vertical-align: top;
}
.lc-guide-table th { background: #f8fafc; font-weight: 600; }
.lc-guide-a { color: #2563eb; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 430px) {
  .lc-guide { padding: 10px 12px 20px; font-size: 14.5px; }
  .lc-guide h1.lc-guide-h { font-size: 1.22rem; }
  .lc-guide h2.lc-guide-h { font-size: 1.08rem; }
  .lc-guide-popup .modal-body { padding: 0; }
}

/* v21.71 — device detail tabs (Thiết bị pane) */
.bx-card-tabs { display: flex; flex-direction: column; gap: 0; }
.bx-detail-head { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px 8px; }
.bx-media-compact { width: 72px; min-width: 72px; height: 72px; }
.bx-media-compact img, .bx-media-compact .bx-ph { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.bx-detail-meta { flex: 1; min-width: 0; }
.bx-model-meta { margin: 4px 0 0; word-break: break-all; }
.bx-tabs {
  display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border, #e2e8f0);
  background: #fafafa; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.bx-tab {
  flex: 0 0 auto; padding: 10px 12px; font-size: 13px; color: #64748b;
  border: 0; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; white-space: nowrap;
}
.bx-tab.on { color: #1d4ed8; border-bottom-color: #2563eb; font-weight: 700; }
.bx-tab-pane { padding: 12px; }
.bx-tab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bx-tab-grid-3d { grid-template-columns: 1.1fr 1fr; align-items: stretch; }
.bx-tab-box {
  border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.bx-tab-h { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: #0f172a; }
.bx-price-lg { font-size: 1.35rem; font-weight: 800; color: #0f172a; }
.bx-kv {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px;
}
.bx-kv-k { color: #64748b; }
.bx-kv-v { text-align: right; font-weight: 600; color: #0f172a; max-width: 220px; overflow-wrap: anywhere; }
.bx-3d-wrap { min-height: 220px; }
.bx-3d-panel, .bx-3d-host { width: 100%; min-height: 220px; height: 240px; border-radius: 8px; background: #0b1220; }
.bx-parts-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; }

/* v21.72/21.74 — desktop: 3D + Linh kiện fill popup body; host absolute-fills panel for Three.js ResizeObserver.
   ≤768 / ≤430 keep compact fixed heights. */
@media (min-width: 769px) {
  .modal.dev-popup .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal.dev-popup .dev-md {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    align-items: stretch;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .modal.dev-popup .dev-list-col {
    max-height: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
  }
  .modal.dev-popup .dev-detail-col {
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal.dev-popup .bx-card.bx-card-tabs {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .bx-card-tabs > .bx-detail-head,
  .bx-card-tabs > .bx-tabs { flex: none; }
  .bx-card-tabs > .bx-tab-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .bx-card-tabs > .bx-tab-pane:has(.bx-tab-grid-3d) {
    min-height: calc(80vh - 210px);
  }
  .bx-card-tabs > .bx-tab-pane > .bx-tab-grid-3d {
    flex: 1 1 auto;
    min-height: calc(80vh - 220px);
    height: 100%;
  }
  .bx-tab-grid-3d > .bx-tab-box {
    display: flex;
    flex-direction: column;
    min-height: calc(80vh - 220px);
    height: 100%;
  }
  .bx-3d-wrap { min-height: 0; }
  .bx-3d-wrap > .bx-tab-h { flex: none; }
  .bx-3d-wrap > .bx-3d-panel {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;
  }
  .bx-3d-panel .dev3d,
  .bx-3d-panel .bx-3d-host,
  .bx-3d-panel .dev3d.bx-3d-host {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border-radius: 8px;
    background: #0b1220;
  }
  .bx-tab-grid-3d > .bx-tab-box > .bx-tab-h { flex: none; }
  .bx-tab-grid-3d .bx-parts-list {
    flex: 1 1 auto;
    max-height: none !important;
    min-height: 0;
    height: auto;
    overflow: auto;
  }
}

@media (max-width: 768px) {
  .bx-3d-wrap { min-height: 200px; }
  .bx-3d-panel, .bx-3d-host { height: clamp(200px, 36vh, 320px); min-height: 200px; }
  .bx-3d-panel .dev3d, .bx-3d-panel .bx-3d-host { height: 100%; min-height: 200px; }
  .bx-parts-list { max-height: 240px; }
}
@media (max-width: 430px) {
  .bx-tab-grid, .bx-tab-grid-3d { grid-template-columns: 1fr; }
  .bx-detail-head { padding: 8px 10px; }
  .bx-tab { padding: 9px 10px; font-size: 12.5px; }
  .bx-tab-pane { padding: 10px; }
  .bx-3d-panel, .bx-3d-host { height: 200px; min-height: 200px; }
  .bx-3d-panel .dev3d, .bx-3d-panel .bx-3d-host { height: 200px; min-height: 200px; }
  .bx-parts-list { max-height: 220px; }
  .bx-kv-v { max-width: 160px; }
}


/* v21.75 Giải pháp / Khách hàng */
.sol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.sol-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sol-card-head h3 { margin: 0; font-size: 1.05rem; }
.sol-feats { margin: 8px 0; padding-left: 1.2em; }
.sol-pkgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pkg-multi { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; border: 1px solid var(--border, #ddd); padding: 8px; border-radius: 8px; }
.req-card { margin-bottom: 12px; }
.req-prods { display: grid; gap: 8px; margin-top: 8px; }
.req-prod { padding: 10px 12px; background: var(--card-bg-2, #f8fafc); }
@media (max-width: 420px) {
  .sol-grid { grid-template-columns: 1fr; }
}


/* v21.76 Quy trình tabs + mode chips */
.lc-flow-tabs {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  margin: 8px 0 6px; padding: 8px 10px; border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px; background: #fff;
}
.lc-flow-tabs-main { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.lc-flow-tab {
  border: 1px solid var(--border, #e5e7eb); background: #f9fafb; border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; color: var(--text, #111827);
}
.lc-flow-tab.on { background: var(--accent-soft, #eff6ff); border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); font-weight: 600; }
.lc-flow-tab-count {
  font-size: 11px; background: #f3f4f6; color: #6b7280; border-radius: 99px; padding: 1px 6px;
}
.lc-flow-tab.on .lc-flow-tab-count { background: #dbeafe; color: #1d4ed8; }
.lc-flow-tab-add {
  border: 1px dashed var(--border, #d1d5db); background: transparent; border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; color: #6b7280;
}
.lc-flow-tab-add:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.lc-flow-tab-acts { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }
.lc-flow-modes {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 0 0 10px; padding: 6px 2px;
}
.lc-flow-modes-label { margin-right: 2px; }
.lc-flow-mode-chip {
  border: 1px solid var(--border, #e5e7eb); background: #f3f4f6; border-radius: 999px;
  padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer; color: #374151;
}
.lc-flow-mode-chip.on { background: var(--accent, #2563eb); color: #fff; border-color: var(--accent, #2563eb); }
.lc-flow-mode-hint { margin-left: auto; }
.lc-flow-mode-badge {
  font-size: 10px; border-radius: 999px; padding: 1px 6px; margin-left: 6px;
  background: #f3f4f6; color: #6b7280; white-space: nowrap;
}
.lc-flow-mode-badge.co-ban { background: #eff6ff; color: #1d4ed8; }
.lc-flow-mode-badge.nang-cao { background: #faf5ff; color: #7e22ce; }
.lc-flow-check-lab { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 420px) {
  .lc-flow-tabs { padding: 6px; }
  .lc-flow-tab-acts { width: 100%; justify-content: flex-end; margin-left: 0; }
  .lc-flow-mode-hint { width: 100%; margin-left: 0; }
}


/* v21.77 Wireframe edit mode */
.wf-screen-world { position: relative; }
.wf-native-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.wf-mode-toggle { display: inline-flex; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; overflow: hidden; margin: 0 8px; }
.wf-mode-btn { border: 0; background: #f9fafb; padding: 4px 12px; font: inherit; font-size: 12px; cursor: pointer; color: #374151; }
.wf-mode-btn.on { background: #1f5fe6; color: #fff; font-weight: 600; }
.wf-mode-btn:disabled { opacity: .45; cursor: not-allowed; }
.wf-screen-row { display: flex; flex: 1; min-height: 0; min-width: 0; }
.wf-screen-row .wf-screen-viewport { flex: 1; min-width: 0; }
.wf-edit-dock {
  width: 260px; flex-shrink: 0; border-left: 1px solid var(--border, #e5e7eb);
  background: #f8fafc; padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 10px;
}
.wf-edit-dock-h { font-weight: 700; font-size: 13px; }
.wf-pal-item {
  border: 1px solid var(--border, #e5e7eb); background: #fff; border-radius: 8px;
  padding: 8px 10px; margin: 4px 0; cursor: grab; font-size: 13px;
}
.wf-pal-item:active { cursor: grabbing; }
.wf-edit-props .field { display: block; margin: 6px 0; }
.wf-edit-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.wf-edit-overlay { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 6; }
.wf-edit-overlay.interactive { pointer-events: none; }
.wf-native.wf-editing .wf-edit-overlay.interactive { pointer-events: auto; }
.wf-ov-el { pointer-events: auto; }
.wf-ov-handle {
  position: absolute; width: 10px; height: 10px; background: #1f5fe6; border: 1px solid #fff;
  border-radius: 50%; z-index: 7;
}
.wf-ov-handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.wf-ov-handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.wf-ov-handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.wf-ov-handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.wf-color-swatches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.wf-swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid #cbd5e1; padding: 0; cursor: pointer; }
.wf-native.wf-editing .wf-native-bar { background: #eff6ff; }
@media (max-width: 900px) {
  .wf-edit-dock { width: 220px; }
}

.wf-screen-world { position: relative; /* wf-edit */ }


/* v21.78 Quy trình QR + mobile checklist */
.lc-flow-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lc-flow-head-acts { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.lc-qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px; }
.lc-qr-img { width: min(280px, 80vw); height: auto; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; padding: 12px; }
.lc-qr-url { width: 100%; font-size: 12px; }
.lc-qr-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
html.m-checklist #side, html.m-checklist .app-top, html.m-checklist .side-rail { display: none !important; }
html.m-checklist #view, html.m-checklist .view { margin: 0; padding: 0; max-width: none; }
.m-check { min-height: 100dvh; background: #f8fafc; padding: 12px 12px 32px; }
.m-check-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.m-check-head h1 { font-size: 1.25rem; margin: 0 0 4px; }
.m-check-prog { font-weight: 700; white-space: nowrap; }
.m-check-sec { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.m-check-sec h2 { font-size: 1rem; margin: 0 0 8px; }
.m-check-list { list-style: none; margin: 0; padding: 0; }
.m-check-item { border-top: 1px solid #f1f5f9; }
.m-check-lab { display: flex; align-items: flex-start; gap: 12px; padding: 14px 4px; font-size: 16px; line-height: 1.35; cursor: pointer; }
.m-check-cb { width: 28px; height: 28px; flex-shrink: 0; margin-top: 1px; }
.m-check-item.done .m-check-lab span { text-decoration: line-through; color: #64748b; }
.m-check-foot { text-align: center; margin-top: 16px; }


/* v21.84 — Box device Benchmark tab (opt-in when b.benchmark present) */
.bx-bench-pane { overflow: auto !important; display: block !important; }
.bx-bench-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.bx-bench-toc { margin: 0 0 12px; padding: 8px 10px; border: 1px solid var(--border,#e2e8f0); border-radius: 10px; background: #f8fafc; font-size: 13px; }
.bx-bench-toc ul { margin: 6px 0 0; padding-left: 18px; }
.bx-bench-toc a { color: #1d4ed8; text-decoration: none; }
.bx-bench-sec, .bx-bench-step { margin: 0 0 16px; }
.bx-bench-step-h { margin: 0 0 8px; font-size: 14px; font-weight: 800; color: #0f172a; }
.bx-bench-table-wrap, .bx-bench-chart { margin: 0 0 10px; border: 1px solid var(--border,#e2e8f0); border-radius: 10px; padding: 8px; background: #fff; cursor: zoom-in; }
.bx-bench-zoomable:focus { outline: 2px solid #2563eb; outline-offset: 2px; }
.bx-bench-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bx-bench-table th, .bx-bench-table td { border-bottom: 1px solid #e2e8f0; padding: 6px 8px; vertical-align: top; text-align: left; }
.bx-bench-table th.num, .bx-bench-table td.num { text-align: right; white-space: nowrap; }
.bx-bench-table .bench-err { color: #b91c1c; font-weight: 700; }
.bx-bench-src { margin: 6px 0 0; }
.bx-bench-bars { display: flex; flex-direction: column; gap: 8px; }
.bx-bench-bar-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr; gap: 8px; align-items: start; }
.bx-bench-bar-label { font-size: 11px; color: #334155; word-break: break-all; }
.bx-bench-bar-tracks { display: flex; flex-direction: column; gap: 3px; }
.bx-bench-bar-track { position: relative; height: 16px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.bx-bench-bar-fill { display: block; height: 100%; background: linear-gradient(90deg,#93c5fd,#2563eb); border-radius: 4px; }
.bx-bench-bar-val { position: absolute; right: 6px; top: 0; font-size: 10px; line-height: 16px; color: #0f172a; }
.bx-bench-scatter { width: 100%; max-width: 480px; height: auto; background: #fff; }
.bx-content-lightbox {
  position: fixed; inset: 0; z-index: 120; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.bx-content-lightbox-panel {
  background: #fff; border-radius: 14px; max-width: min(1100px, 96vw); max-height: 92vh;
  width: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.bx-content-lightbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid #e2e8f0;
}
.bx-content-lightbox-head h3 { margin: 0; font-size: 15px; }
.bx-content-lightbox-body { padding: 12px 14px; overflow: auto; }
.bx-bench-fullscreen-inner { display: grid; grid-template-columns: 200px 1fr; gap: 12px; }
@media (max-width: 768px) {
  .bx-bench-bar-row { grid-template-columns: 1fr; }
  .bx-bench-fullscreen-inner { grid-template-columns: 1fr; }
}


/* v21.85 Wireframe edit P0/P1 — font props + versions */
.wf-prop-row { display: flex; gap: 6px; }
.wf-prop-row .field { flex: 1; min-width: 0; }
.wf-prop-row input.ed, .wf-edit-props select.ed { width: 100%; }
.wf-versions { border-top: 1px dashed #cbd5e1; padding-top: 8px; margin-top: 4px; }
.wf-versions ul { list-style: none; margin: 0; padding: 0; max-height: 120px; overflow: auto; }
.wf-versions li { font-size: 11px; color: #475569; padding: 3px 0; border-bottom: 1px solid #eef2f7; }
.wf-edit-hint { font-size: 11px; color: #64748b; margin: 0; }


/* v21.86 Wireframe horizontal toolbox (Sửa) — primary edit chrome, works at ~1024px modal */
.wf-toolbox {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 6px 8px; border-bottom: 1px solid #bfdbfe; background: linear-gradient(180deg, #eff6ff, #f8fafc);
  flex: 0 0 auto; z-index: 8; min-height: 44px;
}
.wf-toolbox[hidden] { display: none !important; }
.wf-tb-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 2px; border: 1px solid #dbeafe; border-radius: 10px; background: #fff; }
.wf-tb-btn {
  appearance: none; border: 0; background: transparent; border-radius: 8px;
  min-height: 34px; padding: 4px 8px; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; font-size: 12px; font-weight: 600; color: #334155; cursor: pointer;
}
.wf-tb-btn:hover { background: #eff6ff; }
.wf-tb-btn.on { background: #1f5fe6; color: #fff; }
.wf-tb-btn.primary { background: #1f5fe6; color: #fff; }
.wf-tb-btn.primary:hover { filter: brightness(1.05); }
.wf-tb-btn.danger { color: #b91c1c; }
.wf-tb-btn.danger.on, .wf-tb-btn.danger:hover { background: #fee2e2; }
.wf-tb-ico { font-size: 14px; line-height: 1; min-width: 1em; text-align: center; }
.wf-tb-lab { white-space: nowrap; }
.wf-tb-select {
  height: 32px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff;
  font: inherit; font-size: 12px; padding: 0 6px; color: #0f172a; max-width: 110px;
}
.wf-tb-size { max-width: 64px; }
.wf-tb-color-wrap { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; font-size: 11px; color: #475569; }
.wf-tb-color { width: 28px; height: 28px; padding: 0; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; cursor: pointer; }
.wf-tb-fmt.disabled { opacity: .45; }
.wf-tb-hint { margin: 0 0 0 auto; font-size: 11px; color: #64748b; }
.wf-native.wf-tool-place .wf-screen-viewport,
.wf-native.wf-tool-place .wf-edit-overlay { cursor: crosshair !important; }
/* Right dock is optional (Chi tiết); hide by default so toolbox stays obvious on laptop/modal ~1024 */
.wf-edit-dock { width: 240px; }
@media (max-width: 1280px) {
  .wf-tb-hint { display: none; }
  .wf-tb-lab { font-size: 11px; }
}
@media (max-width: 900px) {
  .wf-toolbox { gap: 6px; }
  .wf-tb-btn { padding: 4px 6px; }
}

/* v21.89 single-edit + componentized seed */
.wf-ov-el > span { display:block; width:100%; max-height:100%; overflow:hidden; }
.lc-wireframe-popup .modal-foot [data-act="edit"],
.lc-wireframe-popup .modal-foot [data-act="save"],
.lc-wireframe-popup .modal-foot [data-act="revert"] { display:none !important; }


/* v21.90 — Timeline stats/filter icons on package tab strip */
@media (max-width: 720px) {
  .pkg-tabs-row { top: 0; gap: 4px; }
  .pkg-tl-tools { padding: 2px; }
  .pkg-tl-tool { width: 40px; height: 40px; }
}
.filters.tl-filters[hidden], .card.tl-head[hidden] { display: none !important; }


/* v22.02 — Chi tiết ~280 wrap; Ghi chú ~60; Lịch sát Ghi chú, không gap/tràn */
.tl-table.tl-freeze td.col-task .tl-title {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  line-height: 1.25;
}
.tl-table.tl-freeze thead th { vertical-align: bottom; }
.tl-table.tl-freeze thead th.col-gantt { vertical-align: bottom; }
.pkg-head .tabs { padding-top: 2px; padding-bottom: 2px; margin-bottom: 0; }
.pkg-head .tabs .tab { min-height: 34px; padding: 0 14px; }


/* v22.03 Box Onky muc3 + quy trình Mô tả ảnh */
.bx-muc3-kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin:8px 0 14px}
.bx-muc3-kpi{border:1px solid var(--border,#ddd);border-radius:10px;padding:12px 14px;background:#fff;cursor:zoom-in}
.bx-muc3-kpi-val{font-size:1.45rem;font-weight:700;line-height:1.2}
.bx-muc3-kpi-val small{font-size:.75rem;font-weight:600;opacity:.7}
.bx-muc3-kpi-lbl{font-size:.85rem;color:#555;margin-top:4px}
.bx-muc3-figure{margin:8px 0;cursor:zoom-in}
.bx-muc3-fig{max-width:100%;height:auto;display:block;border:1px solid #eee;border-radius:8px;background:#fff}
.bx-muc3-figure figcaption{font-size:.85rem;color:#555;margin-top:6px}
.bx-muc3-table tr.bx-muc3-hi td{font-weight:700;background:#fff8e6}
.bx-muc3-note{margin-top:8px}
.bx-muc3-total{font-weight:600;margin:6px 0}
.bx-muc3-chua{margin:6px 0 0 1.1rem}
.lc-flow-detail-body{white-space:pre-wrap;line-height:1.45}
.lc-flow-detail-body.ed{white-space:normal}
.lc-flow-detail-p{white-space:pre-wrap;margin:0 0 8px}
.lc-flow-detail-fig{margin:10px 0;padding:0}
.lc-flow-detail-fig img{max-width:min(100%,520px);height:auto;border:1px solid #e5e5e5;border-radius:8px;display:block;background:#fff}
.lc-flow-detail-fig figcaption{font-size:.85rem;color:#555;margin-top:4px}
.lc-flow-detail-ta{width:100%;min-height:180px;font:inherit;padding:8px;border:1px solid #ccc;border-radius:8px}
.lc-flow-detail-acts{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-top:8px}

/* v22.04 VIỆC (TIMELINE) filter */
.tl-filter-head{display:flex;align-items:center;gap:10px;flex-wrap:nowrap}
.tl-filter{display:flex;gap:6px;flex-wrap:nowrap;align-items:center}
.tl-filter-count{margin-left:auto;white-space:nowrap}
.tl-fchip{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;border:1px solid #c9ced6;background:#fff;color:#1f2733;border-radius:999px;padding:4px 12px;font:inherit;font-size:.85rem;cursor:pointer;min-height:32px}
.tl-fchip.on{border:2px solid #1d4ed8;background:#eef3ff;color:#123a9c;font-weight:600;padding:3px 11px}
.tl-fchip:focus-visible{outline:3px solid #1d4ed8;outline-offset:2px}
.tl-fchip-n{font-size:.75rem;background:#eef0f3;color:#333;border-radius:999px;padding:0 7px}
.tl-fchip.on .tl-fchip-n{background:#d6e2ff;color:#0f2f80}
.tl-filter-empty{padding:14px 4px;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
@media (max-width:1023px){.tl-filter-head{flex-wrap:wrap}.tl-filter-count{order:-1;flex-basis:100%;margin-left:0}.tl-filter{flex-wrap:wrap}}
@media (max-width:639px){.tl-filter-head{position:sticky;top:0;z-index:3;background:#fff;padding:6px 0}.tl-filter{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%;padding-bottom:4px;scrollbar-width:thin}.tl-fchip{min-height:44px;padding:6px 14px;flex:0 0 auto}.tl-fchip.on{padding:5px 13px}}

/* AI RnD tabs + Benchmark (v22.05) */
.airnd-tabs { margin: 4px 0 10px; }
.bench-table td input, .bench-table td select { width: 100%; min-width: 90px; }

/* Thông báo (v22.06) */
@media (min-width: 1101px) { .topbar nav a.nav-notify { margin-top: auto; } }
.nav-badge.nav-badge-upd { background: #2563eb; margin-left: 4px; }
.nav-badge[data-badge=reminders] + .nav-badge-upd { margin-left: 4px; }
.tb-tabs { margin: 4px 0 10px; }
.tb-list li.tb-upd { padding: 10px 14px; }
.tb-list li.is-unread { background: rgba(37, 99, 235, .06); border-left: 3px solid #2563eb; }
.tb-new { color: #2563eb; font-weight: 700; }
.tb-chg s { opacity: .7; }

/* Đổi mật khẩu (v22.07) */
.pw-form { max-width: 420px; display: grid; gap: 12px; padding: 18px; }
.pw-form label { display: grid; gap: 4px; font-weight: 500; }
.user-card .pw-link { font-size: 12px; grid-column: 2; }
.user-card .avatar { grid-row: 1 / 4; }
.user-card .pw-link { grid-column: 2; grid-row: 2; }
.user-card .logout { grid-column: 2; grid-row: 3; }

/* ===== Quy tắc trang danh sách (v22.08, docs/UI-RULES.md) ===== */
.lu-crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted-2); margin-bottom: 2px; }
.lu-crumbs a { color: var(--muted-2); }
.lu-crumbs [aria-current=page] { color: var(--text-2); font-weight: 600; }
.lu-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.lu-head-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.lu-hidden { display: none !important; }
@media (min-width: 901px) {
  html.lu-list .page-head.lu-head { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .88); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 6px 18px rgba(30, 41, 59, .08); }
  html.lu-list .table-card.lu-sticky { overflow: visible; }
  html.lu-list .table-card.lu-sticky > table > thead th,
  html.lu-list .table-card.lu-sticky form > table > thead th { position: sticky; top: calc(var(--lu-head-h, 80px) + 0px); z-index: 20; background: rgba(248, 250, 252, .97); }
}
/* Row actions: last column, right-aligned icon buttons */
td.lu-act, th.lu-act-h { text-align: right; white-space: nowrap; width: 1%; }
td.lu-act > *, td.lu-act .card-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
td.lu-act button.icon { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 9px; }
/* Modal form */
html.lu-modal-open { overflow: hidden; }
.lu-modal-back { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .38); display: grid; place-items: center; padding: 16px; }
.lu-modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
.lu-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #e5e7eb; }
.lu-modal-head h3 { margin: 0; font-size: 17px; }
.lu-modal-body { padding: 16px 18px; overflow-y: auto; }
.lu-fields { display: grid; gap: 12px; }
.lu-field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.lu-field input, .lu-field select, .lu-field textarea { width: 100%; font-weight: 400; }
.lu-modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
form.lu-in-modal { display: grid; gap: 12px; margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
form.lu-in-modal.card { padding: 0; }
form.lu-in-modal > * { width: 100%; }
form.lu-in-modal button[type=submit] { justify-self: end; width: auto; }
form.lu-in-modal .add-survey-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

@media (min-width: 901px) {
  html.lu-list .table-card.lu-sticky .tscroll { overflow: visible; }
  html.lu-list .table-card.lu-sticky thead th { position: sticky; top: var(--lu-head-h, 80px); z-index: 20; background: rgba(248, 250, 252, .97); }
}
@media (min-width: 901px) { html.lu-list .page-head.lu-head { background: rgba(255, 255, 255, .97); } }
@media (min-width: 901px) { .page-head.lu-head { flex-wrap: nowrap; } .page-head.lu-head > div:first-child { flex: 1 1 auto; } .lu-head-actions { flex: none; } }

/* ===== AI RnD v2 (ar-*) ===== */

.ar-root, :root {
  /* Biến lấy từ style.ar-css của Insight (v22.05) */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #e9edff; --text: #1e293b; --text-2: #334155; --muted: #475569; --muted-2: #4b5a6e;
  --line: rgba(148, 163, 184, .32); --primary: #2563eb; --primary-2: #4f46e5; --primary-ink: #1d4ed8;
  --primary-soft: rgba(99, 102, 241, .14); --grad: linear-gradient(135deg, #4f46e5, #2563eb);
  --ok: #047857; --ok-soft: rgba(16, 185, 129, .16); --warn: #92400e; --warn-soft: rgba(245, 158, 11, .2);
  --danger: #b91c1c; --red-soft: rgba(239, 68, 68, .14); --violet: #6d28d9; --violet-soft: rgba(139, 92, 246, .16);
  --cyan: #0e7490; --cyan-soft: rgba(6, 182, 212, .16); --gray-soft: rgba(100, 116, 139, .16);
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(255, 255, 255, .8); --glass-border: rgba(255, 255, 255, .82);
  --radius: 20px; --radius-md: 14px; --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(31, 38, 135, .10), inset 0 1px 0 rgba(255, 255, 255, .85);
  --shadow-sm: 0 4px 14px rgba(31, 38, 135, .08); --shadow-primary: 0 8px 20px rgba(37, 99, 235, .3);
  --blur: blur(22px) saturate(170%);
  /* Màu biểu đồ: kiểm bằng validate_palette.ar-js trên nền #f4f6ff (đạt CVD; cam, aqua < 3:1 nên luôn có nhãn + bảng) */
  --c-dung: #2a78d6; --c-nham: #eb6834; --c-khong: #c9ced8;
  --c-detect: #1baf7a; --c-recog: #6250d6;
  --grid: rgba(148, 163, 184, .38); --axis: #94a3b8; --surface: #f8f9ff;
}
main { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }









.ar-intro { color: var(--muted); font-size: 13px; margin: -4px 4px 0; }
/* .ar-toolbar rules moved to insight-global append (B1) */
.ar-spacer { flex: 1 1 auto; }






/* Thư viện */
.ar-lib { padding: 6px 0; overflow: hidden; }
.ar-lib table { width: 100%; border-collapse: collapse; }
.ar-lib th { text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ar-lib td { padding: var(--sp-3) 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ar-lib tr.ar-row { cursor: pointer; }
.ar-lib tr.ar-row:hover td { background: rgba(255,255,255,.55); }
.ar-lib tr.ar-grp td { background: rgba(255,255,255,.35); font-weight: 700; color: var(--text-2); padding: var(--sp-2) 14px; font-size: 13px; }
.ar-lib tr.ar-grp .ar-n { color: var(--muted); font-weight: 500; margin-left: 6px; }
.ar-algo-title { font-weight: 600; }
.ar-algo-desc { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 520px; }
.ar-chip { display: inline-block; font-size: var(--sp-3); padding: 1px 8px; border-radius: 999px; background: var(--gray-soft); color: var(--text-2); margin: 0 4px 4px 0; white-space: nowrap; }
.ar-chip.ar-model { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; margin-left: 6px; }
.ar-chip.ar-ai { background: var(--violet-soft); color: var(--violet); font-weight: 600; }
.ar-chip.ar-tt { background: var(--cyan-soft); color: var(--cyan); font-weight: 600; }
.ar-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.ar-status i { font-style: normal; width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; color: #fff; }
.ar-status.ar-ok { background: var(--ok-soft); color: var(--ok); } .ar-status.ar-ok i { background: #0ca30c; }
.ar-status.ar-warn { background: var(--warn-soft); color: var(--warn); } .ar-status.ar-warn i { background: #d97706; }
.ar-status.ar-danger { background: var(--red-soft); color: var(--danger); } .ar-status.ar-danger i { background: #d03b3b; }

.ar-bm { font-size: 12.5px; min-width: 190px; }
.ar-bm b { font-variant-numeric: tabular-nums; }
.ar-bm .ar-when { color: var(--muted); display: block; }

/* Benchmark tổng quan */
.ar-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.ar-stat { padding: 14px 18px; }
.ar-stat .ar-v { font-size: 26px; font-weight: 650; }
.ar-stat .ar-l { color: var(--muted); font-size: 13px; }
.ar-panel { padding: 18px 20px; }
.ar-panel h3 { margin: 0 0 4px; font-size: var(--sp-4); }
.ar-panel .ar-hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.ar-matrix { width: 100%; border-collapse: separate; border-spacing: 6px; }
.ar-matrix th { font-size: var(--sp-3); color: var(--muted); font-weight: 600; text-align: left; padding: var(--sp-1) var(--sp-2); vertical-align: bottom; }
.ar-matrix th small { display: block; font-weight: 500; }
.ar-matrix td { background: var(--glass-strong); border-radius: var(--sp-3); padding: var(--sp-2) 10px; vertical-align: top; font-size: 12.5px; }
.ar-matrix td.ar-algo { background: transparent; font-weight: 600; min-width: 200px; }
.ar-matrix td a.ar-cell { display: block; color: var(--text); }
.ar-matrix td a.ar-cell:hover { text-decoration: none; }
.ar-matrix td:has(a.ar-cell):hover { background: #fff; box-shadow: var(--shadow-sm); }
.ar-matrix .ar-m { display: flex; justify-content: space-between; gap: 10px; }
.ar-matrix .ar-m b { font-variant-numeric: tabular-nums; }
.ar-matrix .ar-shared { color: var(--muted); font-size: 11px; }
.ar-matrix td.ar-none { color: var(--muted); text-align: center; }
.ar-runs { display: grid; gap: var(--sp-3); }
.ar-run-card { display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-4); padding: var(--sp-4) 18px; background: var(--glass-strong); border-radius: var(--radius-md); }
.ar-run-card h4 { margin: 0; font-size: 15px; }
.ar-run-card .ar-meta { color: var(--muted); font-size: 12.5px; }
.ar-run-card .ar-kpis { display: flex; gap: 18px; grid-column: 1 / -1; }
.ar-run-card .ar-kpis div { font-size: 12.5px; color: var(--muted); }
.ar-run-card .ar-kpis b { display: block; font-size: 18px; color: var(--text); }

/* Trang lần đo */
.ar-crumb { font-size: 13px; color: var(--muted); }
.ar-run-head { padding: var(--sp-5) 24px; display: grid; grid-template-columns: 1fr auto; gap: var(--sp-2) var(--sp-4); align-items: start; }
.ar-run-head h2 { margin: 2px 0 6px; font-size: 22px; }
.ar-run-head .ar-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; align-items: center; }
.ar-run-head .ar-actions { display: flex; gap: var(--sp-2); }
.ar-run-body { display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-4); align-items: start; }
.ar-toc { position: sticky; top: var(--sp-5); padding: 14px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ar-toc b { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 2px 8px 6px; }
.ar-toc a { padding: 6px 8px; border-radius: 10px; color: var(--text-2); }
.ar-toc a:hover { background: var(--glass-strong); text-decoration: none; }
.ar-sec { padding: var(--sp-5) 24px; display: flex; flex-direction: column; gap: 14px; scroll-margin-top: var(--sp-4); }
.ar-sec > h3 { margin: 0; font-size: 18px; }
.ar-sec > h3 small { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: var(--sp-2); }
.ar-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.ar-kpi { background: var(--glass-strong); border-radius: var(--radius-md); padding: 14px 16px; cursor: zoom-in; }
.ar-kpi .ar-v { font-size: 30px; font-weight: 650; line-height: 1.1; }
.ar-kpi .ar-v small { font-size: 15px; font-weight: 600; color: var(--text-2); margin-left: 3px; }
.ar-kpi .ar-l { font-size: 13px; color: var(--text-2); margin-top: var(--sp-1); }
.ar-kpi .ar-s { font-size: 12px; color: var(--muted); }
.ar-callout { background: rgba(37, 99, 235, .07); border: 1px solid rgba(37, 99, 235, .18); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); }
.ar-callout h4 { margin: 0 0 4px; font-size: 13px; color: var(--primary-ink); }
.ar-md p { margin: 0 0 8px; } .ar-md ul { margin: 0; padding-left: var(--sp-5); } .ar-md li { margin: var(--sp-1) 0; }
.ar-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ar-sub { background: var(--glass-strong); border-radius: var(--radius-md); padding: 14px 16px; }
.ar-sub h4 { margin: 0 0 8px; font-size: 14px; }
.ar-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.ar-tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: var(--sp-3); padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
.ar-tbl th.ar-grp { text-align: center; border-bottom: 1px solid var(--line); }
.ar-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ar-tbl td.ar-num, .ar-tbl th.ar-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ar-tbl tr.ar-hl td { background: rgba(37, 99, 235, .08); font-weight: 600; }
.ar-tbl tr.ar-total td { font-weight: 700; }
.ar-note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.ar-src { font-size: 11.5px; color: var(--muted); margin-top: var(--sp-1); }
.ar-viz { margin: 0; background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px; border: 1px solid #fff; }
.ar-viz-head { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: start; }
.ar-viz-head h4 { margin: 0; font-size: 14px; }
.ar-viz-head .ar-btns { display: flex; gap: 6px; flex-shrink: 0; }
.ar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin: var(--sp-2) 0 4px; }
.ar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ar-sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.ar-lk { width: 18px; height: 0; border-top: 2px solid var(--k); display: inline-block; }
.ar-lk.ar-dash { border-top-style: dashed; }
.ar-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.ar-plot text { font-family: var(--font); }
.ar-viz figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.ar-viz .ar-tblview { margin-top: 10px; }
.ar-chips-out { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-chips-out .ar-chip { background: var(--warn-soft); color: var(--warn); font-size: 13px; padding: 3px 10px; }
.ar-seg:hover, .ar-seg:focus { filter: brightness(1.08); outline: none; }
.ar-seg:focus-visible { stroke: var(--text); stroke-width: 1.5; }

/* Tooltip, drawer, lightbox, modal */
.ar-tip { position: fixed; z-index: 50; pointer-events: none; background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .18); padding: var(--sp-2) 10px; font-size: 12.5px; min-width: 140px; }
.ar-tip-title { color: var(--muted); font-size: var(--sp-3); margin-bottom: var(--sp-1); }
.ar-tip-row { display: flex; align-items: center; gap: var(--sp-2); }
.ar-tip-row b { font-variant-numeric: tabular-nums; }
.ar-tip-row .ar-lbl { color: var(--muted); }
.ar-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .28); display: flex; justify-content: flex-end; }
.ar-overlay[hidden] { display: none; }
.ar-drawer { width: min(560px, 92vw); height: 100%; overflow: auto; background: rgba(255,255,255,.94); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: -10px 0 40px rgba(15,23,42,.15); }
.ar-drawer h3 { margin: 0; font-size: 19px; }
.ar-kv { display: grid; grid-template-columns: 140px 1fr; gap: var(--sp-2) var(--sp-3); font-size: 13.5px; }
.ar-kv dt { color: var(--muted); }
.ar-kv dd { margin: 0; }
.ar-overlay.ar-center { justify-content: center; align-items: center; }
.ar-lightbox { width: min(1400px, 94vw); max-height: 92vh; overflow: auto; background: #fff; border-radius: var(--radius); padding: var(--sp-5) 24px; }
.ar-modal { width: min(980px, 94vw); max-height: 92vh; overflow: auto; background: rgba(255,255,255,.97); border-radius: var(--radius); padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; }
.ar-modal h3 { margin: 0; }
.ar-form-sec { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--sp-3) 14px; }
.ar-form-sec h4 { margin: 0 0 8px; font-size: 14px; }
.ar-form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.ar-form-grid input, .ar-form-grid select, .ar-form-sec textarea { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 10px; }
.ar-form-sec textarea { min-height: 170px; font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: 12.5px; }
.ar-form-row-head { display: grid; gap: var(--sp-2); font-size: 11.5px; color: var(--muted); margin-bottom: var(--sp-1); }
.ar-x { position: absolute; }

/* Chế độ toàn màn hình (đọc như báo cáo) */
body.ar-report .ar-side, body.ar-report .ar-page-head, body.ar-report .ar-tabs, body.ar-report .ar-crumb { display: none; }
body.ar-report .ar-app { grid-template-columns: 1fr; max-width: 1180px; margin: 0 auto; }
body.ar-report .ar-run-body { grid-template-columns: 180px 1fr; }
@media print {
  body { background: #fff; } .ar-side, .ar-page-head, .ar-tabs, .ar-toc, .ar-run-head .ar-actions, .ar-viz-head .ar-btns { display: none !important; }
  .ar-app, .ar-run-body { display: block; padding: 0; } .ar-card { box-shadow: none; backdrop-filter: none; border: 0; }
  .ar-sec { break-inside: avoid-page; }
}

/* ==========================================================================
   Insight · token dùng chung + scrollbar  (xem DESIGN-RULES.md)
   Dán vào CUỐI static/style.css. Phần 1–2 áp cho toàn site; phần 3 chỉ AI RnD.
   ========================================================================== */

/* 1. Token: khoảng cách bội số 4 px, cỡ chữ, ô nhập. Thêm biến, không đổi giao diện cũ. */
:root {
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 24px;
  --control-h: 38px; --control-px: 12px;
  --sb-size: 10px;
  --sb-thumb: rgba(100, 116, 139, .38);
  --sb-thumb-hover: rgba(79, 70, 229, .55);
}

/* 2. Scrollbar toàn site: mảnh, nền trong suốt, thanh kéo bo tròn.
   Chrome/Edge 121+ và Firefox dùng thuộc tính chuẩn; Safari dùng ::-webkit-scrollbar. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--sb-thumb) transparent;
}
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: var(--sb-size); height: var(--sb-size); }
  ::-webkit-scrollbar-track,
  ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background-color: var(--sb-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
}

/* 3. AI RnD · hàng lọc. CSS chung của Insight đặt input/select width:100%,
   nên trong hàng flex mỗi ô chiếm trọn một dòng. Ghi đè ở đây, chỉ trong .ar-toolbar. */
.ar-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3);
}
.ar-toolbar > input:not([type="checkbox"]),
.ar-toolbar > select {
  width: auto; flex: 0 1 140px; min-width: 120px; height: var(--control-h);
}
.ar-toolbar > input.ar-search {
  flex: 1 1 200px; min-width: 180px; width: auto;
}
.ar-toolbar > label {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  white-space: nowrap; font-size: var(--fs-sm); color: var(--muted);
}
.ar-toolbar input[type="checkbox"] { width: 16px; height: 16px; min-width: 0; flex: none; margin: 0; }
.ar-toolbar > .ar-spacer { flex: 1 1 auto; }
@media (max-width: 900px) { .ar-toolbar > .ar-search { flex-basis: 100%; } }

/* AI RnD · small btn modifier (B2) — keep Insight .btn, page-scoped size */
.btn.ar-small { min-height: 32px; padding: 4px 10px; font-size: 12px; border-radius: 10px; }


/* ---------- v22.11: shared list filter popover (filterPopover / listHead in app.js) ---------- */
.lf-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 44px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.lf-head .spacer, .lf-panel-foot .spacer, .feature-filter .spacer, .tl-filter-head .spacer { flex: 1 1 auto; }
.lf-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.lf-title b { font-size: .98rem; }
.lf-bar { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card, rgba(255,255,255,.75)); }
.table-card > .lf-head { border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.dm-lf-bar { grid-column: 1 / -1; margin-bottom: 0; }
.lf-wrap { position: relative; display: inline-flex; flex: none; }
.lf-btn { position: relative; width: 2.25rem; height: 2.25rem; color: var(--muted-2, #4b5a6e); }
.lf-btn.on, .lf-wrap.open .lf-btn { color: var(--primary, #2563eb); background: rgba(37, 99, 235, .12); border-color: rgba(37, 99, 235, .25); }
.lf-badge { position: absolute; top: -5px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary, #2563eb); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #fff; pointer-events: none; }
.lf-panel { position: fixed; z-index: 1001; top: 80px; right: 12px; width: min(360px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto;
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); text-align: left; }
.lf-panel[hidden], .lf-backdrop[hidden] { display: none !important; }
.lf-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px; }
.lf-panel-head .lf-x { width: 2rem; height: 2rem; }
.lf-body { display: flex; flex-direction: column; gap: 8px; padding: 6px 12px 10px; }
.lf-body > *, .lf-body select, .lf-body input[type=search], .lf-body input[type=text], .lf-body input[type=date] { width: 100%; min-width: 0; max-width: none; margin: 0; }
.lf-body label.check, .lf-body label.ar-check { display: flex; align-items: center; gap: 6px; width: auto; }
.lf-body label.ar-check input { width: auto; }
.lf-body .date-range { display: flex; align-items: center; gap: 6px; }
.lf-body .date-range input { flex: 1 1 auto; }
.lf-body .dm-filterbar { padding: 0; border: 0; background: none; }
.lf-body .dm-filter-row { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.lf-body .dm-filter-row > * { width: 100%; max-width: none; flex: none !important; height: auto; min-height: 38px; }
.lf-body .dm-tagbox { min-width: 0; }
.lf-body .bx-bar { display: flex; flex-direction: column; gap: 8px; }
.lf-body .bx-filter { display: flex; flex-direction: column; gap: 4px; }
.lf-body .tl-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.lf-body .tl-filter .tl-fchip { width: auto; }
.lf-panel-count { padding: 0 12px 8px; }
.lf-panel-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.lf-backdrop { display: none; }
.feature-filter .lf-wrap, .tl-filter-head .lf-wrap { margin-left: auto; }
.history-tools { display: flex; align-items: center; gap: 8px; }
.ar-toolbar.lf-bar { align-items: center; }
.lf-empty { margin: 12px; }
@media (max-width: 899px) {
  .lf-panel { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 80vh; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0); z-index: 1001; }
  .lf-backdrop { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, .35); }
  .lf-head { padding: 8px 10px; }
  .lf-body select, .lf-body input { min-height: 42px; font-size: 16px; }
}


/* ===== AI RnD · Benchmark thiết kế lại (04/11/2026, mock-benchmark.html) — class ar-bx-* ===== */
.ar-bx-root { min-width: 0; }
.ar-bx-root .card { margin: 0; }
.ar-bx-rsn { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-size: 13px; }
.ar-bx-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--gray-soft); color: var(--text-2); white-space: nowrap; }
.ar-bx-slide .btn.small, .ar-bx-ver .btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 10px; min-height: 0; }
.ar-bx-blk h3, .ar-bx-follow h4, .ar-bx-mhead h2 { line-height: 1.35; }
.ar-bx-slider input[type=range] { padding: 0; height: auto; border: 0; background: none; box-shadow: none; min-height: 0; }
@media (prefers-reduced-motion: reduce) { .ar-bx-ov, .ar-bx-slide, .ar-bx-ov.ar-bx-closing, .ar-bx-ov.ar-bx-closing .ar-bx-slide, .ar-bx-fill { transition: none !important; animation: none !important; } html:has(.ar-bx-root) { scroll-behavior: auto; } }
/* (i) — nút giải thích */
/* Quy tắc: mọi thiết bị và thuật ngữ trong chữ đều có (i) ngay sau, ở mọi chỗ (gắn tự động bằng rich()). */
.ar-bx-i { position: relative; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid currentColor; color: var(--bm-i); background: transparent;
  font: 700 10px/1 Georgia, serif; font-style: italic; padding: 0; margin-left: 3px; vertical-align: 1px; flex: none; }
.ar-bx-i::after { content: ""; position: absolute; inset: -5px; } /* vùng bấm rộng hơn hình */
.ar-bx-i:hover, .ar-bx-i[aria-expanded="true"] { background: #334155; color: #fff; border-color: #334155; }
.ar-bx-term { display: inline-flex; align-items: center; white-space: nowrap; }
.ar-bx-pop { position: fixed; z-index: 60; width: min(400px, 92vw); background: #fff; border-radius: 16px; box-shadow: 0 16px 48px rgba(15,23,42,.22); overflow: hidden; font-size: 13px; }
.ar-bx-pop[hidden] { display: none; }
.ar-bx-pop .ar-bx-fig { background: #f4f6f8; padding: 10px 14px 4px; }
.ar-bx-pop .ar-bx-fig svg { display: block; width: 100%; height: 150px; }
.ar-bx-pop.ar-bx-wide { width: min(580px, 94vw); } .ar-bx-pop.ar-bx-wide .ar-bx-fig svg { height: auto; }
.ar-bx-pop .ar-bx-fig small { display: block; text-align: right; color: var(--muted); font-size: 11px; }
.ar-bx-pop .ar-bx-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.ar-bx-pop h4 { margin: 0; font-size: 15px; } .ar-bx-pop p { margin: 0; color: var(--text-2); }
.ar-bx-pop .ar-bx-why { background: #f1f5f9; border-radius: 10px; padding: 8px 10px; }
.ar-bx-pop .ar-bx-ours { border-left: 3px solid var(--bm-accent); padding-left: 10px; } .ar-bx-pop .ar-bx-ours b { color: var(--bm-accent-ink); }
.ar-bx-pop table { width: 100%; border-collapse: collapse; font-size: 12.5px; } .ar-bx-pop td { padding: 3px 0; vertical-align: top; } .ar-bx-pop td:first-child { color: var(--muted); width: 108px; }
.ar-bx-pop .ar-bx-back { border: 0; background: none; color: #334155; font-weight: 600; font-size: 12.5px; padding: 10px 16px 0; }

/* Benchmark: một trang, mỗi model một phần độc lập, mục lục bên phải */
.ar-bx-bm { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: var(--sp-4); align-items: start; }
/* Mỗi bài toán một khung riêng: nền, viền, nhãn «Bài toán N», tiêu đề dính trên cùng khi cuộn trong khung đó */
.ar-bx-bm-main { display: flex; flex-direction: column; gap: 40px; min-width: 0; }
/* Mỗi bài toán là MỘT khối: tiêu đề dính ở trên, các biểu đồ là ô ngăn bằng đường kẻ mảnh (không thẻ con), «Từ cần biết» gom một dòng cuối */
.ar-bx-msec { display: flex; flex-direction: column; scroll-margin-top: calc(var(--sticky-top, 0px) + 12px); padding: 0; overflow: visible; }
.ar-bx-mhead { position: sticky; top: var(--sticky-top, 0px); z-index: 20; background: #fff; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--line); padding: 14px 24px; display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-4); align-items: center; }
.ar-bx-mhead .ar-bx-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bm-accent-ink); }
.ar-bx-mhead h2 { margin: 0; font-size: 19px; } .ar-bx-mhead .ar-bx-sub { color: var(--muted); font-size: 13px; } .ar-bx-mhead .ar-bx-sub .ar-bx-en { color: #334155; font-weight: 600; }
.ar-bx-acts { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: flex-end; }
.ar-bx-ticon { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg, #2e9b4f, #1f7a3d); display: grid; place-items: center; color: #fff; flex: none; }
.ar-bx-vchip { font: 600 12px/1 var(--font); padding: 4px 8px; border-radius: 8px; background: var(--bm-soft); color: #334155; font-variant-numeric: tabular-nums; }
.ar-bx-vsel { position: relative; } .ar-bx-vmenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 240px; background: #fff; border-radius: 14px; box-shadow: 0 16px 40px rgba(15,23,42,.18); padding: 6px; }
.ar-bx-vmenu[hidden] { display: none; }
.ar-bx-vitem { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; border: 0; background: none; text-align: left; width: 100%; }
.ar-bx-vitem:hover, .ar-bx-vitem.ar-bx-on { background: var(--bm-soft); }
.ar-bx-banner { padding: 10px 16px; border-radius: var(--radius-md); background: var(--warn-soft); color: var(--warn); display: flex; gap: var(--sp-3); align-items: center; font-weight: 600; }
.ar-bx-ondev { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; font-size: 13px; color: var(--muted); }
.ar-bx-devchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--glass-strong); border: 1px solid #fff; color: var(--text); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.ar-bx-devchip .ar-bx-be { display: inline-flex; align-items: center; font-weight: 700; font-size: 10.5px; padding: 1px 4px 1px 6px; border-radius: 6px; background: #e2e8f0; color: #334155; }
.ar-bx-devchip .ar-bx-be.ar-bx-npu { background: rgba(147,51,234,.12); color: #7e22ce; }
.ar-bx-devchip .ar-bx-be .ar-bx-i { width: 13px; height: 13px; font-size: 9px; }
.ar-bx-mbody { border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.ar-bx-blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(420px, calc(50% - 1px)), 1fr)); gap: 1px; background: var(--line); }
.ar-bx-blk { padding: 20px 24px; background: rgba(255,255,255,.6); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; scroll-margin-top: calc(var(--sticky-top, 0px) + 104px); } /* chừa chỗ cho 2 tiêu đề dính */
.ar-bx-blk h3 { margin: 0; font-size: 15.5px; } .ar-bx-blk .ar-bx-ans { font-weight: 650; color: var(--bm-ink); font-size: 14px; }
.ar-bx-blk .ar-bx-hint { font-size: 12px; color: var(--muted); } .ar-bx-blk > .ar-bx-hint:last-child { margin-top: auto; }
.ar-bx-follow { display: flex; flex-direction: column; gap: var(--sp-3); border-top: 1px dashed rgba(148,163,184,.6); padding-top: var(--sp-4); margin-top: var(--sp-1); scroll-margin-top: calc(var(--sticky-top, 0px) + 104px); }
.ar-bx-follow h4 { margin: 0; font-size: 14.5px; }
.ar-bx-mterms { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 12px 24px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: rgba(255,255,255,.45); }
.ar-bx-msec .ar-bx-banner { border-radius: 0; }


.ar-bx-blk.ar-bx-wide { grid-column: 1 / -1; }
.ar-bx-brow { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 12px; align-items: center; }
.ar-bx-btrack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ar-bx-btrack .ar-bx-bar { height: 22px; min-width: 3px; border-radius: 0 6px 6px 0; flex: none; }
/* CPU so với NPU: hai thanh ngang mỗi chỉ số (SPEC-06 3.4) */
.ar-bx-cmp { display: flex; flex-direction: column; gap: 12px; }
.ar-bx-cmp-scale { font-size: 11.5px; color: var(--muted); text-align: right; padding-right: 72px; }
.ar-bx-cmp-row { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr); gap: 12px; align-items: center; }
.ar-bx-cmp-lbl { font-size: 13px; } .ar-bx-cmp-lbl small { display: block; color: var(--muted); font-size: 11px; }
.ar-bx-cmp-bars { display: flex; flex-direction: column; gap: 4px; }
.ar-bx-cmp-bar { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 8px; align-items: center; }
.ar-bx-cmp-track { height: 12px; border-radius: 0 6px 6px 0; background: var(--bm-track); }
.ar-bx-cmp-fill { display: block; height: 100%; min-width: 3px; border-radius: 0 6px 6px 0; } .ar-bx-cmp-fill.ar-bx-cpu { background: var(--c-cpu); } .ar-bx-cmp-fill.ar-bx-npu { background: var(--c-npu); }
.ar-bx-cmp-bar b { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.ar-bx-slider.ar-bx-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-3) var(--sp-6); align-items: center; }
.ar-bx-slider .ar-bx-col { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.ar-bx-toc { position: sticky; top: calc(var(--sticky-top, 0px) + 12px); max-height: calc(100vh - var(--sticky-top, 0px) - 24px); overflow: auto; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ar-bx-toc-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 2px; }
.ar-bx-toc a { display: block; padding: 6px 10px; border-radius: 10px; color: var(--text-2); }
.ar-bx-toc a:hover { text-decoration: none; background: var(--glass-strong); }
.ar-bx-toc .ar-bx-toc-m { margin-top: 8px; } .ar-bx-toc-m b { display: block; font-size: 13.5px; } .ar-bx-toc-m small { color: var(--muted); font-size: 12px; }
.ar-bx-toc .ar-bx-toc-b { padding-left: 22px; }
.ar-bx-toc a.ar-bx-on { background: var(--bm-accent-soft); color: var(--bm-accent-ink); font-weight: 600; }
.ar-bx-toc a.ar-bx-in b { color: var(--bm-accent-ink); }
.ar-bx-blk .ar-bx-why { font-size: 12px; color: var(--muted); background: #f1f5f9; border-radius: 10px; padding: 6px 10px; }
.ar-bx-waffle-wrap { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: var(--sp-5); align-items: center; }
.ar-bx-waffle { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.ar-bx-waffle i { aspect-ratio: 1; border-radius: 4px; display: block; position: relative; overflow: hidden; }
.ar-bx-waffle i.ar-bx-part { background: var(--c-khong); outline: 2px solid var(--c-nham); outline-offset: 1px; }
.ar-bx-waffle i.ar-bx-part::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--c-nham); }
.ar-bx-leg { display: flex; flex-direction: column; gap: var(--sp-3); }
.ar-bx-leg div { display: grid; grid-template-columns: 14px 1fr; gap: 2px 10px; align-items: baseline; }
.ar-bx-leg .ar-bx-sw { width: 14px; height: 14px; border-radius: 4px; transform: translateY(2px); }
.ar-bx-leg b { font-size: 20px; font-weight: 650; } .ar-bx-leg span { grid-column: 2; font-size: 12.5px; color: var(--text-2); }
.ar-bx-slider { display: flex; flex-direction: column; gap: var(--sp-3); }
/* Thẳng trục với biểu đồ nhỏ: lề trái 34/520, lề phải 10/520 của viewBox */
.ar-bx-slider input[type=range], .ar-bx-slider .ar-bx-ticks { margin: 0 1.9% 0 6.5%; width: auto; }
.ar-bx-slider input[type=range] { accent-color: var(--bm-accent); }
.ar-bx-ticks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ar-bx-ticks span.ar-bx-cur { color: var(--bm-accent-ink); font-weight: 700; }
.ar-bx-meter { display: grid; grid-template-columns: 150px 1fr 110px; gap: var(--sp-3); align-items: center; font-size: 13px; }
.ar-bx-meter .ar-bx-track { height: 14px; border-radius: 999px; background: var(--bm-track); overflow: hidden; }
.ar-bx-meter .ar-bx-fill { height: 100%; border-radius: 999px; transition: width .25s; }
.ar-bx-meter b { text-align: right; font-variant-numeric: tabular-nums; }
.ar-bx-mean { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: #f4f6f8; color: var(--text-2); }
.ar-bx-mean.ar-bx-box { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.ar-bx-plot svg { display: block; width: 100%; height: auto; overflow: visible; } .ar-bx-plot text { font-family: var(--font); }

/* Slide-out */
.ar-bx-ov { position: fixed; inset: 0; z-index: 40; background: rgba(15,23,42,.25); display: flex; justify-content: flex-end; animation: ovIn .2s ease; }
.ar-bx-ov[hidden] { display: none; }
.ar-bx-slide { width: min(620px, 94vw); height: 100%; overflow: auto; background: #fff; padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); box-shadow: -10px 0 40px rgba(15,23,42,.15); animation: slIn .28s cubic-bezier(.2,.8,.2,1); }
.ar-bx-ov.ar-bx-closing { animation: ovOut .2s ease forwards; } .ar-bx-ov.ar-bx-closing .ar-bx-slide { animation: slOut .22s ease-in forwards; }
@keyframes ovIn { from { background: rgba(15,23,42,0); } } @keyframes ovOut { to { background: rgba(15,23,42,0); } }
@keyframes slIn { from { transform: translateX(100%); } } @keyframes slOut { to { transform: translateX(100%); } }
.ar-bx-slide .ar-bx-shead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ar-bx-slide .ar-bx-shead small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ar-bx-slide h3 { margin: 0; font-size: 19px; } .ar-bx-slide h4 { margin: 0 0 6px; font-size: 14px; }
.ar-bx-tbl { width: 100%; border-collapse: collapse; font-size: 13px; } .ar-bx-tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ar-bx-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); } .ar-bx-tbl td + td { text-align: right; font-variant-numeric: tabular-nums; }
.ar-bx-slide ul { margin: 0; padding-left: 18px; } .ar-bx-slide li { margin: 4px 0; }
.ar-bx-slide section { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.ar-bx-slide section:first-of-type { border-top: 0; padding-top: 0; }
.ar-bx-slide .ar-bx-ans { font-weight: 650; color: var(--bm-ink); font-size: 13.5px; }
.ar-bx-slide .ar-bx-src { font-size: 12px; margin: 0; color: var(--muted); }
.ar-bx-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-2); }
.ar-bx-set { display: grid; grid-template-columns: 40px 1fr; gap: 0 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: #f6f7f8; }
.ar-bx-set img { grid-row: span 2; width: 40px; height: 48px; object-fit: cover; border-radius: 8px; }
.ar-bx-set b { font-size: 20px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; } .ar-bx-set span { font-size: 12.5px; color: var(--text-2); }
.ar-bx-set small { display: block; color: var(--muted); font-size: 11.5px; }
.ar-bx-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; }
.ar-bx-flow .ar-bx-pill { padding: 5px 10px; border-radius: 999px; background: var(--bm-soft); color: #334155; font-weight: 600; }
.ar-bx-flow svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.ar-bx-lg { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--muted); align-items: center; }
.ar-bx-lg span { display: inline-flex; align-items: center; gap: 6px; }
.ar-bx-lg .ar-bx-dot { width: 10px; height: 10px; border-radius: 50%; } .ar-bx-lg .ar-bx-dot.ar-bx-cpu { background: var(--c-cpu); } .ar-bx-lg .ar-bx-dot.ar-bx-npu { border: 2px solid var(--c-npu); box-sizing: border-box; }
.ar-bx-lg .ar-bx-sq { width: 12px; height: 10px; border-radius: 2px; } .ar-bx-lg .ar-bx-sq.ar-bx-cpu { background: var(--c-cpu); } .ar-bx-lg .ar-bx-sq.ar-bx-npu { background: var(--c-npu); }
.ar-bx-lg .ar-bx-bar-sw { width: 16px; height: 10px; border-radius: 0 3px 3px 0; background: var(--c-lo); } .ar-bx-lg .ar-bx-tick-sw { width: 16px; height: 10px; border-right: 2px solid #475569; background: linear-gradient(#475569,#475569) center/100% 2px no-repeat; }
.ar-bx-mult { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.ar-bx-mult figure { margin: 0; display: flex; flex-direction: column; gap: 4px; } .ar-bx-mult svg { width: 100%; height: auto; display: block; }
.ar-bx-mult figcaption { font-size: 12.5px; font-weight: 600; } .ar-bx-mult figcaption small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.ar-bx-mult .ar-bx-v { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ar-bx-rrow { display: grid; grid-template-columns: 230px 1fr; gap: 12px; align-items: center; }
.ar-bx-rtrack { position: relative; height: 22px; }
.ar-bx-rbar { position: absolute; left: 0; top: 0; height: 22px; border-radius: 0 6px 6px 0; }
.ar-bx-rwhisk { position: absolute; top: 10px; height: 2px; background: #475569; } .ar-bx-rwhisk::after { content: ""; position: absolute; right: -1px; top: -5px; width: 2px; height: 12px; background: #475569; }
.ar-bx-rtrack b { position: absolute; top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 13px; }
.ar-bx-tbl-toggle summary { cursor: pointer; font-size: 12.5px; color: var(--bm-accent-ink); font-weight: 600; width: max-content; }
.ar-bx-tbl-toggle[open] summary { margin-bottom: 6px; }
.ar-bx-notes { list-style: none; padding: 0 !important; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ar-bx-notes li { margin: 0 !important; padding: 7px 12px; border-radius: 10px; background: #f1f5f9; font-size: 13px; }
.ar-bx-vlist { display: flex; flex-direction: column; gap: var(--sp-3); }
.ar-bx-ver { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--sp-3) var(--sp-4); display: grid; grid-template-columns: auto 1fr auto; gap: 4px var(--sp-3); align-items: center; }
.ar-bx-ver.ar-bx-cur { border-color: var(--bm-accent); background: #f3faf5; }
.ar-bx-ver .ar-bx-chg { grid-column: 2 / 4; font-size: 13px; color: var(--text-2); }
.ar-bx-bump { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: #e2e8f0; color: #334155; text-transform: uppercase; }
.ar-bx-bump.ar-bx-minor { background: var(--cyan-soft); color: var(--cyan); } .ar-bx-bump.ar-bx-major { background: var(--red-soft); color: var(--danger); } .ar-bx-bump.ar-bx-patch { background: var(--gray-soft); }
@media (max-width: 1100px) { .ar-bx-bm { grid-template-columns: 1fr; } .ar-bx-toc { position: static; order: -1; max-height: none; flex-direction: row; flex-wrap: wrap; align-items: center; } .ar-bx-toc .ar-bx-toc-m { margin-top: 0; } .ar-bx-toc .ar-bx-toc-b { display: none; } }
@media (max-width: 560px) {
  .ar-bx-brow, .ar-bx-rrow { grid-template-columns: 1fr; gap: 4px; } .ar-bx-mult { grid-template-columns: 1fr; } .ar-bx-blk { padding: 16px; }
  .ar-bx-mhead { position: static; padding: 12px 16px; } /* màn hẹp: tiêu đề không dính, đỡ chiếm chỗ */
  .ar-bx-meter { grid-template-columns: minmax(0, 1fr) auto; } .ar-bx-meter .ar-bx-track { grid-column: 1 / -1; grid-row: 2; }
  .ar-bx-cmp-row { grid-template-columns: 1fr; gap: 4px; } .ar-bx-cmp-scale { padding-right: 0; }
}
@media (max-width: 760px) { .ar-bx-blocks { grid-template-columns: 1fr; } .ar-bx-mhead { grid-template-columns: auto 1fr; } .ar-bx-acts { grid-column: 1 / -1; justify-content: flex-start; } .ar-bx-waffle-wrap, .ar-bx-slider.ar-bx-two { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .ar-bx-rsn { grid-template-columns: minmax(0, 1fr) auto; } .ar-bx-rsn > div { grid-column: 1 / -1; grid-row: 2; } .ar-bx-waffle-wrap { grid-template-columns: 1fr; } .ar-bx-slider.ar-bx-two { grid-template-columns: 1fr; } .ar-bx-btrack .ar-bx-bar { max-width: calc(100% - 140px); } }
/* ===== hết Benchmark ar-bx ===== */

/* ---------- v22.12: tabs inside the header card; list title bar inside its card ---------- */
.page-head { flex-wrap: wrap; }
.page-head > .ph-tabs { position: static; order: 9; flex: 1 1 100%; width: 100%; margin: 10px 0 0; padding: 4px 0 0; background: none; border: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none; border-radius: 0; }
.page-head > .lu-head-actions { order: 5; }
.lf-card { padding-top: 0; overflow: visible; }
.card.lf-card > .lf-head { margin: 0 -1px 0; }
.card.lf-card:not(.table-card) > .lf-head { margin: 0 -16px 12px; padding-left: 16px; padding-right: 16px; }
.card.ar-lib.lf-card > .lf-head, .card.ar-panel.lf-card > .lf-head { margin-left: 0; margin-right: 0; padding-left: 4px; padding-right: 4px; }
.lf-head h3 { margin: 0; }
.lf-head .lf-add { order: 99; }
.lf-grid-card > .dt-profile-cards, .lf-grid-card > .sol-grid, .lf-grid-card > .tl-reminders { margin: 0; }
@media (max-width: 899px) {
  .page-head > .ph-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .card.lf-card:not(.table-card) > .lf-head { margin: 0 -12px 10px; padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 899px) {
  .lf-head { flex-wrap: nowrap; }
  .lf-head .spacer { display: none; }
  .lf-title { flex: 1 1 auto; min-width: 0; overflow: hidden; }
  .lf-title b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lf-title .lf-count { white-space: nowrap; }
  .lf-head .lf-add, .lf-head .lu-add { flex: none; white-space: nowrap; }
}

/* 4/11: last-update label, top-right of the header card */
.page-head { position: relative; }
.page-head > .ph-updated { position: absolute; top: 14px; right: 18px; font-size: 12px; white-space: nowrap; }
@media (max-width: 899px) { .page-head > .ph-updated { top: 12px; right: 14px; font-size: 11px; } }

/* 4/11 14:48: dev popup — bar, add-on stats, then list/detail each get their own grid row (stats no longer collapse under the list). */
@media (min-width: 769px) {
  .modal.dev-popup .dev-md { grid-template-rows: auto minmax(0, 1fr); }
  .modal.dev-popup .dev-md > .dm-lf-bar { grid-row: 1; }
  .modal.dev-popup .dev-md > .dev-list-col, .modal.dev-popup .dev-md > .dev-detail-col { grid-row: 2; }
}

/* 4/11: device list — price after the name; name truncates so the price stays visible */
.dm-name-row { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.dm-name-row .dev-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-price { flex: none; white-space: nowrap; color: #dc2626; font-size: .8rem; font-weight: 600; }
.dm-price.none { color: var(--muted, #64748b); font-style: italic; font-weight: 400; }
.dm-txt { min-width: 0; }
.bx-price-src a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bx-price-src a:hover { color: var(--primary, #2563eb); }

/* v22.14 — shared stats popover (chart icon «Thống kê» next to the funnel); < 900px it is the same bottom sheet as .lf-panel */
.lf-panel.lf-stats { width: min(600px, calc(100vw - 24px)); max-height: min(75vh, 640px); }
.lf-stats .lf-body { padding: 4px 12px 10px; }
.lf-stats .dm-addon-stats { border: 0; padding: 0; background: transparent; }
.lf-stats .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
@media (max-width: 899px) {
  .lf-panel.lf-stats { width: 100%; max-height: 85vh; }
  .lf-stats .dm-stats-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) { .lf-stats .kpis { grid-template-columns: 1fr; } }

/* v22.15 — shared price-range filter in every filter popover of a priced list */
.lf-price { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; width: 100%; min-width: 0; }
.lf-price-l { flex: none; color: var(--muted); font-weight: 600; }
.lf-price .lf-price-in { flex: 1 1 0; min-width: 0; width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.dm-filterbar .lf-price { margin-top: 8px; }

/* v22.16 — package header: icon-only Sửa / Làm mới (same size as the list icons), no % ring */
.pkg-name-row .pkg-icon-btn { flex: none; width: 2.25rem; height: 2.25rem; color: var(--muted-2, #4b5a6e); }
.pkg-name-row .pkg-icon-btn:hover { color: var(--primary, #2563eb); }
.pkg-name-row .pkg-icon-btn[disabled] { opacity: .5; }

/* ===== SPEC-06 (04/11/2026): biến màu chung, khung chờ của router ===== */
:root {
  --bg: #f3f4f6;
  --glass: rgba(255,255,255,.88); --glass-strong: #fff; --glass-border: #e5e7eb;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  /* Màu dữ liệu, dùng chung cho mọi biểu đồ. Đã kiểm mù màu mọi cặp (ΔE ≥ 7,9). Vàng tương phản thấp (2,1:1) nên luôn có nhãn số và «Bảng số». */
  --c-dung: #2e9b4f; --c-khong: #e8a317; --c-nham: #b93d0b; --c-hi: #2e9b4f; --c-lo: #b9dcc5; --c-cpu: #475569; --c-npu: #9333ea;
  --bm-accent: #2e9b4f; --bm-accent-ink: #1f6f38; --bm-accent-soft: rgba(46,155,79,.12);
  --bm-ink: #0f172a; --bm-i: #64748b; --bm-soft: #f1f5f9; --bm-track: #eceef1;
}
.sk { display: block; border-radius: 6px; background: linear-gradient(90deg, #eceef1 0%, #f6f7f9 50%, #eceef1 100%); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.route-sk { display: flex; flex-direction: column; gap: 16px; }
.route-sk > .page-head { margin-bottom: 0; }
/* ===== hết SPEC-06 ===== */

/* ===== Brief 07 · phase + status tokens (DESIGN-RULES-CC) ===== */
:root{
  --st-xong:#2e9b4f; --st-xong-soft:#e8f5ec; --st-xong-ink:#1f6e37;
  --st-dang:#e8a317; --st-dang-soft:#fdf4e1; --st-dang-ink:#8a5a00;
  --st-tre:#b93d0b;  --st-tre-soft:#fdece5;  --st-tre-ink:#9a3412;
  --st-chua:#94a3b8;
  --ph-khao-sat:#c026d3; --ph-phan-tich:#65a30d; --ph-dev:#7c3aed; --ph-mkt-sales:#0d9488;
  --ph-pilot:#ea580c; --ph-trien-khai:#0284c7; --ph-cskh:#db2777;
  --s-1:4px; --s-2:8px; --s-3:12px; --s-4:16px; --s-5:20px; --s-6:24px; --s-8:32px; --s-10:40px;
  --fs-1:12px; --fs-2:13px; --fs-3:14px; --fs-4:16px; --fs-5:18px; --fs-6:20px; --fs-7:24px;
  --fw-r:400; --fw-m:500; --fw-s:600; --fw-b:650;
  --r-sm:6px; --r-md:8px; --r-lg:12px; --r-xl:16px; --r-full:999px;
  --sh-xs:0 1px 2px rgba(15,23,42,.05);
  --sh-sm:0 1px 3px rgba(15,23,42,.08),0 1px 2px rgba(15,23,42,.04);
  --sh-pop:0 10px 38px -10px rgba(22,23,24,.30),0 10px 20px -15px rgba(22,23,24,.20);
  --sh-sheet:-16px 0 40px -12px rgba(15,23,42,.22);
  --h-sm:32px; --h-md:36px;
  --ease:cubic-bezier(.16,1,.3,1); --t-fast:120ms; --t:180ms; --t-slow:260ms;
  --n-0:#ffffff; --n-1:#f8fafc; --n-2:#f1f5f9; --n-3:#e2e8f0; --n-4:#cbd5e1; --n-5:#94a3b8; --n-6:#64748b; --n-7:#475569; --n-8:#334155; --n-9:#1e293b; --n-10:#0f172a;
}

/* v22.19 — dual-handle price slider under «Giá từ – đến» (shared priceRangeInput) */
.lf-price-wrap { display: flex; flex-direction: column; gap: 4px; width: 100%; min-width: 0; }
.dm-filterbar .lf-price-wrap { margin-top: 8px; }
.dm-filterbar .lf-price-wrap .lf-price { margin-top: 0; }
.lf-range[hidden] { display: none !important; }
.lf-range { padding: 2px 4px 0; }
.lf-range-track { position: relative; height: 26px; }
.lf-range-rail, .lf-range-fill { position: absolute; top: 11px; height: 4px; border-radius: 4px; }
.lf-range-rail { left: 0; right: 0; background: var(--line, #e2e8f0); }
.lf-range-fill { background: var(--primary, #2563eb); }
.lf-range-in { position: absolute; left: 0; top: 0; width: 100%; height: 26px; margin: 0; background: none; -webkit-appearance: none; appearance: none; z-index: 2; cursor: pointer; }
.lf-range-in::-webkit-slider-runnable-track { background: none; height: 26px; }
.lf-range-in::-moz-range-track { background: none; }
.lf-range-in::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; margin-top: 4px; border-radius: 50%; background: #fff; border: 2px solid var(--primary, #2563eb); box-shadow: 0 1px 3px rgba(15, 23, 42, .25); cursor: grab; }
.lf-range-in::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--primary, #2563eb); cursor: grab; }
.lf-range-in:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ring, #93c5fd); outline-offset: 1px; }
.lf-range-edges { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
@media (max-width: 899px) { .lf-range-in::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: 1px; } }
/* v22.19.2 — the global field styling must not paint the range inputs (rail + fill stay visible) */
.lf-range .lf-range-in, .lf-range .lf-range-in:focus, .lf-range .lf-range-in:hover { background: transparent !important; border: 0 !important; box-shadow: none !important; outline: none !important; padding: 0 !important; min-height: 0 !important; height: 26px !important; border-radius: 0 !important; }

/* v22.20 / v22.22 — package page (pd.js) header popups; pd.js prefixes every class with pd- */
.lf-panel.lf-stats.pd-pop { width: min(720px, calc(100vw - 24px)); max-height: min(80vh, 720px); }
.lf-panel.pd-pop .pd-pop-body > .pd-card { box-shadow: none; border: 0; padding: 0; margin: 0; background: transparent; }
.lf-panel.pd-pop .pd-pop-body > .pd-card > .pd-card-hd h2 { display: none; }
.lf-panel.pd-pop .pd-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.lf-panel.pd-pop .pd-kpis > .pd-kpi.pd-muc { grid-column: 1 / -1; }
.lf-panel.pd-pop .pd-pop-body { overflow-x: auto; }
@media (max-width: 899px) { .lf-panel.lf-stats.pd-pop { width: 100%; max-height: 85vh; } .lf-panel.pd-pop .pd-kpis { grid-template-columns: 1fr; } }
.pd-root .pd-ttl { flex-wrap: nowrap; }
.pd-root .pd-ttl > * { flex-shrink: 0; }
.pd-root .pd-ttl > h1 { flex-shrink: 1; min-width: 6em; }
@media (max-width: 1440px) { .pd-root .pd-ttl .pd-btn-primary .pd-btn-label { display: none; } }

/* v22.22 — package board: phase columns open/close by their header (default closed, last state per package+phase) */
.pd-root .pd-lane-tgl { cursor: pointer; user-select: none; border-radius: var(--r-md, 8px); }
.pd-root .pd-lane-tgl:hover { background: rgba(15, 23, 42, .03); }
.pd-root .pd-lane-tgl:focus-visible { outline: 2px solid var(--primary-ring, rgba(79, 70, 229, .3)); outline-offset: 2px; }
.pd-root .pd-lane-t .pd-lane-chev { margin-left: auto; flex: none; color: var(--muted, #64748b); transition: transform .15s ease; transform: rotate(180deg); }
.pd-root .pd-lane[data-collapsed] .pd-lane-chev { transform: rotate(0deg); }
.pd-root .pd-lane[data-collapsed] > .pd-lane-bd { display: none; }
.pd-root .pd-lane[data-collapsed] { align-self: stretch; }
/* v22.24: collapsed lanes keep full column width; only height shrinks */
.pd-root .pd-board > .pd-bcol { min-width: 0; }
.pd-root .pd-bcol > .pd-lane { width: 100%; box-sizing: border-box; align-self: stretch; flex: none; }

/* v22.25 — Tối đa 3 màu trên trang gói (DESIGN-RULES §12): primary tím, xanh lá = xong, đỏ = trễ. Còn lại xám. */
html body .pd-root {
  --pd-primary:#5b3fe0; --pd-primary-hover:#4a30c8; --pd-primary-soft:#efecfd; --pd-primary-ring:rgba(91,63,224,.28);
  --pd-grad:linear-gradient(135deg,#5b3fe0,#5b3fe0);
  --pd-st-tre:#d92d20; --pd-st-tre-soft:#fdecea; --pd-st-tre-ink:#b42318;
  --pd-st-dang:#5b3fe0; --pd-st-dang-soft:#efecfd; --pd-st-dang-ink:#4a30c8;
  --pd-ph-khao-sat:var(--pd-n-6); --pd-ph-phan-tich:var(--pd-n-6); --pd-ph-dev:var(--pd-n-6); --pd-ph-mkt-sales:var(--pd-n-6);
  --pd-ph-pilot:var(--pd-n-6); --pd-ph-trien-khai:var(--pd-n-6); --pd-ph-cskh:var(--pd-n-6);
}
html body .pd-root .pd-lane-hd { border-top-color: var(--pd-n-4); background: var(--pd-n-1); }
html body .pd-root .pd-badge-soon,
html body .pd-root .pd-badge-today,
html body .pd-root .pd-badge-dang { background: var(--pd-n-2); color: var(--pd-n-7); }
html body .pd-root .pd-callout.pd-amb { background: var(--pd-surface); }
html body .pd-root .pd-callout.pd-amb .pd-ic,
html body .pd-root .pd-kpi.pd-today .pd-ic { background: var(--pd-n-2); color: var(--pd-n-7); }
html body .pd-root .pd-trk .pd-bar.pd-tre { background: var(--pd-st-tre); }
html body .pd-root .pd-av b { background: var(--pd-n-2); color: var(--pd-n-7); }
html body .pd-root .pd-trk .pd-dm.pd-today { background: var(--pd-n-6); }
/* Tag hạn không tràn mép thẻ */
html body .pd-root .pd-item .pd-im .pd-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pd-s-1, 4px); min-width: 0; max-width: 100%; }
html body .pd-root .pd-item .pd-im { min-width: 0; max-width: 100%; }
html body .pd-root .pd-item .pd-im .pd-badge { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
html body .pd-root .pd-badge-warn { background: var(--pd-primary-soft); color: var(--pd-primary-hover); }
html body .pd-root .pd-badge-warn .pd-bdot { background: var(--pd-primary); }

/* ======================================================================================================================
   v22.40 (brief 10) — Shell phẳng, một màu nhấn. Quy tắc (DESIGN-RULES §12, shadcn/Radix):
   • 1 màu nhấn #5b3fe0 (= trang sản phẩm) cho nút chính, mục đang chọn, link; xanh lá = xong; đỏ = lỗi/trễ; còn lại xám.
   • Không gradient trang trí, không bóng màu. Giữ gradient có chức năng: skeleton, vòng %, sọc «trễ», nền chấm, mép cuộn.
   • Chuyển động 120–180 ms, chỉ màu/nền/bóng; không nhấc nút (translateY) khi hover.
   Gỡ cả khối này = trở về giao diện cũ.
   ====================================================================================================================== */
:root {
  --primary: #5b3fe0; --primary-2: #5b3fe0; --primary-ink: #4a30c8; --indigo-ink: #4a30c8; --primary-soft: #efecfd; --ring: #5b3fe0;
  --grad: #5b3fe0; --grad-green: #2e9b4f; --grad-bar: #5b3fe0;
  --shadow-primary: 0 0 #0000;   /* not «none»: it is used inside box-shadow lists (.dm-tile.on, .dev-row.on) */
  /* bóng: chỉ lớp nổi (menu thả, popup, sheet, toast) mới có bóng; thẻ trên trang chỉ viền + bóng xs trung tính; nút không bóng */
  --shadow: 0 1px 2px rgba(15, 23, 42, .05); --shadow-sm: none;
  --nav-active-bg: #eef0f3; --nav-hover-bg: #f3f4f6; --nav-ink: #111827;
}
.topbar nav a { transition: background-color .15s ease, color .15s ease; }
.topbar nav a:hover { background: var(--nav-hover-bg); color: var(--nav-ink); }
.topbar nav a.on { background: var(--nav-active-bg); color: var(--nav-ink); font-weight: 600; box-shadow: none; }
.topbar nav a.on .nav-ic { color: var(--primary); }
.topbar nav a.on .nav-badge { background: var(--danger); color: #fff; }
.topbar nav a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.avatar, .avatar:empty { background: var(--primary-soft); color: var(--primary-ink); }
.btn { transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease; }
.btn.primary { background: var(--primary); box-shadow: none; }
.btn.primary:hover { background: var(--primary-ink); box-shadow: none; }
@media (hover: hover) { .btn.primary:hover, .kpi:hover, .dt-card:hover { transform: none; } }
.btn.go { background: var(--grad-green); box-shadow: none; }
.btn.danger-btn { background: #d92d20; box-shadow: none; }
.tabs .tab.on, .pager button.cur, .pager button.cur:hover, .step-chip.on, .hw-opt.on, .modal-tab.on { box-shadow: none; }
.k-ic.b, .k-ic.d { background: var(--primary-soft); color: var(--primary-ink); }
.k-ic, .k-ic.c { box-shadow: none; }
.sec-num, li.filled > .node-row .sec-num, .step-head.late .sec-num { box-shadow: none; }
.step-head.late .sec-num { background: #d92d20; }
.seg.doing, .sec-chip.doing .dot { background: #5b3fe0; }
.pkg-head .pct, .pkg-head .pct.full { box-shadow: none; }
.brand-mark { background: var(--primary); box-shadow: none; }
.bx-bench-bar-fill { background: var(--primary); }
.ar-bx-ticon { background: var(--grad-green); }
.wf-board-thumb-ph { background: #f1f5f9; }
/* Font: Inter (OFL 1.1, rsms.me/inter), tự host trong /static/fonts — CSP chỉ cho style từ 'self'. Bản variable 400–700;
   unicode-range tách tiếng Việt / Latin mở rộng / Latin nên trang tiếng Việt chỉ tải 2 tệp (~58 KB). */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-vietnamese-400-700.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-latin-ext-400-700.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-latin-400-700.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root { --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
body { font-optical-sizing: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
/* nút, tab, chip, nút icon: không bóng ở mọi trạng thái (trạng thái chọn = nền/viền, focus = outline) */
.btn, .btn:hover, .btn.primary, .btn.primary:hover, .icon:hover:not(:disabled), .btn-note:hover, .pkg-table .row-btn:hover:not(:disabled),
.tabs .tab.on, .pager button.cur, .pager button.cur:hover, .chip-sel:hover, .step-chip.on, .hw-opt.on, .modal-tab.on, .btn.go, .btn.danger-btn { box-shadow: none; }
.cost-view-btn.on { box-shadow: none; outline: 1px solid var(--line); outline-offset: -1px; }
.kpi:hover, .dt-card:hover { box-shadow: var(--shadow); }
.btn:focus-visible, .icon:focus-visible, .tabs .tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Huy hiệu nhóm / trạng thái (mọi trang): nhóm = viền xám; trạng thái = xám, trừ Đang phát triển (nhấn), Bán được (xanh), Loại (đỏ) */
.badge.seg-dan_dung, .badge.seg-chuyen_dung { background: transparent; color: #475569; box-shadow: inset 0 0 0 1px #e2e8f0; }
.badge.st-y_tuong, .badge.st-nghien_cuu, .badge.st-prototype { background: #f1f5f9; color: #475569; }
.badge.st-dang_phat_trien { background: var(--primary-soft); color: var(--primary-ink); }
.badge.st-ban_duoc { background: #e8f5ec; color: #1f6e37; }
.badge.st-loai { background: #fdecea; color: #b42318; }
/* Menu thả (⋯): lớp nổi nên có bóng trung tính; nền trắng đặc, viền xám */
.node-menu { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 10px 38px -10px rgba(22, 23, 24, .30), 0 10px 20px -15px rgba(22, 23, 24, .20); min-width: 12rem; }
.menu-item { border-radius: 6px; font-size: 13.5px; min-height: 2rem; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: #f1f5f9; color: var(--text); }
.menu-item:hover:not(:disabled) .ic { color: var(--text); }
.menu-item.danger:hover:not(:disabled), .menu-item.danger:focus-visible { background: #fdecea; color: #b42318; }
.menu-btn[aria-expanded="true"] { background: #f1f5f9; color: var(--text); }
.row-menu .menu-item:focus-visible { outline: none; }   /* Radix: the highlighted item is shown by its background */
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.row-menu:not([hidden]) { animation: menu-in .14s cubic-bezier(.16, 1, .3, 1); }
/* Trang Sản phẩm (#/): bảng kiểu shadcn — đầu cột chữ thường, dòng bấm được, không nền kính */
.pkg-table thead th { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; color: #64748b; }
.pkg-table tr.d0 td, .pkg-table tr.d1 td { background: transparent; }
.pkg-table tbody tr.pkg-row { cursor: pointer; transition: background-color .12s ease; }
@media (min-width: 641px) { .pkg-table tbody tr.pkg-row:hover td { background: #f8fafc; } }
@media (max-width: 640px) {   /* dạng thẻ: tô cả thẻ, các ô trong suốt (không thành mảng rời) */
  .pkg-table tbody tr.pkg-row, .pkg-table tbody tr.pkg-row.d1, .pkg-table tbody tr.pkg-row:last-child { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: none; }
  .pkg-table tbody tr.pkg-row:hover td { background: transparent; }
  .pkg-table tbody tr.pkg-row:hover { background: #f8fafc; }
}
.pkg-table .pkg-link { font-weight: 600; font-size: 14px; }
.pkg-table .pkg-link:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.pkg-table .summary { color: #64748b; font-size: 13px; }
.pkg-table .code { background: none; border: 0; padding: 0; color: #475569; font-family: var(--mono); font-size: 12px; font-weight: 500; }
.pkg-table .col-stt { color: #94a3b8; }
.pkg-table .col-actions { width: 3rem; }
.pkg-table .row-menu-btn { color: #64748b; }
.pkg-table tr.pkg-row:not(:hover) .row-menu-btn:not([aria-expanded="true"]):not(:focus-visible) { opacity: .55; }
.pct-bar { position: relative; flex: 1 1 auto; min-width: 5rem; height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.pct-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--primary); }
.pct-bar.full > i { background: #2e9b4f; }
.pkg-table .progress-cell { display: flex; align-items: center; gap: .6rem; }
.pkg-table .progress-cell .pct { min-width: 2.6rem; text-align: right; font-variant-numeric: tabular-nums; color: #334155; font-weight: 500; }
@media (hover: none) { .pkg-table tr.pkg-row .row-menu-btn { opacity: 1; } }
.templates { padding: 0; overflow: hidden; }
.templates .templates-head { padding: 14px 16px 10px; margin: 0; border-bottom: 1px solid #e2e8f0; }
.templates .templates-head h2 { font-size: 15px; font-weight: 600; }
.templates .empty { padding: 14px 16px; }
.tpl-table .col-flow, .tpl-table .col-steps { white-space: nowrap; color: #334155; }
/* Tiêu đề trang sản phẩm trên điện thoại: tên một dòng, chip + nút xuống dòng dưới (không tràn ngang) */
@media (max-width: 640px) {
  .pd-root .pd-ttl { flex-wrap: wrap; row-gap: 8px; }
  .pd-root .pd-ttl > h1 { order: 0; flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
  .pd-root .pd-ttl > .pd-btn { order: 1; }
  .pd-root .pd-ttl > .pd-grow { order: 2; flex: 0 0 100%; width: 0; height: 0; }   /* line break: chips go to row 2 */
  .pd-root .pd-ttl > .pd-badge { order: 3; }
}
.legend-list { list-style: none; margin: 12px 0 0; padding: 0 4px; display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
.legend-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .topbar nav a, .btn { transition: none; } .row-menu:not([hidden]) { animation: none; } }


/* ===== v22.50 (brief 11) — Design system toàn site: Tabs 3 kiểu, (i) thuật ngữ dùng chung, hover vào/ra =====
   Nguồn: CLAUDE.md «Design system» (shadcn/ui + Radix + ui-ux-pro-max: Minimalism/Swiss, ít màu, không bóng trên điều khiển).
   Chỉ NỐI khối này vào cuối style.css; gỡ khối = trở lại như v22.40. */
:root { --ds-accent: #5b3fe0; --ds-accent-hover: #4a30c8; --ds-accent-soft: #efecfd; --ds-border: #e2e8f0; --ds-muted-bg: #f1f5f9;
  --ds-text: #0f172a; --ds-text-2: #475569; --ds-muted: #64748b; --ds-t-fast: 120ms; --ds-t: 180ms; --ds-ease: cubic-bezier(.16,1,.3,1); }

/* Tabs kiểu «đoạn» (trong khung, hộp thoại): nền xám, mục chọn nền trắng + viền 1 px */
.modal-tabs { gap: 2px; padding: 3px; background: var(--ds-muted-bg); border-radius: 8px; width: max-content; max-width: 100%; }
.modal-tab, .lc-flow-tab, .wf-tab-btn { min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ds-text-2); font-weight: 500; box-shadow: none;
  transition: background var(--ds-t-fast) ease, color var(--ds-t-fast) ease; }
.modal-tab:hover, .lc-flow-tab:hover, .wf-tab-btn:not(.on):hover { background: rgba(255,255,255,.7); color: var(--ds-text); }
.modal-tab.on, .lc-flow-tab.on, .wf-tab-btn.on { background: #fff; color: var(--ds-text); border: 0; outline: 1px solid var(--ds-border); outline-offset: -1px; box-shadow: none; font-weight: 600; }
.lc-flow-tab.on .lc-flow-tab-count { background: var(--ds-accent-soft); color: var(--ds-accent); }
/* Tabs kiểu «gạch chân» (phần trong trang): một màu nhấn */
.pilot-tab, .bx-tab { transition: color var(--ds-t-fast) ease, border-color var(--ds-t-fast) ease; }
.pilot-tab.on, .bx-tab.on { color: var(--ds-text); border-bottom-color: var(--ds-accent); font-weight: 600; }
/* Focus bàn phím chung cho mọi tab */
.tabs .tab:focus-visible, .modal-tab:focus-visible, .lc-flow-tab:focus-visible, .wf-tab-btn:focus-visible, .pilot-tab:focus-visible, .bx-tab:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }

/* (i) thuật ngữ — window.InsightTerms (static/insight-terms.js) */
.ins-term { display: inline; white-space: normal; }
.ins-i { position: relative; display: inline-grid; place-items: center; width: 15px; height: 15px; margin: 0 1px 0 3px; padding: 0; vertical-align: 1px; border-radius: 50%;
  border: 1.5px solid currentColor; color: var(--ds-muted); background: transparent; font: italic 700 10px/1 Georgia, "Times New Roman", serif; cursor: help;
  transition: background var(--ds-t-fast) ease, color var(--ds-t-fast) ease, border-color var(--ds-t-fast) ease, transform var(--ds-t-fast) ease; }
.ins-i::after { content: ""; position: absolute; inset: -6px; }               /* vùng bấm 27 px */
.ins-i:hover, .ins-i[aria-expanded="true"] { background: var(--ds-accent); border-color: var(--ds-accent); color: #fff; transform: scale(1.08); }
.ins-i:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.ins-pop { position: fixed; z-index: 80; width: min(400px, 92vw); max-height: min(560px, calc(100vh - 16px)); overflow: auto; background: #fff; border: 1px solid var(--ds-border);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.16); font-size: 13px; color: var(--ds-text); transform-origin: top center; overscroll-behavior: contain; }
.ins-pop[data-side="top"] { transform-origin: bottom center; }
.ins-pop[hidden] { display: none; }
.ins-pop[data-state="open"] { animation: ins-in 160ms var(--ds-ease); }
.ins-pop[data-state="closed"] { animation: ins-out 100ms ease-in forwards; pointer-events: none; }
@keyframes ins-in { from { opacity: 0; transform: scale(.96) translateY(-2px); } to { opacity: 1; transform: none; } }
@keyframes ins-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.98); } }
.ins-pop.ins-wide { width: min(580px, 94vw); }
.ins-pop .ins-fig { background: #f8fafc; border-bottom: 1px solid var(--ds-border); padding: 10px 14px 4px; }
.ins-pop .ins-fig svg { display: block; width: 100%; height: 150px; }
.ins-pop.ins-wide .ins-fig svg { height: auto; }
.ins-pop .ins-fig small { display: block; text-align: right; color: var(--ds-muted); font-size: 11px; }
.ins-pop .ins-body { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 8px; }
.ins-pop h4 { margin: 0; font-size: 15px; font-weight: 600; } .ins-pop p { margin: 0; color: var(--ds-text-2); line-height: 1.55; }
.ins-pop .ins-why { background: var(--ds-muted-bg); border-radius: 8px; padding: 8px 10px; }
.ins-pop .ins-ours { border-left: 3px solid var(--ds-accent); padding-left: 10px; } .ins-pop .ins-ours b { color: var(--ds-accent); }
.ins-pop .ins-price { font-size: 12px; color: var(--ds-muted); }
.ins-pop table { width: 100%; border-collapse: collapse; font-size: 12.5px; } .ins-pop td { padding: 3px 0; vertical-align: top; } .ins-pop td:first-child { color: var(--ds-muted); width: 108px; }
.ins-pop .ins-back { border: 0; background: none; color: var(--ds-text-2); font-weight: 600; font-size: 12.5px; padding: 10px 16px 0; cursor: pointer; }
.ins-pop .ins-back:hover { color: var(--ds-accent); }
@media (prefers-reduced-motion: reduce) { .ins-pop[data-state] { animation: none; } .ins-i { transition: none; } .ins-i:hover { transform: none; } }
@media (pointer: coarse) { .ins-i { width: 18px; height: 18px; font-size: 11px; } .ins-i::after { inset: -10px; } }

/* v22.42 — 6 cột giai đoạn vừa khung ≥900 (không cuộn ngang); thu hẹp vẫn giữ cùng bề ngang khi gập */
html body .pd-root .pd-board {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--pd-s-2, 8px);
  overflow-x: hidden;
}
/* v22.43 — responsive board: tablet/mobile = scroll-snap carousel (cột đọc được) */
@media (max-width: 900px) {
  html body .pd-root .pd-board {
    grid-template-columns: repeat(6, minmax(42vw, 42vw));
    gap: var(--pd-s-3, 12px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  html body .pd-root .pd-board > .pd-bcol { scroll-snap-align: start; }
}
@media (max-width: 640px) {
  html body .pd-root .pd-board {
    grid-template-columns: repeat(6, minmax(82vw, 82vw));
    gap: var(--pd-s-2, 8px);
    padding-bottom: var(--pd-s-3, 12px);
  }
  html body .pd-root .pd-lane-hd { padding: var(--pd-s-2, 8px); }
  html body .pd-root .pd-card-hd { gap: var(--pd-s-2, 8px); }
  html body .pd-root .pd-ttl { gap: var(--pd-s-2, 8px); }
}
html body .pd-root .pd-lane-hd { padding: var(--pd-s-2, 8px); }
html body .pd-root .pd-lane-bd { padding: 0 var(--pd-s-1, 4px) var(--pd-s-1, 4px); }
html body .pd-root .pd-item { padding: var(--pd-s-2, 8px); min-width: 0; }
html body .pd-root .pd-item .pd-it { min-width: 0; }
html body .pd-root .pd-item .pd-it > span:not(.pd-mk) {
  min-width: 0; flex: 1;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
  overflow-wrap: anywhere; word-break: break-word;
}
html body .pd-root .pd-item .pd-im > span:first-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; min-width: 0;
}

/* v22.51 — lifecycle item side panels + header stats pop */
.modal-layer.dock-right {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
  background: rgba(15, 23, 42, .32);
  animation: sheet-fade .18s ease-out;
}
.modal-layer.dock-right .modal,
.modal.modal-dock-right {
  width: min(720px, 100vw);
  height: 100%;
  max-height: none;
  min-width: 0;
  border-radius: 0;
  border: 0;
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(15, 23, 42, .18);
  animation: modal-side-in .22s cubic-bezier(.2, .8, .2, 1);
}
.modal-layer.dock-right .modal.panel-wide { width: min(1200px, 90vw); }
.modal-layer.dock-right .modal.panel-md { width: min(720px, 100vw); }
.modal-layer.dock-right .modal.panel-sm { width: min(560px, 100vw); }
.modal-layer.dock-right .modal.modal-sm { width: min(560px, 100vw); height: 100%; max-height: none; }
.modal-layer.dock-right .modal-foot { flex: none; }
.modal-layer.dock-right.swap, .modal-layer.dock-right.swap .modal { animation: none; }
@keyframes modal-side-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}
@media (max-width: 720px) {
  .modal-layer.dock-right .modal,
  .modal-layer.dock-right .modal.panel-wide,
  .modal-layer.dock-right .modal.panel-md,
  .modal-layer.dock-right .modal.panel-sm,
  .modal-layer.dock-right .modal.modal-sm { width: 100vw; }
  .modal-layer.dock-right .modal-has-nav .modal-body { padding-left: 14px; padding-right: 14px; }
}
