/* Trang web Boss — hệ giao diện: thanh bên tối + nội dung sáng, thẻ trắng nổi nhẹ, bảng gọn, huy hiệu màu dịu.
   Mọi màu là biến ở :root (có bản tối theo hệ điều hành). Bố cục: ≥1024px thanh bên cố định; nhỏ hơn thanh bên thành dải trên cuộn ngang. */
:root {
  /* Nền trung tính hơi xanh xám; MỖI màu trạng thái một nghĩa (dùng chung với bảng của bot — src/panel/panel.css):
     --run đang chạy · --warn cần bạn (chờ duyệt/OTP) · --ok xong · --err lỗi · --idle nghỉ/ngoại tuyến/chờ lượt (KHÔNG phải lỗi)
     · --live chế độ chạy thật. Màu nút chính (--pri) tách khỏi màu "đang chạy". */
  --bg: #eef1f4; --surface: #ffffff; --surface-2: #f6f8fa; --fg: #14202b; --fg-2: #3a4754; --muted: #5b6673;
  --line: #dde3e9; --line-2: #c9d2db;
  --pri: #1d5fd6; --pri-2: #174fb4; --pri-soft: #e4edfb; --ring: rgba(29, 95, 214, .25);
  --run: #0b7490; --run-soft: #dcf0f5;
  --ok: #1d7a3b; --ok-soft: #e0f2e5; --warn: #a8520a; --warn-soft: #fdefd9; --err: #b42318; --err-soft: #fce5e2;
  --idle: #5b6673; --idle-soft: #eceff2; --idle-dot: #8a95a1;
  --live: #6a3dcc; --live-fg: #ffffff;
  --hi: #eaf1fc; --gold-bg: #fde68a; --gold-fg: #6b3a07;
  /* nền nút đặc: tách khỏi màu chữ để ở chế độ tối chữ trắng vẫn đủ tương phản (≥ 4,5) */
  --btn-pri: #1d5fd6; --btn-pri-2: #174fb4; --btn-ok: #1d7a3b; --btn-err: #b42318;
  --brand-a: #1d5fd6; --brand-b: #0b7490;
  /* màu theo THỨ TỰ bước trên sơ đồ (bước 1, 2, 3… xoay vòng 10 — mauBuoc ở src/shared/so-do-sua.ts): huy hiệu số, viền trái + nền nhạt
     đầu thẻ, mũi tên đi RA từ bước. Mỗi màu ≥ 4,5 với nền thẻ và với --buoc-chu (chữ số trên huy hiệu) — tests/unit/so-do-mau.test.ts */
  --buoc-1: #1d5fd6; --buoc-2: #c2410c; --buoc-3: #0f766e; --buoc-4: #7c3aed; --buoc-5: #a16207;
  --buoc-6: #be185d; --buoc-7: #15803d; --buoc-8: #4338ca; --buoc-9: #0369a1; --buoc-10: #9f1239;
  --buoc-chu: #ffffff;
  --side-bg: #111b25; --side-fg: #c8d2dc; --side-muted: #7d8b99; --side-active: rgba(255, 255, 255, .09); --side-line: rgba(255, 255, 255, .08); --side-accent: #7aa8f5;
  --shadow-1: 0 1px 2px rgba(20, 32, 43, .06), 0 1px 3px rgba(20, 32, 43, .04);
  --shadow-2: 0 6px 18px rgba(20, 32, 43, .09);
  --shadow-3: 0 18px 50px rgba(20, 32, 43, .28);
  --toast-bg: #14202b; --toast-fg: #ffffff;
  --r: 10px; --r-lg: 14px;
  --side-w: 236px; --top-h: 56px; --nav-h: 60px;
  /* tên cũ vẫn dùng ở vài chỗ */
  --card: var(--surface);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c131a; --surface: #141d26; --surface-2: #192430; --fg: #e5ebf0; --fg-2: #c2ccd5; --muted: #95a2ae;
    --line: #25323e; --line-2: #33424f;
    --pri: #7aa8f5; --pri-2: #5b92f0; --pri-soft: #172a4b; --ring: rgba(122, 168, 245, .35);
    --run: #5cc6df; --run-soft: #0f2c35;
    --ok: #5fcf8b; --ok-soft: #11301d; --warn: #f3ab52; --warn-soft: #36260d; --err: #f6857a; --err-soft: #3a1714;
    --idle: #9aa6b2; --idle-soft: #222d38; --idle-dot: #7b8794;
    --live: #b096f7; --live-fg: #140b2e;
    --hi: #172338; --gold-bg: #6b3a07; --gold-fg: #fde68a;
    --btn-pri: #2e68d8; --btn-pri-2: #3f78e6; --btn-ok: #1d7a3b; --btn-err: #c2362a;
    --brand-a: #2e68d8; --brand-b: #0b7490;
    --buoc-1: #7aa8f5; --buoc-2: #fb923c; --buoc-3: #2dd4bf; --buoc-4: #b79cfa; --buoc-5: #facc15;
    --buoc-6: #f472b6; --buoc-7: #4ade80; --buoc-8: #818cf8; --buoc-9: #38bdf8; --buoc-10: #fda4af;
    --buoc-chu: #0c131a;
    --side-bg: #0a1017; --side-fg: #c8d2dc; --side-muted: #6f7d8a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 6px 18px rgba(0, 0, 0, .45); --shadow-3: 0 18px 50px rgba(0, 0, 0, .7);
    --toast-bg: #26333f; --toast-fg: #f1f5f9;
  }
}

