/* VIP AI BRAIN — G01 HTML-first. Thuần CSS, không import, không font ngoài.
   Màu dùng qua biến (token); bộ sáng/tối đổi bằng [data-theme]. */

/* ---------- 1. Token ---------- */
:root, :root[data-theme="dark"] {
  --bg: #07101d; --panel: #0d1829; --panel2: #12233b; --line: #243a58; --text: #eef5ff; --muted: #a3b3c7;
  --blue: #4f8cff; --green: #22c55e; --red: #ef4444; --orange: #f59e0b; --purple: #8b5cf6; --teal: #2dd4bf; --focus: #ffd24d;
  --topbar: #08111e; --input: #091322;
  --link: #8fb6ff; --btn: #2f6fe6; --btn-text: #ffffff; --btn2: #21334d; --btn-danger: #8f2a2a;
  --ok-text: #8df0ad; --warn-text: #ffd483; --bad-text: #ffb4b0; --off-text: #d2dceb; --info-text: #a9c7ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f6fb; --panel: #ffffff; --panel2: #e9eef7; --line: #c9d4e5; --text: #0d1829; --muted: #4b5b72;
  --blue: #2f6fe6; --green: #15803d; --red: #b91c1c; --orange: #b45309; --purple: #6d28d9; --teal: #0f766e; --focus: #1d4ed8;
  --topbar: #ffffff; --input: #ffffff;
  --link: #1d4ed8; --btn: #2f6fe6; --btn-text: #ffffff; --btn2: #d9e2f0; --btn-danger: #b91c1c;
  --ok-text: #166534; --warn-text: #92400e; --bad-text: #991b1b; --off-text: #334155; --info-text: #1e40af;
  --shadow: 0 10px 30px rgba(13, 24, 41, .18);
  color-scheme: light;
}

/* ---------- 2. Nền tảng ---------- */
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}
body.modal-open { overflow: hidden; }
a { color: var(--link); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--btn); color: var(--btn-text); padding: 8px 12px; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.accent { color: var(--blue); }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

/* ---------- 3. Vỏ ứng dụng ---------- */
.app {
  display: grid; grid-template-columns: 230px minmax(0, 1fr); grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "side main"; min-height: 100vh;
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--topbar); position: sticky; top: 0; z-index: 30; min-width: 0;
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: .01em; white-space: nowrap; }
.brand span { color: var(--blue); }
.workspace { color: var(--muted); font-size: 13px; padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.topbar .menu-toggle { display: none; }
.btn-icon .ico { font-size: 16px; line-height: 1; }

.sidebar {
  grid-area: side; background: var(--topbar); border-right: 1px solid var(--line); padding: 12px 10px;
  overflow-y: auto; min-width: 0;
}
.nav-group { margin-bottom: 14px; }
.nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 4px 10px; margin: 0 0 2px; }
.sidebar a {
  display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; padding: 8px 10px;
  border-radius: 8px; margin: 2px 0; font-size: 14px; min-height: 40px;
}
.sidebar a .ico { width: 18px; text-align: center; color: var(--muted); }
.sidebar a:hover { background: var(--panel2); }
.sidebar a[aria-current="page"] { background: var(--panel2); font-weight: 700; box-shadow: inset 3px 0 0 var(--blue); }
.sidebar a[aria-current="page"] .ico { color: var(--blue); }
.sidebar-foot { margin-top: 10px; padding: 8px 10px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }

.content { grid-area: main; padding: 22px 24px 40px; min-width: 0; }
.content:focus { outline: none; }
.content:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

.page-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-header p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 4. Khối ---------- */
.grid { display: grid; gap: 14px; margin-bottom: 14px; min-width: 0; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; margin-bottom: 14px; }
.grid > .panel { margin-bottom: 0; }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-title h2, .panel-title h3 { font-size: 14px; font-weight: 700; }
.panel-body { padding: 16px; min-width: 0; }
.panel-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.state { margin: 0; font-size: 14px; }
.state-empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.state-error { color: var(--bad-text); padding: 16px 8px; }
.state-error .btn { margin-top: 10px; }

