/* TransMind — Kho tri thức vận tải 360° (#/kb), Luồng điều phối (#/flow), nguồn trích dẫn dưới câu trả lời.
   Bám token --tm-* của transmind.css (khai báo ở .tm-root) — không hardcode màu mới ngoài sắc trạng thái.
   z-index theo UI-STACKING-REGISTRY: ngăn chi tiết = tầng Modal/Drawer trong module (backdrop 1090, drawer 1100) — dưới lớp trò chuyện trực tiếp (1200) và toast dùng chung. */
/* AI-MARK[TRANSMIND-UI:kb-360] 2026-11-12 08:48 (GMT+7) — style kho 360° (thống kê, kéo-thả, thẻ nhóm, danh sách, ngăn chi tiết), luồng điều phối (7 chặng, công tắc, đề xuất, thử truy hồi, biểu đồ nhóm) và khối nguồn [K#]/internet | rel: transmind/transmind-kb.js, transmind/transmind.js sourcesHtml */

.tm-kb-head h1, .tm-flow .tm-head h1 { font-size: 24px; }
.tm-kb-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; width: 100%; margin: 4px 0 6px; }
.tm-kb-stat { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 8px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; }
.tm-kb-stat svg { grid-row: span 2; color: var(--tm-orange-d); }
.tm-kb-stat b { color: var(--tm-ink); font-size: 18px; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.tm-kb-stat span { color: var(--tm-muted); font-size: 11.5px; font-weight: 700; }
.tm-kb-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-kb-warnbtn { border-color: #fcd34d; background: #fffbeb; color: #92400e; }
.tm-kb-err { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--tm-red); font-size: 13px; font-weight: 700; }
.tm-kb-note { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; color: var(--tm-muted); font-size: 12px; font-weight: 600; line-height: 1.5; }

/* Kéo-thả nạp tệp */
.tm-kb-drop { display: grid; gap: 10px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; padding: 14px; }
.tm-kb-dropzone { display: flex; align-items: center; gap: 14px; padding: 18px; border: 2px dashed var(--tm-orange-line); border-radius: 12px; background: var(--tm-orange-bg); cursor: pointer; transition: .15s ease; }
.tm-kb-dropzone:hover, .tm-kb-dropzone.is-over { border-color: var(--tm-orange); background: #ffedd5; }
.tm-kb-dropzone:focus-visible { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-kb-dropzone > div { display: grid; gap: 3px; min-width: 0; }
.tm-kb-dropzone b { color: var(--tm-ink); font-size: 14.5px; font-weight: 800; }
.tm-kb-dropzone span { color: var(--tm-text); font-size: 12.5px; line-height: 1.5; }
.tm-kb-drop-ico { flex: 0 0 auto; width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; background: linear-gradient(135deg, #ff7a3d, var(--tm-orange-d)); color: #fff; }
.tm-kb-drop-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; color: var(--tm-text); font-size: 12.5px; font-weight: 700; }
.tm-kb-drop-opts .tm-kb-note { margin: 0; }
.tm-kb-select { min-height: 34px; max-width: 100%; border: 1px solid var(--tm-line); border-radius: 10px; padding: 0 10px; background: #fff; color: var(--tm-ink); font-size: 13px; font-weight: 600; }
.tm-kb-select:focus { outline: 2px solid var(--tm-orange-line); outline-offset: 1px; }
.tm-kb-queue { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tm-kb-q { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 7px 10px; border-radius: 10px; background: var(--tm-soft); font-size: 12.5px; }
.tm-kb-q-name { flex: 0 1 auto; min-width: 0; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tm-ink); font-weight: 800; }
.tm-kb-q-msg { flex: 1; min-width: 0; color: var(--tm-muted); font-weight: 600; overflow-wrap: anywhere; }
.tm-kb-q-msg a { color: var(--tm-orange-d); font-weight: 800; }
.tm-kb-q.is-busy .tm-kb-q-ico, .tm-kb-q.is-wait .tm-kb-q-ico { color: var(--tm-orange-d); animation: tm-rot 1s linear infinite; }
.tm-kb-q.is-done .tm-kb-q-ico { color: var(--tm-green); }
.tm-kb-q.is-error .tm-kb-q-ico { color: var(--tm-red); }
.tm-kb-q.is-error .tm-kb-q-msg { color: var(--tm-red); }
.tm-kb-q.is-dup .tm-kb-q-ico { color: #b45309; }

/* Thẻ nhóm */
.tm-kb-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.tm-kb-cat { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 8px; padding: 11px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; text-align: left; cursor: pointer; transition: .15s ease; }
.tm-kb-cat svg { color: var(--tm-orange-d); }
.tm-kb-cat b { min-width: 0; color: var(--tm-ink); font-size: 13px; font-weight: 800; line-height: 1.3; }
.tm-kb-cat-n { min-width: 26px; padding: 1px 8px; border-radius: 999px; background: #f1f5f9; color: var(--tm-text); font-size: 12px; font-weight: 900; text-align: center; }
.tm-kb-cat small { grid-column: 1 / -1; color: var(--tm-muted); font-size: 11.5px; font-weight: 500; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tm-kb-cat:hover { border-color: var(--tm-orange-line); background: var(--tm-orange-bg); }
.tm-kb-cat.is-active { border-color: var(--tm-orange); box-shadow: inset 0 0 0 1px var(--tm-orange); background: var(--tm-orange-bg); }
.tm-kb-cat.is-active .tm-kb-cat-n { background: var(--tm-orange-d); color: #fff; }

/* Tìm + lọc */
.tm-kb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.tm-kb-search { flex: 1 1 300px; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; color: var(--tm-faint); }
.tm-kb-search:focus-within { border-color: var(--tm-orange-line); box-shadow: 0 0 0 3px rgba(255,107,43,.12); }
.tm-kb-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--tm-ink); font-size: 13.5px; font-weight: 600; }
.tm-kb-kinds { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--tm-line); border-radius: 999px; background: #fff; }
.tm-kb-kind { min-height: 32px; border: 0; border-radius: 999px; padding: 0 12px; background: transparent; color: var(--tm-muted); font-size: 12.5px; font-weight: 800; cursor: pointer; }
.tm-kb-kind:hover { color: var(--tm-orange-d); }
.tm-kb-kind.is-active { background: var(--tm-navy); color: #fff; }

/* Danh sách */
.tm-kb-count { color: var(--tm-muted); font-size: 12.5px; font-weight: 700; margin: 2px 0 6px; }
.tm-kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tm-kb-item { min-width: 0; }
.tm-kb-open { width: 100%; height: 100%; display: grid; align-content: start; gap: 6px; padding: 12px 14px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; text-align: left; cursor: pointer; transition: .15s ease; }
.tm-kb-open:hover { border-color: var(--tm-orange-line); box-shadow: 0 6px 18px rgba(15,23,42,.06); }
.tm-kb-open:focus-visible { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-kb-title { color: var(--tm-ink); font-size: 14px; font-weight: 800; line-height: 1.4; overflow-wrap: anywhere; }
.tm-kb-open p { margin: 0; color: var(--tm-text); font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tm-kb-snip { background: #fffbeb; border-radius: 8px; padding: 4px 6px; }
.tm-kb-foot { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--tm-faint); font-size: 11.5px; font-weight: 600; }
.tm-kb-foot span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-kb-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.tm-kb-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 8px; border-radius: 999px; background: #f1f5f9; color: var(--tm-text); font-size: 11px; font-weight: 800; white-space: nowrap; }
.tm-kb-chip svg { color: var(--tm-muted); }
.tm-kb-chip.is-warn { background: #fffbeb; color: #92400e; }
.tm-kb-chip.is-warn svg { color: #b45309; }
.tm-kb-tag { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: 999px; background: var(--tm-orange-bg); color: #9a3412; font-size: 11.5px; font-weight: 700; }
.tm-kb-empty { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 18px; border: 1px dashed var(--tm-line); border-radius: 12px; background: #fff; color: var(--tm-muted); font-size: 13px; font-weight: 600; line-height: 1.55; }
.tm-kb-empty span { flex: 1 1 260px; }
.tm-kb-skel { height: 76px; border-radius: 12px; background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 50%, #eef2f7 75%); background-size: 200% 100%; animation: tm-kb-shim 1.2s ease infinite; }
.tm-kb-skel--row { height: 64px; margin-bottom: 8px; }
@keyframes tm-kb-shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Ngăn chi tiết (drawer) */
.tm-kb-backdrop { position: fixed; inset: 0; z-index: 1090; background: rgba(2,6,23,.42); }
.tm-kb-backdrop[hidden], .tm-kb-drawer[hidden] { display: none; }
.tm-kb-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1100; width: min(640px, 100vw); display: flex; flex-direction: column; background: #fff; box-shadow: -18px 0 48px rgba(2,6,23,.22); }
.tm-kb-dr-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--tm-line); }
.tm-kb-x { flex: 0 0 auto; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--tm-line); border-radius: 10px; background: #fff; color: var(--tm-ink); cursor: pointer; }
.tm-kb-x:hover { background: var(--tm-soft); }
.tm-kb-dr-body { flex: 1; overflow-y: auto; padding: 16px 18px 28px; display: grid; align-content: start; gap: 10px; }
.tm-kb-dr-body h2 { margin: 0; color: var(--tm-ink); font-size: 19px; font-weight: 900; line-height: 1.35; overflow-wrap: anywhere; }
.tm-kb-dr-body h3 { margin: 10px 0 0; color: var(--tm-ink); font-size: 14px; font-weight: 900; }
.tm-kb-dr-sum { margin: 0; padding: 10px 12px; border-left: 3px solid var(--tm-orange); border-radius: 0 10px 10px 0; background: var(--tm-orange-bg); color: #7c2d12; font-size: 13.5px; line-height: 1.6; }
.tm-kb-dr-load { flex: 1; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--tm-muted); font-size: 13px; font-weight: 700; }
.tm-kb-dr-load svg { color: var(--tm-orange-d); animation: tm-rot 1s linear infinite; }
.tm-kb-srcs { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-kb-srcs li { display: grid; gap: 2px; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 10px; }
.tm-kb-srcs a { display: flex; align-items: flex-start; gap: 6px; color: var(--tm-orange-d); font-size: 13px; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.tm-kb-srcs a:hover { text-decoration: underline; }
.tm-kb-srcs svg { flex: 0 0 auto; margin-top: 2px; }
.tm-kb-srcs small { color: var(--tm-muted); font-size: 11.5px; }
.tm-kb-dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.tm-kb-dl dt { color: var(--tm-muted); font-weight: 700; }
.tm-kb-dl dd { margin: 0; color: var(--tm-ink); font-weight: 600; overflow-wrap: anywhere; }
.tm-kb-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: var(--tm-soft); font-size: 12.5px; font-weight: 700; color: var(--tm-text); }
.tm-kb-danger { color: var(--tm-red); }
.tm-kb-danger:hover { border-color: #fca5a5; background: #fef2f2; color: var(--tm-red); }
.tm-kb-pre { margin: 0; max-height: 360px; overflow: auto; padding: 12px; border-radius: 10px; background: var(--tm-soft); border: 1px solid var(--tm-line); color: var(--tm-text); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Luồng điều phối */
.tm-flow-pipe { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; counter-reset: none; }
.tm-flow-node { position: relative; min-width: 0; display: grid; align-content: start; gap: 6px; padding: 10px; border: 1px solid var(--tm-line); border-top: 3px solid #22c55e; border-radius: 12px; background: #fff; }
.tm-flow-node.is-warn { border-top-color: #f59e0b; }
.tm-flow-node.is-error { border-top-color: var(--tm-red); }
.tm-flow-node.is-off { border-top-color: #94a3b8; background: var(--tm-soft); }
.tm-flow-node header { display: flex; align-items: center; gap: 6px; color: var(--tm-ink); font-size: 12.5px; }
.tm-flow-node header svg { color: var(--tm-orange-d); }
.tm-flow-node ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.tm-flow-node li { display: flex; justify-content: space-between; gap: 6px; color: var(--tm-muted); font-size: 11.5px; font-weight: 600; }
.tm-flow-node li b { color: var(--tm-ink); font-weight: 800; }
.tm-flow-status { display: inline-flex; align-items: center; gap: 5px; color: var(--tm-muted); font-size: 11px; font-weight: 800; }
.tm-flow-status i { width: 8px; height: 8px; border-radius: 999px; background: #22c55e; }
.is-warn .tm-flow-status i { background: #f59e0b; }
.is-error .tm-flow-status i { background: var(--tm-red); }
.is-off .tm-flow-status i { background: #94a3b8; }
.tm-flow-step { flex: 0 0 auto; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: var(--tm-navy); color: #fff; font-size: 10.5px; font-weight: 900; }
.tm-flow-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.tm-flow-card { display: grid; align-content: start; gap: 10px; padding: 14px 16px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; min-width: 0; }
.tm-flow-card .tm-h2 { display: flex; align-items: center; gap: 6px; margin: 0; }
.tm-flow-card .tm-h2 svg { color: var(--tm-orange-d); }
.tm-flow-toggle { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; cursor: pointer; }
.tm-flow-toggle.is-ro { cursor: default; opacity: .85; }
.tm-flow-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.tm-flow-switch { position: relative; width: 38px; height: 22px; margin-top: 1px; border-radius: 999px; background: #cbd5e1; transition: background .15s ease; }
.tm-flow-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(2,6,23,.3); transition: transform .15s ease; }
.tm-flow-toggle input:checked + .tm-flow-switch { background: var(--tm-orange-d); }
.tm-flow-toggle input:checked + .tm-flow-switch::after { transform: translateX(16px); }
.tm-flow-toggle input:focus-visible + .tm-flow-switch { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-flow-toggle input:disabled + .tm-flow-switch { opacity: .6; }
.tm-flow-toggle > span:last-child { display: grid; gap: 2px; }
.tm-flow-toggle b { color: var(--tm-ink); font-size: 13.5px; font-weight: 800; }
.tm-flow-toggle small { color: var(--tm-muted); font-size: 12px; line-height: 1.45; }
.tm-flow-sugs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tm-flow-sug { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #eff6ff; color: #1e40af; }
.tm-flow-sug > div { display: grid; gap: 2px; min-width: 0; }
.tm-flow-sug b { font-size: 13px; font-weight: 800; color: var(--tm-ink); }
.tm-flow-sug span { font-size: 12px; line-height: 1.5; color: var(--tm-text); overflow-wrap: anywhere; }
.tm-flow-sug svg { margin-top: 2px; }
.tm-flow-sug.is-warn { background: #fffbeb; color: #b45309; }
.tm-flow-sug.is-error { background: #fef2f2; color: var(--tm-red); }
.tm-flow-sug.is-ok { background: #ecfdf5; color: var(--tm-green); }
.tm-flow-probe { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-flow-probe input { flex: 1 1 280px; min-height: 40px; border: 1px solid var(--tm-line); border-radius: 12px; padding: 0 12px; color: var(--tm-ink); font-size: 13.5px; font-weight: 600; }
.tm-flow-probe input:focus { outline: 2px solid var(--tm-orange-line); outline-offset: 1px; }
.tm-flow-hits { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tm-flow-hits li { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; }
.tm-flow-hits li > div { display: grid; gap: 4px; min-width: 0; }
.tm-flow-hits a { color: var(--tm-ink); text-decoration: none; }
.tm-flow-hits a:hover b { color: var(--tm-orange-d); }
.tm-flow-hits b { font-size: 13.5px; font-weight: 800; overflow-wrap: anywhere; }
.tm-flow-hits p { margin: 0; color: var(--tm-text); font-size: 12.5px; line-height: 1.55; }
.tm-flow-score { align-self: center; color: var(--tm-faint); font-size: 11px; font-weight: 700; }
.tm-flow-bars { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-flow-bars a { display: grid; grid-template-columns: minmax(130px, 200px) 1fr 32px; align-items: center; gap: 8px; color: var(--tm-text); font-size: 12px; font-weight: 700; text-decoration: none; }
.tm-flow-bars a:hover { color: var(--tm-orange-d); }
.tm-flow-bar-l { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-flow-bar-l svg { flex: 0 0 auto; color: var(--tm-orange-d); }
.tm-flow-bar { height: 8px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.tm-flow-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #ff7a3d, var(--tm-orange-d)); }
.tm-flow-bars b { text-align: right; color: var(--tm-ink); }
.tm-flow-q { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-flow-q li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--tm-soft); color: var(--tm-text); font-size: 12.5px; font-weight: 600; }
.tm-flow-q b { color: var(--tm-ink); font-weight: 900; }

/* Nguồn dưới câu trả lời + ký hiệu [K#] */
.tm-welcome-kb { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--tm-orange-line); border-radius: 999px; background: var(--tm-orange-bg); color: #9a3412; font-size: 12.5px; font-weight: 600; text-decoration: none; }
.tm-welcome-kb:hover { background: #ffedd5; }
.tm-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 18px; padding: 0 5px; border-radius: 6px; background: var(--tm-navy); color: #fff; font-size: 10.5px; font-weight: 900; line-height: 1; }
.tm-cite--inline { position: relative; top: -1px; margin: 0 1px; vertical-align: baseline; }
/* AI-MARK[TRANSMIND-ORCH:research-harness] 2026-11-16 11:19 (GMT+7) — B1: nhãn nguồn internet [N#] — viền thay nền đặc để phân biệt với nguồn kho [K#]; là liên kết thì giữ màu, không gạch chân (a.tm-cite.tm-cite--web thắng .tm-md a — đã kiểm kiểu tính toán thật) | rel: transmind/transmind.js citeMarks/sourcesHtml */
/* .tm-md a (cam, gạch chân) có độ ưu tiên 0,1,1 ⇒ nhãn liên kết phải dùng a.tm-cite.tm-cite--web (0,2,1) mới giữ được kiểu nhãn. */
.tm-cite--web, a.tm-cite.tm-cite--web { background: transparent; color: var(--tm-navy); box-shadow: inset 0 0 0 1.5px var(--tm-navy); text-decoration: none; }
a.tm-cite.tm-cite--web:hover, a.tm-cite.tm-cite--web:focus-visible { background: var(--tm-navy); color: #fff; }
.tm-srcs { display: grid; gap: 6px; margin-top: 2px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; }
.tm-ground { justify-self: start; display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 0 10px; border-radius: 999px; font-size: 11.5px; font-weight: 800; }
.tm-ground.is-grounded { background: #ecfdf5; color: var(--tm-green); }
.tm-ground.is-reference { background: #fffbeb; color: #92400e; }
.tm-ground.is-internal { background: #eff6ff; color: #1d4ed8; }
.tm-ground.is-none { background: #f1f5f9; color: var(--tm-muted); }
.tm-src-group { display: grid; gap: 4px; }
.tm-src-group > b { display: flex; align-items: center; gap: 5px; color: var(--tm-muted); font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.tm-src-kb, .tm-src-web { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 8px; border-radius: 8px; color: var(--tm-text); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.tm-src-kb:hover, .tm-src-web:hover { background: var(--tm-soft); color: var(--tm-orange-d); }
.tm-src-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-src-kb small, .tm-src-web small { flex: 0 0 auto; color: var(--tm-faint); font-size: 11px; }
.tm-src-web svg { color: var(--tm-faint); }
.tm-src-web.is-cited svg { color: var(--tm-green); }
.tm-src-more summary { cursor: pointer; color: var(--tm-muted); font-size: 12px; font-weight: 700; }
.tm-src-more[open] summary { margin-bottom: 4px; }

@media (max-width: 640px) {
  .tm-kb-dropzone { flex-direction: column; align-items: flex-start; }
  .tm-kb-grid { grid-template-columns: 1fr; }
  .tm-kb-dl { grid-template-columns: 1fr; }
  .tm-flow-pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-flow-bars a { grid-template-columns: 1fr 70px 28px; }
  .tm-kb-q-name { max-width: 55%; }
}
@media (prefers-reduced-motion: reduce) {
  .tm-kb-skel, .tm-kb-q-ico, .tm-kb-dr-load svg { animation: none !important; }
}

/* Bộ não TransMind (màn Luồng điều phối) */
/* AI-MARK[TRANSMIND-UI:brain-360] 2026-11-12 08:58 (GMT+7) — style khu Bộ não: 7 lớp, thống kê, ý định, sổ nguồn, bảng vết | rel: transmind/transmind-kb.js brainHtml */
.tm-brain-layers { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.tm-brain-layers li { display: grid; grid-template-columns: auto auto 1fr; align-items: start; gap: 6px; padding: 9px 10px; border: 1px solid var(--tm-line); border-radius: 12px; background: linear-gradient(180deg, #fffaf5, #fff); }
.tm-brain-layers li > svg { margin-top: 1px; color: var(--tm-orange-d); }
.tm-brain-layers li > div { display: grid; gap: 1px; min-width: 0; }
.tm-brain-layers b { color: var(--tm-ink); font-size: 12.5px; font-weight: 800; }
.tm-brain-layers small { color: var(--tm-muted); font-size: 11px; line-height: 1.4; }
.tm-brain-h3 { margin: 4px 0 6px; color: var(--tm-ink); font-size: 13px; font-weight: 900; }
.tm-brain-h3 small { color: var(--tm-muted); font-weight: 600; }
.tm-brain-intents li { display: grid; grid-template-columns: minmax(110px, 160px) 1fr 32px; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--tm-text); }
.tm-brain-srcs { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-brain-srcs li { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--tm-soft); }
.tm-brain-srcs b { color: var(--tm-ink); font-size: 12.5px; }
.tm-brain-srcs span { color: var(--tm-muted); font-size: 11.5px; }
.tm-brain-tablewrap { overflow-x: auto; border: 1px solid var(--tm-line); border-radius: 10px; }
.tm-brain-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tm-brain-table th, .tm-brain-table td { padding: 6px 8px; border-bottom: 1px solid var(--tm-line); text-align: left; white-space: nowrap; }
.tm-brain-table th { background: var(--tm-soft); color: var(--tm-muted); font-weight: 800; }
.tm-brain-table tr:last-child td { border-bottom: 0; }
/* Nhãn định tuyến + kiểm số liệu dưới câu trả lời */
.tm-route { display: flex; flex-wrap: wrap; gap: 4px; }
.tm-route span { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 8px; border-radius: 999px; background: #f1f5f9; color: var(--tm-text); font-size: 11px; font-weight: 700; }
.tm-route .is-warn { background: #fffbeb; color: #92400e; }
.tm-route .is-cache { background: #ecfdf5; color: var(--tm-green); }

/* AI-MARK[TRANSMIND-UI:kb-360] 2026-11-12 09:33 (GMT+7) — nhãn trạng thái nguồn của bộ tài liệu nạp (bản lưu lịch sử / đề xuất / OCR) | rel: scripts/transmind-kb-import.mjs status_note */
.tm-kb-dl dd.tm-kb-status { color: #92400e; background: #fffbeb; border-radius: 8px; padding: 4px 8px; font-weight: 700; }

/* Từ điển khái niệm (#/kb/dict) */
/* AI-MARK[TRANSMIND-UI:concept-dict] 2026-11-12 13:31 (GMT+7) — style màn Từ điển khái niệm: 4 bước Từ điển → Nhóm → Đóng gói → Truy hồi, danh sách mã + chi tiết bám cột phải, dòng nén AI đọc, chip khái niệm dưới câu trả lời | rel: transmind/transmind-kb.js renderDictPage, transmind/transmind.js sourcesHtml */
.tm-dict-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; justify-self: stretch; width: 100%; margin: 6px 0 4px; padding: 0; list-style: none; }
.tm-dict-steps li { display: grid; grid-template-columns: auto 1fr; column-gap: 6px; align-items: center; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 12px; background: linear-gradient(180deg, #fffaf5, #fff); }
.tm-dict-steps li svg { color: var(--tm-orange-d); grid-row: span 2; }
.tm-dict-steps b { color: var(--tm-ink); font-size: 12.5px; }
.tm-dict-steps span { color: var(--tm-muted); font-size: 11.5px; font-weight: 600; }
.tm-dict-select { min-height: 36px; max-width: 240px; padding: 0 10px; border: 1px solid var(--tm-line); border-radius: 999px; background: var(--tm-card); color: var(--tm-text); font: inherit; font-size: 12.5px; font-weight: 700; }
.tm-dict-select:focus-visible, .tm-dict-row:focus-visible, .tm-dict-chip:focus-visible { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-dict-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 12px; }
.tm-dict-list { display: grid; gap: 6px; min-width: 0; }
.tm-dict-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; width: 100%; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: var(--tm-card); color: var(--tm-text); text-align: left; font: inherit; cursor: pointer; }
.tm-dict-row:hover { border-color: var(--tm-orange-line); }
.tm-dict-row.is-active { border-color: var(--tm-orange); box-shadow: inset 3px 0 0 var(--tm-orange); background: var(--tm-orange-bg); }
.tm-dict-code { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 6px; background: var(--tm-navy); color: #fff; font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; white-space: nowrap; }
.tm-dict-main { display: grid; gap: 3px; min-width: 0; }
.tm-dict-main b { color: var(--tm-ink); font-size: 13.5px; }
.tm-dict-main small { color: var(--tm-muted); font-weight: 700; }
.tm-dict-def { color: var(--tm-text); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.tm-dict-def i { color: var(--tm-faint); }
.tm-dict-side { display: grid; justify-items: end; gap: 4px; }
.tm-dict-n { color: var(--tm-muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.tm-dict-detail { position: sticky; top: 12px; display: grid; gap: 8px; min-width: 0; max-height: calc(100vh - 96px); overflow: auto; padding: 14px; border: 1px solid var(--tm-line); border-radius: 14px; background: var(--tm-card); }
.tm-dict-dh { display: grid; gap: 6px; }
.tm-dict-dh h2 { margin: 0; color: var(--tm-ink); font-size: 18px; line-height: 1.3; }
.tm-dict-dh .tm-dict-code { justify-self: start; }
.tm-dict-ai { display: grid; gap: 4px; padding: 10px; border-radius: 10px; background: var(--tm-navy); color: #e2e8f0; }
.tm-dict-ai small { display: inline-flex; align-items: center; gap: 4px; color: var(--tm-orange-line); font-size: 11px; font-weight: 800; }
.tm-dict-ai code, .tm-dict-cards code { font: 600 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.tm-dict-p { margin: 0; color: var(--tm-text); font-size: 13.5px; line-height: 1.6; }
.tm-dict-conf, .tm-dict-anchors { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tm-dict-conf li { padding: 8px 10px; border: 1px solid #fde68a; border-radius: 10px; background: #fffbeb; }
.tm-dict-conf b { color: #92400e; font-size: 12px; }
.tm-dict-conf p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; }
.tm-dict-anchors li { color: var(--tm-text); font-size: 12.5px; }
.tm-dict-chip { border: 0; cursor: pointer; text-decoration: none; font-family: inherit; }
.tm-dict-chip:hover { background: var(--tm-orange-bg); color: var(--tm-orange-d); }
.tm-dict-probe { display: grid; gap: 6px; margin: 10px 0; padding: 10px 12px; border: 1px dashed var(--tm-orange-line); border-radius: 12px; background: var(--tm-orange-bg); }
.tm-dict-probe > b { display: inline-flex; align-items: center; gap: 6px; color: var(--tm-ink); font-size: 12.5px; }
.tm-dict-cards { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.tm-dict-cards li { padding: 6px 8px; border-radius: 8px; background: var(--tm-card); }
.tm-concepts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 2px; }
.tm-concepts > span { display: inline-flex; align-items: center; gap: 4px; color: var(--tm-muted); font-size: 11.5px; font-weight: 800; }
.tm-concepts a { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 11px; font-weight: 800; text-decoration: none; }
.tm-concepts a:hover, .tm-concepts a:focus-visible { background: var(--tm-orange-bg); color: var(--tm-orange-d); outline: none; }
@media (max-width: 900px) {
  .tm-dict-cols { grid-template-columns: 1fr; }
  .tm-dict-detail { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .tm-dict-row { grid-template-columns: auto minmax(0, 1fr); }
  .tm-dict-side { grid-column: 1 / -1; justify-items: start; grid-auto-flow: column; justify-content: start; }
  .tm-dict-select { max-width: 100%; flex: 1 1 100%; }
}

/* Khoanh vùng hội thoại + nút ghim nguồn */
/* AI-MARK[TRANSMIND-UI:scope] 2026-11-12 14:40 (GMT+7) — thanh "Đang khoanh vùng / Đang bàn" trên ô soạn, nút ghim cạnh nguồn kho dưới câu trả lời, nút "Hỏi TransMind trong tài liệu này" ở ngăn chi tiết | rel: transmind/transmind.js renderScope, transmind/transmind-kb.js askIn */
.tm-scope { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 6px; }
.tm-scope[hidden] { display: none; }
.tm-scope-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; max-width: 100%; padding: 0 10px; border-radius: 999px; background: var(--tm-soft); color: var(--tm-text); font-size: 12px; font-weight: 600; }
.tm-scope-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-scope-chip b { color: var(--tm-ink); font-weight: 800; }
.tm-scope-chip svg { flex: 0 0 auto; color: var(--tm-muted); }
.tm-scope-chip.is-pinned { background: var(--tm-orange-bg); box-shadow: inset 0 0 0 1px var(--tm-orange-line); }
.tm-scope-chip.is-pinned svg { color: var(--tm-orange-d); }
.tm-scope-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px; border: 1px solid var(--tm-line); border-radius: 999px; background: var(--tm-card); color: var(--tm-text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.tm-scope-btn:hover { border-color: var(--tm-orange-line); color: var(--tm-orange-d); }
.tm-scope-btn:focus-visible, .tm-src-pin:focus-visible { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-src-item { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tm-src-item .tm-src-kb { flex: 1 1 auto; }
.tm-src-pin { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--tm-faint); cursor: pointer; }
.tm-src-pin:hover { background: var(--tm-orange-bg); color: var(--tm-orange-d); }
.tm-kb-askin { margin: 4px 0 8px; }
@media (max-width: 640px) {
  .tm-scope-chip { flex: 1 1 100%; }
}

/* Trao đổi tiếp: gợi ý + nút nhanh dưới câu trả lời mới nhất */
/* AI-MARK[TRANSMIND-UI:follow-ups] 2026-11-12 14:39 (GMT+7) — gợi ý hỏi tiếp + Phản biện / Chi tiết hơn / Áp dụng cho tôi; chip hành vi hội thoại | rel: transmind/transmind.js followHtml */
.tm-follow { display: grid; gap: 6px; margin: -4px 0 8px 44px; }
.tm-follow-sug { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-sug--follow { max-width: 100%; }
.tm-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-quick-btn { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 11px; border: 1px dashed var(--tm-orange-line); border-radius: 999px; background: var(--tm-card); color: var(--tm-orange-d); font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.tm-quick-btn:hover { background: var(--tm-orange-bg); }
.tm-quick-btn:focus-visible { outline: 2px solid var(--tm-orange); outline-offset: 2px; }
.tm-route .is-act { background: var(--tm-orange-bg); color: var(--tm-orange-d); }
@media (max-width: 640px) { .tm-follow { margin-left: 0; } }

/* Kết nối Telegram (hộp thoại từ menu tài khoản) */
/* AI-MARK[TRANSMIND-UI:telegram-link] 2026-11-12 14:39 (GMT+7) — hộp thoại liên kết Telegram: nút mở bot, mã /start, ghi chú hết hạn | rel: transmind/transmind.js openTelegramDialog */
.tm-tg-card p { margin: 8px 0; color: var(--tm-text); font-size: 13.5px; line-height: 1.55; }
.tm-tg-open { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.tm-tg-code code { padding: 2px 6px; border-radius: 6px; background: var(--tm-soft); color: var(--tm-ink); font: 700 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; }

/* Bảo vệ dữ liệu kho: chờ duyệt dùng chung, thùng rác, lịch sử tài liệu */
/* AI-MARK[TRANSMIND-UI:kb-protect] 2026-11-13 10:43 (GMT+7) — style huy hiệu/ghi chú chờ duyệt, thẻ thùng rác, lịch sử tài liệu; 2026-11-13 11:24 giai đoạn 2: khối Phiên bản, bộ chọn bản cũ, nhãn Hạn chế, form ngày hiệu lực, ô Hạn chế khi nạp; chỉ dùng token --tm-* + sắc cảnh báo sẵn có (#fffbeb/#92400e), không z-index mới (hộp xác nhận là <dialog> native) | rel: transmind/transmind-kb.js */
.tm-kb-kind--pending { color: #92400e; }
.tm-kb-kind--pending.is-active { background: #b45309; color: #fff; }
.tm-kb-open .tm-kb-pending-why { display: flex; align-items: flex-start; gap: 6px; padding: 4px 8px; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; font-weight: 700; -webkit-line-clamp: unset; overflow: visible; }
.tm-kb-pending-why svg { flex: 0 0 auto; margin-top: 2px; }
.tm-kb-q-pend { display: flex; align-items: flex-start; gap: 6px; margin-top: 4px; color: #92400e; font-weight: 700; }
.tm-kb-q-pend svg { flex: 0 0 auto; margin-top: 2px; }
.tm-kb-pending { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid #fcd34d; border-radius: 12px; background: #fffbeb; color: #92400e; font-size: 13px; line-height: 1.5; }
.tm-kb-pending > svg { flex: 0 0 auto; margin-top: 2px; color: #b45309; }
.tm-kb-pending > div { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.tm-kb-pending ul { margin: 0; padding-left: 18px; font-weight: 600; }
.tm-kb-pending small { font-size: 12px; font-weight: 600; }
.tm-trash-item { display: grid; align-content: start; gap: 6px; padding: 12px 14px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; }
.tm-trash-item .tm-kb-title { text-decoration: none; }
.tm-trash-item .tm-kb-title:hover { color: var(--tm-orange-d); text-decoration: underline; }
.tm-trash-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tm-kb-audit { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.tm-kb-audit li { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 10px; background: #fff; }
.tm-kb-audit li > svg { flex: 0 0 auto; margin-top: 3px; color: var(--tm-orange-d); }
.tm-kb-audit li > div { display: grid; gap: 2px; min-width: 0; font-size: 12.5px; }
.tm-kb-audit b { color: var(--tm-ink); font-weight: 800; }
.tm-kb-audit small, .tm-kb-audit span { color: var(--tm-muted); font-weight: 600; overflow-wrap: anywhere; }
/* Giai đoạn 2: phiên bản · ngày hiệu lực · nhãn Hạn chế (nằm trong ngăn chi tiết sẵn có, không overlay riêng) */
.tm-kb-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tm-kb-check input { accent-color: var(--tm-orange-d); }
.tm-kb-valflag { color: var(--tm-muted); font-weight: 700; }
.tm-kb-valflag.is-warn { color: #92400e; }
.tm-kb-valform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 10px; background: var(--tm-soft); }
.tm-kb-valform label { display: grid; gap: 2px; color: var(--tm-muted); font-size: 11.5px; font-weight: 700; }
.tm-kb-valform input[type="date"] { min-height: 32px; border: 1px solid var(--tm-line); border-radius: 8px; padding: 0 8px; background: #fff; color: var(--tm-ink); font: 600 13px/1.2 inherit; }
.tm-kb-valform input[type="date"]:focus { outline: 2px solid var(--tm-orange-line); outline-offset: 1px; }
.tm-kb-valform small { flex: 1 0 100%; color: var(--tm-muted); font-size: 11.5px; font-weight: 600; line-height: 1.45; }
.tm-kb-label { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: #fff; }
.tm-kb-label.is-on { border-color: #fcd34d; background: #fffbeb; }
.tm-kb-label-txt { display: flex; align-items: flex-start; gap: 8px; min-width: 0; flex: 1 1 220px; font-size: 12.5px; }
.tm-kb-label-txt > svg { flex: 0 0 auto; margin-top: 2px; color: var(--tm-orange-d); }
.tm-kb-label.is-on .tm-kb-label-txt > svg { color: #b45309; }
.tm-kb-label-txt > div { display: grid; gap: 2px; min-width: 0; }
.tm-kb-label-txt b { color: var(--tm-ink); font-weight: 800; }
.tm-kb-label-txt span { color: var(--tm-muted); font-weight: 600; line-height: 1.45; }
.tm-kb-ver { display: grid; gap: 8px; margin-bottom: 4px; }
.tm-kb-ver-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tm-kb-ver-list li { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 600; color: var(--tm-ink); }
.tm-kb-ver-list li > svg { flex: 0 0 auto; margin-top: 3px; color: var(--tm-orange-d); }
.tm-kb-ver-list a { color: var(--tm-orange-d); font-weight: 800; overflow-wrap: anywhere; }
.tm-kb-ver-list small { color: var(--tm-muted); font-weight: 600; }
.tm-kb-ver-note { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 6px 10px; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; font-weight: 700; line-height: 1.5; }
.tm-kb-ver-note svg { flex: 0 0 auto; margin-top: 2px; }
.tm-kb-ver-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tm-kb-picker { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--tm-line); border-radius: 12px; background: var(--tm-soft); }
.tm-kb-picker-h { margin: 0; color: var(--tm-text); font-size: 12.5px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.tm-kb-picker .tm-btn { justify-self: start; }
.tm-kb-pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.tm-kb-pick-item { display: grid; gap: 2px; width: 100%; padding: 8px 10px; border: 1px solid var(--tm-line); border-radius: 10px; background: #fff; text-align: left; cursor: pointer; font: inherit; }
.tm-kb-pick-item:hover, .tm-kb-pick-item:focus-visible { border-color: var(--tm-orange-line); outline: none; background: var(--tm-orange-bg); }
.tm-kb-pick-item b { color: var(--tm-ink); font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.tm-kb-pick-item small { color: var(--tm-muted); font-size: 11.5px; font-weight: 600; overflow-wrap: anywhere; }