/* ---------- nền tảng ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-width: 0; overflow-x: hidden; }
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: inline-block; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

/* ---------- thanh bên ---------- */
.side { position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; color: #fff; text-decoration: none; border-bottom: 1px solid var(--side-line); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand-a) 35%, transparent); flex: none; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--side-muted); white-space: nowrap; }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); padding: 12px 10px 4px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-fg); text-decoration: none; font-size: 13.5px; font-weight: 500; white-space: nowrap; position: relative; transition: background .12s, color .12s; }
#nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .8; flex: none; }
#nav a:hover { background: var(--side-active); color: #fff; }
#nav a.active { background: var(--side-active); color: #fff; }
#nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-accent); }
#nav a.active svg { opacity: 1; color: var(--side-accent); }
/* Số bot chờ duyệt trên mục Bot: ::after để chữ của liên kết không đổi (test đọc chữ menu). */
#nav a[data-count]::after { content: attr(data-count); margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: var(--surface); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--side-line); min-width: 0; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--pri-soft); color: var(--pri); font-weight: 700; font-size: 13px; flex: none; }
.who { font-size: 12.5px; color: var(--side-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- thanh trên ---------- */
.topbar { position: sticky; top: 0; height: var(--top-h); margin-left: var(--side-w); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); z-index: 6; }
.spacer { flex: 1; }
/* Ai đang đăng nhập trên thanh trên — chỉ ở màn ≤ 1023 px (màn rộng đã có ở chân thanh bên). */
.who-top { display: none; }
.rt { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--ok); background: var(--ok-soft); padding: 4px 10px 4px 8px; border-radius: 999px; }
.rt i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.rt.off { color: var(--err); background: var(--err-soft); }
.rt.off i { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 20%, transparent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
#stop-all { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; letter-spacing: .02em; }
/* Thanh đầu: nút đỏ "Download" (tải bot + cách cài → #/cai-bot) và nút xanh "Hướng Dẫn" (các bài VIDEO hướng dẫn → /huong-dan/) + trang #/cai-bot */
#tai-bot { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; text-decoration: none; }
/* Nút ĐỎ NHÁY (theo yêu cầu người dùng): "Download và Hướng Dẫn" trên thanh đầu + nút tải zip trong trang #/cai-bot.
   Đỏ tươi + vòng sáng loé ra mỗi 1,1 s; rê chuột vào thì đứng yên để bấm cho dễ. Người bật "giảm chuyển động" của hệ điều hành → không nháy, vẫn đỏ.
   Cố ý KHÁC nút DỪNG TẤT CẢ (đỏ sẫm, đứng yên) để hai nút đỏ cạnh nhau không bị nhầm. */
@keyframes nut-do-nhay { 0%, 100% { background: #d92d20; box-shadow: 0 0 0 0 rgba(240, 68, 56, .65); } 50% { background: #f04438; box-shadow: 0 0 0 8px rgba(240, 68, 56, 0); } }
.btn.nut-do-nhay { background: #d92d20; border-color: #d92d20; color: #fff; animation: nut-do-nhay 1.1s ease-in-out infinite; }
.btn.nut-do-nhay:hover { background: #b42318; border-color: #b42318; animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .btn.nut-do-nhay { animation: none; box-shadow: 0 0 0 3px rgba(240, 68, 56, .35); } }
#huong-dan-video { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; text-decoration: none; background: var(--btn-ok); border-color: var(--btn-ok); color: #fff; }
#huong-dan-video:hover { background: color-mix(in srgb, var(--btn-ok) 88%, black); border-color: color-mix(in srgb, var(--btn-ok) 88%, black); }
#huong-dan-video svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#tai-bot svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cai-tieu-de { display: flex; align-items: center; gap: 10px; }
.cai-nhen { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.cai-the h2 { font-size: 16px; margin: 0 0 10px; }
.cai-the ol, .cai-the ul { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.cai-ban-dong { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cai-ban-so { font-size: 22px; font-weight: 700; }
.cai-sha code { overflow-wrap: anywhere; word-break: break-all; }
.cai-lenh { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; flex-wrap: wrap; }
.cai-lenh pre { flex: 1 1 320px; min-width: 0; margin: 0; max-height: none; font-size: 12px; user-select: all; }
.cai-lenh button { flex: none; }
#stop-all svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }

#top:not([hidden]) ~ main, #top:not([hidden]) ~ #banner, #top:not([hidden]) ~ #new-version { margin-left: var(--side-w); }
main { padding: 22px 24px 90px; max-width: 1360px; }
.banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); padding: 9px 24px; font-size: 13px; }
.banner a { font-weight: 600; color: var(--warn); text-decoration: underline; }

/* ---------- chữ ---------- */
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 16px; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 600; margin: 6px 0 10px; }
h3 { font-size: 11.5px; font-weight: 600; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card > h3:first-child { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--fg); text-transform: none; letter-spacing: 0; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); } .running { color: var(--run); } .idle { color: var(--idle); }
.wrap { overflow-wrap: anywhere; word-break: break-word; }
.status { font-weight: 600; }
p { margin: 8px 0; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; overflow: auto; font-size: 11.5px; line-height: 1.5; max-height: 260px; white-space: pre-wrap; word-break: break-word; }
pre code { background: none; border: 0; padding: 0; }
kbd { font: 11px ui-monospace, monospace; background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; padding: 1px 5px; border-radius: 4px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
details summary:hover { color: var(--fg); }

/* ---------- thẻ ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 12px; min-width: 0; box-shadow: var(--shadow-1); }
.card.hi { background: var(--hi); border-color: color-mix(in srgb, var(--pri) 45%, var(--line)); }
/* Khung có nhãn màu (05/10/2026, người dùng: "nhìn không rõ được chia ra, cứ tưởng 1 mảng"): MỌI thẻ có tiêu đề (h3 đứng đầu, hoặc hàng đầu
   tiêu đề + nút) có viền trái màu + dải tiêu đề tô nhạt cùng màu + chấm màu trước tên. Phần BỐ CỤC (viền, khoảng cách, dải) áp ngay bằng :has()
   → thẻ vẽ lại không nhích; khung-mau.ts chỉ gán data-khung="0..7" để chọn MÀU (khung liền nhau khác màu). */
/* :where → màu mặc định (xám, trước khi khung-mau.ts gán) có độ ưu tiên 0, không đè .card[data-khung="n"] */
:where(.card:has(> h3:first-child), .card:has(> :first-child > h3:first-child)) { --khung: var(--line-2); }
.card:has(> h3:first-child), .card:has(> :first-child > h3:first-child) { border-left: 4px solid var(--khung); margin-bottom: 16px; }
.card[data-khung="0"] { --khung: #2563eb; } .card[data-khung="1"] { --khung: #7c3aed; } .card[data-khung="2"] { --khung: #0d9488; }
.card[data-khung="3"] { --khung: #ea580c; } .card[data-khung="4"] { --khung: #db2777; } .card[data-khung="5"] { --khung: #16a34a; }
.card[data-khung="6"] { --khung: #64748b; } .card[data-khung="7"] { --khung: #0891b2; }
.card > h3:first-child, .card > :first-child > h3:first-child { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700;
  color: var(--fg); text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.card > h3:first-child, .card > :first-child:has(> h3:first-child) { background: color-mix(in srgb, var(--khung) 11%, var(--surface)); border: 0;
  border-radius: 8px; padding: 9px 12px; margin: -4px -6px 14px; }
.card > :first-child:has(> h3:first-child) > h3:first-child { margin: 0; padding: 0; border: 0; background: none; }
.card > h3:first-child::before, .card > :first-child > h3:first-child::before { content: ""; flex: none; width: 10px; height: 10px;
  border-radius: 50%; background: var(--khung); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.empty { color: var(--muted); padding: 36px 16px; text-align: center; }
.empty.card { border-style: dashed; box-shadow: none; background: transparent; }

/* ---------- huy hiệu ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5; background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.tag.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.tag.running { background: var(--run-soft); color: var(--run); border-color: color-mix(in srgb, var(--run) 30%, transparent); }
/* Chế độ chạy: chạy thật là khối đặc (rủi ro thật), chạy thử viền gạch, chỉ định vị viền chấm. */
.tag.live { background: var(--live); color: var(--live-fg); border-color: var(--live); }
.tag.draft { border-style: dashed; border-color: var(--line-2); }
.tag.dry { border-style: dotted; border-color: var(--line-2); color: var(--muted); }
.tag.gold { background: var(--gold-bg); color: var(--gold-fg); border-color: transparent; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); vertical-align: middle; margin-right: 5px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.dot.off { background: var(--idle-dot); box-shadow: 0 0 0 3px color-mix(in srgb, var(--idle-dot) 18%, transparent); }

/* ---------- nút ---------- */
button, .btn { font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: var(--shadow-1); transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--line-2); text-decoration: none; }
button:active { transform: translateY(1px); }
button.pri, .btn.pri { background: var(--btn-pri); border-color: var(--btn-pri); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .3); }
button.pri:hover, .btn.pri:hover { background: var(--btn-pri-2); border-color: var(--btn-pri-2); }
button.ok { background: var(--btn-ok); border-color: var(--btn-ok); color: #fff; }
button.ok:hover { background: color-mix(in srgb, var(--btn-ok) 88%, black); }
button.danger, .btn.danger { background: var(--btn-err); border-color: var(--btn-err); color: #fff; }
button.danger:hover, .btn.danger:hover { background: color-mix(in srgb, var(--btn-err) 88%, black); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
button.mini, .btn.mini { padding: 4px 10px; font-size: 12px; border-radius: 7px; box-shadow: none; }
button.link { border: 0; background: none; color: var(--pri); padding: 0; box-shadow: none; font-weight: 500; text-decoration: underline; }
button.link:hover { background: none; }

/* ---------- ô nhập ---------- */
input, select, textarea { font: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--fg); width: 100%; max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-2) 50%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--pri); margin: 0; box-shadow: none; }
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { min-height: 100px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; line-height: 1.5; }
label.f { display: block; margin-bottom: 10px; min-width: 0; }
/* Ô nhập đứng một mình trong thẻ rộng: giới hạn bề ngang cho dễ đọc (ô trong lưới .field-row/.two vẫn theo cột). */
.card > label.f, .card > form > label.f { max-width: 640px; }
label.f > span { display: block; font-size: 12px; font-weight: 600; color: var(--fg-2); margin-bottom: 4px; }
label.inline { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: 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='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; }

/* ---------- hộp thông báo ---------- */
.err-box { border: 1px solid color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); background: var(--err-soft); padding: 10px 12px; border-radius: var(--r); font-size: 13px; }
.warn-box { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: var(--r); font-size: 13px; }
.info-box { border: 1px solid color-mix(in srgb, var(--pri) 35%, transparent); background: var(--pri-soft); padding: 10px 12px; border-radius: var(--r); font-size: 13px; }

/* ---------- bảng ---------- */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); max-width: 100%; background: var(--surface); box-shadow: var(--shadow-1); }
/* Bảng rộng hơn khung (web/cuon-bang.ts): dòng gợi ý ngay trên bảng + mép phải mờ dần khi còn cột bên phải; kéo tới cuối thì hết mờ. */
.tbl-goi-y { margin: 0 0 4px; text-align: right; font-size: 12px; }
.tbl-goi-y[hidden] { display: none; }
.tbl.con-phai { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 44px); mask-image: linear-gradient(to left, transparent 0, #000 44px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl table { min-width: 560px; }
.tbl.params table { min-width: 0; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
td .tag { white-space: nowrap; }
td.wrap { min-width: 140px; }
td.name { min-width: 140px; max-width: 260px; }
td.name > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
td.reason { min-width: 160px; max-width: 360px; overflow-wrap: anywhere; }
td.nowrap, th.nowrap { white-space: nowrap; }
tr.hl td { background: var(--hi); }
.log { max-height: 420px; overflow: auto; }
td.tabular, .num { font-variant-numeric: tabular-nums; }
.params td input { padding: 5px 8px; font-size: 13px; }

/* ---------- duyệt ---------- */
.approval { border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-soft); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 12%, transparent); }
.approval img { max-width: 100%; border-radius: var(--r); border: 1px solid var(--line); margin-top: 8px; background: var(--surface); }

/* ---------- toast ---------- */
#toast { position: fixed; right: 20px; bottom: 20px; left: auto; max-width: 420px; background: var(--toast-bg); color: var(--toast-fg); padding: 10px 8px 10px 14px; border-radius: var(--r); z-index: 40; box-shadow: var(--shadow-3); overflow-wrap: anywhere; font-size: 13.5px; border-left: 4px solid var(--pri); animation: toast-in .18s ease-out; display: flex; align-items: flex-start; gap: 8px; }
#toast:not([hidden]) { display: flex; }
#toast .toast-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#toast .toast-item { padding-top: 1px; }
/* Nhiều thông báo: mỗi cái có vạch màu riêng theo loại; cái cũ hơn mờ hơn một chút. */
#toast .toast-item + .toast-item { border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); padding-top: 6px; }
#toast .toast-item:not(:last-child) { opacity: .8; }
#toast .toast-item.err::before, #toast .toast-item.warn::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--err); }
#toast .toast-item.warn::before { background: var(--warn); }
#toast .toast-x { flex: none; border: 0; background: transparent; color: inherit; box-shadow: none; padding: 0 6px; font-size: 18px; line-height: 1.1; opacity: .75; }
#toast .toast-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
#toast.err { border-left-color: var(--err); }
#toast.warn { border-left-color: var(--warn); }
/* Hộp thoại đang mở: thông báo lên đầu màn để không che hàng nút ở đáy hộp. */
body:has(.modal-wrap) #toast { top: 12px; bottom: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- đăng nhập ---------- */
#top[hidden] ~ main { min-height: 100vh; padding: 0; max-width: none; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--pri) 14%, transparent), transparent 60%), radial-gradient(900px 500px at 100% 100%, color-mix(in srgb, var(--brand-b) 12%, transparent), transparent 60%), var(--bg); }
.login { width: 100%; max-width: 400px; margin: 0 auto; padding: 24px 16px; }
.login h1 { text-align: center; font-size: 20px; margin: 0 0 18px; }
.login h1::before { content: ""; display: block; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M13 2 4 14h7l-1 8 9-12h-7z'/></svg>"), linear-gradient(135deg, var(--brand-a), var(--brand-b)); background-size: 26px 26px, auto; background-position: center; background-repeat: no-repeat; box-shadow: 0 8px 24px color-mix(in srgb, var(--brand-a) 35%, transparent); }
.login .card { padding: 22px 24px; box-shadow: var(--shadow-2); }
.login .card button.pri { width: 100%; padding: 10px 14px; font-size: 14px; }
.login .row.end { justify-content: stretch; }

/* ---------- bảng bot ---------- */
.toolbar { position: sticky; top: calc(var(--top-h) + 10px); z-index: 4; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow-1); }
.toolbar label.inline { padding: 0 6px 0 2px; font-weight: 500; }
/* Màn hình chính: thẻ có hình rộng ~400 px; thẻ không hình gọn (align-items: start — không bị kéo cao bằng thẻ có hình). min(400px,100%) để màn hẹp không tràn. */
.bots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 14px; align-items: start; }
.bot { display: flex; flex-direction: column; gap: 8px; margin: 0; min-width: 0; padding: 14px 16px 12px 18px; transition: box-shadow .15s, border-color .15s; position: relative; overflow: hidden; }
/* Viền trái mang màu trạng thái: quét lưới bằng mắt biết ngay bot nào đang chạy / cần bạn / ngoại tuyến. */
.bot::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stripe, transparent); }
.bot.s-run { --stripe: var(--run); }
.bot.s-need { --stripe: var(--warn); }
.bot.s-idle { --stripe: var(--line-2); }
.bot.s-off { --stripe: var(--idle-dot); }
.bot:hover { box-shadow: var(--shadow-2); }
/* Tên dài: tối đa 2 dòng (đủ tên ở title và trong hộp Sửa). */
.bot .name { font-weight: 600; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bot.pending { border-color: color-mix(in srgb, var(--warn) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 14%, transparent); }
.bot.offline { background: var(--surface-2); }
.bot .what { min-height: 1.4em; font-size: 13.5px; font-weight: 600; }
.bot .what a { font-weight: 600; }
/* Dòng "N kịch bản · được phép chạy thật: …" chiếm cả hàng; hàng nút thành chân thẻ có kẻ trên. */
.card.bot > .row.small:has(> button.mini) { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.card.bot .row.small > .grow { flex-basis: 100%; }
.card.bot details { padding-top: 6px; }
.card.bot details > div { padding: 6px 0 0; }
/* Chân thẻ: "Chạy" là nút chính; Xem / Lịch sử chạy / Sửa là nút phụ nhẹ để mắt không bị 5 nút ngang nhau kéo đi. */
.card.bot .row.small > button.mini:not(.pri):not(.ok):not(.danger), .card.bot .row.small > a.btn.mini { background: transparent; border-color: transparent; color: var(--fg-2); }
.card.bot .row.small > button.mini:not(.pri):not(.ok):not(.danger):hover:not(:disabled), .card.bot .row.small > a.btn.mini:hover { background: var(--surface-2); border-color: var(--line); }

/* ---------- dải "Cần bạn" (trang Bot) ---------- */
.attn { background: var(--surface); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-left: 4px solid var(--warn); border-radius: var(--r); padding: 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 6px; }
.attn-h { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }
.attn-n { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: var(--surface); font-size: 11px; line-height: 18px; text-align: center; letter-spacing: 0; }
.attn-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; padding: 4px 0; border-top: 1px solid var(--line); }
.attn-h + .attn-row { border-top: 0; }
.attn-what { min-width: 180px; }
.btn.quiet, button.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--pri); }

/* ---------- thống kê ---------- */
.stat-tile { flex: 1; min-width: 140px; margin: 0; padding: 14px 16px; }
.stat-tile .stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
[data-testid="stat-tiles"] { margin-bottom: 12px; gap: 12px; align-items: stretch; }
.chart { width: 100%; height: auto; max-height: 260px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- màn hình bot trên thẻ (gộp Xem trực tiếp) ---------- */
.bot-hinh { min-width: 0; }
.live-shot { position: relative; margin-top: 8px; background: #0f172a; border-radius: var(--r); min-height: 120px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.bot-hinh .live-shot { margin-top: 0; }
.live-shot img { display: block; width: auto; max-width: 100%; height: auto; }
.live-shot img:not([src]) { display: none; }
.bot-hinh.no-shot img { opacity: .35; }
.bot-hinh-chan { margin-top: 6px; }
.live-why { margin: 6px 0 0; overflow-wrap: anywhere; color: var(--muted); }
.live-err { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; color: #fca5a5; font-weight: 600; background: rgba(15, 23, 42, .75); }
/* Nút phóng to MỜ ở góc ô hình: rõ lên khi rê chuột / bàn phím. */
.bot-phong-to { position: absolute; top: 6px; right: 6px; z-index: 2; width: 30px; height: 30px; padding: 0; border-radius: 8px; border: 0; background: rgba(15, 23, 42, .7); color: #fff; font-size: 17px; line-height: 1; opacity: .45; box-shadow: none; transition: opacity .15s; }
.bot-phong-to:hover, .bot-phong-to:focus-visible { opacity: 1; background: rgba(15, 23, 42, .92); }
.bot-zoom-nen { z-index: 40; }
.bot-zoom-hop { display: flex; flex-direction: column; gap: 8px; max-width: 96vw; max-height: 94vh; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 12px; box-shadow: var(--shadow-3); }
.bot-zoom-dau { flex: 0 0 auto; }
.bot-zoom-anh { display: block; margin-top: 0; overflow: auto; min-height: 0; max-height: calc(94vh - 72px); }
.bot-zoom-anh img { max-width: none; height: auto; }

/* ---------- thẻ bot = MÁY TÍNH (06/10/2026) ----------
   Màn hình có viền đen/xám (bezel) bo góc, "cằm" bên dưới có đèn LED trạng thái + chữ, cổ + đế dưới màn hình. Chỉ CSS thuần (không ảnh/phông ngoài).
   Viền luôn TỐI ở cả giao diện sáng lẫn tối (màn hình thật), chữ ở cằm sáng nên đọc được trên cả hai. LED: tắt = ngoại tuyến, xanh lá = trực tuyến rảnh,
   xanh lơ "thở" = đang chạy, cam = chờ duyệt, đỏ nháy = CAPTCHA / cần người (có chữ đi kèm — không chỉ dựa vào màu). */
:root {
  --may-a: #3a4553; --may-b: #1c242e; --may-line: #0c1218; --may-hi: rgba(255, 255, 255, .11);
  --may-man: #05090f; --may-chu: #cfd8e1; --may-chu-2: #98a5b3;
  --may-co-a: #2b343f; --may-co-b: #4b5766;
  --led-tat: #5a6675; --led-ranh: #34d27b; --led-chay: #38d4f2; --led-cho: #f5a524; --led-can: #ff4d3d;
}
@media (prefers-color-scheme: dark) {
  :root { --may-a: #455162; --may-b: #242d39; --may-line: #04070b; --may-hi: rgba(255, 255, 255, .13); --may-co-a: #333d4a; --may-co-b: #5a6676; }
}
.may-the { padding-top: 12px; }
.may-dau { margin-bottom: 2px; }
.may-man { display: flex; flex-direction: column; align-items: center; margin: 2px 0 0; min-width: 0; }
.may-vien { width: 100%; min-width: 0; background: linear-gradient(165deg, var(--may-a), var(--may-b)); border: 1px solid var(--may-line); border-radius: 13px; padding: 9px 9px 0; box-shadow: var(--shadow-2), inset 0 1px 0 var(--may-hi); }
.may-khung { position: relative; border-radius: 7px; overflow: hidden; background: var(--may-man); box-shadow: 0 0 0 1px rgba(0, 0, 0, .75), inset 0 0 16px rgba(0, 0, 0, .6); }
.may-cam { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 10px; padding: 7px 4px 8px; color: var(--may-chu); font-size: 12px; line-height: 1.3; }
.may-cam-trai { display: inline-flex; align-items: center; font-weight: 600; }
.may-cam-phai { color: var(--may-chu-2); min-width: 0; }
.may-co { width: 46px; height: 13px; background: linear-gradient(90deg, var(--may-co-a), var(--may-co-b) 50%, var(--may-co-a)); border-left: 1px solid var(--may-line); border-right: 1px solid var(--may-line); }
.may-de { width: 132px; max-width: 62%; height: 8px; border-radius: 5px 5px 10px 10px; background: linear-gradient(180deg, var(--may-co-b), var(--may-co-a)); border: 1px solid var(--may-line); box-shadow: 0 4px 9px rgba(0, 0, 0, .28); }
/* Khung hình: tỉ lệ 16:10 cố định cho mọi máy (lưới đều như dàn màn hình); ảnh vừa khung, không méo. */
.may-khung .bot-hinh { display: block; min-width: 0; }
.bot-hinh .live-shot { margin-top: 0; border-radius: 0; min-height: 0; aspect-ratio: 16 / 10; background: transparent; }
.bot-hinh .live-shot img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; }
.may-trong { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; padding: 12px; text-align: center; color: var(--may-chu-2); background: radial-gradient(120% 150% at 50% 0%, #121c2a, var(--may-man)); }
.may-trong-chu { overflow-wrap: anywhere; }
.may-tat { background: #04070b; color: #5d6874; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 11.5px; }
.may-osd { position: absolute; left: 7px; top: 7px; z-index: 2; margin: 0; padding: 2px 8px; border: 0; border-radius: 999px; background: rgba(8, 12, 20, .74); color: #dbe4ee; font-size: 11px; font-weight: 600; max-width: calc(100% - 52px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.may-an { position: absolute; right: 7px; bottom: 7px; z-index: 2; }
/* Thông báo trên màn hình (lỗi chụp / ngoại tuyến): lớp phủ tối, chữ vừa trong khung, không tràn. */
.live-thong-bao { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 30px 12px 12px; text-align: center; background: rgba(5, 9, 15, .82); overflow: auto; }
.bot-hinh .live-err { position: static; inset: auto; display: block; padding: 0; background: none; font-size: 12.5px; line-height: 1.4; }
.bot-hinh .live-why { margin: 0; color: #aab6c3; font-weight: 400; font-size: 11.5px; line-height: 1.35; }
.bot-hinh.o-ngoai-tuyen .live-err { color: #9fb0c0; }
/* Đèn LED ("cằm" màn hình). Giữ lớp .dot.on / .dot.off để kiểm thử cũ vẫn nhận ra chấm trực tuyến / ngoại tuyến. */
.dot.may-led { width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; flex: none; vertical-align: baseline; }
.dot.may-led.led-tat { background: var(--led-tat); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .45); }
.dot.may-led.led-ranh { background: var(--led-ranh); box-shadow: 0 0 0 2px rgba(52, 210, 123, .22), 0 0 9px 1px rgba(52, 210, 123, .7); }
.dot.may-led.led-chay { background: var(--led-chay); box-shadow: 0 0 0 2px rgba(56, 212, 242, .22), 0 0 9px 1px rgba(56, 212, 242, .75); animation: led-tho 1.8s ease-in-out infinite; }
.dot.may-led.led-cho { background: var(--led-cho); box-shadow: 0 0 0 2px rgba(245, 165, 36, .25), 0 0 9px 1px rgba(245, 165, 36, .7); }
.dot.may-led.led-can { background: var(--led-can); box-shadow: 0 0 0 2px rgba(255, 77, 61, .3), 0 0 10px 2px rgba(255, 77, 61, .85); animation: led-nhay .9s ease-in-out infinite; }
@keyframes led-tho { 50% { opacity: .55; box-shadow: 0 0 0 2px rgba(56, 212, 242, .1), 0 0 3px 0 rgba(56, 212, 242, .3); } }
@keyframes led-nhay { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .dot.may-led { animation: none !important; } }
/* Ghi chú riêng của bot: một dòng xem trước dưới màn hình + chấm trên nút. */
.bot-ghi-chu-xem { display: flex; align-items: baseline; gap: 8px; width: 100%; min-width: 0; margin: 0; padding: 5px 10px; text-align: left; font-size: 12.5px; font-weight: 500; background: var(--warn-soft); color: var(--fg-2); border: 1px dashed color-mix(in srgb, var(--warn) 50%, transparent); border-radius: 8px; box-shadow: none; }
.bot-ghi-chu-xem:hover { border-style: solid; }
/* Sao lưu dữ liệu plugin (07/10/2026): một dòng chữ nhỏ dưới màn hình bot — không nổi bật trừ khi bản sao lưu đã cũ. */
.bot-sao-luu { display: block; width: 100%; min-width: 0; margin: 0; padding: 2px 6px; text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); background: transparent; border: 0; box-shadow: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-sao-luu:hover { text-decoration: underline; background: transparent; }
.bot-sao-luu.sl-cu { color: var(--warn); }
.badge-plugin { white-space: nowrap; }
.sao-luu-hop .sl-ban { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sao-luu-hop .sl-ban-dau { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.sao-luu-hop .sl-chep-hang { flex-wrap: wrap; gap: 8px; }
.sao-luu-hop .sl-chep-hang select { min-width: 0; max-width: 100%; flex: 1 1 220px; }
.bot-ghi-chu-nhan { flex: none; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }
.bot-ghi-chu-chu { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-ghi-chu { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--warn); vertical-align: middle; }
.modal.ghi-chu-hop { max-width: 520px; }
.ghi-chu-o { display: block; width: 100%; min-height: 150px; resize: vertical; font: inherit; line-height: 1.45; }

/* ---------- thẻ bot: việc đang chạy, tình trạng, hàng nút ---------- */
.bot-viec { gap: 6px; flex-wrap: nowrap; min-width: 0; }
.bot-chip { display: block; flex: 1 1 auto; min-width: 0; max-width: 100%; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 13px; padding: 5px 10px; background: var(--surface-2); }
.bot-chip.chip-chuoi, .bot-chip.chip-kich-ban { border-color: color-mix(in srgb, var(--run) 45%, var(--line-2)); color: var(--run); }
.bot-chip.chip-ranh { color: var(--muted); font-weight: 500; }
.bot-tinh-trang { flex: 0 0 auto; white-space: nowrap; }
.bot-tinh-trang.tt-chay { background: var(--run-soft); color: var(--run); border-color: color-mix(in srgb, var(--run) 30%, transparent); }
.bot-tinh-trang.tt-cho-duyet { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.bot-tinh-trang.tt-tam-dung, .bot-tinh-trang.tt-loi { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.bot-hanh-dong { gap: 6px; }
.bot-hanh-dong button.mini { flex: 0 0 auto; }
.bot-hanh-dong button.bot-noi-bat { font-weight: 700; }
.bot-hanh-dong button.ok.bot-noi-bat { box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-ok) 28%, transparent); }
.bot-hanh-dong button.danger.bot-noi-bat { box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-err) 30%, transparent); }
/* Nút "Giải CAPTCHA" / "Cần bạn xử lý": ĐỎ NHÁY (hai sắc đỏ đều đủ tương phản với chữ trắng — chữ luôn đọc được) + vòng sáng nở ra. Giảm chuyển động → đứng yên, giữ vòng tĩnh. */
@keyframes bot-nhay { 0%, 100% { background: #b42318; border-color: #b42318; box-shadow: 0 0 0 0 rgba(217, 45, 32, .7); } 50% { background: #d92d20; border-color: #d92d20; box-shadow: 0 0 0 7px rgba(217, 45, 32, 0); } }
.bot-hanh-dong button.danger.bot-nhay { animation: bot-nhay 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .bot-hanh-dong button.danger.bot-nhay { animation: none; box-shadow: 0 0 0 3px rgba(217, 45, 32, .45); } }
.bot.bi-captcha { --stripe: var(--err); border-color: color-mix(in srgb, var(--btn-err) 55%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-err) 12%, transparent); }

/* ---------- hộp mở từ thẻ bot (đang chạy, lịch sử, nhóm, lệnh) ---------- */
.modal.bot-hop { max-width: 560px; }
.modal.bot-hop.bot-lenh { max-width: 640px; }
/* Số liệu kênh (07/10/2026, nhóm 3): bảng tăng trưởng theo mạng trong hộp của thẻ bot. */
.modal.bot-hop.so-lieu-hop { max-width: 640px; }
.so-lieu-ds { display: flex; flex-direction: column; gap: 14px; }
.so-lieu-mang { border-top: 1px solid var(--line); padding-top: 10px; min-width: 0; }
.so-lieu-mang:first-child { border-top: 0; padding-top: 0; }
.sl-tieu-de { margin: 0 0 2px; font-size: 15px; overflow-wrap: anywhere; }
.sl-tai-khoan { font-weight: 500; font-size: 13px; }
.so-lieu-cuon { max-width: 100%; overflow-x: auto; }
.so-lieu-bang { table-layout: fixed; } /* các mạng thẳng cột với nhau */
.so-lieu-bang th:nth-child(2) { width: 20%; } .so-lieu-bang th:nth-child(3) { width: 26%; } .so-lieu-bang th:nth-child(4) { width: 96px; }
.so-lieu-bang th, .so-lieu-bang td { padding: 6px 8px; vertical-align: middle; }
.so-lieu-bang .num { text-align: right; white-space: nowrap; }
.sl-nhan { min-width: 110px; }
.sl-tang { color: var(--ok); font-weight: 600; }
.sl-giam { color: var(--err); font-weight: 600; }
.sl-ngang { color: var(--muted); }
.sl-duong { display: block; }
.sl-duong polyline { fill: none; stroke: var(--accent, var(--ok)); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
@media (max-width: 480px) { .so-lieu-bang th, .so-lieu-bang td { padding: 5px 4px; font-size: 12px; } .so-lieu-bang th:nth-child(2) { width: 18%; } .so-lieu-bang th:nth-child(3) { width: 28%; } .so-lieu-bang th:nth-child(4) { width: 84px; } .sl-nhan { min-width: 0; overflow-wrap: anywhere; } }
.bot-hop-dau h3, .modal .bot-hop-dau h3 { margin: 0; }
.bot-hop-chan { margin-top: 14px; }
.bot-hop-khoi { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin: 8px 0; min-width: 0; overflow-wrap: anywhere; }
.bot-ls-ds, .bot-nhom-ds { max-height: 52vh; overflow: auto; }
.bot-ls-dong { padding: 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.bot-ls-dong:first-child { border-top: 0; }
.bot-nhom-dong { padding: 5px 0; border-top: 1px solid var(--line); }
.bot-nhom-dong:first-child { border-top: 0; }
.bot-lenh-xem { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.bot-lenh-xem h4 { margin: 0 0 6px; font-size: 14px; }
.bot-lenh-xem.lenh-low { border-top: 2px solid var(--warn); }

/* ---------- form lệnh ---------- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.bot-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 12px; }
.bot-pick label { display: flex; gap: 8px; align-items: center; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.bot-pick label:hover { border-color: var(--line-2); }
.bot-pick label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-pick label.locked { opacity: .55; cursor: not-allowed; }

/* ---------- hộp thoại ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; animation: fade-in .12s ease-out; }
.modal { background: var(--surface); color: var(--fg); border-radius: var(--r-lg); padding: 20px 22px; max-width: 500px; width: 100%; box-shadow: var(--shadow-3); max-height: 90vh; overflow: auto; border: 1px solid var(--line); animation: pop-in .15s ease-out; }
.modal h3 { margin: 0 0 10px; text-transform: none; letter-spacing: 0; color: var(--fg); font-size: 16px; font-weight: 700; }
.modal h3 + h3, .modal .tbl + h3, .modal label + h3 { margin-top: 16px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal .tbl table { min-width: 0; }
.code { font: 700 30px/1.2 ui-monospace, "Cascadia Code", Consolas, monospace; letter-spacing: .14em; text-align: center; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r); user-select: all; }
.code.sm { font-size: 15px; letter-spacing: .06em; overflow-wrap: anywhere; word-break: break-all; }

/* ---------- màn hẹp: thanh bên thành dải trên ---------- */
@media (max-width: 1023px) {
  :root { --top-h: 48px; }
  .side { position: sticky; top: 0; bottom: auto; width: auto; height: 52px; flex-direction: row; align-items: center; gap: 6px; padding: 0 8px 0 12px; }
  .brand { padding: 0 8px 0 0; border: 0; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .brand-mark svg { width: 15px; height: 15px; }
  .brand-sub { display: none; }
  #nav { flex-direction: row; gap: 2px; padding: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex: 1; align-items: center; }
  #nav::-webkit-scrollbar { display: none; }
  .nav-label { display: none; }
  #nav a { padding: 6px 9px; font-size: 13px; gap: 6px; }
  #nav a svg { display: none; }
  #nav a.active::before { display: none; }
  .side-foot { display: none; }
  .topbar { margin-left: 0; top: 52px; padding: 0 12px; }
  .who-top { display: inline-flex; flex-direction: column; align-items: flex-end; flex: 0 1 auto; min-width: 0; max-width: 200px; line-height: 1.15; font-size: 12px; color: var(--fg-2); }
  .who-top-ten { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who-top-sep { display: none; }
  .who-top-vai { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
  #top:not([hidden]) ~ main, #top:not([hidden]) ~ #banner, #top:not([hidden]) ~ #new-version { margin-left: 0; }
  main { padding: 14px 12px 90px; }
  .banner { padding: 8px 12px; }
  .toolbar { position: static; }
  #toast { left: 12px; right: 12px; max-width: none; }
}
@media (max-width: 640px) {
  /* Thanh trên ≤ 640 px đã kín nút (Download, Hướng Dẫn, chuông, DỪNG TẤT CẢ) → "ai đang đăng nhập" là một dòng chữ mảnh riêng ở ĐÁY thanh
     ("super · Super Boss", căn phải), nằm ngoài hàng nút (absolute) nên không chen/ép nút nào; thanh cao thêm đúng một dòng chữ. */
  :root { --top-h: 64px; }
  .topbar { padding-bottom: 14px; }
  .who-top { position: absolute; left: 12px; right: 12px; bottom: 1px; max-width: none; flex-direction: row; justify-content: flex-end; align-items: baseline; font-size: 11.5px; line-height: 14px; }
  .who-top-ten { max-width: 60%; }
  .who-top-sep { display: inline; white-space: pre; color: var(--muted); }
  .who-top-vai { font-size: 11.5px; }
  /* L-76: nút trong trang (không phải thanh trên) có nhãn dài (vd "Cập nhật kinh nghiệm mới vào kịch bản (sẽ cần chạy thử lại)") xuống dòng thay vì lọt khỏi màn hẹp */
  #main button, #main .btn { white-space: normal; max-width: 100%; }
  .bots { grid-template-columns: minmax(0, 1fr); }
  /* Màn hẹp: chip + tình trạng + Dừng xuống dòng thay vì ép nhau; hàng nút tự xuống dòng. */
  .bot-viec { flex-wrap: wrap; }
  .bot-chip { flex-basis: 100%; }
  .bot-hop-chan { justify-content: stretch; }
  .bot-hop-chan > * { flex: 1 1 auto; }
  .two, .stat-grid { grid-template-columns: 1fr; }
  .modal { padding: 16px; }
  td.reason { min-width: 120px; max-width: 220px; }
  .rt .rt-text { display: none; }
  .rt { padding: 0; background: none; }
  .rt i { width: 10px; height: 10px; }
  #stop-all { padding: 7px 10px; font-size: 12.5px; }
  /* Màn hẹp: hai nút Download / Hướng Dẫn nhỏ lại (chữ 11.5px, ẩn biểu tượng) — kẻo đẩy DỪNG TẤT CẢ ra ngoài khung */
  #tai-bot, #huong-dan-video { white-space: normal; padding: 5px 8px; font-size: 11.5px; line-height: 1.15; gap: 4px; }
  #tai-bot svg, #huong-dan-video svg { display: none; }
  h1 { font-size: 20px; }
  .card { padding: 14px; border-radius: var(--r); }
}

/* ---------- so sánh Boss ---------- */
.cmp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.score { min-width: 90px; }
.score b { font-size: 16px; font-variant-numeric: tabular-nums; }
.score2 { min-width: 90px; }
.score2 b { font-size: 16px; font-variant-numeric: tabular-nums; }
.trend { font-weight: 700; margin-left: 4px; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--err); }
.score-bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 3px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); border-radius: 3px; }
[data-testid="cmp-table"] td { vertical-align: middle; }
.cmp-board { margin-bottom: 22px; }
.cmp-board h2 { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.cmp-board tr.hl td { background: var(--hi); }

/* ---------- ảnh lúc lỗi ---------- */
.fail-shot summary { cursor: pointer; }
.fail-shot img { display: block; max-width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }

/* ---------- mạch hội thoại (Việc đã làm) ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; max-height: 55vh; overflow: auto; }
.thread-item { border-left: 3px solid var(--line-2); padding: 6px 10px; background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0; }
.thread-item.tra_loi { border-left-color: var(--pri); }
.thread-item.dang { border-left-color: var(--ok); }
.thread-quote { border-left: 2px solid var(--line-2); margin: 4px 0; padding-left: 8px; color: var(--muted); font-style: italic; }

/* ---------- nhật ký máy chủ ---------- */
.server-log { max-height: 360px; font-size: 11.5px; white-space: pre-wrap; }
.log-line { padding: 1px 0; border-bottom: 1px dashed color-mix(in srgb, var(--line) 60%, transparent); overflow-wrap: anywhere; }
.log-line .log-at { color: var(--muted); }
.log-line .log-lv { font-weight: 700; }
.log-line.warn .log-lv { color: var(--warn); }
.log-line.error { background: color-mix(in srgb, var(--err) 8%, transparent); }
.log-line.error .log-lv { color: var(--err); }

/* ---------- ô tóm tắt trang Bot ---------- */
.bot-tiles { gap: 10px; margin-bottom: 12px; align-items: stretch; }
.bot-tiles .stat-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 0; font-weight: 500; text-align: left; cursor: pointer; min-width: 120px; box-shadow: var(--shadow-1); border-radius: var(--r-lg); transition: border-color .12s, box-shadow .12s; }
.bot-tiles .stat-tile:hover { background: var(--surface); border-color: var(--line-2); box-shadow: var(--shadow-2); }
.bot-tiles .stat-tile.on { border-color: var(--pri); box-shadow: 0 0 0 3px var(--ring); }
.bot-filters { margin: 0 0 10px; }
.bot-filters select { width: auto; }
.bot-filters p { margin: 0; }
.bot-search-wrap { max-width: 320px; }
@media (max-width: 640px) { .bot-tiles .stat-tile { min-width: calc(50% - 5px); flex-basis: calc(50% - 5px); } .bot-search-wrap { max-width: none; flex-basis: 100%; } }
/* Ô tóm tắt gọn hơn (một hàng số liệu, không chiếm cả màn); ô "Lỗi 24 giờ" mở trang khác → có mũi tên. */
.bot-tiles .stat-tile { padding: 10px 14px; }
.bot-tiles .stat-tile .stat-value { font-size: 22px; }
.stat-value.idle { color: var(--idle); }
.bot-tiles .stat-tile[data-tile="loi"] .stat-label::after { content: " →"; color: var(--pri); }

/* ---------- màn hẹp (≤ 1023 px): menu thành thanh điều hướng ở ĐÁY, chỉ còn MỘT thanh dính ở trên ---------- */
@media (max-width: 1023px) {
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: auto; padding: 0 0 env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--side-line); z-index: 20; }
  .side > .brand, .side-foot { display: none; }
  #nav { gap: 0; padding: 4px 6px; scroll-snap-type: x proximity;
    /* mép phải mờ dần: báo còn mục phía sau, cuộn ngang được */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  #nav a { flex: none; flex-direction: column; justify-content: center; gap: 2px; min-width: 76px; height: calc(var(--nav-h) - 8px); padding: 4px 6px; font-size: 11px; line-height: 1.2; scroll-snap-align: start; }
  /* Mục cuối có điểm bám "end" (chừa đúng dải mờ 24 px): không có nó, bám "start" kéo mục cuối lệch ra ngoài mép phải vài px khi mở (W33, GĐ4a thêm mục). */
  #nav a:last-child { margin-right: 24px; scroll-snap-align: end; scroll-margin-right: 24px; }
  /* Mục đang mở cuộn vào tầm nhìn cách mép 28 px — không nằm dưới dải mờ bên phải (nhãn dài như "Sổ kinh nghiệm" bị mờ mất chữ).
     Điểm bám "end" riêng: không có nó, bám "start" của mục khác kéo mục đang mở ra ngoài mép phải sau scrollIntoView. */
  #nav a.active { scroll-snap-align: end; scroll-margin-inline: 28px; }
  #nav a svg { display: inline-block; width: 20px; height: 20px; }
  #nav a.active::before { display: block; left: 22px; right: 22px; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  #nav a[data-count]::after { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; line-height: 16px; font-size: 10.5px; }
  .topbar { top: 0; }
  main { padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px)); }
  /* Thanh điều hướng cố định ở đáy: khi trình duyệt tự cuộn tới phần tử (Tab, scrollIntoView, tìm chữ) phải chừa chỗ, kẻo phần tử nằm SAU thanh (W41). */
  html { scroll-padding-bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  #toast { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 640px) {
  /* Dải "Cần bạn": chữ một hàng riêng, ba nút cùng một hàng bên dưới (không để nút Duyệt rơi lẻ). */
  .attn-what { flex-basis: 100%; }
  .attn-row > a.btn { margin-left: auto; }
}
/* Bảng trong lưới 2 cột của Thống kê: không ép rộng 560 px (bị cắt tiêu đề cột ở màn rộng). */
.stat-grid .tbl table { min-width: 0; }

/* ---------- chuông thông báo + hộp thông báo ---------- */
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 34px; padding: 0; }
.bell svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bell-count { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--btn-err); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.notice-panel { position: fixed; top: calc(var(--top-h) + 8px); right: 16px; width: min(440px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 14px 16px; z-index: 25; }
.notice-head h3 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--fg); }
.notice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.notice-item { border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: var(--r); padding: 8px 10px; cursor: pointer; background: var(--surface-2); }
.notice-item.unread { border-left-color: var(--btn-pri); background: color-mix(in srgb, var(--btn-pri) 7%, var(--surface)); }
.notice-item.unread .notice-text { font-weight: 600; }
.notice-item.warn { border-left-color: var(--warn); }
.notice-item.err { border-left-color: var(--err); }
.notice-item:focus-visible { outline: 2px solid var(--btn-pri); outline-offset: 1px; }
.notice-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 3px; }
.notice-dot { color: var(--btn-pri); font-size: 10px; }
.notice-text { overflow-wrap: anywhere; }
.row.center { justify-content: center; margin-top: 10px; }
@media (max-width: 1023px) { .notice-panel { top: calc(var(--top-h) + 60px); } }
@media (max-width: 640px) { .notice-panel { right: 8px; left: 8px; width: auto; } }

/* ---------- cửa sổ nổi thông báo (giữa màn hình, dấu × ở góc) ---------- */
.notice-popup { position: relative; width: min(640px, 100%); max-width: 640px; max-height: 88vh; }
.notice-popup h3 { margin-right: 44px; }
.np-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.np-body { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 12px; }
.np-card { border: 1px solid var(--line); border-left: 4px solid var(--btn-pri); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); }
.np-card.warn { border-left-color: var(--warn); }
.np-card.err { border-left-color: var(--err); }
.np-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.np-card p { margin: 4px 0; }
.np-card ul { margin: 6px 0 2px 18px; padding: 0; }
.np-card .tbl { margin-top: 4px; }
.np-card table { min-width: 0; width: 100%; }
.np-card tr.hl { background: color-mix(in srgb, var(--btn-pri) 9%, transparent); }
.np-card td .tag { align-self: flex-start; width: fit-content; }

/* ---------- soạn thông báo + thẻ thông báo của Super ---------- */
.np-msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }
.np-msg a { color: var(--btn-pri); text-decoration: underline; }
.np-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.np-imgs img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.np-imgs a { max-width: 100%; }
.an-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.an-thumb { position: relative; width: 96px; height: 96px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.an-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.an-thumb-x { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.an-boss { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); max-height: 220px; overflow: auto; }
/* danh mục "Quản lý các Boss" (Super) */
.nav-label-qly { color: var(--brand-b, #7aa2ff); }
.nav-label-qly::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: currentColor; vertical-align: middle; }
/* dải "có phiên bản mới": tab mở từ trước một lần deploy */
.new-version { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.new-version[hidden] { display: none; }
.new-version span { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Kịch bản sơ đồ (pages/kich-ban.ts) ---------- */
.kb-ten { overflow-wrap: anywhere; min-width: 0; }
.kb-yc, .kb-dong-loi, .kb-buoc-mo-ta, .kb-noi-dung, .kb-cau-mau li { white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-dong-loi { margin: 4px 0; }
.kb-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--fg); }
.kb-dong:hover { background: var(--surface-2); }
.kb-dong-ten { font-weight: 600; flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.kb-dong-phu { flex: 1 1 200px; min-width: 0; }
/* ---------- Xoá kịch bản ở danh sách + Thùng rác (06/10/2026, pages/kich-ban-xoa.ts) ---------- */
/* dòng = [ô tick][liên kết kịch bản][nút Xoá]; viền dưới chuyển sang khung bọc */
.kb-dong-boc { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.kb-dong-boc > .kb-dong { flex: 1 1 auto; min-width: 0; border-bottom: 0; }
.kb-dong-boc.chon { background: var(--pri-soft); box-shadow: inset 3px 0 0 var(--pri); }
.kb-dong-boc.chon > .kb-dong:hover { background: transparent; }
.kb-chon-nhan-o { flex: none; display: flex; align-items: center; justify-content: center; width: 40px; min-height: 44px; cursor: pointer; }
.kb-chon-nhan-o > input, .kb-chon-tat-ca > input { width: 18px; height: 18px; margin: 0; cursor: pointer; accent-color: var(--pri); }
.kb-xoa-dong { flex: none; display: inline-flex; align-items: center; gap: 5px; margin: 0 4px 0 2px; padding: 7px 12px; min-height: 36px; font-size: 13px; font-weight: 600; border-radius: 8px; box-shadow: none;
  color: var(--err); background: var(--err-soft); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); cursor: pointer; }
.kb-xoa-dong:hover:not(:disabled), .kb-xoa-dong:focus-visible { background: var(--btn-err); border-color: var(--btn-err); color: #fff; }
.kb-xoa-bieu { flex: none; }
.kb-chon-hang { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 2px; padding: 4px 4px 4px 0; border-bottom: 1px solid var(--line); }
.kb-chon-tat-ca { display: inline-flex; align-items: center; gap: 8px; width: auto; min-height: 36px; padding-left: 11px; font-weight: 600; cursor: pointer; }
.kb-loc-nhanh-hang { margin: 2px 0 0; align-items: center; gap: 6px 8px; }
.kb-loc-nhanh { border-radius: 999px; padding: 4px 12px; }
.kb-loc-nhanh.bat { background: var(--pri); border-color: var(--pri); color: #fff; }
.kb-nut-thung { display: inline-flex; align-items: center; gap: 6px; }
.kb-nut-thung.mo { background: var(--surface-2); border-color: var(--line-2); }
.kb-thung-rac { margin: 10px 0; border: 1px dashed var(--line-2); background: var(--surface-2); }
.kb-thung-rac h3 { margin: 0; }
.kb-tr-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.kb-tr-dong:last-child { border-bottom: 0; }
.kb-tr-nut { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.kb-tr-vinh-vien { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line-2)); }
/* thanh hành động NỔI khi có dòng được chọn + thanh Hoàn tác (nằm trên nó) */
.kb-thanh-noi, .kb-ht-xoa { position: fixed; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; max-width: min(640px, calc(100vw - 24px));
  padding: 10px 14px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-fg); box-shadow: var(--shadow-3); }
.kb-thanh-noi { bottom: 14px; }
.kb-ht-xoa { bottom: 76px; }
.kb-thanh-noi > button, .kb-ht-xoa > button.mini { min-height: 34px; }
.kb-thanh-noi > button:not(.danger) { background: transparent; color: var(--toast-fg); border-color: rgba(255, 255, 255, .35); }
.kb-thanh-noi > button.danger { display: inline-flex; align-items: center; gap: 6px; background: var(--btn-err); border-color: var(--btn-err); color: #fff; }
.kb-ht-xoa-chu { overflow-wrap: anywhere; min-width: 0; }
.kb-ht-xoa .kb-noi-x { color: var(--toast-fg); }
.kb-xoa-hop { max-width: 560px; }
.kb-xoa-ds { margin: 6px 0 10px; padding-left: 20px; }
.kb-xoa-hop .warn-box, .kb-xoa-hop .err-box { margin: 8px 0; }
.kb-xoa-hop ul { margin: 6px 0 0; padding-left: 20px; }
.kb-xoa-go-nhan { display: block; margin: 10px 0; }
.kb-xoa-go-nhan input { width: 100%; margin-top: 4px; }
body:has(.kb-thanh-noi:not([hidden])) main, body:has(.kb-ht-xoa:not([hidden])) main { padding-bottom: 140px; }
@media (max-width: 1023px) { /* thanh dưới cùng của điện thoại / máy tính bảng: nổi phía TRÊN nó, không che các mục */
  .kb-thanh-noi { bottom: calc(var(--nav-h) + 10px); }
  .kb-ht-xoa { bottom: calc(var(--nav-h) + 72px); }
}
@media (max-width: 520px) {
  .kb-chon-nhan-o { width: 36px; }
  .kb-xoa-dong { padding: 7px 10px; }
  .kb-thanh-noi { left: 12px; right: 12px; transform: none; max-width: none; justify-content: space-between; }
  .kb-ht-xoa { left: 12px; right: 12px; transform: none; max-width: none; }
}
/* ---------- Sơ đồ các bước — BỐ CỤC B (04/10/2026, docs/phan-tich-ux-so-do.md): 2 cột "con rắn" ≥ 1024 px (JS chọn), thẻ gọn có màu theo
   loại bước; hàng đầu thẻ cố định [tay nắm][số][tên + 1 chip][⋯] — nút ⋯ không rơi xuống dòng 2; túm cả thẻ để kéo (chuột), con trỏ grab. ---------- */
.kb-ds-buoc { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.kb-so-do { position: relative; }
.kb-so-do > h3:first-child { padding-right: 150px; }
.kb-luu { position: absolute; top: 15px; right: 18px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--ok); }
.kb-luu[data-trang-thai="dang-luu"] { color: var(--run); }
.kb-luu[data-trang-thai="loi"] { color: var(--err); }
.kb-goi-y { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 6px 8px 6px 10px; border-radius: var(--r); background: var(--pri-soft); color: var(--fg-2); font-size: 13px; }
/* màu THEO THỨ TỰ bước (lớp mau-buoc-N, N = mauBuoc(số bước)): thẻ, khe có mũi tên đi ra từ bước, huy hiệu nối cột */
.mau-buoc-1 { --mau: var(--buoc-1); } .mau-buoc-2 { --mau: var(--buoc-2); } .mau-buoc-3 { --mau: var(--buoc-3); } .mau-buoc-4 { --mau: var(--buoc-4); }
.mau-buoc-5 { --mau: var(--buoc-5); } .mau-buoc-6 { --mau: var(--buoc-6); } .mau-buoc-7 { --mau: var(--buoc-7); } .mau-buoc-8 { --mau: var(--buoc-8); }
.mau-buoc-9 { --mau: var(--buoc-9); } .mau-buoc-10 { --mau: var(--buoc-10); }
/* mặc định khi chưa có lớp màu — :where = độ ưu tiên 0, lớp mau-buoc-N luôn thắng dù đứng trước hay sau */
:where(.kb-buoc, .kb-khe, .kb-mui-sang, .kb-dau-cot) { --mau: var(--line-2); }
/* --kb-pl / --kb-pr / --kb-tay: lề trong của thẻ + bề rộng tay nắm — dùng chung cho đầu thẻ tô nền và vị trí mũi tên ↓ (thẳng dưới huy hiệu số) */
.kb-ds-buoc { --kb-pl: 8px; --kb-pr: 10px; --kb-tay: 32px; }
.kb-buoc { position: relative; border: 1px solid var(--line); border-left: 5px solid var(--mau); border-radius: var(--r-lg); padding: 8px var(--kb-pr) 10px var(--kb-pl); background: var(--surface); min-width: 0; cursor: grab; box-shadow: var(--shadow-1); transition: box-shadow .12s, border-color .12s; }
.kb-buoc:hover { box-shadow: var(--shadow-2); }
.kb-buoc.cao { border-top-color: color-mix(in srgb, var(--warn) 45%, var(--line)); border-right-color: color-mix(in srgb, var(--warn) 45%, var(--line)); border-bottom-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.kb-buoc :is(input, textarea, select) { cursor: text; }
.kb-buoc :is(button, a, label, input[type="checkbox"]) { cursor: pointer; }
.kb-buoc .kb-kq { cursor: auto; }
.loai-tim { --loai: #2563eb; } .loai-luot { --loai: #0d9488; } .loai-tuong_tac { --loai: #7c3aed; } .loai-dang { --loai: #ea580c; } .loai-nghi { --loai: #64748b; }
@media (prefers-color-scheme: dark) { .loai-tim { --loai: #60a5fa; } .loai-luot { --loai: #2dd4bf; } .loai-tuong_tac { --loai: #a78bfa; } .loai-dang { --loai: #fb923c; } .loai-nghi { --loai: #94a3b8; } }
.kb-buoc-dau { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: start; gap: 8px; margin: -8px calc(-1 * var(--kb-pr)) 0 calc(-1 * var(--kb-pl)); padding: 8px var(--kb-pr) 6px var(--kb-pl); border-radius: 9px calc(var(--r-lg) - 1px) 0 0; background: color-mix(in srgb, var(--mau) 11%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--mau) 28%, var(--line)); }
/* tên bước chảy như chữ: biểu tượng + tên + chip xuống dòng tự nhiên (không để biểu tượng đứng lẻ một dòng khi thẻ hẹp — ảnh 1024) */
.kb-buoc-ten { display: block; min-width: 0; padding-top: 5px; line-height: 1.5; overflow-wrap: anywhere; }
.kb-buoc-ten .kb-bieu { margin-right: 6px; }
.kb-buoc-ten .tag { margin-left: 6px; vertical-align: 1px; }
.kb-so { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-top: 2px; border-radius: 50%; background: var(--mau); color: var(--buoc-chu); font-weight: 700; font-size: 13.5px; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.kb-bieu { font-size: 16px; }
.kb-tieu-de { overflow-wrap: anywhere; min-width: 0; }
.kb-buoc-ten .tag { font-size: 11px; padding: 1px 8px; }
.kb-menu-nut { width: 36px; height: 32px; min-width: 0; padding: 0; justify-content: center; font-size: 18px; line-height: 1; font-weight: 700; color: var(--fg-2); background: transparent; border: 1px solid var(--line); box-shadow: none; }
.kb-menu-nut:hover, .kb-menu-nut[aria-expanded="true"] { background: var(--pri-soft); border-color: var(--pri); color: var(--pri); }
.kb-buoc-mo-ta { margin: 6px 0 2px; color: var(--fg-2); }
.kb-ghi-chu { margin: 2px 0; }
.kb-ts-luoi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2px 12px; margin-top: 6px; }
.kb-ts { margin-bottom: 4px; }
/* thẻ gọn: nút "Sửa tham số" + tóm tắt 1 dòng; mở → ô tham số */
.kb-ts-hang { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; margin-top: 6px; }
.kb-mo-the { flex: 0 1 auto; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 3px 10px; min-height: 28px; font-size: 12px; font-weight: 600; color: var(--pri); background: var(--pri-soft); border: 1px solid color-mix(in srgb, var(--pri) 30%, transparent); box-shadow: none; }
.kb-mo-the:hover { background: color-mix(in srgb, var(--pri) 16%, var(--surface)); }
.kb-ts-tom-tat { min-width: 0; flex: 1; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-ts-luoi[hidden] { display: none; }
.kb-buoc.gon .kb-buoc-mo-ta { margin-bottom: 0; }
.kb-so-do-cong-cu { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin: -4px 0 6px; }
input.kb-sai { border-color: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 20%, transparent); }
.kb-kq { margin-top: 8px; padding: 8px 10px; border-radius: var(--r); background: var(--surface-2); font-size: 13px; overflow-wrap: anywhere; }
.kb-kq.ok { background: var(--ok-soft); } .kb-kq.err { background: var(--err-soft); } .kb-kq.warn { background: var(--warn-soft); }
.kb-kq-bieu { font-weight: 700; }
.kb-cau-mau ul { margin: 4px 0 0; padding-left: 20px; color: var(--fg); }
/* bước vừa thêm / vừa chuyển: nhấp nháy ~1,5 s */
.kb-buoc.kb-moi { animation: kb-nhay 1.5s ease-out; }
@keyframes kb-nhay { 0%, 35% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--pri) 45%, transparent); background: var(--pri-soft); } 100% { box-shadow: var(--shadow-1); background: var(--surface); } }
@media (prefers-reduced-motion: reduce) { .kb-buoc.kb-moi { animation: none; outline: 2px solid var(--pri); outline-offset: 2px; } }
.kb-nut-chay { margin: 8px 0; }
/* Bố cục trang một kịch bản: Mô tả + Sơ đồ luôn hết bề rộng; các CẶP khung (Sản phẩm | Sửa bằng lời, Kịch bản
   mẫu | Kinh nghiệm AI | Đề xuất sửa) đứng cạnh nhau từ 1280 px (cột ≥ ~490 px — đủ cho hàng nút Chạy thử/Chạy thật/Xuất/Xoá), căn trên;
   khung trống bị ẩn → khung còn lại hết bề rộng; khung lẻ cuối nhóm hết bề rộng. Thứ tự DOM (Tab) giữ nguyên: trái → phải → hàng dưới.
   ≥ 1600 px: trang rộng tới 1680 px (màn 1920 không còn trống ~400 px bên phải). */
.kb-cap { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 16px; }
.kb-cap > * { flex: 1 1 100%; min-width: 0; }
.kb-cap > :empty { display: none; }
@media (min-width: 1280px) { .kb-cap > * { flex-basis: calc(50% - 8px); } }
@media (min-width: 1600px) { main:has(> .kb-trang) { max-width: 1680px; } }
/* lưới cột: 1 cột (≤ 1023px) / 2 cột theo THỨ TỰ CỘT (≥ 1024px); khe "＋ Chèn bước" giữa thẻ + mũi tên chiều chạy */
.kb-luoi-buoc { display: grid; grid-template-columns: minmax(0, 640px); gap: 0 56px; align-items: start; margin-bottom: 8px; }
.kb-luoi-buoc[data-so-cot="2"] { grid-template-columns: repeat(2, minmax(0, 600px)); }
@media (min-width: 1600px) { .kb-luoi-buoc[data-so-cot="2"] { grid-template-columns: repeat(2, minmax(0, 640px)); } }
/* ≤ 1023 px: một cột NGAY bằng CSS (JS vẽ lại 1 cột sau sự kiện đổi cỡ — trong lúc chờ, 2 cột bóp hẹp làm trang tràn ngang: E2E KB17 04/10) */
@media (max-width: 1023px) { .kb-luoi-buoc[data-so-cot="2"] { grid-template-columns: minmax(0, 640px); } }
.kb-cot-boc { min-width: 0; }
.kb-ds-buoc.kb-cot { gap: 0; margin: 0; }
.kb-khe { position: relative; display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 0 2px 8px; }
/* khe GIỮA hai bước: mũi tên dọc dày 3 px màu của bước phía trên (đi ra từ bước đó), cao hết khe, đầu tam giác; thẳng dưới huy hiệu số.
   "＋ Chèn bước" đứng bên phải mũi tên (không đè). */
.kb-khe.giua { min-height: 44px; padding-top: 0; padding-bottom: 0; padding-left: calc(var(--kb-pl) + var(--kb-tay) + 15px); }
.kb-khe .kb-mui { position: relative; flex: none; align-self: stretch; width: 24px; min-height: 32px; color: var(--mau); }
.kb-khe .kb-mui::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 9px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: currentColor; }
.kb-khe .kb-mui::after { content: ""; position: absolute; left: 50%; bottom: 0; margin-left: -7px; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 11px solid currentColor; }
.kb-chen { height: 28px; min-width: 28px; padding: 0 10px; border-radius: 999px; gap: 0; font-weight: 600; font-size: 12px; line-height: 1; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); box-shadow: none; }
.kb-chen:hover:not(:disabled), .kb-chen:focus-visible, .kb-khe[data-chon="1"] .kb-chen { background: var(--pri); color: #fff; border-style: solid; border-color: var(--pri); }
.kb-dang-keo-ds .kb-chen { visibility: hidden; }
.kb-khe[data-tha="1"], .kb-khe[data-cam="1"] { z-index: 6; }
.kb-khe[data-tha="1"]::after, .kb-khe[data-cam="1"]::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; margin-top: -2px; border-top: 4px solid var(--pri); border-radius: 2px; pointer-events: none; }
.kb-khe[data-cam="1"]::after { border-top: 4px dashed var(--err); }
.kb-khe-nhan { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 7; max-width: calc(100% - 20px); padding: 3px 10px; border-radius: 999px; background: var(--pri); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; box-shadow: var(--shadow-2); }
.kb-khe[data-cam="1"] .kb-khe-nhan { top: calc(50% + 6px); transform: none; border-radius: 8px; background: var(--err); white-space: normal; overflow-wrap: anywhere; }
/* nối sang cột phải: cuối cột trái + đầu cột phải là HUY HIỆU màu của bước cuối cột trái (đường đi ra từ bước đó), mũi tên tròn đặc */
.kb-mui-sang, .kb-dau-cot { display: flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; min-height: 40px; margin: 4px 0 8px; padding: 5px 14px 5px 6px; border: 2px solid var(--mau); border-radius: 999px; background: color-mix(in srgb, var(--mau) 12%, var(--surface)); color: var(--fg); font-weight: 700; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; box-shadow: var(--shadow-1); }
.kb-mui-sang { padding: 5px 6px 5px 14px; }
.kb-mui-ngang { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--mau); color: var(--buoc-chu); font-size: 18px; font-weight: 700; line-height: 1; }
.kb-keo { width: 32px; height: 40px; min-width: 0; min-height: 0; padding: 0; justify-content: center; flex: none; cursor: grab; touch-action: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); box-shadow: none; }
.kb-keo:hover:not(:disabled) { border-color: var(--pri); color: var(--pri); }
.kb-keo:disabled { cursor: not-allowed; opacity: .4; }
.kb-keo-cham { display: block; width: 12px; height: 20px; background-image: radial-gradient(circle, currentColor 1.6px, transparent 1.9px); background-size: 6px 6.5px; }
.kb-buoc.dang-keo { z-index: 5; opacity: .96; box-shadow: 0 16px 36px rgba(0, 0, 0, .25); cursor: grabbing; transition: none; }
.kb-dang-keo-ds { user-select: none; -webkit-user-select: none; }
html.kb-dang-keo-trang, html.kb-dang-keo-trang * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
/* bảng chọn thao tác: NỔI ngay cạnh nút (≤ 640 px: trượt từ dưới) — không cuộn trang */
.kb-pop { position: fixed; z-index: 5; width: min(560px, calc(100vw - 16px)); padding: 0 12px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow-y: auto; overscroll-behavior: contain; }
.kb-pop[data-kieu="sheet"] { position: fixed; left: 0; right: 0; bottom: 0; width: auto; z-index: 35; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); animation: kb-truot .18s ease-out; }
@keyframes kb-truot { from { transform: translateY(24px); opacity: .5; } }
.kb-pop-dau { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; gap: 8px; padding: 10px 0 4px; background: var(--surface); }
.kb-pop-dau p { margin: 0; }
.kb-pop-esc { white-space: nowrap; padding-top: 2px; }
.kb-chen-vi-tri { margin: 0; font-weight: 600; }
.kb-pop-tim { padding: 4px 0 2px; }
.kb-nhom { margin: 10px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kb-bang-luoi { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-tt { --loai: var(--line-2); justify-content: flex-start; white-space: normal; text-align: left; flex-wrap: wrap; min-width: 0; max-width: 100%; padding: 6px 10px; gap: 6px; font-size: 13px; border-left: 3px solid var(--loai); box-shadow: none; }
.kb-tt-ten { overflow-wrap: anywhere; }
.kb-tt .kb-tt-canh { font-size: 10.5px; padding: 0 6px; }
.kb-tt[data-cam="1"] { border-style: dashed; border-left-style: solid; color: var(--muted); }
.kb-tt-ly-do { flex-basis: 100%; font-size: 11.5px; font-weight: 500; color: var(--err); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-tt.chon { outline: 2px solid var(--pri); outline-offset: 1px; }
.kb-tt-trong { margin: 10px 0; }
.kb-them-form { margin: 10px 0 0; padding: 10px 12px 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.kb-them-form > p { margin: 0 0 6px; }
.kb-them-nut { position: sticky; bottom: 0; z-index: 2; margin: 4px -12px 0; padding: 8px 12px 10px; background: var(--surface-2); border-top: 1px solid var(--line); }
.kb-pop > :last-child { margin-bottom: 12px; }
.kb-o-loi { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--err); }
/* ô số vượt KHUYẾN NGHỊ (05/10/2026): lời khuyên mềm, không chặn lưu */
.kb-o-khuyen { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: var(--warn); overflow-wrap: anywhere; }
.kb-o-khuyen[hidden] { display: none; }
.kb-o-loi[hidden] { display: none; }
/* (06/10/2026) bảng "Từ khoá" nhiều dòng (Từ khoá | Số lượng | Chuyển từ khoá tiếp sau (giờ)) + cặp "Chờ giữa các lần" — chiếm cả hàng của lưới tham số */
.kb-tk, .kb-ts-cho { grid-column: 1 / -1; min-width: 0; margin-bottom: 6px; }
.kb-tk-che-do-nhan { margin: 0 0 4px; }
.kb-tk-che-do-nhan select { max-width: 100%; }
.kb-tk-giai { margin: 2px 0 6px; overflow-wrap: anywhere; }
.kb-tk-da-tach { margin: 2px 0 6px; color: var(--warn); }
.kb-tk-ds { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kb-tk-dong { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.3fr) minmax(0, 1.7fr) auto; gap: 6px 8px; align-items: end; min-width: 0; }
.kb-tk-dong:not(.kb-tk-tieu-de) { padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.kb-tk-tieu-de { font-size: 12px; font-weight: 600; color: var(--muted); align-items: end; }
.kb-tk-tieu-de .kb-tk-cot[hidden], .kb-tk-o[hidden] { display: none; }
.kb-tk-o { display: block; min-width: 0; margin: 0; }
.kb-tk-o input, .kb-cho-hang input { width: 100%; min-width: 0; box-sizing: border-box; }
.kb-tk-nhan-nho { display: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.kb-tk-c-nut { display: inline-flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.kb-tk-c-nut .mini { min-width: 30px; padding: 4px 8px; }
.kb-tk-xoa { color: var(--err); }
.kb-tk-chan { margin-top: 6px; }
.kb-tk-xem-truoc { margin: 6px 0 0; overflow-wrap: anywhere; }
.kb-tk-xem-truoc[hidden] { display: none; }
.kb-cho-hang { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 2px 0; }
.kb-cho-hang input { width: 96px; }
.kb-cho-nhan { font-size: 13px; color: var(--fg-2); }
.kb-cho-goi-y { margin-left: 4px; }
.kb-cho-doc { display: block; margin-top: 2px; }
@media (max-width: 640px) {
  .kb-tk-dong { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kb-tk-tieu-de { display: none; }
  .kb-tk-c-tu { grid-column: 1 / -1; }
  .kb-tk-c-nut { grid-column: 1 / -1; justify-content: flex-start; }
  .kb-tk-nhan-nho { display: block; }
  .kb-tk-c-nut .mini { min-height: 44px; min-width: 44px; }
  .kb-cho-hang input { width: 84px; }
}
/* menu ⋯ */
.kb-menu { position: fixed; z-index: 5; min-width: 240px; width: max-content; max-width: min(340px, calc(100vw - 16px)); padding: 6px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow-3); overflow-y: auto; }
.kb-menu[data-kieu="sheet"] { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-width: none; z-index: 35; border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
.kb-menu-muc { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 36px; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; box-shadow: none; text-align: left; white-space: normal; font-weight: 500; }
.kb-menu-muc:hover:not([aria-disabled="true"]), .kb-menu-muc:focus-visible { background: var(--pri-soft); border: 0; }
.kb-menu-muc:focus-visible { outline: 2px solid var(--pri); outline-offset: -2px; }
.kb-menu-muc[aria-disabled="true"] { color: var(--muted); cursor: not-allowed; }
.kb-menu-muc.nguy:not([aria-disabled="true"]) { color: var(--err); }
.kb-menu-ly-do { font-size: 11.5px; font-weight: 400; color: var(--muted); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-menu-vach { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
/* hộp lỗi + thanh Hoàn tác NỔI: không chiếm chỗ trong trang → sơ đồ không bị đẩy */
.kb-loi-noi { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 38; display: flex; align-items: flex-start; gap: 6px; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow-3); overflow-wrap: anywhere; }
.kb-noi-than { flex: 1; min-width: 0; }
.kb-loi-tieu-de { display: block; margin-bottom: 2px; }
.kb-ht-noi { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 38; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 8px 8px 8px 14px; border-radius: var(--r); background: var(--toast-bg); color: var(--toast-fg); box-shadow: var(--shadow-3); font-size: 13.5px; }
.kb-loi-noi[hidden], .kb-ht-noi[hidden] { display: none; }
.kb-noi-x { flex: none; padding: 0 8px; min-height: 28px; border: 0; background: transparent; box-shadow: none; color: inherit; font-size: 18px; line-height: 1; }
.kb-noi-x:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
@media (max-width: 1023px) {
  .kb-loi-noi { bottom: calc(var(--nav-h) + 72px + env(safe-area-inset-bottom, 0px)); }
  .kb-ht-noi { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
}
/* Tự duyệt cấp bước: công tắc "Tự động (không cần duyệt)" + nhãn "⚡ tự động" */
.kb-tu-duyet { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 2px; font-size: 13px; cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.kb-tu-duyet.bat { color: var(--pri); font-weight: 600; }
.kb-tu-dong-tat-ca { display: flex; margin: 4px 0 8px; }
input[type="checkbox"].kb-cong-tac { appearance: none; -webkit-appearance: none; display: inline-block; box-sizing: border-box; padding: 0; border: 0; flex: none; width: 36px; min-width: 36px; height: 20px; margin: 0; border-radius: 10px; background: var(--line-2); position: relative; cursor: pointer; transition: background .12s; }
input[type="checkbox"].kb-cong-tac::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: left .12s; }
input[type="checkbox"].kb-cong-tac:checked { background: var(--pri); }
input[type="checkbox"].kb-cong-tac:checked::after { left: 18px; }
input[type="checkbox"].kb-cong-tac:indeterminate { background: color-mix(in srgb, var(--pri) 45%, var(--line-2)); }
input[type="checkbox"].kb-cong-tac:indeterminate::after { left: 10px; }
input[type="checkbox"].kb-cong-tac:disabled { opacity: .45; cursor: not-allowed; }
input[type="checkbox"].kb-cong-tac:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
.tag.kb-tu-dong-tag { border-color: var(--pri); color: var(--pri); background: var(--pri-soft); }
.kb-canh-bao-tu-dong { margin: 4px 0 8px; overflow-wrap: anywhere; }
.kb-cho-duyet { margin-top: 8px; overflow-wrap: anywhere; }
.kb-cho-duyet .row { margin-top: 8px; }
@media (max-width: 640px) {
  .kb-ds-buoc { --kb-pl: 6px; --kb-pr: 8px; --kb-tay: 44px; }
  .kb-ts-luoi { grid-template-columns: 1fr; }
  .kb-nut-chay > button { flex: 1 1 auto; }
  /* chạm: tay nắm, ⋯, "＋ Chèn bước", mục menu ≥ 44 px */
  .kb-keo, .kb-menu-nut { width: 44px; height: 44px; }
  .kb-chen { min-height: 44px; min-width: 44px; }
  .kb-khe, .kb-khe.giua { min-height: 50px; }
  .kb-menu-muc { min-height: 44px; }
  .kb-mo-the { min-height: 44px; }
  .kb-so-do > h3:first-child { padding-right: 0; padding-top: 18px; }
  .kb-pop-esc { display: none; }
  .kb-luu { top: 8px; }
}

/* Bản đồ giao diện (Super): ô sửa JSON chữ đơn cách, dòng đang chọn, id bước không tràn bảng */
textarea.bd-code { min-height: 260px; white-space: pre; overflow: auto; tab-size: 2; }
.bd-code-cell { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; overflow-wrap: anywhere; }
.bd-dx-ds { display: grid; gap: 10px; }
.bd-dx-the { border: 1px solid var(--line, #e5e7eb); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.bd-dx-the p { margin: 0; }
/* Trang Bản đồ có HAI .toolbar: chỉ thanh nút (Phát hành/Nhập/Xuất) được dính; thanh ô tìm kiếm phải trôi theo trang, nếu không nó dính cùng chỗ và ĐÈ LÊN nút Phát hành khi cuộn. */
.toolbar.bd-khong-dinh { position: static; }
.bd-tc { display: grid; gap: 8px; }
.bd-tc-row { border: 1px solid var(--line, #e5e7eb); border-radius: 8px; padding: 8px 10px; }
.bd-tc-row .row { gap: 8px; flex-wrap: wrap; }
.bd-tc-goiy { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.bd-tc-goiy li { overflow-wrap: anywhere; }
tr.sel td { background: var(--ring); }
td.name.bd-name { min-width: 260px; max-width: 340px; }
td.bd-mota { min-width: 240px; }
/* Lịch sử phát hành: cột "Thay đổi" mỗi thay đổi một dòng, đủ rộng để "facebook/binh_luan_mot_bai: bản sửa mới" đọc liền (390 px: bảng cuộn ngang có gợi ý). */
td.bd-thay-doi { min-width: 250px; }
.bd-thay-doi-ds { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.bd-thay-doi-ds li { overflow-wrap: anywhere; }
.bd-thay-doi-ds .bd-ma { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; }
@media (max-width: 720px) { td.name.bd-name { min-width: 170px; } }

/* Bản đồ giao diện — tab Giao diện */
.bdg-h { margin: 0; font-size: 15px; }
.bdg-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.bdg-section { margin: 14px 0; min-width: 0; }
.bdg-warn { color: var(--warn); font-weight: 700; }
.bdg-empty { text-align: center; padding: 28px 16px; border-style: dashed; box-shadow: none; }
.bdg-empty p { margin: 6px 0; }
.bdg-cell { min-width: 100px; max-width: 340px; overflow-wrap: anywhere; word-break: break-word; }
.bdg-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.bdg-wrap { overflow-wrap: anywhere; }
.bdg-table td, .bdg-table th { vertical-align: top; }
.tbl .bdg-table { min-width: 760px; }
.bdg-attrs { display: flex; flex-wrap: wrap; gap: 4px; }
.bdg-attr { display: inline-block; max-width: 100%; padding: 1px 7px; border-radius: 6px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere; word-break: break-word; }
.bdg-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.bdg-filter input { flex: 1 1 240px; width: auto; min-width: 0; }
.bdg-filter select { flex: 0 0 180px; width: 180px; }
.bdg-paging { margin-top: 10px; justify-content: center; }
.bdg-copy-box { margin: 6px 0; }
.bdg-copy-box textarea { min-height: 140px; }
tr.bdg-page-row { cursor: pointer; }
tr.bdg-page-row:hover td { background: var(--surface-2); }
tr.bdg-page-row:focus-visible { outline: 2px solid var(--pri); outline-offset: -2px; }
tr.bdg-page-row.sel td { background: var(--ring); }
tr.bdg-tt-mat td, tr.bdg-doi-mat td { background: var(--err-soft); }
tr.bdg-tt-moi td { background: var(--run-soft); }
tr.bdg-doi-moi td { background: var(--run-soft); }
@media (max-width: 600px) {
  .bdg-cell { max-width: 240px; }
  .bdg-filter select { flex: 1 1 100%; width: 100%; }
}

/* ---- Trạng thái kịch bản (Nháp đỏ / Chạy thử vàng / Hoàn thiện xanh lá) — chấm LUÔN đi kèm chữ ---- */
.kb-nhan { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 2px 9px 2px 7px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--fg-2); white-space: nowrap; }
.kb-cham { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; box-shadow: 0 0 0 2px var(--surface); }
.kb-nhan-nhap .kb-cham { background: #d92d20; }
.kb-nhan-chay_thu .kb-cham { background: #eab308; }
.kb-nhan-hoan_thien .kb-cham { background: #16a34a; }
.kb-nhan-nhap { border-color: #f0b7b1; } .kb-nhan-chay_thu { border-color: #ecd27a; } .kb-nhan-hoan_thien { border-color: #9fd8b2; }
.kb-dau { align-items: flex-start; gap: 8px 12px; }
.kb-dau-trai { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 280px; }
.kb-ten-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.kb-ten-wrap h1 { margin: 0; }
.kb-ten-sua { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.kb-ten-sua input { flex: 1 1 220px; min-width: 0; font-size: 18px; }
.kb-chon-nhan, .kb-loc { display: inline-flex; align-items: center; gap: 6px; }
.kb-chon-nhan > span, .kb-loc > span { white-space: nowrap; }
.kb-dau-trai > .kb-nhan { align-self: flex-start; }
/* (07/10/2026) thẻ "Nhập tệp kịch bản" gọn: một hàng Tệp · Trạng thái · Nhập (xuống dòng khi hẹp) */
.kb-nhap-hang { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.kb-nhap-hang > .f { flex: 1 1 180px; min-width: 0; margin: 0; }
.kb-nhap-hang > .kb-nhap-tep-o { flex-basis: 220px; }
.kb-nhap-hang > button { flex: none; }
.kb-nhap input[type="file"] { max-width: 100%; min-width: 0; }
.kb-nhap .err-box { margin-top: 8px; }

/* ---- GĐ3: đề xuất sửa trên trang Kịch bản ---- */
.ts-ds { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.ts-dx { border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; background: var(--surface); min-width: 0; }
.ts-dx.ts-A { border-left-color: var(--run); } .ts-dx.ts-B { border-left-color: var(--warn); } .ts-dx.ts-C { border-left-color: var(--err); }
.ts-dx-dau { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ts-dx p { margin: 6px 0; }
.ts-ly-do { font-weight: 600; }
.ts-bang-chung { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.ts-doi-wrap { overflow-x: auto; max-width: 100%; }
.ts-doi { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0; }
.ts-doi th, .ts-doi td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.ts-doi .ts-truoc { text-decoration: line-through; color: var(--muted); }
.ts-doi .ts-sau { font-weight: 600; }
.ts-muc-an_toan td:last-child { color: var(--ok); } .ts-muc-can_hoi td:last-child { color: var(--warn); } .ts-muc-chan td:last-child { color: var(--err); font-weight: 600; }
.ts-truoc-sau { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
.ts-truoc-sau ul { margin: 4px 0; padding-left: 18px; overflow-wrap: anywhere; }
.ts-radio { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; cursor: pointer; }
.ts-radio input { margin-top: 3px; }

/* ---- GĐ3: trang Chờ duyệt ---- */
.cd-thanh { margin-bottom: 10px; }
.cd-muc { padding: 12px 14px; }
.cd-muc-dau { gap: 6px 10px; align-items: baseline; }
.cd-muc textarea { width: 100%; min-height: 64px; }
.cd-bai { font-size: 13px; overflow-wrap: anywhere; margin: 4px 0 8px; }
.cd-bai-nd { color: var(--fg-2); }
/* Kèm ảnh (04/10/2026): ảnh sẽ gửi cùng câu + "Bỏ ảnh (chỉ gửi chữ)" */
.cd-anh { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin: 6px 0 8px; }
.cd-anh img { max-width: 160px; max-height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.cd-anh-chu { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 180px; overflow-wrap: anywhere; }
.cd-bo-anh { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.cd-anh.cd-anh-bo img { opacity: .35; filter: grayscale(1); }
.cd-td-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .ts-truoc-sau { grid-template-columns: 1fr; }
  /* bảng trước/sau thành từng khối dọc ở màn hẹp — không cuộn ngang */
  .ts-doi thead { display: none; }
  .ts-doi, .ts-doi tbody, .ts-doi tr, .ts-doi td { display: block; width: 100%; }
  .ts-doi tr { border-bottom: 1px solid var(--line-2); padding: 4px 0; }
  .ts-doi td { border: 0; padding: 2px 0; }
  .ts-doi td::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 400; }
  .kb-dau > .row { width: 100%; }
}

/* Bản đồ giao diện — áp dụng bản mới cho kịch bản */
.modal.bda-modal { max-width: 560px; }
.bda-preview { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.bda-preview p { margin: 4px 0; }
.bda-list { margin: 4px 0; padding-left: 20px; min-width: 0; }
.bda-list li { overflow-wrap: anywhere; word-break: break-word; }
.bda-ten { overflow-wrap: anywhere; }
.bda-warn { color: var(--warn); font-weight: 600; }
.bda-check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 2px; font-size: 13px; cursor: pointer; }
.bda-check input { margin-top: 2px; flex: 0 0 auto; }
.bda-check span { min-width: 0; overflow-wrap: anywhere; }
.bda-result { margin: 0 0 14px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--pri) 35%, transparent); background: var(--pri-soft); border-radius: var(--r); font-size: 13px; min-width: 0; }
.bda-result[hidden] { display: none; }
.bda-result.bda-has-err { border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.bda-result p { margin: 6px 0; overflow-wrap: anywhere; }
h3.bda-h { margin: 0; font-size: 15px; font-weight: 700; color: var(--fg); text-transform: none; letter-spacing: 0; }
.bda-err { margin: 8px 0; padding: 10px 12px; border: 2px solid var(--err); border-radius: var(--r); background: var(--err-soft); color: var(--err); min-width: 0; }
.bda-err p.bda-err-h { margin: 0 0 6px; font-weight: 700; }
.bda-err ul.bda-list { max-height: 260px; overflow: auto; }
@media (max-width: 600px) {
  .bda-result { padding: 10px; }
  .bda-err ul.bda-list { max-height: 200px; }
}
/* GĐ4a Sổ kinh nghiệm (pages/so-kinh-nghiem.ts): thẻ bài học có chấm màu trạng thái; 390 px xếp dọc, chữ dài xuống dòng. */
.kn-day-hang { margin-top: 8px; }
.kn-day-hang select, .kn-loc select { flex: 0 1 200px; width: 200px; max-width: 100%; }
.kn-day-the textarea, .kn-sua-khung textarea { font-family: inherit; font-size: 14px; min-height: 64px; }
.kn-loc { margin: 4px 0 10px; }
.kn-ds { display: flex; flex-direction: column; gap: 10px; }
.kn-the { margin-bottom: 0; border-left: 4px solid var(--line-2); }
.kn-the.tt-xac_nhan { border-left-color: var(--ok); }
.kn-the.tt-thu_nghiem { border-left-color: var(--warn); }
.kn-the.tt-tat { opacity: .72; }
.kn-dau { gap: 6px 8px; }
.kn-cham { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.kn-noi-dung, .kn-cau, .kn-kb-ds li, .kn-cho-hoc-loi { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.kn-noi-dung { margin: 8px 0 4px; font-size: 14.5px; }
.kn-meta { margin: 0 0 8px; overflow-wrap: anywhere; }
.kn-sua-khung textarea { width: 100%; margin: 8px 0 6px; }
.kn-cho-hoc { margin-bottom: 10px; }
.kn-cho-hoc-loi { margin: 6px 0 0; }
.kn-bc { max-height: 60vh; overflow: auto; min-width: 0; }
.kn-bc-dong { border-top: 1px solid var(--line); padding: 6px 0; }
.kn-bc-cap { margin: 4px 0; padding-left: 18px; }
.kn-bc-cap li { margin-bottom: 6px; }
.kn-kb-ds { margin: 6px 0; padding-left: 18px; }
@media (max-width: 640px) {
  .kn-day-hang > select, .kn-day-hang > button, .kn-loc > select { flex: 1 1 100%; width: 100%; }
  .kn-nut > button { flex: 1 1 auto; }
}

/* ---------- GĐ4b Trợ lý (#/tro-ly): hội thoại người phải / trợ lý trái, chip nguồn, thẻ đề xuất ---------- */
.tl-chon { margin: 0 0 10px; }
.tl-chon select { flex: 0 1 240px; width: 240px; max-width: 100%; }
.tl-chi-xem { margin: 0 0 10px; }
.tl-ds { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 12px; min-width: 0; }
.tl-tin { max-width: min(760px, 82%); min-width: 0; padding: 10px 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1); }
.tl-tin.tl-nguoi { align-self: flex-end; background: var(--pri-soft); border-color: color-mix(in srgb, var(--pri) 25%, transparent); }
.tl-tin.tl-tro-ly { align-self: flex-start; }
.tl-ai { margin-bottom: 4px; }
.tl-noi-dung, .tl-dx-mo-ta, .tl-dx-kq, .tl-loi-tin { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.tl-dang { color: var(--muted); font-style: italic; }
.tl-loi-tin { margin-top: 6px; }
.tl-nguon-ds { margin-top: 8px; gap: 6px; }
.tl-nguon { display: inline-block; max-width: 100%; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.tl-dx { margin-top: 10px; padding: 8px 10px; border-radius: var(--r); border: 1px solid var(--line); border-left: 4px solid var(--pri); background: var(--surface-2); min-width: 0; }
.tl-dx.dx-da_lam { border-left-color: var(--ok); }
.tl-dx.dx-loi { border-left-color: var(--err); }
.tl-dx.dx-bo_qua { opacity: .7; border-left-color: var(--line-2); }
.tl-dx[data-loai="mo_trang"] { border-left-color: var(--warn); }
.tl-dx-mo-ta { margin: 6px 0; }
.tl-dx-kq { margin: 4px 0; }
.tl-dx-nut button, .tl-dx .btn { white-space: normal; text-align: left; }
.tl-goi-y-ds { justify-content: center; }
.tl-goi-y-nut { white-space: normal; text-align: left; max-width: 100%; }
.tl-go textarea { width: 100%; font-family: inherit; font-size: 14px; min-height: 72px; resize: vertical; }
.tl-go-hang { margin-top: 8px; }
.tl-go .err-box { margin-top: 8px; }
@media (max-width: 640px) {
  .tl-tin { max-width: 94%; }
  .tl-chon select { flex: 1 1 100%; width: 100%; }
  .tl-dx-nut > button { flex: 1 1 auto; }
}
/* L-50 (d): dòng số liệu máy đếm dưới câu trả lời của Trợ lý */
.tl-so-lieu { margin-top: 6px; padding: 4px 8px; border-left: 3px solid var(--pri); background: var(--surface-2); border-radius: 4px; overflow-wrap: anywhere; }
/* GĐ4c — Trợ lý tự làm (vòng có rào): khung "Đang tự làm" trên trang Trợ lý + dải trên trang kịch bản */
.vg-khung { margin: 0 0 14px; min-width: 0; }
.vg-tieu-de { font-size: 16px; margin: 4px 0 8px; }
.vg-the { border-left: 4px solid var(--run); min-width: 0; margin-bottom: 10px; }
.vg-the.vg-xong { border-left-color: var(--ok); }
.vg-the.vg-dung_tai_khoan { border-left-color: var(--err); }
.vg-the.vg-cham_gioi_han, .vg-the.vg-dung_loi, .vg-the.vg-dung_khoi_dong_lai { border-left-color: var(--warn); }
.vg-the.vg-da_dung { border-left-color: var(--line-2); }
.vg-dau { gap: 8px; }
.vg-kb, .vg-muc-tieu, .vg-dem, .vg-giai-doan, .vg-ket-qua, .vg-buoc { overflow-wrap: anywhere; min-width: 0; }
.vg-muc-tieu, .vg-dem { margin: 6px 0 0; }
.vg-giai-doan { margin: 6px 0 0; color: var(--run); font-style: italic; }
.vg-luot-ds { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.vg-luot { padding: 6px 8px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.vg-luot-ten { font-weight: 600; margin-bottom: 2px; }
.vg-buoc-ds { margin: 0; padding-left: 18px; }
.vg-buoc { margin: 2px 0; white-space: pre-wrap; }
.vg-buoc-loai { color: var(--muted); }
.vg-b-chan { color: var(--err); }
.vg-b-sua .vg-buoc-loai, .vg-b-ket_qua .vg-buoc-loai { color: var(--fg-2); font-weight: 600; }
.vg-ket-qua { margin: 8px 0 0; white-space: pre-wrap; }
.vg-ket-qua.ok { color: var(--ok); font-weight: 600; }
.vg-ket-qua.err { color: var(--err); }
.vg-nut { margin-top: 8px; gap: 8px; }
.vg-nut .btn, .vg-nut button { white-space: normal; text-align: center; }
.vg-dai { margin: 0 0 10px; gap: 8px; overflow-wrap: anywhere; min-width: 0; }
.vg-dai.ok-box { border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); background: var(--ok-soft); padding: 10px 12px; border-radius: var(--r); font-size: 13px; }
@media (max-width: 600px) {
  .vg-nut > .btn, .vg-nut > button { flex: 1 1 100%; }
  .vg-buoc-ds { padding-left: 14px; }
}

/* ---- Thư viện sản phẩm (pages/san-pham.ts) + ô chọn sản phẩm trên trang Kịch bản ---- */
.ok-box { border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); background: var(--ok-soft); padding: 10px 12px; border-radius: var(--r); font-size: 13px; }
.sp-dong { align-items: baseline; }
.sp-dong-tt { flex: 1 1 100%; min-width: 0; color: var(--fg-2); overflow-wrap: anywhere; }
.sp-tha { border: 2px dashed var(--line-2); border-radius: var(--r-lg); padding: 14px; background: var(--surface-2); text-align: center; overflow-wrap: anywhere; position: relative; }
.sp-tha.keo { border-color: var(--pri); background: var(--pri-soft); }
.sp-tha p { margin: 4px 0; }
.sp-an-tep { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sp-tep-ds { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.sp-tep { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; background: var(--surface); min-width: 0; }
.sp-tep-ten { overflow-wrap: anywhere; min-width: 0; flex: 1 1 160px; }
.sp-chu { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; background: var(--surface-2); padding: 8px; border-radius: 8px; font-size: 12.5px; margin: 6px 0 0; }
.sp-anh-ds { display: flex; flex-wrap: wrap; gap: 10px; }
.sp-anh { margin: 0; width: 132px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.sp-anh img { width: 132px; height: 100px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
.sp-anh figcaption { display: flex; flex-direction: column; gap: 4px; align-items: center; width: 100%; }
.sp-anh figcaption input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 3px 6px; }
.sp-nut { margin: 12px 0; }
.kb-sp-chon-hang { align-items: flex-end; }
.kb-sp-chon-hang select { max-width: 100%; }
.kb-sp-tom-tat { margin-top: 10px; overflow-wrap: anywhere; }
.kb-sp-muc ul { margin: 4px 0 8px; padding-left: 20px; }
@media (max-width: 640px) {
  .sp-nut > .btn, .sp-nut > button { flex: 1 1 100%; }
  .kb-sp-chon-hang > .btn { flex: 1 1 100%; text-align: center; }
  .sp-anh { width: calc(50% - 5px); }
  .sp-anh img { width: 100%; }
}

/* Kịch bản mẫu của Super + chạy trên nhiều bot (pages/kich-ban-mau.ts, pages/kich-ban-nhieu-bot.ts) */
.mau-dong { padding: 10px 4px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mau-dong:last-child { border-bottom: 0; }
.mau-dau { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.mau-ten { overflow-wrap: anywhere; min-width: 0; }
.mau-buoc summary { cursor: pointer; font-size: 13px; }
.mau-loi { margin-top: 4px; }
.mau-nhan .row { gap: 6px 18px; }
.mau-doi { margin-top: 8px; }
.mau-dong a.btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.nb-chon { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--r); max-height: 240px; overflow: auto; }
/* L-77: nhãn bot chảy như một dòng chữ (không chia cột flex) — tên dài xuống dòng theo từ, "· trực tuyến" giữ nguyên một khối */
label.inline.nb-bot { display: block; min-width: 0; overflow-wrap: anywhere; }
.nb-bot > input { vertical-align: middle; margin: 0 6px 0 0; }
.nb-bot > .small { white-space: nowrap; }
.nb-lo { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.nb-ds { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nb-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 10px; border-radius: var(--r); background: var(--surface-2); overflow-wrap: anywhere; min-width: 0; }
.nb-dong.ok { background: var(--ok-soft); }
.nb-dong.err { background: var(--err-soft); }
.nb-ten { min-width: 0; }
.nb-kq { flex: 1 1 200px; min-width: 0; }
.nb-cho-duyet { width: 100%; }
@media (max-width: 600px) {
  .kb-nut-chay > button[data-testid="kb-nhap"], .kb-nut-chay > button[data-testid="kb-that"] { flex: 1 1 auto; white-space: normal; } /* chữ dài "Chạy thử trên N bot" xuống dòng trong nút */
}

/* Gói seeding (pages/goi-seeding.ts): danh sách, trình hướng dẫn 4 bước, trang một gói */
div.f { display: block; margin-bottom: 10px; min-width: 0; }
.f > .f-nhan { display: block; font-size: 12px; font-weight: 600; color: var(--fg-2); margin-bottom: 4px; }
.goi-h3 { margin: 0; }
.goi-the-ten { margin: 0; text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--fg); }
.goi-mang-tag { gap: 6px; }
.goi-ds-co-san { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.goi-the { margin: 0; }
.goi-the > .row:first-child h3 { padding: 0; border: 0; margin: 0; }
.goi-dong { cursor: pointer; }
.goi-nhap-do { margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.goi-gioi-thieu p { margin: 0 0 6px; }
.goi-buoc { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: none; }
.goi-buoc-o { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.goi-buoc-o.on { background: var(--pri-soft); color: var(--pri); border-color: color-mix(in srgb, var(--pri) 45%, var(--line)); }
.goi-buoc-o.xong { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--line)); }
.goi-buoc-o button.link { color: inherit; font-weight: 600; }
.goi-san-khau > h3:first-child { margin-top: 0; font-size: 15px; color: var(--fg); text-transform: none; letter-spacing: 0; }
.goi-loi { margin: 0 0 12px; }
.goi-loi-tieu-de { font-weight: 700; margin-bottom: 4px; }
.goi-loi-ds { margin: 0; padding-left: 20px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.goi-dieu-huong { gap: 8px; margin-bottom: 24px; }
.goi-sp-ds { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 420px; overflow-y: auto; }
.goi-sp-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); cursor: pointer; min-width: 0; }
.goi-sp-dong.on, .goi-sp-dong:has(input:checked) { border-color: var(--pri); background: var(--pri-soft); }
.goi-sp-ten { font-weight: 600; overflow-wrap: anywhere; min-width: 0; flex: 1 1 200px; }
.goi-sp-tt { flex: 1 1 100%; overflow-wrap: anywhere; }
.goi-mang-the { margin-bottom: 10px; }
.goi-mang-the.on { border-color: color-mix(in srgb, var(--pri) 45%, var(--line)); }
.goi-mang-nhan { font-size: 15px; }
.goi-bot-ds { margin: 4px 0 8px; padding-left: 20px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.goi-kb-ds { display: grid; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.goi-kb-dong { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; min-width: 0; }
.goi-kb-dong > input { margin-top: 3px; flex: none; }
.goi-kb-noi { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.goi-kb-noi .tag { white-space: normal; text-align: left; } /* W62: nhãn loại dài ("Chăm sóc kênh (…)") phải xuống dòng ở 390px, không tràn ô */
.goi-kb-o { display: grid; gap: 4px; min-width: 0; }
/* "Tự động (không cần duyệt)" của từng kịch bản: thụt vào dưới ô tick kịch bản, chữ cảnh báo xuống dòng được ở 390px */
.goi-tu-duyet-dong { display: flex; align-items: flex-start; gap: 8px; margin-left: 24px; cursor: pointer; min-width: 0; font-size: 13px; }
.goi-tu-duyet-dong > input { margin-top: 2px; flex: none; }
.goi-tu-duyet-chu { min-width: 0; overflow-wrap: anywhere; }
.goi-tu-duyet-chu .tag { white-space: normal; }
.goi-ta { font-family: inherit; font-size: 13.5px; min-height: 64px; line-height: 1.5; }
.goi-dem { font-weight: 400; }
.goi-cam-ky { display: grid; gap: 6px; }
.goi-cam-ky-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.goi-cam-ky-dong input { flex: 1 1 260px; min-width: 0; width: auto; }
.goi-tu-khoa-dau { margin-top: 12px; }
.goi-lv-the { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; background: var(--surface-2); min-width: 0; }
.goi-lv-the h4, .goi-mang-sua + h4, .card > h4 { margin: 0 0 8px; font-size: 14px; }
.goi-gd summary { cursor: pointer; font-size: 13px; }
.goi-mang-sua { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; margin-bottom: 12px; }
.goi-mang-sua-o { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; background: var(--surface-2); min-width: 0; }
.goi-mang-sua-o.on { border-color: color-mix(in srgb, var(--pri) 45%, var(--line)); }
.goi-the-lich { margin-bottom: 12px; min-width: 0; }
.goi-the-lich.card, .card > .goi-the-lich { padding: 0; border: 0; box-shadow: none; }
.goi-lich-kb { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: var(--surface); min-width: 0; }
.goi-lich-ten { overflow-wrap: anywhere; }
.goi-khung-ds { display: grid; gap: 8px; margin-top: 6px; }
.goi-khung { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.goi-khung-o { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.goi-khung-o input[inputmode] { width: 84px; }
.goi-khung-thu { flex: 1 1 280px; }
.goi-thu { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 6px 0; }
.goi-thu-o { font-size: 13px; }
.goi-khung-cuoi { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.goi-khung-tt { flex: 1 1 100%; }
.goi-ban-moi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.goi-tom-tat { margin-bottom: 12px; gap: 6px; }
.goi-lv h3 { margin-top: 14px; }
@media (max-width: 640px) {
  .goi-ds-co-san { grid-template-columns: 1fr; }
  .goi-dieu-huong { flex-direction: column; align-items: stretch; }
  .goi-dieu-huong > .row { justify-content: stretch; }
  .goi-dieu-huong button { flex: 1 1 auto; }
  .goi-khung-thu { flex-basis: 100%; }
  .goi-khung-cuoi { margin-left: 0; }
  .goi-buoc-o { padding: 5px 9px; font-size: 12px; }
}

/* ---------- bảng → thẻ ở màn hẹp (dùng chung) ----------
   Bảng nhiều cột ở ≤ 600 px phải vuốt ngang trong khung mà người dùng không biết (03/10: Lịch sử chạy chỉ thấy 3 cột đầu, không biết lần
   chạy đạt hay lỗi). Thêm class "bang-the" vào <table> + data-label="Tên cột" vào từng <td>: mỗi hàng thành một thẻ, mỗi ô một khối
   "nhãn trên, giá trị dưới", rộng đúng khung — không vuốt ngang (web/cuon-bang.ts thấy không tràn nên tự ẩn dòng "Kéo ngang…").
   Ô trống (chưa kết thúc, không lý do, không nút) ẩn đi. Ô mang class "the-nua" chiếm nửa hàng thẻ. Màn rộng giữ bảng như cũ. */
@media (max-width: 600px) {
  .tbl:has(> table.bang-the) { overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
  .tbl table.bang-the { min-width: 0; }
  table.bang-the thead { display: none; }
  table.bang-the, table.bang-the tbody { display: block; width: 100%; }
  table.bang-the tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; padding: 12px 14px; margin: 0 0 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
  table.bang-the tbody tr:hover td { background: none; }
  table.bang-the td { display: block; grid-column: 1 / -1; min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  table.bang-the td.the-nua { grid-column: auto; }
  table.bang-the td:empty { display: none; }
  table.bang-the td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
  table.bang-the td .tag { white-space: normal; }
  /* Lịch sử chạy: Trạng thái | Chế độ lên đầu thẻ (biết ngay đạt hay lỗi), rồi Bot, Kịch bản, Bắt đầu | Kết thúc, Lý do, nút Mở. */
  table.ls-bang td.ls-tt { order: -3; }
  table.ls-bang td.ls-cd { order: -2; }
  table.ls-bang td.ls-bot, table.ls-bang td.ls-kb { order: -1; }
  table.ls-bang td.ls-ld { order: 1; font-size: 13px; }
  table.ls-bang td.ls-mo { order: 2; }
  table.ls-bang td.ls-mo .btn { min-height: 34px; padding: 6px 16px; font-size: 13px; }
}

/* ---------- Gói seeding: chọn NHIỀU bot cho mỗi kịch bản (04/10/2026) — khối riêng, chỉ class goi-bot-chon-* / goi-khung-bot-gio ----------
   Danh sách cuộn trong khung (1000+ bot không kéo dài trang), tên bot dài/emoji xuống dòng, nút "Chọn tất cả / Bỏ chọn" không bị che ở 390px. */
.goi-bot-chon { display: grid; gap: 6px; margin: 8px 0 10px; min-width: 0; }
.goi-bot-chon-dau { gap: 4px 10px; }
.goi-bot-chon-nut { gap: 6px 8px; align-items: center; }
.goi-bot-tim { flex: 1 1 180px; min-width: 0; width: auto; }
.goi-bot-chon-ds { list-style: none; margin: 0; padding: 4px; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); display: grid; gap: 2px; min-width: 0; }
.goi-bot-chon-dong { min-width: 0; }
.goi-bot-chon-nhan { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; min-width: 0; font-size: 13.5px; }
.goi-bot-chon-nhan:hover { background: var(--surface); }
.goi-bot-chon-nhan:has(input:checked) { background: var(--pri-soft); }
.goi-bot-chon-nhan > input { flex: none; margin: 0; }
/* Tên bot rất dài: tối đa 2 dòng (đủ tên ở title của dòng) — không đẩy ô tick lên dòng riêng */
.goi-bot-ten { font-weight: 600; overflow-wrap: anywhere; min-width: 0; flex: 0 1 auto; max-width: calc(100% - 28px); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.goi-bot-chon-nhan .tag { white-space: normal; }
.goi-khung-bot-gio { flex: 1 1 100%; overflow-wrap: anywhere; }
.goi-khung-bot-gio:empty { display: none; }
.goi-khung-tt-bot { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .goi-bot-chon-nut > button { flex: 1 1 auto; }
  .goi-bot-tim { flex-basis: 100%; }
  .goi-bot-chon-ds { max-height: 300px; }
}

/* ================= Nhóm C — rà soát người dùng 05/10/2026 (Bot, Chờ duyệt, khung trang). Khối riêng, chỉ thêm — không sửa luật cũ ở trên. ================= */
/* N2: dải "Cần bạn" hiện câu sẽ đăng + bài đích + hạn; nút gom bên phải (màn hẹp: xuống hàng riêng). */
.attn-what > div + div { margin-top: 2px; }
.attn-cau { font-size: 13px; color: var(--fg); background: var(--surface-2); border-left: 3px solid var(--warn); border-radius: 0 6px 6px 0; padding: 3px 8px; overflow-wrap: anywhere; }
.attn-bai { overflow-wrap: anywhere; }
.attn-nut { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
@media (max-width: 640px) { .attn-nut { flex-basis: 100%; justify-content: flex-end; } }
/* N2: hộp xác nhận duyệt — liệt kê từng câu, cuộn trong hộp khi nhiều câu. */
.modal.dh-modal { max-width: 620px; }
.dh-ds { list-style: decimal; margin: 8px 0 12px; padding: 0 0 0 22px; max-height: 50vh; overflow-y: auto; display: grid; gap: 8px; }
.dh-muc { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); min-width: 0; }
.dh-dau { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.dh-cau { margin: 4px 0 2px; padding: 4px 8px; background: var(--surface); border-left: 3px solid var(--ok); border-radius: 0 6px 6px 0; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dh-bai, .dh-khong-bai { display: block; overflow-wrap: anywhere; }
.warn-box label.dh-thay { display: flex; width: fit-content; margin-top: 6px; color: var(--fg); font-weight: 600; }
/* V2: thẻ "Bắt đầu" cho người mới. */
.bat-dau { margin-bottom: 12px; border-left: 4px solid var(--pri); }
.bat-dau-dau { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bat-dau-dau h2 { margin: 0; font-size: 17px; }
.bat-dau-ds { list-style: none; margin: 10px 0 6px; padding: 0; display: grid; gap: 8px; }
.bat-dau-buoc { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.bat-dau-chu { min-width: 0; flex: 1 1 220px; overflow-wrap: anywhere; }
.bat-dau-so { flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--fg-2); }
.bat-dau-buoc.xong .bat-dau-so { background: var(--ok); border-color: var(--ok); color: #fff; }
.bat-dau-buoc.xong b { color: var(--muted); }
/* V2: hộp ghép cặp — mã + nút chép cùng hàng. */
.ghep-dong { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: 100%; }
.ghep-cap code { overflow-wrap: anywhere; }
/* L6: tiêu đề cột bảng kịch bản trong hộp Sửa bot ("Tối đa mỗi giờ"…) xuống dòng được — bảng vừa khung 390 px, không phải kéo ngang. */
[data-testid="edit-bot"] .tbl th { white-space: normal; }
[data-testid="edit-bot"] .tbl input[type="number"] { min-width: 64px; }
/* L6: vùng nguy hiểm trong hộp Sửa bot — tách khỏi Huỷ/Lưu. */
.vung-nguy-hiem { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--err) 35%, var(--line)); border-radius: var(--r); background: var(--err-soft); }
/* L4: DỪNG TẤT CẢ khi không có lần chạy nào → viền đỏ, nền trắng (vẫn bấm được để huỷ lệnh đang chờ). */
#stop-all.stop-nghi { background: var(--surface); color: var(--btn-err); border-color: color-mix(in srgb, var(--btn-err) 45%, var(--line-2)); box-shadow: none; }
#stop-all.stop-nghi:hover { background: var(--err-soft); }
/* L5: nút đỏ khi KHOÁ (vd "Chạy thật" chưa được phép) không còn đỏ nhạt như sắp bấm được — xám trung tính. */
button.danger:disabled { background: var(--surface-2); border-color: var(--line-2); color: var(--muted); opacity: 1; }
/* L5: "Đăng xuất" (Cài đặt) và "Xoá" bài học (Sổ kinh nghiệm) dạng viền — đỏ đặc để dành cho việc nguy hiểm thật (DỪNG TẤT CẢ, Thu hồi bot). */
button[data-testid="logout"].danger, button[data-testid="kn-xoa"].danger { background: var(--surface); color: var(--btn-err); border-color: color-mix(in srgb, var(--btn-err) 45%, var(--line-2)); }
button[data-testid="logout"].danger:hover, button[data-testid="kn-xoa"].danger:hover { background: var(--err-soft); }
/* L5: Download khi mọi bot đã bản mới → nút xanh đứng yên (app.ts đổi lớp pri ↔ nut-do-nhay); chưa có bot / có bot cũ → vẫn đỏ nháy. */
#tai-bot.pri { animation: none; }
/* V10: menu đáy cuộn ngang — nút ‹ / › kèm số mục còn khuất. */
.nav-cuon { display: none; }
@media (max-width: 1023px) {
  .nav-cuon:not([hidden]) { display: inline-flex; position: absolute; top: 0; height: var(--nav-h); z-index: 2; align-items: center; gap: 3px; padding: 0 6px; border: 0; border-radius: 0; box-shadow: none; font-size: 22px; font-weight: 700; line-height: 1; color: #fff; }
  .nav-cuon-phai { right: 0; padding-left: 16px; background: linear-gradient(to right, transparent, var(--side-bg) 40%); }
  .nav-cuon-trai { left: 0; padding-right: 16px; background: linear-gradient(to left, transparent, var(--side-bg) 40%); }
  .nav-cuon:hover { color: var(--side-accent); }
  .nav-cuon-so { font-size: 10.5px; font-weight: 700; background: var(--side-accent); color: var(--side-bg); border-radius: 999px; padding: 0 5px; line-height: 16px; }
}
/* V10: thanh trên ≤ 640 px — "Hướng Dẫn" / "Download" một dòng (trước đây xuống 2 dòng), khe hẹp hơn để vẫn vừa 390 px. */
@media (max-width: 640px) {
  .topbar { gap: 8px; }
  #tai-bot, #huong-dan-video { white-space: nowrap; padding: 6px 8px; }
}
/* V10: bảng Lệnh chạy ở ≤ 600 px thành thẻ (như Lịch sử chạy) — Trạng thái lên đầu thẻ, không phải kéo ngang mới thấy. */
@media (max-width: 600px) {
  .tbl:has(tbody[data-testid="job-rows"]) { overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
  .tbl:has(tbody[data-testid="job-rows"]) table { min-width: 0; display: block; width: 100%; }
  .tbl:has(tbody[data-testid="job-rows"]) thead { display: none; }
  tbody[data-testid="job-rows"] { display: block; width: 100%; }
  tbody[data-testid="job-rows"] tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; padding: 12px 14px; margin: 0 0 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
  tbody[data-testid="job-rows"] tr:hover td { background: none; }
  tbody[data-testid="job-rows"] td { display: block; min-width: 0; max-width: none; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  tbody[data-testid="job-rows"] td::before { display: block; margin-bottom: 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
  tbody[data-testid="job-rows"] td:nth-child(1)::before { content: "Tạo lúc"; }
  tbody[data-testid="job-rows"] td:nth-child(2) { grid-column: 1 / -1; order: -1; }
  tbody[data-testid="job-rows"] td:nth-child(2)::before { content: "Kịch bản"; }
  tbody[data-testid="job-rows"] td:nth-child(3)::before { content: "Chế độ"; }
  tbody[data-testid="job-rows"] td:nth-child(4)::before { content: "Kiểu"; }
  tbody[data-testid="job-rows"] td:nth-child(5)::before { content: "Số bot"; }
  tbody[data-testid="job-rows"] td:nth-child(6) { order: -2; }
  tbody[data-testid="job-rows"] td:nth-child(6)::before { content: "Trạng thái"; }
  tbody[data-testid="job-rows"] td:nth-child(7)::before { content: "Xong / lỗi"; }
  tbody[data-testid="job-rows"] td:nth-child(8) { grid-column: 1 / -1; }
  tbody[data-testid="job-rows"] td .tag { white-space: normal; }
}
/* ---- Kho ảnh (pages/kho-anh.ts) + chọn ảnh cho bước / ô chọn tham số (pages/chon-anh.ts) — 05/10/2026 ---- */
.ka-tai-truong { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; margin-top: 10px; }
.ka-tai-ds { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; max-height: 320px; overflow: auto; }
.ka-tai-dong { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.ka-tai-ten { font-weight: 600; overflow-wrap: anywhere; min-width: 0; flex: 1 1 160px; }
.ka-tai-tt { flex: 1 1 200px; overflow-wrap: anywhere; }
.ka-tai-tt.err { color: var(--err); }
.ka-tai-tt.ok { color: var(--ok); }
.ka-loc-hang { margin: 10px 0; }
.ka-loc-hang > input, .ka-loc-hang > select { flex: 1 1 180px; min-width: 0; max-width: 100%; }
.ka-luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ka-anh { margin: 0; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ka-anh img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--surface-2); border-radius: 6px; display: block; }
.ka-anh figcaption { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ka-anh figcaption input { width: 100%; box-sizing: border-box; font-size: 12px; padding: 4px 6px; }
.ka-anh-ten { font-weight: 600; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ka-anh .mini.danger { align-self: flex-start; }
.ka-o { display: flex; flex-direction: column; gap: 6px; grid-column: 1 / -1; }
.ka-o-nhan { display: block; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.ka-o-tom-tat { font-size: 13px; overflow-wrap: anywhere; }
.ka-o-nho { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ka-o-nho:empty { display: none; }
.ka-o-nho img { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); }
.kb-ts-chon select { width: 100%; max-width: 100%; }
.kb-ts-giai { display: block; margin-top: 2px; overflow-wrap: anywhere; }
.modal.ka-hop { max-width: 920px; display: flex; flex-direction: column; gap: 6px; }
.ka-chip-ds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ka-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; max-width: 100%; overflow-wrap: anywhere; }
.ka-chip:has(input:checked) { background: var(--pri-soft); border-color: var(--pri); }
.ka-hop-loc > input, .ka-hop-loc > select { flex: 1 1 200px; min-width: 0; }
.ka-luoi-chon { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.ka-o-anh { position: relative; display: flex; flex-direction: column; gap: 3px; border: 2px solid var(--line); border-radius: 8px; padding: 4px; cursor: pointer; min-width: 0; background: var(--surface); }
.ka-o-anh.chon { border-color: var(--pri); background: var(--pri-soft); }
.ka-o-anh img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; background: var(--surface-2); }
.ka-o-anh input[type=checkbox] { position: absolute; top: 8px; left: 8px; width: 18px; height: 18px; }
.ka-o-chu, .ka-o-phu { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ka-hop-chan { position: sticky; bottom: -20px; background: var(--surface); border-top: 1px solid var(--line); padding: 8px 0 4px; margin-top: 4px; }
.ka-hop-dem { margin: 0 0 6px; overflow-wrap: anywhere; }
.goi-kem-anh-chon:not(:empty) { margin: 2px 0 8px 26px; }
@media (max-width: 640px) {
  .ka-luoi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ka-luoi-chon { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal.ka-hop { padding: 12px; }
  .ka-hop-chan { bottom: -12px; }
  .ka-hop-chan .row.end > button { flex: 1 1 auto; }
}

/* ===== (05/10/2026) Chuỗi kịch bản (pages/chuoi.ts) + khung Tần suất chạy (pages/lich-khung.ts, kich-ban-tan-suat.ts) ===== */
.kb-tan-suat { display: grid; gap: 0; min-width: 0; }
.ls-the > .row:first-child { padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; gap: 8px; }
.ls-the > .row:first-child > h3 { margin: 0; color: var(--fg); text-transform: none; letter-spacing: 0; } /* cỡ chữ theo "Khung có nhãn màu" (15px) */
.ls-ds { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; min-width: 0; }
.ls-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.ls-dong.muted { opacity: .75; }
.ls-gio { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.ls-gio b { font-size: 16px; font-variant-numeric: tabular-nums; }
.ls-chi-tiet { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.ls-nut { gap: 6px; align-items: center; margin-left: auto; }
.ls-form { border-top: 1px dashed var(--line-2); padding-top: 10px; margin-top: 4px; display: grid; gap: 8px; min-width: 0; }
.ls-bot-chon { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.ls-bot-chon label { overflow-wrap: anywhere; min-width: 0; }
.ch-buoc-ds { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 6px; min-width: 0; }
.ch-buoc { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); min-width: 0; }
.ch-buoc-so { flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--pri-soft); color: var(--pri); }
.ch-buoc-ten { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.ch-buoc-nut { gap: 4px; margin-left: auto; }
/* L-99 (07/10/2026): chip mạng của bot + cảnh báo bot × mạng dưới từng kịch bản — xuống dòng, không đẩy trang tràn ngang ở 390 px */
label.inline.ch-bot-dong { flex-wrap: wrap; max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
.ch-buoc-canh-bao { flex: 1 1 100%; min-width: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.ch-buoc-canh-bao:empty { display: none; }
.ch-kq-ly-do { overflow-wrap: anywhere; }
label.inline.nb-bot .tag { white-space: normal; }
.ch-lan { border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: var(--r); padding: 8px 10px; margin-bottom: 8px; min-width: 0; overflow-wrap: anywhere; }
.ch-lan.ok, .ch-lan.err, .ch-lan.running { color: inherit; }
.ch-lan.ok { border-left-color: var(--ok); }
.ch-lan.err { border-left-color: var(--err); }
.ch-lan.running { border-left-color: var(--run); }
.ch-lan-tt { font-weight: 600; margin: 4px 0; }
.ch-kq { margin: 0; padding-left: 22px; display: grid; gap: 2px; }
.ch-kq li { min-width: 0; }
.ch-kq-ten { font-weight: 600; margin-right: 8px; color: var(--fg); }
@media (max-width: 640px) {
  .ls-nut, .ch-buoc-nut { margin-left: 0; }
  .ch-buoc-ten { flex-basis: 100%; }
}

/* ---- Nhóm A rà soát 05/10/2026 (N4/N5/V4/V5/V8/L10) ---- */
/* V8: khu Chạy (một bot + nhiều bot) ngay dưới tiêu đề, hai thẻ xếp chồng hết bề rộng */
.kb-chay-vung { display: flex; flex-direction: column; min-width: 0; }
.kb-chay-vung > :empty { display: none; }
/* N4: thẻ kết quả chạy thử — chữ dài (lý do lỗi) xuống dòng, không tràn ở 390 */
.tag.kb-chay-tt { white-space: normal; max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.kb-dong > .kb-chay-tt { flex: 0 1 auto; }
/* V4: hàng tìm / lọc */
.kb-tim-hang { margin: 8px 0 4px; gap: 8px 14px; }
.kb-tim-o { flex: 1 1 240px; min-width: 0; }
.kb-tim-o > input { flex: 1 1 auto; min-width: 0; width: 100%; }
/* V5: dải "Chưa chọn sản phẩm" */
.kb-chua-sp { align-items: center; gap: 8px 12px; margin: 8px 0; }
/* 05/10: "Kịch bản chưa gắn sản phẩm" — mức thông tin (info-box) / cảnh báo (warn-box); gợi ý tên sản phẩm thư viện xuống dòng an toàn */
.kb-chua-sp-than { min-width: 0; flex: 1 1 260px; overflow-wrap: anywhere; }
.kb-chua-sp-goi-y { margin-top: 2px; color: var(--fg-2); }
.kb-chua-sp > button { flex: 0 0 auto; }
.kb-goi-y-sp { margin: 2px 0 8px; overflow-wrap: anywhere; }
.modal-nhac { margin: 0 0 10px; padding: 6px 10px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 13px; }
/* L10: tóm tắt một thẻ */
.kb-loi-tieu-de-phu { margin: 12px 0 4px; font-size: 13px; color: var(--fg-2); }
/* N5: khung kiểm trước chạy thật nhiều bot */
.nb-kiem ul { margin: 6px 0; padding-left: 18px; }
.nb-kiem li { overflow-wrap: anywhere; }
/* N11 (05/10/2026) gom lối chạy về Kịch bản: dải báo chuyển hướng / dải bot đã chọn, nhóm menu Kỹ thuật, hộp "Chạy gì trên bot này?",
   khung phát lệnh rút gọn (trang Kịch bản học trên bot). */
.dai-chuyen { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 6px 8px 6px 12px; border-radius: var(--r); background: var(--pri-soft); color: var(--fg-2); font-size: 13px; border: 1px solid color-mix(in srgb, var(--pri) 25%, transparent); overflow-wrap: anywhere; }
.dai-chuyen .grow { min-width: 0; }
.nav-label-kt { color: var(--warn); }
.modal.chon-kb { max-width: 620px; display: flex; flex-direction: column; gap: 8px; overflow-x: hidden; }
.chon-kb-dau { gap: 8px; flex-wrap: nowrap; align-items: flex-start; }
.chon-kb-dau h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chon-kb-cuon { max-height: 42vh; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line); border-radius: var(--r); padding: 4px 8px; }
.chon-kb-nhom h4 { margin: 8px 0 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.chon-kb-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; border-radius: 6px; }
.chon-kb-dong:last-child { border-bottom: 0; }
.chon-kb-dong:hover, .chon-kb-dong:focus-visible { background: var(--surface-2); text-decoration: none; }
.chon-kb-ten { font-weight: 600; flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.chon-kb-phu { flex: 0 1 auto; min-width: 0; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chon-kb-moi textarea { resize: vertical; }
.khung-gon .bot-pick label { flex-wrap: wrap; }
.param-nhan { display: grid; gap: 8px; }
details.nang-cao { margin: 10px 0; }
@media (max-width: 600px) {
  .modal.chon-kb { padding: 14px; }
  .chon-kb-cuon { max-height: 36vh; }
  .chon-kb-moi .row.end button { width: 100%; white-space: normal; }
}
.htb-ban-tbl table { min-width: 0; } /* bảng "Các bản" chỉ 3 cột ngắn — vừa 390 px, không cần kéo ngang */

/* Giai đoạn 2 "màn hình chính bot" (05/10/2026): hộp "Giải CAPTCHA" — điều khiển từ xa BỞI NGƯỜI (dieu-khien-tu-xa.ts). Tiền tố dk-. */
.modal.dk-hop { max-width: min(1120px, 100%); display: flex; flex-direction: column; gap: 8px; overflow-x: hidden; }
.dk-dau { gap: 8px; flex-wrap: nowrap; align-items: flex-start; }
.dk-dau h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dk-canh-bao { margin: 0; font-weight: 600; }
.dk-thanh { gap: 6px; }
.dk-man { position: relative; background: #05080b; border-radius: var(--r); overflow: hidden; line-height: 0; min-height: 160px; border: 1px solid var(--line-2); cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.dk-man.dk-tat { cursor: default; opacity: .75; }
.dk-hinh { display: block; width: 100%; height: auto; max-height: 68vh; object-fit: contain; background: #05080b; touch-action: none; user-select: none; -webkit-user-drag: none; }
.dk-cho { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; color: #cfd8e0; font-size: 14px; line-height: 1.4; }
.dk-cho[hidden], .dk-hinh[hidden] { display: none; }
.dk-nhap { position: absolute; left: 0; top: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; resize: none; overflow: hidden; pointer-events: none; }
.dk-huong-dan { margin: 0; }
.dk-chan { gap: 8px; }
@media (max-width: 600px) {
  .modal.dk-hop { padding: 14px; }
  .dk-hinh { max-height: 52vh; }
  .dk-chan button { flex: 1 1 100%; white-space: normal; }
}

/* ===== (06/10/2026) Kho video (pages/kho-video.ts, kho-video-hop.ts) + ô cấu hình bước Đăng video (pages/video-cau-hinh.ts) =====
   Người dùng không rành kỹ thuật: nút lớn (≥ 40 px, chạm được trên điện thoại), trạng thái bằng CHỮ + dấu ✓ + màu (không chỉ màu), chạy ở 390 px và 1440 px, sáng / tối (mọi màu là biến). */
.kv-nut, a.kv-nut { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 40px; padding: 8px 14px; font-size: 14px; border-radius: 9px; text-align: center; }
.kv-nut.pri { background: var(--btn-pri); border-color: var(--btn-pri); color: #fff; }
.kv-nut.danger { background: var(--surface); border-color: var(--btn-err); color: var(--err); }
.kv-nut.danger:hover { background: var(--err-soft); }
.kv-nut-lon { min-height: 56px; padding: 12px 28px; font-size: 18px; font-weight: 700; border-radius: 12px; background: var(--btn-pri); border-color: var(--btn-pri); color: #fff; box-shadow: var(--shadow-2); }
.kv-nut-lon:hover { background: var(--btn-pri-2); border-color: var(--btn-pri-2); }
.kv-tha { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.kv-tha-hang { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.kv-tha-hoac { color: var(--muted); font-size: 14px; }
.kv-tha.keo { outline: 3px dashed var(--pri); outline-offset: 4px; background: var(--pri-soft); }
.kv-tai-ds { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.kv-tai-ds:empty { display: none; }
.kv-tai-dong { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.kv-tai-ten { font-weight: 600; overflow-wrap: anywhere; min-width: 0; flex: 1 1 200px; }
.kv-tai-tt { flex: 1 1 200px; overflow-wrap: anywhere; }
.kv-tai-tt.err { color: var(--err); font-weight: 600; }
.kv-tai-tt.ok { color: var(--ok); font-weight: 600; }
.kv-thanh { flex: 1 1 100%; height: 10px; border-radius: 999px; background: var(--idle-soft); overflow: hidden; }
.kv-thanh-day { height: 100%; background: var(--pri); border-radius: 999px; transition: width .2s; }
.kv-loc-hang { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 14px; }
.kv-loc-hang > input, .kv-loc-hang > select { flex: 1 1 200px; min-width: 0; max-width: 100%; min-height: 40px; }
.kv-luoi { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.kv-the { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: flex; flex-direction: column; min-width: 0; overflow: hidden; box-shadow: var(--shadow-1); }
.kv-xem-nut { position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: var(--surface-2); aspect-ratio: 16 / 10; cursor: pointer; overflow: hidden; }
.kv-xem-nut img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.kv-khong-hinh { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 44px; color: var(--muted); }
.kv-thoi-luong { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .78); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.kv-phat { position: absolute; left: 8px; bottom: 8px; width: 36px; height: 36px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.kv-the-than { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; min-width: 0; }
.kv-the-ten { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.kv-huy-hieu, .kv-nhan-ds { display: flex; flex-wrap: wrap; gap: 6px; }
.kv-mo-ta { margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-line; }
.kv-the-so { margin: 0; }
.kv-hang-nut { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
/* Tự xoá tệp video sau khi đăng (06/10/2026): công tắc lớn ở đầu trang Kho; công tắc "Giữ lại" từng video; thẻ video đã xoá tệp */
.kv-tu-xoa-hang { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
.kv-tu-xoa-chu-de { flex: 1 1 280px; min-width: 0; }
.kv-tu-xoa-chu-de h3 { margin: 0 0 6px; }
.kv-tu-xoa-mo-ta { margin: 0; overflow-wrap: anywhere; }
.kv-don-hang { margin-top: 12px; gap: 10px 14px; align-items: center; }
.kv-don-hang p { margin: 0; flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.kv-cong-tac { display: inline-flex; align-items: center; gap: 10px; min-height: 56px; min-width: 120px; padding: 6px 18px 6px 8px; border-radius: 999px; border: 2px solid var(--line-2); background: var(--idle-soft); color: var(--fg-2); font-size: 16px; font-weight: 800; cursor: pointer; flex: 0 0 auto; }
.kv-cong-tac.bat { flex-direction: row-reverse; padding: 6px 8px 6px 18px; background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.kv-cong-tac-nut { width: 38px; height: 38px; border-radius: 50%; background: var(--idle-dot); flex: 0 0 auto; box-shadow: var(--shadow-1); }
.kv-cong-tac.bat .kv-cong-tac-nut { background: var(--ok); }
.kv-cong-tac:disabled { opacity: .6; cursor: progress; }
.kv-cong-tac:focus-visible, .kv-giu:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.kv-giu { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--fg); font-size: 13.5px; text-align: left; cursor: pointer; align-self: flex-start; max-width: 100%; }
.kv-giu-o { width: 22px; height: 22px; border: 2px solid var(--line-2); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex: 0 0 auto; }
.kv-giu.bat { border-color: var(--pri); background: var(--pri-soft); }
.kv-giu.bat .kv-giu-o { background: var(--pri); border-color: var(--pri); color: #fff; }
.kv-giu:disabled { opacity: .6; cursor: progress; }
.kv-huy-hieu .tag { white-space: normal; text-align: left; } /* huy hiệu dài ("Đã đăng · tệp đã xoá khỏi máy chủ") xuống dòng thay vì tràn khỏi thẻ hẹp */
.kv-xem-nut.kv-da-xoa { cursor: default; }
.kv-da-xoa img { filter: grayscale(1) opacity(.5); }
.kv-da-xoa-chu { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; }
.tag.idle { background: var(--idle-soft); color: var(--idle); border-color: var(--line-2); }
.kv-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.kv-seg-nut { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 16px; font-size: 14.5px; border-radius: 10px; border: 2px solid var(--line-2); background: var(--surface); color: var(--fg); cursor: pointer; }
.kv-seg-nut .kv-seg-tick { visibility: hidden; font-weight: 800; }
.kv-seg-nut.chon { border-color: var(--pri); background: var(--pri-soft); color: var(--fg); font-weight: 700; }
.kv-seg-nut.chon .kv-seg-tick { visibility: visible; color: var(--pri); }
.kv-seg-nut:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.kv-chip-ds { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.kv-chip { min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--line-2); background: var(--surface); font-size: 14px; }
.kv-chip.chon { border-color: var(--pri); background: var(--pri-soft); font-weight: 700; }
.kv-nhan-hang { display: flex; gap: 8px; align-items: center; }
.kv-nhan-hang > input { flex: 1 1 auto; min-width: 0; min-height: 40px; }
.modal.kv-hop { max-width: 640px; width: calc(100vw - 24px); display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 24px); overflow: auto; }
.modal.kv-hop > * { flex-shrink: 0; } /* hộp cột có cuộn: không để hàng nút bị ép thấp hơn 40 px (E2E K14) */
.kv-hop-chan { position: sticky; bottom: -20px; background: var(--surface); padding-top: 8px; }
.kv-hop input, .kv-hop textarea, .kv-hop select { width: 100%; box-sizing: border-box; min-height: 40px; }
.kv-xem-video { width: 100%; max-height: 62vh; background: #000; border-radius: 8px; }
.kv-dn-muc h4 { margin: 4px 0 6px; font-size: 14px; }
.kv-ls-dong { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.kv-ls-chinh { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.kv-ls-ghi { flex: 1 1 100%; margin: 0; overflow-wrap: anywhere; }
.kv-canh-bao { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kv-canh-bao > div { flex: 1 1 280px; min-width: 0; overflow-wrap: anywhere; }
/* ô cấu hình bước Đăng video (trang Kịch bản) */
.kv-cau-hinh { display: flex; flex-direction: column; gap: 14px; grid-column: 1 / -1; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--surface-2); min-width: 0; }
.kv-muc { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kv-muc-nhan { font-size: 13px; font-weight: 700; color: var(--fg-2); }
.kv-tom-tat { margin: 0; padding: 10px 12px; border-radius: 9px; background: var(--pri-soft); border: 1px solid color-mix(in srgb, var(--pri) 35%, transparent); font-size: 14px; overflow-wrap: anywhere; }
.kv-nang-cao { border: 1px dashed var(--line-2); border-radius: 9px; padding: 4px 12px 10px; }
.kv-nang-cao > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; font-weight: 700; }
.kv-nang-cao .kv-muc { margin-top: 10px; }
.kv-nang-cao input { min-height: 40px; box-sizing: border-box; }
.kv-so-hang { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kv-so-hang input { width: 96px; max-width: 100%; }
@media (max-width: 640px) {
  .kv-luoi { grid-template-columns: minmax(0, 1fr); }
  .kv-hang-nut > .kv-nut { flex: 1 1 calc(50% - 8px); }
  .kv-nut-lon { width: 100%; }
  .kv-seg-nut { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .modal.kv-hop { padding: 12px; }
  .kv-hop-chan { bottom: -12px; }
  .kv-hop-chan.row.end > button { flex: 1 1 auto; }
}

/* ===== CỜ VÀNG / ĐỎ trên thẻ bước + hộp tổng + danh sách bước đỏ khi Chạy (07/10/2026, Giai đoạn 0 · pha B) =====
   Luôn BIỂU TƯỢNG + CHỮ (⛔ / ⚠), không chỉ màu. Màu lấy từ token --err/--warn (đã có bản tối): chữ trên nền đạt tương phản ≥ 4.5:1 ở cả sáng/tối. */
.tag.kb-co { white-space: normal; text-align: left; max-width: 100%; }
.tag.kb-co-do { background: var(--err); color: var(--surface); border-color: var(--err); }
.tag.kb-co-vang { background: var(--warn-soft); color: var(--warn); border: 1px dashed var(--warn); }
.kb-buoc.co-do { border-top-color: var(--err); border-right-color: var(--err); border-bottom-color: var(--err); box-shadow: 0 0 0 1px color-mix(in srgb, var(--err) 30%, transparent), var(--shadow-1); }
.kb-buoc.co-vang { border-top-color: color-mix(in srgb, var(--warn) 65%, var(--line)); border-right-color: color-mix(in srgb, var(--warn) 65%, var(--line)); border-bottom-color: color-mix(in srgb, var(--warn) 65%, var(--line)); }
.kb-co-ly { margin: 4px 0 2px; font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.kb-co-ly-do { color: var(--err); }
.kb-co-ly-vang { color: var(--warn); }
.kb-co-bieu { font-weight: 700; }
.kb-co-tong { margin: 0 0 10px; padding: 8px 12px; border: 1px solid; border-radius: var(--r); font-size: 13px; }
.kb-co-tong.co-do { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
.kb-co-tong.co-vang { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.kb-co-tong-chu { margin: 0 0 6px; overflow-wrap: anywhere; }
.kb-co-nhay-hang { display: flex; flex-wrap: wrap; gap: 6px; }
button.kb-co-nhay { min-height: 30px; font-weight: 600; background: var(--surface); }
button.kb-co-nhay-do { color: var(--err); border-color: var(--err); }
button.kb-co-nhay-vang { color: var(--warn); border-color: var(--warn); }
.kb-chay-do { margin-top: 8px; }
.kb-chay-do ul { margin: 6px 0 0; padding-left: 18px; }
.kb-chay-do li { margin: 4px 0; overflow-wrap: anywhere; }
.kb-chay-do li button.mini { margin-left: 4px; }

/* ============================================================================================================================================================
   SƠ ĐỒ CANVAS — BẮT ĐẦU (thành phần pages/so-do-canvas.ts: canvas kéo thả cho sơ đồ nhiều mạng; chưa nối vào trang Kịch bản). Mọi lớp bắt đầu bằng .sdc-.
   Màu mạng = bảng riêng dưới đây (chữ trắng trên mọi nền ≥ 4,5 — kiểm bằng server/test/so-do-canvas-mo-hinh.test.ts M14, cả sáng lẫn tối); mọi màu khác dùng token sẵn có của :root.
   ============================================================================================================================================================ */
:root {
  --sdc-net-fb: #1565d8; --sdc-net-yt: #cc0000; --sdc-net-tt: #111111; --sdc-net-x: #3a4350; --sdc-net-rd: #c2410c; --sdc-net-kh: #475569;
  --sdc-net-chu: #ffffff; --sdc-net-vong: rgba(45, 212, 191, .75);
}
@media (prefers-color-scheme: dark) {
  :root {
    --sdc-net-fb: #2563eb; --sdc-net-yt: #c81e1e; --sdc-net-tt: #1b2630; --sdc-net-x: #475569; --sdc-net-rd: #c2410c; --sdc-net-kh: #475569;
    --sdc-net-vong: rgba(45, 212, 191, .85);
  }
}
.sdc { --sdc-cao: 560px; display: flex; flex-direction: column; height: var(--sdc-cao); min-height: 360px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; position: relative; }
.sdc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sdc .sdc-btn { min-height: 36px; padding: 0 12px; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.sdc .sdc-btn.tat, .sdc .sdc-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.sdc .sdc-btn[role="switch"][aria-checked="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.sdc .sdc-btn-nho { min-height: 32px; padding: 0 10px; }
.sdc button:focus-visible, .sdc .sdc-o:focus-visible, .sdc .sdc-vp:focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; }
.sdc-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sdc-gian { flex: 1; }
.sdc-dem { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sdc-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.sdc-vp { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; background-image: radial-gradient(var(--line-2) 1px, transparent 1.2px); background-size: 24px 24px; }
.sdc-vp.panning { cursor: grabbing; }
.sdc-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.sdc-canh-svg { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.sdc-nuts, .sdc-ui { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.sdc-canh { fill: none; stroke-linecap: round; }
.sdc-canh.k-tt { stroke: var(--fg-2); stroke-width: 2.4; }
.sdc-canh.k-nhuong { stroke: var(--live); stroke-width: 4.5; }
.sdc-hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
.sdc-mui-tt { fill: var(--fg-2); } .sdc-mui-nhuong { fill: var(--live); }
.sdc-tam { fill: none; stroke: var(--pri); stroke-width: 2.6; stroke-dasharray: 4 4; }
.sdc-eu { position: absolute; display: flex; align-items: center; transform: translate(-50%, -50%); pointer-events: none; }
.sdc-nhan { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) scale(var(--sdc-ik, 1)); transform-origin: 50% 100%; pointer-events: none; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface); border: 1.5px solid var(--live); color: var(--live); white-space: nowrap; }
.sdc .sdc-canh-them { pointer-events: auto; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--fg-2); background: var(--surface); color: var(--fg); font-weight: 700; font-size: 15px; line-height: 1; opacity: .75; box-shadow: none; transform: scale(var(--sdc-ik, 1)); }
.sdc .sdc-canh-them:hover, .sdc .sdc-canh-them:focus-visible { opacity: 1; border-color: var(--pri); color: var(--pri); }
.sdc .sdc-more { position: absolute; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--fg); background: var(--surface); color: var(--fg); font-weight: 800; font-size: 16px; line-height: 1; transform-origin: 0 0; z-index: 6; }

/* ---------- Ô ---------- */
.sdc-o { position: absolute; left: 0; top: 0; width: 176px; height: 64px; border-radius: 12px; padding: 8px 10px 8px 8px; display: flex; align-items: center; gap: 8px; color: var(--sdc-net-chu); cursor: grab; box-shadow: var(--shadow-2); outline: none; touch-action: none; background: var(--sdc-net-kh); }
.sdc-o.net-fb { background: var(--sdc-net-fb); } .sdc-o.net-yt { background: var(--sdc-net-yt); } .sdc-o.net-x { background: var(--sdc-net-x); } .sdc-o.net-rd { background: var(--sdc-net-rd); } .sdc-o.net-kh { background: var(--sdc-net-kh); }
.sdc-o.net-tt { background: var(--sdc-net-tt); border: 2px solid var(--sdc-net-vong); padding: 6px 8px 6px 6px; }
.sdc-o.keo { cursor: grabbing; box-shadow: var(--shadow-3); z-index: 5; }
.sdc-o.sel { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--fg), var(--shadow-2); }
.sdc-o:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--pri); }
.sdc-o.nguon { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--pri); }
.sdc-o.drop-ok { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--ok); }
.sdc-o.chop { animation: sdc-chop .5s 3; }
@keyframes sdc-chop { 50% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px var(--err); } }
.sdc-o.nghi { border-radius: 32px; padding-left: 12px; }
.sdc-o.nghi.nhuong::after { content: ""; position: absolute; inset: -7px; border: 2px dashed var(--live); border-radius: 40px; pointer-events: none; }
.sdc-hh { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--sdc-net-chu); color: var(--sdc-net-kh); font-weight: 800; font-size: 14px; display: grid; place-items: center; border: 2px solid var(--sdc-net-chu); }
.sdc-hh.sdc-hh-khong { background: transparent; border: 0; width: 6px; }
.sdc-o.net-fb .sdc-hh { color: var(--sdc-net-fb); } .sdc-o.net-yt .sdc-hh { color: var(--sdc-net-yt); } .sdc-o.net-rd .sdc-hh { color: var(--sdc-net-rd); } .sdc-o.net-x .sdc-hh { color: var(--sdc-net-x); }
.sdc-o.net-tt .sdc-hh { color: var(--sdc-net-tt); box-shadow: 0 0 0 2px var(--sdc-net-vong); }
.sdc-chu { min-width: 0; flex: 1; }
.sdc-ten { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; line-height: 1.2; }
.sdc-ten-chu { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sdc-bt-hop { flex: none; display: inline-flex; }
.sdc-bt { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sdc-lan { flex: none; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 99px; background: color-mix(in srgb, var(--sdc-net-chu) 22%, transparent); border: 1px solid color-mix(in srgb, var(--sdc-net-chu) 55%, transparent); white-space: nowrap; }
.sdc-tt { font-size: 11.5px; opacity: .96; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.sdc-cong { position: absolute; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--fg); cursor: crosshair; }
.sdc-cong::before { content: ""; position: absolute; inset: -9px; }
.sdc-cong-vao { left: -8px; } .sdc-cong-ra { right: -8px; }
.sdc-cong-ra:hover, .sdc-o.nguon .sdc-cong-ra { background: var(--pri); border-color: var(--pri); }
.sdc.dang-noi .sdc-o:not(.nguon) .sdc-cong-vao { animation: sdc-xung 1s infinite; border-color: var(--ok); }
@keyframes sdc-xung { 50% { transform: scale(1.5); } }
.sdc.chidoc .sdc-cong, .sdc.chidoc .sdc-canh-them, .sdc.chidoc .sdc-sua, .sdc.chidoc .sdc-more { display: none; }
.sdc.chidoc .sdc-o { cursor: pointer; }
.sdc-nhuong { position: absolute; left: 50%; top: calc(100% + 27px); transform: translateX(-50%) scale(var(--sdc-ik, 1)); transform-origin: 50% 0; font-size: 10.5px; font-weight: 700; color: var(--live); background: var(--surface); border: 1.5px solid var(--live); border-radius: 99px; padding: 0 7px; white-space: nowrap; display: none; }
.sdc-o.nghi.nhuong .sdc-nhuong { display: block; }
/* cờ: tam giác vàng ⚠ / bát giác đỏ ⛔ — KHÁC DẠNG huy hiệu tròn của mạng, và khác nhau cả khi không nhìn màu */
/* (07/10/2026) cờ ở GÓC DƯỚI-TRÁI ô (góc trên phải là nút Xoá ô) */
.sdc-co-box { position: absolute; left: -9px; bottom: -11px; width: 24px; height: 24px; display: block; transform: scale(var(--sdc-ik, 1)); transform-origin: 0 100%; }
.sdc-co { width: 24px; height: 24px; display: block; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .4)); }
.sdc-co-vien { fill: var(--surface); stroke: var(--surface); stroke-width: 4; stroke-linejoin: round; }
.sdc-co-vang .sdc-co-than { fill: var(--gold-bg); stroke: var(--gold-fg); stroke-width: 1.6; stroke-linejoin: round; }
.sdc-co-vang .sdc-co-dau { stroke: var(--gold-fg); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.sdc-co-vang .sdc-co-cham { fill: var(--gold-fg); }
/* "sẽ không chạy" = tròn VÀNG ĐẶC viền đỏ + chấm than (cùng màu ở sáng / tối); "nên xem lại" = tam giác viền vàng nhỏ, nền trắng */
.sdc-co-do .sdc-co-than { fill: #facc15; stroke: var(--err); stroke-width: 2.6; }
.sdc-co-do .sdc-co-dau { stroke: #2a1d00; stroke-width: 2.8; stroke-linecap: round; fill: none; }
.sdc-co-do .sdc-co-cham { fill: #2a1d00; }
.sdc-co-vang { width: 20px; height: 20px; margin: 2px; }
.sdc-co-vang .sdc-co-than { fill: var(--surface); stroke: var(--warn); stroke-width: 2.2; }
.sdc-co-vang .sdc-co-dau { stroke: var(--warn); }
.sdc-co-vang .sdc-co-cham { fill: var(--warn); }
.kb-co-bieu .sdc-co { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; filter: none; margin: 0; }
.kb-dt-chu-giai { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.kb-dt-chu-giai span { display: inline-flex; align-items: center; gap: 4px; }
/* (07/10/2026) thời gian ước chừng ngay DƯỚI thân ô */
.sdc-uoc { position: absolute; left: 34px; right: 34px; top: calc(100% + 2px); text-align: center; font-size: 11px; font-weight: 600; line-height: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transform: scale(var(--sdc-ik, 1)); transform-origin: 50% 0; }
.sdc-o.nghi.nhuong .sdc-uoc { top: calc(100% + 10px); } /* ngoài viền nét đứt của điểm nhường */
/* (07/10/2026) nút XOÁ ô ở góc trên phải (nằm ngoài ô — không lồng nút trong nút) */
.sdc .sdc-xoa { position: absolute; width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--fg-2); font-size: 12px; font-weight: 700; line-height: 1; transform: translate(-50%, -50%) scale(var(--sdc-ik, 1)); box-shadow: var(--shadow-1, none); z-index: 3; opacity: .85; }
.sdc .sdc-xoa:hover, .sdc .sdc-xoa:focus-visible { opacity: 1; color: var(--err); border-color: var(--err); }
.sdc.chidoc .sdc-xoa, .sdc.chidoc .sdc-lap-ca { display: none; }
/* (07/10/2026) VÒNG LẶP: cạnh cam cong phía dưới + nhãn "lặp ×2" */
.sdc { --sdc-lap: #ea580c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sdc { --sdc-lap: #fb923c; } }
:root[data-theme="dark"] .sdc { --sdc-lap: #fb923c; }
.sdc-lap { fill: none; stroke: var(--sdc-lap); stroke-width: 2.6; stroke-dasharray: 7 4; stroke-linecap: round; }
.sdc-mui-lap { fill: var(--sdc-lap); }
.sdc .sdc-lap-nhan { position: absolute; transform: translate(-50%, -50%) scale(var(--sdc-ik, 1)); min-height: 0; height: 22px; padding: 0 8px; border-radius: 99px; border: 1.5px solid var(--sdc-lap); background: var(--surface); color: var(--sdc-lap); font-size: 11.5px; font-weight: 700; white-space: nowrap; z-index: 2; }
.sdc .sdc-lap-nhan:hover, .sdc .sdc-lap-nhan:focus-visible { background: var(--sdc-lap); color: #fff; }
.sdc-lap-ca-chu { font-size: 12.5px; font-weight: 600; color: var(--sdc-lap); }
.sdc-lap-ca-chu:empty { display: none; }
.sdc-tong-uoc { font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.sdc .sdc-lap-ca[aria-pressed="true"] { border-color: var(--sdc-lap); color: var(--sdc-lap); }
.sdc-lap-mo-ta { font-size: 12.5px; color: var(--muted); margin: 0 4px 8px; }
.sdc-lap-dong { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 4px 8px; font-size: 13px; }
.sdc-lap-dong input[inputmode="numeric"] { width: 72px; min-height: 36px; }
.sdc-lap-dong input[type="time"] { min-height: 36px; }
.sdc-lap-gio span { flex: 1 1 160px; }
.sdc-lap-cb { margin: 0 4px 8px; font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 8px; }
.sdc-lap-cb:empty { display: none; }
.sdc-lap-loi { margin: 0 4px 8px; font-size: 12.5px; color: var(--err); }
.sdc-lap-nut { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px; }
.sdc .sdc-menu .sdc-lap-nut button { width: auto; flex: 1 1 auto; justify-content: center; border-color: var(--line-2); }
.sdc .sdc-menu .sdc-lap-nut .sdc-btn-chinh { background: var(--btn-pri); color: var(--sdc-net-chu); border-color: transparent; }
.sdc .sdc-menu .sdc-md-lap { color: var(--sdc-lap); }
.sdc-li-lap { font-size: 12.5px; margin-top: 2px; color: var(--sdc-lap); font-weight: 600; }
.sdc-li-uoc { color: var(--muted); }
.sdc-tip { position: absolute; z-index: 30; max-width: 280px; background: var(--surface); color: var(--fg); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; box-shadow: var(--shadow-2); pointer-events: none; overflow-wrap: anywhere; }
.sdc-tip b { display: block; margin-bottom: 2px; }
.sdc-tip b.do { color: var(--err); } .sdc-tip b.vang { color: var(--warn); }
.sdc-tip .sdc-co, .sdc-li-co .sdc-co { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; filter: none; }
.sdc-tip b { display: flex; align-items: center; }
.sdc-li-co { display: inline-flex; align-items: center; }
.sdc .sdc-btn, .sdc .sdc-snack button { transition: none; }
.sdc-tip.t-do { border-color: var(--err); } .sdc-tip.t-vang { border-color: var(--warn); }

/* ---------- Điều khiển nổi ---------- */
.sdc-zoom { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 4px; z-index: 10; }
.sdc-zoom-nhan { min-width: 44px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sdc-mini { position: absolute; left: 12px; bottom: 12px; width: 180px; height: 104px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; z-index: 10; overflow: hidden; touch-action: none; }
.sdc-mini svg { width: 100%; height: 100%; display: block; cursor: pointer; }
.sdc-mm-o { fill: var(--sdc-net-kh); stroke: none; } .sdc-mm-o.net-fb { fill: var(--sdc-net-fb); } .sdc-mm-o.net-yt { fill: var(--sdc-net-yt); } .sdc-mm-o.net-tt { fill: var(--sdc-net-tt); } .sdc-mm-o.net-x { fill: var(--sdc-net-x); } .sdc-mm-o.net-rd { fill: var(--sdc-net-rd); }
.sdc-mm-o.co-do { stroke: var(--err); stroke-width: 14; } .sdc-mm-o.co-vang { stroke: var(--gold-bg); stroke-width: 14; }
.sdc-mm-canh { stroke: var(--muted); stroke-width: 6; }
.sdc-mm-vp { fill: var(--ring); stroke: var(--pri); stroke-width: 2; }
.sdc-banner { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 12; background: var(--btn-pri); color: var(--sdc-net-chu); border-radius: 99px; padding: 6px 14px; font-weight: 600; max-width: calc(100% - 24px); display: flex; gap: 10px; align-items: center; }
.sdc .sdc-banner .sdc-btn-nho { background: var(--surface); color: var(--fg); border: 0; min-height: 28px; border-radius: 99px; padding: 0 12px; }
.sdc-snack { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); z-index: 40; background: var(--toast-bg); color: var(--toast-fg); padding: 8px 12px; border-radius: 10px; max-width: min(92%, 520px); display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow-2); }
.sdc .sdc-snack .sdc-btn-nho { background: var(--toast-fg); color: var(--toast-bg); border: 0; }

/* ---------- Menu nổi ---------- */
.sdc-menu { position: fixed; z-index: 400; background: var(--surface); color: var(--fg); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-3); padding: 8px; width: 270px; max-width: calc(100vw - 16px); max-height: min(72vh, 480px); overflow: auto; }
.sdc-menu h3 { font-size: 13px; margin: 2px 4px 6px; overflow-wrap: anywhere; }
.sdc-seg { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.sdc .sdc-menu button { min-height: 36px; width: 100%; justify-content: flex-start; text-align: left; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px; background: none; box-shadow: none; white-space: normal; }
.sdc .sdc-menu button:hover { background: var(--surface-2); border-color: var(--line); }
.sdc .sdc-seg button { flex: 1 1 auto; width: auto; justify-content: center; border-color: var(--line-2); }
.sdc .sdc-menu button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.sdc .sdc-menu button[aria-disabled="true"] { opacity: .6; }
.sdc .sdc-menu .sdc-nguy { color: var(--err); }
.sdc-md-chu { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.sdc-md-chu small { font-size: 11.5px; color: var(--muted); }
.sdc-sep { border-top: 1px solid var(--line); margin: 6px 0; }
.sdc-trong { margin: 8px 4px; color: var(--muted); }
.sdc-b { display: inline-grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 800; color: var(--sdc-net-chu); background: var(--sdc-net-kh); }
.sdc-b.b-fb { background: var(--sdc-net-fb); } .sdc-b.b-yt { background: var(--sdc-net-yt); } .sdc-b.b-tt { background: var(--sdc-net-tt); box-shadow: 0 0 0 1.5px var(--sdc-net-vong); } .sdc-b.b-x { background: var(--sdc-net-x); } .sdc-b.b-rd { background: var(--sdc-net-rd); }

/* ---------- Danh sách dọc ---------- */
.sdc-ds { position: absolute; inset: 0; overflow: auto; padding: 12px; background: var(--bg); display: none; }
.sdc.che-do-ds .sdc-ds { display: block; }
.sdc.che-do-ds .sdc-vp, .sdc.che-do-ds .sdc-mini, .sdc.che-do-ds .sdc-zoom, .sdc.che-do-ds .sdc-banner, .sdc.che-do-ds .sdc-tip { display: none; }
.sdc-ds-duong { max-width: 680px; margin: 0 auto 14px; }
.sdc-ds-duong h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); }
.sdc-ds-duong ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sdc-li { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.sdc-li.lv-do { border-color: var(--err); box-shadow: inset 4px 0 0 var(--err); }
.sdc-li.lv-vang { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.sdc-li.sel { outline: 2px solid var(--fg); outline-offset: 1px; }
.sdc-idx { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.sdc-li-chinh { flex: 1; min-width: 0; }
.sdc-li-ten { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.sdc-li-mang { color: var(--muted); font-size: 12.5px; }
.sdc-lan-ds { background: var(--surface-2); border-color: var(--line-2); color: var(--fg-2); }
.sdc-li-nhuong { font-size: 11px; font-weight: 700; color: var(--live); border: 1.5px dashed var(--live); border-radius: 99px; padding: 0 7px; }
.sdc-li-co.do { color: var(--err); } .sdc-li-co.vang { color: var(--warn); }
.sdc-li-tom, .sdc-li-vi, .sdc-li-ra { font-size: 12.5px; margin-top: 2px; overflow-wrap: anywhere; }
.sdc-li-tom { color: var(--muted); }
.sdc-li-nut { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sdc .sdc-li-nut button { min-height: 36px; padding: 0 10px; font-size: 13px; }
.sdc .sdc-li-nut button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.sdc .sdc-li-nut .sdc-nguy { color: var(--err); border-color: var(--err); }
@media (max-width: 640px) {
  .sdc-bar { padding: 6px 10px; gap: 6px; }
  .sdc .sdc-btn { min-height: 40px; padding: 0 10px; font-size: 13px; }
  .sdc-dem { flex: 1 1 100%; order: 9; }
  .sdc-tong-uoc, .sdc-lap-ca-chu { flex: 1 1 100%; order: 8; }
  .sdc-gian { display: none; }
  .sdc-mini { width: 120px; height: 70px; }
  .sdc { min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) { .sdc *, .sdc *::before, .sdc *::after { animation: none !important; transition: none !important; } }
/* SƠ ĐỒ CANVAS — HẾT */

/* ============================================================================================================================================================
   ĐỒ THỊ NHIỀU MẠNG — TRANG KỊCH BẢN (GĐ-A/B1 lượt 2, 07/10/2026): pages/kich-ban-do-thi.ts (khung canvas + chi tiết ô + kế hoạch) và pages/kich-ban-luot.ts (thẻ chạy theo lượt). Lớp .kb-dt-* / .kb-luot-*.
   ============================================================================================================================================================ */
.kb-dt-dau { align-items: baseline; }
.kb-dt-cong-cu { margin: 0 0 8px; }
.kb-dt-chinh { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 4px; }
.kb-dt-chinh.co-ct { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
.kb-dt-canvas { min-width: 0; }
.kb-dt-canvas .sdc { --sdc-cao: clamp(420px, 72vh, 1100px); } /* (08/10/2026 Kiểu B) vùng thao tác lớn hơn: 72% chiều cao màn */
.kb-dt-ct { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 12px; position: relative; max-height: clamp(420px, 72vh, 1100px); overflow: auto; }
.kb-dt-ct-dau { gap: 8px; align-items: flex-start; }
.kb-dt-ct-dau h4 { margin: 0; overflow-wrap: anywhere; }
.kb-dt-ct .kb-noi-x { position: static; flex: none; }
.kb-dt-luoi { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 8px; }
.kb-dt-tong-box:empty { display: none; }
.kb-dt-nhom-hang { display: flex; flex-direction: column; gap: 6px; }
.kb-dt-nhom { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kb-dt-nhom-ten { font-weight: 600; }
.kb-dt-ke-hoach { margin-top: 14px; }
.kb-dt-ke-hoach h4 { margin: 0 0 4px; }
.kb-dt-duongs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.kb-dt-duong { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; background: var(--surface); min-width: 0; }
.kb-dt-duong h5 { margin: 0 0 4px; font-size: 13px; }
.kb-dt-duong ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.kb-dt-muc { overflow-wrap: anywhere; }
.kb-dt-muc-nghi { color: var(--muted); }
.kb-dt-chip { margin-left: 6px; white-space: nowrap; }
.kb-dt-chip-ok { color: var(--ok); border-color: var(--ok); }
.kb-dt-chip-loi { color: var(--err); border-color: var(--err); }
.kb-dt-kq-box { margin-top: 10px; }
.kb-dt-kq ul { margin: 6px 0 0; padding-left: 18px; }
@media (max-width: 1100px) { .kb-dt-chinh.co-ct { grid-template-columns: minmax(0, 1fr); } .kb-dt-ct { max-height: none; } }
.kb-dong-mang { margin-right: 4px; }
/* thẻ chạy theo LƯỢT */
.kb-luot-tien-do { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.kb-luot-duong { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.kb-luot-d { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; min-width: 0; overflow-wrap: anywhere; }
.kb-luot-d.dang { border-color: var(--pri); }
.kb-luot-kq { margin: 4px 0 0; }
.kb-luot-gan { margin-top: 10px; }
.kb-luot-gan ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
/* việc A: bảng tiến độ TỪNG bot của lượt nhiều bot */
.kb-luot-bang { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.kb-luot-bot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 10px; border-radius: var(--r); background: var(--surface-2); min-width: 0; overflow-wrap: anywhere; }
.kb-luot-bot.ok { background: var(--ok-soft); }
.kb-luot-bot.err { background: var(--err-soft); }
.kb-luot-bot.dang-xem { outline: 2px solid var(--pri); outline-offset: -2px; }
.kb-luot-bot .grow { flex: 1 1 200px; min-width: 0; }
@media (max-width: 640px) { .kb-dt-duongs { grid-template-columns: minmax(0, 1fr); } .kb-luot-d .row { gap: 6px; } }
/* ĐỒ THỊ — HẾT */

/* =====================================================================================================================================
   GIAO DIỆN TỔNG 2026-10 — BẮT ĐẦU (07/10/2026, người dùng: "đập đi xây mới")
   (1) ≥ 1200 px: thẻ (.card) xếp LƯỚI HAI CỘT, mỗi thẻ một nửa khung — không thẻ nào trải dài trái → phải.
       NGOẠI LỆ RỘNG (được rộng hết khung; danh sách TRÙNG với tests/e2e/boss-giao-dien-tong.e2e.ts, hằng RONG):
         .rong · .kb-so-do (danh sách thẻ bước của sơ đồ) · .card:has(.sdc) (canvas sơ đồ) · .card:has(.kb-dt-chinh) (sơ đồ đồ thị)
         · .card:has(table tr > :nth-child(5)) (bảng dữ liệu ≥ 5 cột: danh sách kịch bản, lịch, lịch sử, thống kê…).
       Bảng .tbl đứng ngoài thẻ, lưới thẻ bot (.bots — kèm xem trực tiếp màn hình), ô số liệu: giữ bố cục riêng như cũ.
       < 1200 px: một cột như trước; 390 px không đổi.
   (2) Chữ giải thích → nút ⓘ (goi-y.ts): .gt-nut / .gt-bong / .ly-do-chan.
   (3) (08/10/2026 "Kiểu B") THANH METRO dọc hẹp luôn hiện ≥ 1024 px, nội dung rộng hết bên phải (thay bản 07/10 menu ẩn + ☰ + Ghim).
   ===================================================================================================================================== */

/* ---- (1) lưới hai cột ---- */
/* Dấu "luoi-2" (#main / vùng có thẻ) và data-luoi-boc (hộp bọc không lớp chứa thẻ) do luoi-trang.ts gắn — KHÔNG dùng :has(> .card) ở đây:
   đo trên trang Bot 1000 bot, mỗi nhóm :has() như vậy làm thời gian tính lại kiểu tăng ~6 lần (E2E boss-web W36). */
@media (min-width: 1200px) {
  #main.luoi-2, :is(.cmp-board, [data-testid="bd-vung-thao-tac"]).luoi-2,
  .kb-trang {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; align-items: start; align-content: start;
  }
  /* :where → độ ưu tiên thấp: luật "thẻ = một nửa" bên dưới thắng */
  #main:where(.luoi-2) > *, :where(.cmp-board, [data-testid="bd-vung-thao-tac"]):where(.luoi-2) > *,
  .kb-trang > * { grid-column: 1 / -1; min-width: 0; }
  /* hộp bọc không lớp chỉ để gom thẻ → "trong suốt": thẻ con vào thẳng lưới */
  #main > div[data-luoi-boc], .kb-trang > div[data-luoi-boc],
  .kb-trang > .kb-chay-vung, .kb-chay-vung > div, .kb-trang > .kb-cap, .kb-cap > div,
  .kb-tan-suat, .kb-tan-suat > div { display: contents; }
  #main > div[data-luoi-boc] > *, .kb-trang > div:not([class]) > *, .kb-chay-vung > div > *, .kb-cap > div > *,
  .kb-tan-suat > *, .kb-tan-suat > div > * { grid-column: 1 / -1; min-width: 0; }
  /* thẻ = một nửa */
  #main > .card, #main > div:not([class]) > .card, :is(.cmp-board, [data-testid="bd-vung-thao-tac"]) > .card,
  .kb-trang > div:not([class]) > .card, .kb-chay-vung > div > .card, .kb-cap > div > .card, .kb-tan-suat > div > .card { grid-column: auto; }
  /* ngoại lệ rộng */
  /* (chỉ thẻ là ô của các lưới trên — thẻ trong lưới riêng như .stat-grid giữ bố cục cũ) */
  :is(#main, #main > div:not([class]), :is(.cmp-board, [data-testid="bd-vung-thao-tac"]), .kb-trang > div:not([class]), .kb-chay-vung > div, .kb-cap > div, .kb-tan-suat > div)
    > :is(.rong, .kb-so-do, .card:has(.sdc), .card:has(.kb-dt-chinh), .card:has(table tr > :nth-child(5))) { grid-column: 1 / -1; }
  /* trang một kịch bản: "Chạy kịch bản" nửa trái + "Sản phẩm" nửa phải ngay dưới tiêu đề (người dùng vẽ khung), rồi các khung còn lại */
  /* chỉ khối đứng SAU khu chạy (~) mới lùi xuống order 3; mọi khối đứng TRƯỚC khu chạy trong DOM (tiêu đề, "AI đang viết", và ở kịch bản ĐỒ THỊ:
     khung sơ đồ tự do — trang đưa lên trên) giữ order 0 mặc định = chỗ cũ. (Bản đầu dùng .kb-trang > :has(~ .kb-chay-vung) — :has() theo anh em
     làm mỗi lần chèn phần tử tính lại kiểu cả danh sách: xem luoi-trang.ts.) */
  .kb-trang > .kb-chay-vung ~ *, .kb-trang > .kb-chay-vung ~ div:not([class]) > .card, .kb-cap > div > *, .kb-tan-suat > div > * { order: 3; }
  .kb-chay-vung > div > * { order: 1; }
  /* Sản phẩm chiếm 2 hàng bên phải → "Mong muốn" lên ngay dưới "Chạy kịch bản" (cột trái): sơ đồ không bị đẩy xuống thấp hơn bố cục cũ */
  .kb-cap > div > [data-testid="kb-sp-card"] { order: 2; grid-row: span 2; }
  .kb-trang .card { margin-bottom: 16px; }
  /* (07/10/2026) danh sách #/kich-ban: cột TRÁI = hộp .kb-cot-trai (Tạo kịch bản mới → Nhập tệp → mẫu, xếp dọc sát nhau), cột PHẢI = thẻ danh
     sách — cùng hàng nên đỉnh danh sách ngang đỉnh "Tạo"; thẻ ngắn không còn tự nhảy sang cột phải để lại khoảng trống bên dưới. */
  #main > .kb-cot-trai { grid-column: 1; }
  #main > .card.kb-ds-the { grid-column: 2; }
}
.kb-cot-trai { min-width: 0; }

/* ô nhập / ô chọn không kéo dài vô lý trong thẻ rộng */
#main :is(.rong, .card:has(table tr > :nth-child(5))) > :is(.row, .field-row) select { max-width: 360px; }

/* ---- (2) giải thích: nút ⓘ + bong bóng ---- */
.gt-nut { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 20px; height: 20px; padding: 0; margin: 0 0 0 6px;
  border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--pri) 60%, var(--line-2)); background: var(--surface); color: var(--pri);
  box-shadow: none; cursor: help; vertical-align: middle; font: italic 700 12px/1 Georgia, "Times New Roman", serif; text-transform: none; letter-spacing: 0; }
.gt-nut::before { content: "i"; }
.gt-nut:hover, .gt-nut[aria-expanded="true"] { background: var(--pri-soft); border-color: var(--pri); }
.gt-nut:active { transform: none; }
h1 > .gt-nut { width: 22px; height: 22px; font-size: 13px; margin-left: 8px; vertical-align: 3px; }
.gt-dong { display: block; margin: 2px 0 6px; }
.gt-bong:not(.gt-mo) { display: none !important; }
.gt-bong.gt-mo { position: fixed; inset: auto; margin: 0; z-index: 60; display: block; width: max-content; max-width: min(400px, calc(100vw - 16px));
  max-height: min(60vh, 420px); overflow: auto; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--toast-fg) 18%, transparent);
  border-radius: 10px; background: var(--toast-bg); color: var(--toast-fg) !important; box-shadow: var(--shadow-3);
  font: 400 12.5px/1.5 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; text-align: left; text-transform: none; letter-spacing: 0;
  overflow-wrap: anywhere; white-space: normal; }
.gt-bong.gt-mo a { color: #9cc3ff; }
.gt-bong.gt-mo b, .gt-bong.gt-mo strong { color: inherit; }
/* lý do bị chặn: vẫn hiện, gọn MỘT dòng; câu đầy đủ ở ⓘ cuối dòng */
.ly-do-chan { position: relative; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 28px; }
.ly-do-chan > .gt-nut { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); margin: 0; }
.ly-do-chan > .gt-nut:active { transform: translateY(-50%); }

/* ---- (3) THANH METRO KIỂU B (08/10/2026, người dùng chọn "Kiểu B") — chỉ ≥ 1024 px; màn hẹp giữ thanh tab dưới như cũ ----
   Thanh dọc hẹp (--side-w 72px) LUÔN hiện, không cần rê chuột. Mỗi mục một ô màu RIÊNG cố định (bảng MAU trong tests/e2e/boss-giao-dien-tong.e2e.ts
   phải TRÙNG), biểu tượng trắng, nhãn ngắn = data-ngan; tên đầy đủ ở aria-label + title (<span> tên đầy đủ ẩn ở màn rộng nhưng vẫn trong DOM).
   Màu: cùng họ với màu mẫu người dùng chọn nhưng đậm hơn một bậc — màu mẫu (#378ADD, #1D9E75, #BA7517, #639922, #D4537E) với chữ trắng chỉ đạt
   tương phản 3,4–3,9 (< 4,5). Nhóm Quản lý (So sánh Boss + mục Super) + Kỹ thuật + Cài đặt dồn ĐÁY; không đủ chỗ → thanh tự cuộn bên trong.
   Nội dung (#main) dùng hết bề rộng bên phải thanh (không còn max-width 1360), lề phải 12px. */
@media (min-width: 1024px) {
  :root { --side-w: 72px; }
  .side > .brand, .side-foot { display: none; }
  #nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 5px 10px; overflow-x: hidden; overflow-y: auto; min-height: 0; flex: 1;
    scrollbar-width: thin; scrollbar-color: var(--side-muted) transparent; }
  /* tên nhóm (W48 — người dùng 30/09: danh mục "Quản lý các Boss") vẫn hiện: chữ nhỏ căn giữa, xuống dòng trong thanh */
  #nav .nav-label { flex: none; margin: 6px 0 0; padding: 2px 0 1px; color: var(--side-fg); font-size: 10px; font-weight: 700; line-height: 1.15;
    letter-spacing: 0; text-transform: none; text-align: center; white-space: normal; overflow-wrap: break-word; }
  #nav .nav-label:first-child { margin-top: 0; }
  #nav .nav-label-qly::before { margin-right: 3px; }
  #nav a { --o: #5F5E5A; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 42px; padding: 5px 2px 4px;
    border-radius: 6px; background: var(--o); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); white-space: normal; text-align: center;
    font-size: 11px; font-weight: 600; line-height: 1.1; transition: filter .1s; }
  #nav a > span { display: none; }
  #nav a::before, #nav a.active::before { content: attr(data-ngan); order: 1; display: block; position: static; inset: auto; width: auto; height: auto;
    max-width: 100%; background: none; border-radius: 0; color: #fff; font-size: 11px; font-weight: 600; line-height: 1.1; overflow-wrap: anywhere; }
  #nav a svg, #nav a.active svg { width: 18px; height: 18px; color: #fff; stroke: #fff; opacity: 1; }
  #nav a:hover { background: var(--o); color: #fff; filter: brightness(1.18); text-decoration: none; }
  #nav a:focus-visible { outline: 2px solid var(--side-accent); outline-offset: 1px; }
  /* ô đang mở: vòng trắng (nền thanh luôn tối ở cả sáng lẫn tối) */
  #nav a.active { background: var(--o); color: #fff; outline: 2px solid #ffffff; outline-offset: 2px; }
  #nav a[data-count]::after { position: absolute; top: 2px; right: 2px; margin: 0; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 15px; }
  /* dồn đáy: Super — từ nhóm "Quản lý các Boss" trở xuống; Boss thường (nhóm đó ẩn, So sánh Boss ở cuối "Dữ liệu" — W48b) — nhóm "Hệ thống" */
  #nav .nav-label[data-nhom="he-thong"], #nav .nav-label[data-nhom="quan-ly"]:not([hidden]) { margin-top: auto; }
  #nav .nav-label[data-nhom="quan-ly"]:not([hidden]) ~ .nav-label[data-nhom="he-thong"] { margin-top: 6px; }
  /* màu từng mục — cùng họ cho mục liên quan: xanh dương = bot/so sánh, tím = kịch bản, cam đất = cần duyệt/thông báo, hồng = AI,
     xanh lá = kết quả, xanh ngọc = nick/bản đồ, hổ phách = kho/sản phẩm, đỏ = cảnh báo, xám = hệ thống, xám xanh = kỹ thuật */
  #nav a[data-route="bots"] { --o: #185FA5; }
  #nav a[data-route="kich-ban"] { --o: #534AB7; }
  #nav a[data-route="goi-seeding"] { --o: #6A3FA8; }
  #nav a[data-route="chuoi"] { --o: #3C3489; }
  #nav a[data-route="cho-duyet"] { --o: #993C1D; }
  #nav a[data-route="tro-ly"] { --o: #993556; }
  #nav a[data-route="works"] { --o: #3B6D11; }
  #nav a[data-route="nhom-nick"] { --o: #0F6E56; }
  #nav a[data-route="history"] { --o: #27500A; }
  #nav a[data-route="stats"] { --o: #4A7A1A; }
  #nav a[data-route="so-kinh-nghiem"] { --o: #72243E; }
  #nav a[data-route="san-pham"] { --o: #854F0B; }
  #nav a[data-route="kho-anh"] { --o: #9A5B0C; }
  #nav a[data-route="kho-video"] { --o: #633806; }
  #nav a[data-route="compare"] { --o: #0C447C; }
  #nav a[data-route="users"] { --o: #444441; }
  #nav a[data-route="announce"] { --o: #712B13; }
  #nav a[data-route="canh-bao"] { --o: #A32D2D; }
  #nav a[data-route="ban-do"] { --o: #085041; }
  #nav a[data-route="mo-hinh-ai"] { --o: #8B2F6B; }
  #nav a[data-route="audit"] { --o: #6B6A64; }
  #nav a[data-route="jobs-new"] { --o: #2F5D74; }
  #nav a[data-route="jobs"] { --o: #26495C; }
  #nav a[data-route="bundles"] { --o: #3A5266; }
  #nav a[data-route="lenh"] { --o: #1F3B4D; }
  #nav a[data-route="settings"] { --o: #5F5E5A; }
  /* thanh trên + nội dung bắt đầu ngay sau thanh (margin-left: var(--side-w) ở luật gốc), nội dung rộng hết bên phải */
  .topbar { padding-left: 16px; }
  #top:not([hidden]) ~ main { max-width: none; margin-right: 0; padding-left: 16px; padding-right: 12px; }
  /* ai đang đăng nhập: chân thanh bên đã ẩn → hiện trên thanh trên */
  .who-top { display: inline-flex; flex-direction: column; align-items: flex-end; flex: 0 1 auto; min-width: 0; max-width: 220px; line-height: 1.15; font-size: 12px; color: var(--fg-2); }
  .who-top-ten { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .who-top-sep { display: none; }
  .who-top-vai { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
}
@media (min-width: 1024px) and (prefers-reduced-motion: reduce) { #nav a { transition: none; } }
/* GIAO DIỆN TỔNG 2026-10 — HẾT */
/* ===== (08/10/2026, đợt A) Hẹn giờ trên canvas (nút đỏ chữ trắng, góc dưới phải, bên trái cụm zoom) + nhãn "dành cho nhánh" / tần suất dưới bước ===== */
.sdc-hen-gio { position: absolute; right: 156px; bottom: 12px; z-index: 11; max-width: calc(100% - 360px); }
.sdc-hen-gio-nut { background: #c62828; color: #fff; border: 1px solid #a31515; border-radius: 10px; padding: 7px 12px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; box-shadow: var(--shadow-1, 0 1px 3px rgba(0,0,0,.25)); }
.sdc-hen-gio-nut:hover { background: #b71c1c; }
.sdc-hen-gio-nut:focus-visible { outline: 3px solid #ffb4a9; outline-offset: 2px; }
/* danh sách dọc: nút đỏ nằm trên một DẢI riêng ở đầu khung, vùng cuộn của danh sách bắt đầu DƯỚI dải → khi cuộn, các dòng không chui xuống dưới nút
   (bản cũ chỉ chừa padding-top 56px: ở đầu thì không che, nhưng cuộn xuống thì nút đỏ đè lên các dòng — người dùng thấy ở 390px, 08/10/2026) */
.sdc.che-do-ds .sdc-hen-gio { top: 0; right: 0; bottom: auto; left: 0; height: 52px; padding: 0 12px; max-width: none; display: flex; align-items: center;
  justify-content: flex-end; background: var(--bg); border-bottom: 1px solid var(--line); }
.sdc.che-do-ds .sdc-stage:has(.sdc-hen-gio:not([hidden])) .sdc-ds { top: 52px; }
@media (max-width: 640px) {
  .sdc-hen-gio { right: 12px; bottom: 60px; max-width: calc(100% - 24px); }
}
.sdc-gan { position: absolute; left: 4px; max-width: calc(100% - 30px); bottom: calc(100% + 8px); font-size: 11px; font-weight: 700; line-height: 16px; color: #4a148c; background: #f3e5f5; border: 1px solid #ce93d8; border-radius: 99px; padding: 0 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; transform: scale(var(--sdc-ik, 1)); transform-origin: 0 100%; }
.sdc-lap-het { align-items: center; }
.hg-modal { max-width: min(640px, 96vw); width: 100%; max-height: 90vh; overflow: auto; }
.hg-ds { display: grid; gap: 6px; margin: 6px 0 10px; }
.hg-dong { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.hg-dong .grow { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.hg-form { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 8px; }
.hg-form .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.hg-form input[type="text"] { width: 100%; min-width: 0; box-sizing: border-box; }
.hg-bots { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lt-cau-hinh { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin: 6px 0; }
.lt-cau-hinh input[type="text"], .lt-cau-hinh select { width: 100%; min-width: 0; box-sizing: border-box; }
.sdc-li-gan { font-size: 11px; font-weight: 700; color: #4a148c; background: #f3e5f5; border: 1px solid #ce93d8; border-radius: 99px; padding: 0 7px; margin-left: 6px; white-space: nowrap; }

/* (08/10/2026) Chỉ báo lưu + nút "Lưu" của SƠ ĐỒ — MỘT chỗ, trên thanh công cụ canvas cạnh Hoàn tác / Làm lại; lớn, có màu theo trạng thái */
.kb-luu-box { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kb-luu-box .kb-luu { position: static; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; border: 1.5px solid currentColor; white-space: normal; line-height: 1.25;
  color: var(--ok); background: var(--ok-soft); }
.kb-luu-box .kb-luu[data-trang-thai="dang-luu"] { color: var(--run); background: transparent; }
.kb-luu-box .kb-luu[data-trang-thai="cho-luu"] { color: var(--warn); background: var(--warn-soft); }
.kb-luu-box .kb-luu[data-trang-thai="loi"], .kb-luu-box .kb-luu[data-trang-thai="loi-thu-lai"] { color: var(--err); background: var(--err-soft); }
.kb-luu-box .kb-luu-nut { font-weight: 700; }
.kn-kb-gon > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.kn-kb-gon[open] > summary { margin-bottom: 6px; }