.badge { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; border: 1px dashed; white-space: nowrap; vertical-align: middle; }
.badge-mock { color: var(--warn-text); border-color: var(--orange); background: rgba(245, 158, 11, .12); }
.badge-coming { color: var(--purple); border-color: var(--purple); background: rgba(139, 92, 246, .12); }
/* G02.5: badge nguồn dữ liệu BACKEND (ds-api.js dò /api/health) */
.badge-backend { color: var(--ok-text); border-color: var(--green); background: rgba(34, 197, 94, .12); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.pill-ok   { background: rgba(34, 197, 94, .16);   color: var(--ok-text); }
.pill-warn { background: rgba(245, 158, 11, .16);  color: var(--warn-text); }
.pill-off  { background: rgba(150, 167, 189, .18); color: var(--off-text); }
.pill-bad  { background: rgba(239, 68, 68, .16);   color: var(--bad-text); }
.pill-info { background: rgba(79, 140, 255, .16);  color: var(--info-text); }

.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 4px; word-break: break-word; }
.stat-hint { margin-top: 4px; font-size: 12px; color: var(--muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.list > li { min-width: 0; }
.grow.ellipsis { flex-basis: 0; }
.list-rows > li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.list-rows > li:last-child { border-bottom: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table-wrap { overflow-x: auto; max-width: 100%; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--panel2); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: var(--blue); }

/* ---------- 5. Biểu mẫu ---------- */
.form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; min-width: 0; }
label, legend { font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 9px 10px; font: inherit; min-height: 40px;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--blue); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
textarea { min-height: 80px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0; min-width: 0; }
.radio-list { display: grid; gap: 6px; }
.radio-list label { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-weight: 500; font-size: 13px; cursor: pointer; }
.radio-list label small { display: block; color: var(--muted); font-weight: 400; }
.check-inline { display: inline-flex; gap: 8px; align-items: center; color: var(--text); font-weight: 500; font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px;
  padding: 9px 14px; min-height: 40px; font: inherit; font-weight: 700; color: var(--btn-text); background: var(--btn);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; }
.btn-secondary { background: var(--btn2); color: var(--text); }
.btn-danger { background: var(--btn-danger); }
.btn-ghost { background: transparent; color: var(--link); border: 1px solid var(--line); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.chip { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; font: inherit; }
.chip:hover { border-color: var(--blue); }
.filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(130px, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters-3 { grid-template-columns: repeat(3, minmax(120px, 1fr)) auto; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.toggle .sw { width: 36px; height: 20px; border-radius: 999px; background: var(--line); position: relative; display: inline-block; }
.toggle .sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); }
.note { border: 1px solid var(--line); border-left: 4px solid var(--blue); background: var(--panel2); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.note-warn { border-left-color: var(--orange); }
.note-bad { border-left-color: var(--red); }
.note-ok { border-left-color: var(--green); }

/* ---------- 6. Chat / Playground ---------- */
.chat { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 14px; min-width: 0; }
.chat-side { display: grid; gap: 12px; align-content: start; }
.chat-main { display: flex; flex-direction: column; min-height: 520px; }
.chat-log { flex: 1 1 auto; overflow-y: auto; display: grid; gap: 12px; align-content: start; padding: 4px 2px; max-height: 60vh; }
.msg { max-width: 86%; background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 14px; }
.msg-user { margin-left: auto; background: rgba(79, 140, 255, .14); border-color: rgba(79, 140, 255, .4); }
.msg-ai ul { margin: 6px 0; padding-left: 18px; }
.msg-ai p { margin: 0 0 8px; }
.msg-meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: grid; gap: 3px; }
.msg-actions { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: end; margin-top: 12px; }
.chat-form textarea { min-height: 72px; }
.typing { color: var(--muted); font-style: italic; }
.pg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pg-col .msg { max-width: none; }

/* ---------- 7. Sơ đồ luồng, biểu đồ ---------- */
.flow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.flow-node { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; text-align: center; }
.flow-node.hub { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.flow-node small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.flow-arrow { color: var(--muted); font-size: 18px; }
.flow-stack { display: grid; gap: 4px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); }
.chart-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 0; }
.chart-bar { width: 100%; min-height: 0; }
.chart-bar.local { background: var(--green); }
.chart-bar.deepseek { background: var(--blue); }
.chart-bar.claude { background: var(--purple); }
.chart-bar.chatgpt { background: var(--teal); }
.chart-empty { width: 100%; height: 2px; background: var(--line); }
.chart-labels { display: flex; gap: 6px; font-size: 10px; color: var(--muted); }
.chart-labels span { flex: 1 1 0; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; margin-top: 8px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.dot.local { background: var(--green); } .dot.deepseek { background: var(--blue); } .dot.claude { background: var(--purple); } .dot.chatgpt { background: var(--teal); }
.bar-line { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-line > span { display: block; height: 100%; background: var(--blue); }
.bar-line > span.warn { background: var(--orange); } .bar-line > span.bad { background: var(--red); }

/* ---------- 8. Tabs, Knowledge, Settings ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 9px 12px; font: inherit; font-weight: 700; cursor: pointer; min-height: 40px; }
.tab[aria-selected="true"], .tab[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--blue); }
tr.ngoai-bo-loc { opacity: .5; }
.tab:hover { color: var(--text); }
.two-col { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; }
.kho-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.kho-item { width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 10px; padding: 9px 10px; color: var(--text); font: inherit; cursor: pointer; display: grid; gap: 4px; }
.kho-item:hover { background: var(--panel2); }
.kho-item[aria-current="true"] { background: var(--panel2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--blue); }
.kho-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 10px 2px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.dropzone.over { border-color: var(--blue); background: rgba(79, 140, 255, .08); }
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; }
.settings-nav { display: grid; gap: 4px; align-content: start; }
.settings-nav .tab { text-align: left; border-bottom: 0; border-left: 3px solid transparent; border-radius: 0 8px 8px 0; }
.settings-nav .tab[aria-selected="true"] { border-left-color: var(--blue); background: var(--panel2); }
.settings-select { display: none; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.timeline li { position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.timeline time { display: block; color: var(--muted); font-size: 12px; }

/* ---------- 9. Skeleton, toast, modal ---------- */
.skeleton { background: linear-gradient(90deg, var(--panel2) 25%, var(--line) 50%, var(--panel2) 75%); background-size: 200% 100%; border-radius: 8px; animation: sk 1.2s infinite; min-height: 14px; }
.skeleton.h-lg { min-height: 60px; } .skeleton.h-xl { min-height: 140px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-stack { display: grid; gap: 10px; }

.toast-wrap { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
.toast-ok { border-left-color: var(--green); } .toast-warn { border-left-color: var(--orange); } .toast-error { border-left-color: var(--red); }
.toast .ico { font-weight: 800; }
.toast .btn-x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 4px; min-width: 32px; min-height: 32px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(720px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; flex: 1 1 auto; min-width: 0; }
.modal-body { padding: 16px; overflow-y: auto; min-width: 0; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal .btn-x { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }

/* ---------- 10. Responsive ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: 200px minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters, .filters-3 { grid-template-columns: 1fr 1fr; }
  .chat { grid-template-columns: 250px minmax(0, 1fr); }
  .two-col { grid-template-columns: 260px minmax(0, 1fr); }
  .settings { grid-template-columns: 190px minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .topbar .menu-toggle { display: inline-flex; }
  .workspace { display: none; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 85vw); z-index: 40; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow); padding-top: 14px;
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { display: block; }
  .content { padding: 16px 14px 32px; }
  .grid-2, .grid-3, .grid-4, .pg-grid, .chat, .two-col, .settings { grid-template-columns: minmax(0, 1fr); }
  .filters, .filters-3 { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .chat-main { min-height: 0; }
  .chat-log { max-height: 50vh; }
  .msg { max-width: 100%; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal { width: 100%; max-height: 100vh; border-radius: 0; }
  .settings-nav { display: none; }
  .settings-select { display: grid; }
  .page-header h1 { font-size: 20px; }
  .btn { min-height: 44px; }
}
@media (max-width: 390px) {
  html { font-size: 13px; }
  .content { padding: 10px; }
  .stat-value { font-size: 18px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { font-size: 16px; }
  .btn-icon .txt { display: none; }
  .panel-body { padding: 12px; }
  th, td { padding: 7px 8px; }
}

/* ---------- 12. Dashboard nâng cấp: KPI 6 thẻ, grid 12 cột, router động, sức khoẻ, thanh ngang ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-grid > .panel { margin-bottom: 0; }
.kpi .panel-body { padding: 12px 14px; }
.kpi .stat-value { font-size: 21px; }
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; min-width: 0; }
.grid-12 > * { min-width: 0; }
.grid-12 > * > .panel { margin-bottom: 0; height: 100%; }
.col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; }
.tabs-mini { margin: 0; border: 0; gap: 2px; }
.tabs-mini .tab { padding: 4px 8px; min-height: 32px; font-size: 12px; }
.list-compact { font-size: 13px; }
.list-compact > li { padding: 6px 0; }
.table-compact { font-size: 12px; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.router-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(140px, 1fr) auto; gap: 8px; align-items: end; margin-bottom: 12px; }
.router-kq { margin: 10px 0 0; font-size: 13px; min-height: 20px; }
.flow-dyn { gap: 6px; }
.flow-dyn .flow-node { padding: 6px 9px; font-size: 12px; transition: background-color .2s, border-color .2s, box-shadow .2s, opacity .2s; border-width: 2px; border-style: dashed; }
.flow-dyn .flow-node[data-tt="dang"] { border-style: solid; border-color: var(--blue); background: rgba(79, 140, 255, .18); box-shadow: 0 0 0 3px rgba(79, 140, 255, .25); animation: nhip 1s ease-in-out infinite; }
.flow-dyn .flow-node[data-tt="xong"] { border-style: solid; border-color: var(--green); background: rgba(34, 197, 94, .12); }
.flow-dyn .flow-node.chon { box-shadow: inset 0 0 0 2px var(--green); }
.flow-dyn .flow-node.chon::after { content: " ★ chọn"; color: var(--ok-text); font-weight: 800; font-size: 11px; }
.flow-dyn .flow-node.mo { opacity: .45; }
@keyframes nhip { 0%, 100% { box-shadow: 0 0 0 3px rgba(79, 140, 255, .25); } 50% { box-shadow: 0 0 0 6px rgba(79, 140, 255, .08); } }
.health-list > li { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.health-list > li:last-child { border-bottom: 0; }
.hbar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--line); }
.hbar-seg { display: block; height: 100%; }
.hbar-seg.local { background: var(--green); } .hbar-seg.deepseek { background: var(--blue); } .hbar-seg.claude { background: var(--purple); } .hbar-seg.chatgpt { background: var(--teal); }
.bar-line > span.local { background: var(--green); } .bar-line > span.deepseek { background: var(--blue); } .bar-line > span.claude { background: var(--purple); } .bar-line > span.chatgpt { background: var(--teal); }
.chart-sm { height: 140px; }

/* ---------- 13. AI Command Center: 3 vùng + drawer, planner, timeline, 4 ngăn ---------- */
.cc { display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; gap: 14px; align-items: start; min-width: 0; }
.cc-drawer-btn { display: none; }
.cc-left { margin-bottom: 0; }
.cc-left-body { padding: 10px; }
.cc-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; max-height: 60vh; overflow-y: auto; }
.cc-item { width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; color: var(--text); font: inherit; cursor: pointer; display: grid; gap: 2px; }
.cc-item strong { display: block; }
.cc-item:hover { background: var(--panel2); }
.cc-item[aria-current="true"] { background: var(--panel2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--blue); }
.cc-main { display: flex; flex-direction: column; min-height: 560px; margin-bottom: 0; }
.cc-main > .panel-body { padding: 12px 16px 16px; }
.cc-top h2 { font-size: 15px; }
.cc-mode { border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.field-inline { grid-template-columns: auto minmax(120px, 1fr); align-items: center; gap: 8px; }
.field-inline select { min-height: 34px; padding: 5px 8px; }
.radio-row { display: flex; gap: 14px; flex-wrap: wrap; }
.radio-row label { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.radio-row label small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.cc-goi-y { font-size: 13px; }
.cc-log { max-height: 52vh; min-height: 200px; margin: 0 16px; padding-top: 12px; }
.cc-main > .chat-form { margin: 12px 16px 0; }
.cc-main > .row, .cc-main > p { margin-left: 16px; margin-right: 16px; }
.cc-main > p:last-child { margin-bottom: 14px; }
.msg-time { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }
.msg-loi { border-color: var(--red); }
.tl { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; border-top: 1px dashed var(--line); padding-top: 8px; }
.tl li { display: grid; grid-template-columns: auto 1fr; gap: 1px 6px; align-items: baseline; }
.tl .tl-ico { font-weight: 800; grid-row: span 3; }
.tl-xong .tl-ico { color: var(--ok-text); } .tl-loi .tl-ico { color: var(--bad-text); } .tl-cho .tl-ico { color: var(--muted); }
.tl-loi .tl-ten { color: var(--bad-text); font-weight: 700; }
.tl-cho .tl-ten { color: var(--muted); }
.tl-time { color: var(--muted); font-size: 11px; }
.tl-ghi { grid-column: 2; }
.planner { margin: 10px 16px 0; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; background: var(--panel2); }
.planner-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.planner-list li { display: flex; gap: 8px; align-items: center; }
.planner-list input[type="checkbox"] { width: 16px; height: 16px; }
.pl-ico { font-weight: 800; width: 16px; text-align: center; }
.pl-cho { color: var(--muted); } .pl-dang .pl-ico { color: var(--blue); } .pl-xong .pl-ico { color: var(--ok-text); }
.cc-right { display: grid; gap: 10px; align-content: start; }
.ngan { margin-bottom: 0; }
.ngan-head { margin: 0; font-size: 13px; }
.ngan-btn { width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; padding: 10px 14px; cursor: pointer; display: flex; gap: 8px; align-items: center; min-height: 40px; border-radius: 14px; }
.ngan-btn:hover { background: var(--panel2); }
.ngan-caret { color: var(--muted); width: 12px; }
.ngan-body { padding: 0 14px 12px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.ngan-body .list-compact > li { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ngan-body .list-compact > li:last-child { border-bottom: 0; }
.ngan-body code { word-break: break-all; }
.cc-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 35; }
.ss-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ss-grid .panel { margin-bottom: 0; }
.ss-grid h3 { font-size: 14px; }
.modal.modal-wide { width: min(1240px, 100%); }

/* ---------- 14. Team Mode: switch + sơ đồ 7 nút với 5 trạng thái (icon + chữ + màu + viền) ---------- */
.team-box { display: grid; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 32px; }
.switch .sw { width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; display: inline-block; transition: background-color .15s; }
.switch .sw::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch[aria-checked="true"] .sw { background: var(--green); }
.switch[aria-checked="true"] .sw::after { background: #fff; transform: translateX(14px); }
.switch:disabled { opacity: .6; cursor: not-allowed; }
.team-flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; counter-reset: nut; }
.team-node { position: relative; border: 2px dashed var(--line); border-radius: 10px; padding: 8px 6px 8px; text-align: center; font-size: 12px; display: grid; gap: 4px; background: var(--panel2); color: var(--muted); min-width: 0; }
.team-node + .team-node::before { content: "→"; position: absolute; left: -9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }
.tn-ten { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.tn-tt { font-size: 11px; font-weight: 700; }
.team-node.nut-cho { border-style: dashed; border-color: var(--line); color: var(--muted); }
.team-node.nut-dang { border-style: solid; border-color: var(--blue); color: var(--info-text); background: rgba(79, 140, 255, .16); box-shadow: 0 0 0 3px rgba(79, 140, 255, .25); animation: nhip 1s ease-in-out infinite; }
.team-node.nut-xong { border-style: solid; border-color: var(--green); color: var(--ok-text); background: rgba(34, 197, 94, .12); }
.team-node.nut-loi { border-style: double; border-color: var(--red); color: var(--bad-text); background: rgba(239, 68, 68, .14); }
.team-node.nut-bo-qua { border-style: dotted; border-color: var(--line); color: var(--muted); opacity: .55; text-decoration: line-through; }
.team-node.nut-bo-qua .tn-tt { text-decoration: none; }
.team-cards { display: grid; gap: 10px; }
.team-card { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: grid; gap: 6px; }
.team-card.nut-xong { border-left-color: var(--green); } .team-card.nut-loi { border-left-color: var(--red); } .team-card.nut-bo-qua { border-left-color: var(--line); opacity: .7; }
.team-card.team-final { border-left-color: var(--blue); background: rgba(79, 140, 255, .08); }
.team-card .badge { justify-self: start; }
.msg-team { max-width: 100%; }

/* ---------- 15. Responsive cho phần nâng cấp ---------- */
@media (max-width: 1439px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-12 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-4, .col-6, .col-8 { grid-column: span 1; }
  .col-8 { grid-column: span 2; }
  .cc { grid-template-columns: 220px minmax(0, 1fr) 280px; }
  .team-flow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .team-node + .team-node::before { display: none; }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-12 { grid-template-columns: minmax(0, 1fr); }
  .col-8 { grid-column: span 1; }
  .router-form { grid-template-columns: 1fr; }
  .cc { grid-template-columns: 260px minmax(0, 1fr); }
  .cc-drawer-btn { display: inline-flex; }
  .cc-drawer-btn-trai { display: none; }
  /* drawer đóng: visibility hidden SAU khi trượt xong (delay = thời gian transform) → Tab/SR không vào; JS còn đặt inert */
  .cc-right { position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 90vw); z-index: 40; background: var(--bg); padding: 14px; overflow-y: auto; transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: var(--shadow); }
  .cc-right.open { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }
  .cc-backdrop.open { display: block; }
  .ss-grid { grid-template-columns: 1fr; }
  .radio-row { flex-direction: column; gap: 8px; }
  .team-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .cc { grid-template-columns: minmax(0, 1fr); }
  .cc-drawer-btn-trai { display: inline-flex; }
  .cc-left { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 90vw); z-index: 40; background: var(--bg); overflow-y: auto; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: var(--shadow); border-radius: 0; }
  .cc-left.open { transform: none; visibility: visible; transition: transform .2s ease, visibility 0s; }
  .cc-main { min-height: 0; }
  .cc-log { max-height: 46vh; margin: 0 10px; }
  .cc-main > .chat-form, .cc-main > .row, .cc-main > p, .planner { margin-left: 10px; margin-right: 10px; }
  .cc-main > .panel-body { padding: 10px; }
  .team-flow { grid-template-columns: minmax(0, 1fr); }
  .team-node + .team-node::before { content: "↓"; display: block; position: static; transform: none; }
  .field-inline { grid-template-columns: 1fr; }
  .tl { flex-direction: column; gap: 4px; }
}

/* ---------- 11. Giảm chuyển động, in ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .skeleton { background: var(--panel2); }
}

/* ---------- 12. G03.8 — Knowledge backend + RAG (khối trích dẫn, chọn kho) ---------- */
.cc-trich-dan, .cc-rag { margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--panel2); }
.cc-trich-dan > summary, .cc-rag > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); }
.cc-trich-dan ul, .cc-rag .radio-list { margin-top: 8px; }
.cc-rag .radio-list { display: flex; flex-wrap: wrap; gap: 8px 16px; }

/* G06 — Nguồn kết nối: dùng bộ màu sáng/tối chung, giới hạn trong trang. */
.cn-page { max-width: 1480px; margin: 0 auto; }
.cn-page .cn-banner { margin-bottom: 22px; line-height: 1.7; }
.cn-page .cn-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cn-page .cn-toolbar p { margin: 0; max-width: 65ch; }
.cn-page .cn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cn-page .cn-card { min-width: 0; overflow: hidden; }
.cn-page .cn-card .panel-title { flex-wrap: wrap; gap: 12px; }
.cn-page .cn-eyebrow { font-size: 12px; font-weight: 750; letter-spacing: .08em; color: var(--warn-text); }
.cn-page .kv { margin: 18px 0; }
.cn-page .kv dd, .cn-page td, .cn-page th { overflow-wrap: anywhere; }
.cn-page .cn-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.cn-page .cn-actions .btn, .cn-page .cn-config .btn { min-height: 44px; }
.cn-page .cn-config fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 18px; background: var(--panel2); }
.cn-page .cn-config legend { font-size: 13px; padding: 0 6px; font-weight: 650; }
.cn-page .cn-check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.cn-page .cn-check input { width: 20px; height: 20px; }
.cn-page .cn-result, .cn-page .cn-history { display: grid; gap: 12px; min-width: 0; }
.cn-page .cn-result:empty { display: none; }
.cn-page .cn-history { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 18px; }
.cn-page .cn-history h3 { font-size: 16px; }
.cn-page .table-wrap { max-height: 380px; overflow: auto; }
.cn-page pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.cn-page .note { overflow-wrap: anywhere; }
@media (max-width: 1100px) { .cn-page .cn-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .cn-page .cn-actions { flex-direction: column; } .cn-page .cn-actions .btn { width: 100%; } }

/* ===================== G07.8 — MÀN VẬN HÀNH #/ops =====================
   Dùng NGUYÊN hệ token màu ở :root (dark + light), không thêm biến mới và không
   hard-code mã màu nào — một màu hard-code ở đây là một ô không đổi theo chủ đề sáng,
   và nó chỉ lộ ra khi có người bật chủ đề sáng, tức là muộn.
   `overflow-wrap: anywhere` khắp nơi là cố ý: lý do UNKNOWN của backend là câu dài, và
   một câu dài không ngắt được làm tràn ngang ở 390 px. */
.ops-page { min-width: 0; }
.ops-page .ops-banner { margin-bottom: 12px; overflow-wrap: anywhere; }
.ops-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ops-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- thanh 9 tab: cuộn ngang trong chính nó, không đẩy trang tràn ---- */
.ops-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.ops-tab { font-size: 12px; padding: 6px 10px; }
.ops-tab.dang { background: var(--btn); color: var(--btn-text); border-color: var(--btn); font-weight: 800; }
.ops-tab-tieu-de { font-size: 16px; margin-bottom: 10px; }
#ops-panel { min-width: 0; }

/* ---- nhãn nguồn + ô giá trị ---- */
.pill-nguon { font-size: 10px; letter-spacing: .04em; padding: 2px 7px; }
.ops-gt { font-weight: 700; margin-left: 4px; overflow-wrap: anywhere; }
.ops-gt-khuyet { color: var(--muted); font-weight: 800; }
.ops-vi-sao { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; overflow-wrap: anywhere; }
.ops-kv { font-size: 13px; }
.ops-kv dd { overflow-wrap: anywhere; }
.ops-no { color: var(--warn-text); overflow-wrap: anywhere; }
.ops-pham-vi { overflow-wrap: anywhere; margin-top: 8px; }
.ops-khuyet { margin: 10px 0; overflow-wrap: anywhere; }
.ops-ds { margin: 4px 0 0 18px; padding: 0; font-size: 12.5px; }
.ops-ds li { overflow-wrap: anywhere; margin-bottom: 4px; }

/* ---- lưới thẻ: 1440 hai cột, 1024 trở xuống một cột ---- */
.ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 12px; }
.ops-khoi { margin-bottom: 12px; }
.ops-khoi .table-wrap { max-height: 420px; overflow: auto; }
.ops-page pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ops-page .note { overflow-wrap: anywhere; }

/* ---- tab 1 ---- */
.ops-tt-lon { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ops-tt-chu { min-width: 0; flex: 1 1 260px; }
.ops-nhom { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.ops-nhom:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.ops-nhom-dau { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ops-nhom-dau h4 { font-size: 13px; }

/* ---- tab 2: cảnh báo gọi mạng phải đọc được ra ngay, không nằm lẫn vào chữ xám ---- */
.ops-canh-bao-mang { color: var(--warn-text); border-left: 3px solid var(--orange); padding-left: 8px; overflow-wrap: anywhere; }

/* ---- tab 5/6/7: dải màu phân biệt "ý kiến" với "bằng chứng" ---- */
.ops-dg-dong { border-left: 3px solid var(--green); padding: 8px 10px; margin-bottom: 8px; background: var(--panel2); border-radius: 0 8px 8px 0; }
.ops-dg-dong.ops-dg-y-kien { border-left-color: var(--purple); border-left-style: dashed; }
.ops-nhan-bc { font-weight: 700; overflow-wrap: anywhere; }
.ops-nhan-bc.la-bc { color: var(--ok-text); }
.ops-nhan-bc.khong-bc { color: var(--purple); }
.ops-diem-mu { margin-top: 10px; }
.ops-hc-muc, .ops-luat { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.ops-hc-muc:first-child, .ops-luat:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* ---- tab 7 ---- */
.ops-dem { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 8px; margin: 10px 0; }
.ops-dem-o { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.ops-dem-so { font-size: 20px; font-weight: 800; }
.ops-dem-ten { font-size: 12px; font-weight: 700; }
.ops-cb { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 0 10px 10px 0; padding: 10px 12px; margin-bottom: 10px; background: var(--panel); }
.ops-cb-dau { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ops-cb-thong-tin { border-left-color: var(--off-text); }
.ops-cb-canh-bao { border-left-color: var(--orange); }
.ops-cb-nghiem-trong { border-left-color: var(--red); }
.ops-cb-nguy-kich { border-left-color: var(--red); border-left-width: 7px; }

/* ---- tab 8: dòng thời gian ---- */
.ops-timeline { list-style: none; margin: 10px 0 0; padding: 0; }
.ops-timeline li { display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr) minmax(90px, auto) minmax(0, 1fr); gap: 4px 12px; padding: 7px 0 7px 12px; border-left: 2px solid var(--line); font-size: 12.5px; }
.ops-timeline li:hover { border-left-color: var(--blue); }
.ops-tl-luc { color: var(--muted); }
.ops-tl-hd { font-weight: 700; overflow-wrap: anywhere; }
.ops-tl-nguoi { color: var(--info-text); overflow-wrap: anywhere; }
.ops-tl-dt { color: var(--muted); overflow-wrap: anywhere; }

/* ---- biểu mẫu: cùng khuôn `.form` cũ, chỉ xếp hàng ngang khi đủ chỗ ---- */
.ops-loc fieldset, .ops-cai-dat fieldset, .ops-cham fieldset { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.ops-loc .field, .ops-cham .field { flex: 1 1 180px; min-width: 0; }
.ops-cai-dat .field { flex: 1 1 260px; min-width: 0; }
.ops-cai-dat .field p { overflow-wrap: anywhere; }

@media (max-width: 1024px) { .ops-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 768px) {
  .ops-timeline li { grid-template-columns: minmax(0, 1fr); }
  .ops-tabs { gap: 5px; }
  .ops-tab { font-size: 11.5px; padding: 5px 8px; }
}
@media (max-width: 480px) {
  .ops-actions { flex-direction: column; align-items: stretch; }
  .ops-actions .btn { width: 100%; }
  .ops-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ops-kv dt { font-weight: 700; margin-top: 6px; }
  .ops-loc fieldset, .ops-cai-dat fieldset, .ops-cham fieldset { flex-direction: column; align-items: stretch; }
}

/* ---------- 16. G08 · G09-A · G09-B · G10 (AG-06, V-13890) ------------------
   Dùng LẠI từ vựng `.ops-*` của G07 (pill, ops-gt, ops-vi-sao, ops-tabs, ops-dem,
   ops-pham-vi, ops-no). Khối này chỉ thêm những mảnh G07 chưa có: ô xem diff, hai bảng
   hạn mức sandbox đặt cạnh nhau, dòng ca contract test bị LỌT, thẻ provider readiness.
   Không mã màu nào gõ cứng — tất cả qua biến token, nên chủ đề sáng tự theo.
   --------------------------------------------------------------------------- */
.rd-page, .ca-page, .dp-page { min-width: 0; }
.rd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; }
.rd-grid > .panel { margin-bottom: 0; }
.rd-actions, .ca-actions, .dp-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.rd-kq { margin-top: 10px; overflow-wrap: anywhere; }

/* ---- ô xem diff: dòng thêm / dòng bỏ / mốc @@ phân biệt bằng CẢ màu LẪN ký tự đầu
        dòng (ký tự đầu là thứ còn đọc được khi mất màu hoặc khi in trắng đen) ---- */
.ca-diff, .ca-tep, .ca-ra { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.55; max-height: 420px; overflow: auto; white-space: pre; margin: 0; }
.ca-diff:focus-visible, .ca-tep:focus-visible, .ca-ra:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ca-d { display: block; }
.ca-d-them { color: var(--ok-text); background: rgba(34, 197, 94, .1); }
.ca-d-bo { color: var(--bad-text); background: rgba(239, 68, 68, .1); }
.ca-d-moc { color: var(--info-text); font-weight: 700; }
.ca-ra-loi { border-left: 4px solid var(--orange); }
.ca-h4, .dp-h4 { font-size: 13px; margin: 14px 0 6px; }
.ca-h4-canh { color: var(--warn-text); }
.ca-h5 { font-size: 12px; margin: 10px 0 4px; color: var(--muted); }

/* ---- hai bảng hạn mức NGANG HÀNG. Bảng "không đặt được" không bị gấp, không bị thu nhỏ:
        một hạn mức bị hệ từ chối nghĩa là KHÔNG CÓ trần đó ---- */
.ca-gh-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 10px 0; }
.ca-gh-2 > div { min-width: 0; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.ca-gh-2 > div:last-child { border-left: 4px solid var(--orange); }
.ca-two { align-items: start; }
.ca-two > .panel { margin-bottom: 0; }
.ca-kh-dau { margin-bottom: 8px; }
.ca-buoc li { margin-bottom: 8px; }
.ca-run, .dp-luot, .dp-hoso { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel); min-width: 0; }
.ca-cham-model { border-left-color: var(--purple); }

/* ---- contract test: ca LỌT phải đọc ra ngay, và không chỉ bằng màu ---- */
.dp-ca-lot > td { background: rgba(239, 68, 68, .1); }
.dp-ca-lot > td:first-child::before { content: "⚠ "; color: var(--bad-text); font-weight: 800; }
.dp-cong-kq { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 0 10px 10px 0; padding: 10px 12px; margin-top: 12px; background: var(--panel2); }

.rd-page pre, .ca-page pre, .dp-page pre { overflow-wrap: anywhere; }
.rd-page .note, .ca-page .note, .dp-page .note { overflow-wrap: anywhere; }
.rd-page code, .ca-page code, .dp-page code { overflow-wrap: anywhere; }

@media (max-width: 1024px) {
  .rd-grid { grid-template-columns: minmax(0, 1fr); }
  .ca-gh-2 { grid-template-columns: minmax(0, 1fr); }
  .ca-two { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 768px) {
  .ca-two { grid-template-columns: minmax(0, 1fr); }
  .ca-diff, .ca-tep, .ca-ra { font-size: 11.5px; max-height: 300px; }
}
@media (max-width: 480px) {
  .rd-actions, .ca-actions, .dp-actions { flex-direction: column; align-items: stretch; }
  .rd-actions .btn, .ca-actions .btn, .dp-actions .btn { width: 100%; }
}
