/* ============================================================
   Playbook — visual reskin (Phase 1, 2026-09-16)
   Indigo accent + light-gray canvas + white rounded cards, in the
   style of the DA's mockup (Tailwind-ish look, reproduced here as
   plain CSS — no external CDN).

   Pass 1 (same day) only swapped color/radius/shadow CSS-custom-property
   VALUES and was reported back as "not meaningfully different" — box-model
   (padding/margin/max-width/gap/flex layout) was untouched, which is most
   of what actually reads as "mockup-like" at a glance. Pass 2 (this state)
   changes real box-model values on top of the pass-1 palette: taller
   topbar, centered+narrower content columns (.pick/.panel/.conv now have
   margin:0 auto — they didn't before), more generous card/table/composer
   padding, bigger turn-marker spacing, and a wrapping pill-chip layout for
   Quick Analysis instead of a stacked full-width list. Still CSS-only —
   every selector below matches the exact same HTML structure/classes the
   templates and app.js already use (side-item, side-check, selecting,
   bulk-del-btn, runblock, qchip, box.warn/bad/ok, warnlist sev-*,
   generated-sql-box, box.narration, …); no DOM restructuring was needed to
   get the box-model changes above, even though template edits were
   authorized for this pass.
   ============================================================ */
:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #15181d; --muted: #5b6470;
  --line: #e3e6ea; --line-soft: #f1f3f5;
  --accent: #0f5f57; --accent-ink: #fff; --accent-soft: #e7f2f0; --accent-hover: #0a443e;
  /* màu theo nhóm câu hỏi (tag): version / hàng ngày / cohort / minigame / A-B / level */
  --tag-version: #2b4a9e; --tag-version-bg: #e8eefb;
  --tag-daily: #0f5f57; --tag-daily-bg: #e7f2f0;
  --tag-cohort: #8a4b12; --tag-cohort-bg: #fbefe3;
  --tag-mini: #663d8a; --tag-mini-bg: #f2eaf8;
  --tag-ab: #9b2c3f; --tag-ab-bg: #fce9ec;
  --tag-level: #1f6f8a; --tag-level-bg: #e4f2f7;
  /* sidebar reads as "page background, walled off by a border" rather than
     a 3rd distinct panel tone — matches the mockup's flat left rail. */
  --sidebar-bg: #ffffff;
  --warn-bg: #fff6e5; --warn-line: #f0c66b; --warn-ink: #8a6d1f;
  --bad-bg: #fdecec; --bad-line: #e3a1a1; --bad-ink: #a33;
  --ok-bg: #e9f6ec; --ok-line: #9fd3ab; --ok-ink: #2f6b3d;

  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .08);
  --shadow-card: 0 2px 8px rgba(16, 24, 40, .05);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, .14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1114; --panel: #161a1f; --ink: #e8ebef; --muted: #8b95a3;
    --line: #2a313a; --line-soft: #222831;
    --accent: #3bb3a3; --accent-ink: #06201c; --accent-soft: #15332f; --accent-hover: #6fd3c4;
    --sidebar-bg: #161a1f;
    --tag-version: #a9c1ff; --tag-version-bg: #1c2a4a;
    --tag-daily: #7fd8ca; --tag-daily-bg: #14332f;
    --tag-cohort: #f0b87a; --tag-cohort-bg: #3a2a16;
    --tag-mini: #d2b0f0; --tag-mini-bg: #2e2140;
    --tag-ab: #f5a3b1; --tag-ab-bg: #3f1d25;
    --tag-level: #8fd3ea; --tag-level-bg: #14303a;
    --warn-bg: #3a2f15; --warn-line: #7a6528; --warn-ink: #e8c877;
    --bad-bg: #3a1f1f; --bad-line: #7a3d3d; --bad-ink: #ee9c9c;
    --ok-bg: #1c3323; --ok-line: #3f6b4c; --ok-ink: #8fd3a3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1114; --panel: #161a1f; --ink: #e8ebef; --muted: #8b95a3;
  --line: #2a313a; --line-soft: #222831;
  --accent: #3bb3a3; --accent-ink: #06201c; --accent-soft: #15332f; --accent-hover: #6fd3c4;
  --sidebar-bg: #161a1f;
  --tag-version: #a9c1ff; --tag-version-bg: #1c2a4a;
  --tag-daily: #7fd8ca; --tag-daily-bg: #14332f;
  --tag-cohort: #f0b87a; --tag-cohort-bg: #3a2a16;
  --tag-mini: #d2b0f0; --tag-mini-bg: #2e2140;
  --tag-ab: #f5a3b1; --tag-ab-bg: #3f1d25;
  --tag-level: #8fd3ea; --tag-level-bg: #14303a;
  --warn-bg: #3a2f15; --warn-line: #7a6528; --warn-ink: #e8c877;
  --bad-bg: #3a1f1f; --bad-line: #7a3d3d; --bad-ink: #ee9c9c;
  --ok-bg: #1c3323; --ok-line: #3f6b4c; --ok-ink: #8fd3a3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 "Be Vietnam Pro", -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.015em; margin: 0 0 8px; text-wrap: balance; color: var(--ink); }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; margin: 28px 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.muted { color: var(--muted); }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 6px; }
code { background: var(--line-soft); padding: 2px 6px; border-radius: 5px; font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
hr.turn-sep { border: 0; border-top: 1px dashed var(--line); margin: 36px 0 0; }
hr.conv-sep { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

/* custom thin scrollbar (mockup's style, ported as plain CSS) */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ---- shell layout ---- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w, 264px) 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: 16px;
  min-height: 64px; padding: 0 24px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  /* .shell scrolls as the plain document (see app.js), not internally — so
     without this the topbar scrolls away with everything else the moment a
      2nd question's answer is brought into view, and the page reads as a
     blank screen with no app chrome around it at all. */
  position: sticky; top: 0; z-index: 20;
}
/* Logomark + 2-tier wordmark ("MetaGame" = studio, "Playbook" = product) —
   gives the bar a real identity instead of a bare text link. PROJECT name
   still carries the bigger/bolder weight via .proj-switch: it's what the
   user is actually looking at, the brand is just context. */
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
/* 2026-09-16 DA feedback: brand mark bigger + a real mark (mini bar-chart
   icon, fits an analytics tool) instead of a bare "M" letter; wordmark
   bumped back up from the earlier "shrink it, project name matters more"
   pass — DA wants both readable, not a strict either/or. */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm); flex: none;
  background: var(--accent);
  color: #fff; box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand-text .brand-sub { color: var(--muted); font-weight: 500; }
.topbar-divider { width: 1px; height: 26px; background: var(--line); }
.proj-switch select {
  font: inherit; font-weight: 700; font-size: 16px; padding: 6px 14px;
  min-width: 190px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.proj-switch select:hover, .proj-switch select:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.data-note { color: var(--muted); font-size: 13px; }
/* Both topbar links grouped on the right (2026-09-23 UI review — each had
   its own margin-left:auto, so "Giới thiệu" floated mid-bar). */
.topbar-links { margin-left: auto; display: flex; align-items: center; gap: 8px; }
a.data-note {
  padding: 6px 13px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  font-weight: 600; transition: color .12s, border-color .12s, background .12s;
}
a.data-note:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); text-decoration: none; }

.sidebar {
  grid-area: side;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  padding: 20px 16px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 24px;
  /* Sticky below the (sticky, 64px) topbar with its own scroll — the page
     scrolls as the document, so without this the sidebar column is blank
     once you're deep into a long conversation (2026-09-23 UI review). */
  position: sticky; top: 64px; align-self: start;
  height: calc(100vh - 64px);
}

/* ---- kéo độ rộng sidebar (2026-09-27) ---- */
/* Handle is position: FIXED, pinned to the sidebar's right edge via the same
   --sidebar-w var (sidebar = first grid column from x=0, sticky top 64px,
   height 100vh-64px). An absolute child of .sidebar (overflow-y: auto) would
   scroll away with a long conversation list (bug found by Head 2026-09-27). */
.sidebar-rsz {
  position: fixed; top: 64px; bottom: 0; left: calc(var(--sidebar-w, 264px) - 7px); width: 7px; z-index: 5;
  cursor: col-resize; touch-action: none; user-select: none;
}
.sidebar-rsz::after {
  content: ""; position: absolute; top: 22%; bottom: 22%; left: 3px; width: 2px; border-radius: 1px;
  background: var(--line);
}
.sidebar-rsz:hover::after, .sidebar-rsz.is-drag::after { top: 0; bottom: 0; background: var(--accent); }
html.sidebar-resizing, html.sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }
.new-btn {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background .12s, box-shadow .12s, transform .05s;
}
.new-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow-card); }
.new-btn:active { transform: translateY(1px); }
.side-section { display: flex; flex-direction: column; gap: 6px; }
/* Bug user báo 2026-10-08: "Lịch sử hội thoại" dài (tối đa 50, store.list_conversations)
   đẩy "Dữ liệu đã lưu" xuống quá thấp/ngoài màn hình — cả .sidebar cuộn CHUNG 1 khối.
   Giới hạn + tự cuộn riêng #conv-list để "Dữ liệu đã lưu" luôn hiện ngay dưới. Nút Xóa
   (.bulk-del-btn) nằm NGOÀI #conv-list (sau nó trong DOM, cùng .side-section) — không bị
   cuộn mất, luôn thấy khi có dòng được tích. #run-list không giới hạn (feed limit=30, ít
   khi dài bằng lịch sử hội thoại; .sidebar vẫn overflow-y:auto làm phương án dự phòng). */
#conv-list { max-height: 38vh; overflow-y: auto; }
/* 2026-09-16 DA feedback: "HỘI THOẠI" and "ĐÃ CHẠY" read as one blurred
   block, not 2 separate sections — a divider + a small accent-colored dot
   on each header gives real visual separation, not just whitespace. */
.side-section + .side-section { margin-top: 4px; padding-top: 22px; border-top: 1px solid var(--line); }
.side-h {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); font-weight: 800; padding: 2px 13px 10px;
}
.side-h-label { display: inline-flex; align-items: center; gap: 8px; }
.side-h-label svg { flex: none; color: var(--accent); }
.side-h-link {
  font-size: 12px; letter-spacing: 0; text-transform: none;
  border: 0; background: transparent; color: var(--accent); cursor: pointer; padding: 0;
  font-weight: 600;
}
.side-h-actions { display: flex; gap: 10px; align-items: baseline; }
.side-item { position: relative; display: flex; align-items: stretch; border-radius: var(--radius-sm); }
.side-item:hover, .side-item.on { background: var(--line-soft); }
.side-item .side-row:hover { background: transparent; }
.side-row {
  display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0;
  padding: 11px 13px; border-radius: var(--radius-sm); color: var(--ink);
}
.side-row:hover { background: var(--line-soft); text-decoration: none; }
.side-row.on { background: var(--accent-soft); }
.side-item.on .side-row-t { color: var(--accent); font-weight: 600; }
.side-row-t { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row-m { font-size: 12.5px; color: var(--muted); }
/* 2026-09-16 DA feedback: "→ Xem chi tiết" nên hiện rõ ràng thay vì chỉ ngụ
   ý cả dòng bấm được — nhỏ, màu accent, không tranh chú ý với tiêu đề. */
.side-row-cta { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 1px; }
.side-empty { font-size: 13px; color: var(--muted); padding: 2px 8px; }

/* 2026-09-16 DA feedback (2 vòng) — bỏ hẳn nút xóa × riêng từng dòng (từng
   là 1 cơ chế xóa RIÊNG, tách biệt với chọn-nhiều) đổi sang kiểu Gmail: ô
   chọn (checkbox) LUÔN nằm trong DOM ở bên TRÁI mỗi dòng, mờ đi (opacity 0)
   cho tới khi hover/được tích/focus — không còn khái niệm "bật chế độ chọn
   nhiều" qua nút riêng nữa, hover là thấy ô chọn ngay, tích 1-nhiều dòng rồi
   bấm nút xóa (🗑) hiện ra ở cuối danh sách. Đơn giản hoá còn ĐÚNG 1 cách xóa
   thay vì 2 cách (× lẻ + chọn nhiều) — xem shell.html/app.js. */
.side-check {
  flex: none; align-self: center; margin: 0 2px 0 10px; cursor: pointer;
  accent-color: var(--accent); opacity: 0; transition: opacity .12s;
}
.side-item:hover .side-check, .side-check:checked, .side-check:focus-visible { opacity: 1; }

/* Đổi tên hội thoại (2026-09-30) — pencil icon = <summary>, ẩn viền/marker
   mặc định của <details>; mờ như .side-check cho tới khi hover/mở. Form nổi
   như popover (position:absolute, .side-item đã position:relative) thay vì
   đẩy các dòng bên dưới xuống khi mở, giữ chiều cao hàng ổn định. */
.side-rename { position: relative; flex: none; align-self: center; margin-right: 2px; }
.side-rename-btn {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--muted); opacity: 0; transition: opacity .12s, background .12s, color .12s;
  list-style: none;
}
.side-rename-btn::-webkit-details-marker { display: none; }
.side-rename-btn:hover { background: var(--line); color: var(--ink); }
.side-item:hover .side-rename-btn, .side-rename[open] > .side-rename-btn,
.side-rename-btn:focus-visible { opacity: 1; }
.side-rename-form {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 6;
  display: flex; gap: 6px; padding: 8px; width: max(100%, 220px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}
.side-rename-form input[type=text] { flex: 1; min-width: 0; font-size: 13px; padding: 6px 9px; }
.side-rename-form .btn { font-size: 12px; padding: 6px 11px; white-space: nowrap; }

.bulk-del-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 7px 14px; border-radius: var(--radius-pill); white-space: nowrap;
  border: 1px solid var(--bad-line); background: var(--bad-bg); color: var(--bad-ink);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background .12s, color .12s, opacity .12s;
}
.bulk-del-btn .icon { flex: none; }
/* `display: inline-flex` above beats the browser's built-in `[hidden]` rule
   at equal specificity (author CSS always wins over the UA stylesheet) — so
   the button rendered even with the `hidden` attribute set. Force it back. */
.bulk-del-btn[hidden] { display: none; }
.bulk-del-btn:hover:not(:disabled) { background: var(--bad-ink); color: #fff; border-color: var(--bad-ink); }
.bulk-del-btn:disabled { opacity: .45; cursor: not-allowed; }
.bulk-del-count { font-variant-numeric: tabular-nums; }

.main {
  /* No overflow here (was overflow-y:auto, which never actually scrolled —
     the document does, see app.js — but it made .main the sticky scroll
     container, so the sticky composer never stuck). min-width:0 keeps wide
     tables from widening the grid column (they scroll inside .scroll). */
  grid-area: main; min-width: 0;
  padding: 36px clamp(20px, 5vw, 56px) 88px;
}
/* 2026-09-16 DA feedback: trang chủ nên đọc như 1 ô hỏi canh giữa màn hình
   (kiểu trang tìm kiếm), không phải 1 form nằm ở đầu trang với danh sách dài
   bên dưới. CHỈ áp dụng cho main=="home" (shell.html) — trang câu hỏi/hội
   thoại/feed vẫn đọc từ trên xuống như cũ, canh giữa dọc ở đó không hợp lý. */
.main-hero { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - 64px); }
.pick-hero { width: 100%; }
.pick-hero h1 { text-align: center; }
.pick-hero .ask-wrap { max-width: 720px; margin: 0 auto; }

/* Quick Analysis = dropdown gợi ý, không phải danh sách luôn hiện tràn
   trang. .ask-wrap là điểm neo relative; .qa-panel định vị absolute NGAY
   DƯỚI ask-box, giới hạn chiều cao + tự cuộn bên trong thay vì đẩy phần còn
   lại của trang xuống. Mở khi focus vào ô hỏi, đóng khi bấm ra ngoài/Esc
   (app.js) — KHÔNG đóng theo blur (đua với việc bấm 1 chip: mousedown làm
   input blur TRƯỚC khi click "tới đích", sẽ khiến chip gần như không bấm
   được bằng chuột). */
.ask-wrap { position: relative; }
.qa-panel {
  display: none;
  position: absolute; top: calc(100% + 10px); left: 0; right: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 18px 22px 22px;
  max-height: min(60vh, 520px); overflow-y: auto;
}
.pick.qa-open .qa-panel { display: block; }
/* Opens upward (app.js adds .qa-up when there's more room above — always the
   case for the sticky conversation composer). max-height is set inline by
   app.js from the space actually left in the viewport. */
.qa-panel.qa-up { top: auto; bottom: calc(100% + 10px); }

/* Sticky chat composer at the bottom of a conversation (2026-09-23 UI
   review). Only while #ask-more holds the plain ask box (.pick) — once a
   quick chip swaps a whole question panel in, it flows normally. */
.conv #ask-more:has(> .pick) {
  position: sticky; bottom: 0; z-index: 10;
  background: var(--bg); padding: 14px 0;
  box-shadow: 0 -10px 16px -12px rgba(15, 18, 26, .25);
}
.conv #ask-more:has(> .pick) .pick > h2 { display: none; }
/* 2026-09-25: composer spans the same column as the conversation cards
   (was capped at .pick's 900px → narrower than the 1320px .conv column,
   edges didn't line up), and the band's padding is even above/below the
   box (was 12px + the ask-box's 20px margin on top vs 16px below). */
.conv #ask-more > .pick { max-width: none; }
.conv #ask-more > .pick .ask-box { margin-top: 0; }
.main:has(.conv #ask-more > .pick) { padding-bottom: 0; }
/* Every content column is now CENTERED (margin: 0 auto), not just capped —
   before this reskin pass the max-width rules below had no margin: auto,
   so on any monitor wider than ~1100-1600px the whole page content sat
   flush against the sidebar instead of reading as a designed, centered
   column (this was most of why the first CSS-token-only pass "looked the
   same" — no box-model actually changed). .pick/.panel (catalog + form, no
   wide tables) read closest to the mockup's max-w-4xl (~896px) column.
   .conv (holds run/answer cards) is kept wider than that on purpose: result
   tables can run ~25 columns (R3) and already get their own internal
   horizontal scroll via .scroll, but a too-narrow outer column forces that
   scroll far more often than needed — 1200px is a deliberate middle ground,
   still visibly narrower/more centered than the old 1600px edge-to-edge. */
.pick, .panel { max-width: 900px; margin: 0 auto; }
/* 2026-09-16 DA feedback ("Phần hội thoại to hơn và kích chữ cũng lớn hơn")
   — widened further (1200 -> 1320) and bumped the base font-size so prose/
   labels inside a conversation read larger without needing a 2nd pass at
   every individual selector; .scroll (result tables) opts back down since
   dense numeric tables get worse, not better, from a bigger base size. */
.conv { max-width: 1320px; margin: 0 auto; font-size: 16px; }
.conv h3 { font-size: 17px; }
.conv .scroll table { font-size: 14px; }
.conv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.conv-head h1 { margin-bottom: 0; }

/* "Turn" marker — one per question asked, even when it answers with several
   run blocks (multi-recipe questions). Without this the conversation reads
   as a stack of report cards with no visible question/answer structure —
   unlike a real chat thread (Claude/Gemini) where each turn's own question
   is visible before its reply. Styled like a small user chat bubble
   (avatar + text) so the turn boundary is obvious at a glance while
   scrolling, not just inferable from a run block's own <h3>. */
/* 2026-09-16 DA feedback: đọc như tin nhắn "của mình" trong 1 khung chat —
   bubble xanh (accent), canh PHẢI, avatar bên cạnh — khác hẳn AI
   (_answer_card.html, "câu trả lời bình thường", KHÔNG đổi thành bubble, chỉ
   khối card như cũ) để vẫn phân biệt rõ "ai đang nói". */
.turn-ask { display: flex; align-items: center; gap: 10px; margin: 40px 0 16px; justify-content: flex-end; }
.turn-ask:first-child { margin-top: 4px; }
.turn-ask-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.turn-ask-clarify, .title-clarify {
  display: block; font-size: 12.5px; font-weight: 400; opacity: .8; margin-top: 3px;
}
.title-clarify { color: var(--muted); opacity: 1; }
.turn-ask-text {
  font-size: 15px; font-weight: 500; color: #fff; line-height: 1.5;
  background: var(--accent);
  padding: 10px 18px; border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  max-width: 72%; box-shadow: var(--shadow-card); text-align: left;
}
/* Bong bóng dài thu gọn (2026-09-30) — <details> mang chung .turn-ask-text
   nên vẫn có màu nền/bo góc bubble; chỉ thêm phần riêng cho <summary> (nút
   mắt) + vùng nội dung bị che bớt khi đóng. */
.turn-ask-collapse { cursor: default; }
.turn-ask-collapse > summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  list-style: none; font-size: 12px; font-weight: 600; opacity: .85;
  margin-bottom: 6px; user-select: none;
}
.turn-ask-collapse > summary::-webkit-details-marker { display: none; }
.turn-ask-collapse > summary:hover { opacity: 1; }
.turn-ask-collapse .eye-off, .turn-ask-collapse .turn-ask-eye-off { display: none; }
.turn-ask-collapse[open] .eye-on, .turn-ask-collapse[open] .turn-ask-eye-on { display: none; }
.turn-ask-collapse[open] .eye-off { display: inline; }
.turn-ask-collapse[open] .turn-ask-eye-off { display: inline-block; }
.turn-ask-body {
  display: block; white-space: pre-wrap; word-break: break-word;
  max-height: 6.5em; overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4em), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4em), transparent 100%);
}
.turn-ask-collapse[open] .turn-ask-body {
  max-height: none; mask-image: none; -webkit-mask-image: none;
}

/* ---- ask box — the primary interaction: heading -> ask-box -> Quick
   Analysis suggestions below. Free-text question box (Vòng 6 nhánh A,
   app/ask.py) — a real <input>+submit inside the same pill shape the
   "coming soon" placeholder used before. ---- */
.ask-box {
  display: flex; align-items: stretch; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 10px 10px 10px 24px; margin: 20px 0 0; color: var(--muted);
  background: var(--panel); box-shadow: var(--shadow-card);
  transition: border-color .12s, box-shadow .12s;
}
.ask-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-card); }
.ask-box input[type="text"], .ask-box textarea {
  flex: 1; width: auto; max-width: none; border: none; background: transparent; font-size: 16px;
  color: var(--ink, inherit); outline: none; padding: 0; border-radius: 0;
}
/* 2026-09-25 "cân đối, tránh bị thọt lỏm": the generic
   input[type=text]:focus-visible rule (same specificity, later in file) drew
   a 2nd focus ring on the borderless inner input — a sunken box inside the
   .ask-box, which already shows focus via :focus-within. Input and button
   now share one height (align-items: stretch above, input padding 0). */
.ask-box input[type="text"]:focus-visible, .ask-box textarea:focus-visible { box-shadow: none; }
/* 2026-10-01 (câu hỏi dài bị dồn lại trên 1 dòng, phải cuộn ngang): ô hỏi
   là <textarea> tự cao dần theo nội dung (app.js autoGrowAskText, "input" +
   htmx:afterSettle), không phải <input> 1 dòng — chữ xuống dòng tự nhiên.
   resize:none vì JS đã lo việc đó; quá cao (nhiều dòng) thì tự cuộn bên
   trong thay vì đẩy nút "Hỏi" ra ngoài màn hình. Enter gửi câu hỏi như cũ
   (Shift+Enter xuống dòng) — xem keydown handler trong app.js. */
.ask-box textarea {
  resize: none; overflow-y: auto; max-height: 200px; line-height: 1.4;
  font-family: inherit; padding: 8px 0;
}
/* Send button reads as a distinct rounded action (pill) against the
   rounded-xl composer box around it — mockup's "right-aligned rounded send
   button" — instead of matching the container's own corner radius. Pinned
   to the bottom (align-self) so it doesn't stretch tall alongside a
   multi-line textarea. */
.ask-box button { flex: none; align-self: flex-end; margin-left: 10px; border-radius: var(--radius-pill); padding: 10px 20px; }
.ask-box .soon {
  font-size: 11px; letter-spacing: .02em;
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px 9px;
}

/* ---- clarify round-trip (Vòng 6 nhánh A) — 1 câu hỏi mở còn thiếu param,
   round-trip qua hidden `ask_state`, không dựng picker (bất biến #10). ---- */
.ask-clarify-form {
  display: flex; gap: 8px; margin-top: 10px;
}
.ask-clarify-form input[type="text"] {
  flex: 1; max-width: none; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 15px; background: var(--panel); color: inherit;
}
.ask-clarify-form input[type="text"]:focus-visible { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
/* ---- Nhánh B (Vòng 6) — SQL Sonnet tự soạn, hiện nguyên văn cho user/DA
   đối chiếu trước/sau khi chạy. .ask-confirm-actions mirrors .ask-clarify-form
   (flex + gap) but for 2 side-by-side submit forms (Chạy/Hủy) instead of 1
   text input. ---- */
.generated-sql {
  margin: 8px 0 0; padding: 10px 12px; overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; white-space: pre; background: var(--line-soft);
  border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.ask-confirm-actions { display: flex; gap: 8px; margin-top: 12px; }

.quick-divider {
  margin: 32px 0 16px; padding-top: 24px; border-top: 1px solid var(--line);
}
.quick-divider .eyebrow { margin-bottom: 8px; }
.quick-divider p { margin: 0; }

/* ---- question groups + chips ---- */
.qgroup { margin: 26px 0; }
.qgroup.off { opacity: .5; }
.qgroup-h { display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.qgroup-h::before { content: ""; width: 6px; height: 6px; border-radius: 2px;
  background: var(--accent); flex: none; }
.qgroup.off .qgroup-h::before { background: var(--muted); }
.qgroup-note { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
/* Pill-shaped chips in a WRAPPING row (mockup reference), not a stacked
   one-per-line list — the most visible layout change of this reskin pass.
   Note: unlike a typical short-tag suggestion chip, this app's chip text IS
   the actual catalog question ("Mỗi ngày bao nhiêu % user xem ít nhất 1
   quảng cáo?", ~50 chars) — the whole point is reading it to pick the right
   analysis, so chips wrap onto new lines instead of a single-line
   horizontally-scrolling strip that would need to truncate/ellipsis the
   question text and hide the thing the user is choosing between. */
.qchips { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; }
.qchip {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex: 0 1 auto; max-width: 100%;
  padding: 13px 22px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm);
  transition: border-color .12s, box-shadow .12s, transform .08s;
}
.qchip:hover { border-color: var(--accent); box-shadow: var(--shadow-card); text-decoration: none; transform: translateY(-1px); }
.qchip.disabled { cursor: not-allowed; }
.qchip.disabled:hover { transform: none; box-shadow: var(--shadow-sm); }
.qchip-t { font-size: 14.5px; font-weight: 500; }
.qchip-tag {
  flex: none; font-size: 11px; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px 10px;
}
.qchip-tag.ok { color: var(--ok-ink); border-color: var(--ok-line); background: var(--ok-bg); }

/* ---- panel / form ---- */
.panel-crumb { font-size: 13px; margin-bottom: 10px; }
.qinline { border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); padding: 28px 32px; margin-top: 20px; box-shadow: var(--shadow-card); }
.qinline h3 { margin-top: 0; }
.qinline-back { margin: 16px 0 0; }
.qinline-back a { font-size: 13px; }
.qform { border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); padding: 24px; margin: 20px 0; box-shadow: var(--shadow-sm); }
.field { margin: 16px 0; }
.field:first-child { margin-top: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=date], select {
  width: 100%; max-width: 340px; padding: 8px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input[type=text]:focus-visible, input[type=date]:focus-visible, select:focus-visible {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}
.checks { display: flex; flex-wrap: wrap; gap: 7px 16px; }
.checks label { font-weight: 400; display: flex; gap: 5px; align-items: center; }
.checks input[type=checkbox] { accent-color: var(--accent); }
button, .btn {
  display: inline-block; padding: 9px 17px; border-radius: var(--radius-sm);
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
}
button:hover, .btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); font-weight: 500; }
button.ghost:hover, .btn.ghost:hover { background: var(--line-soft); border-color: var(--line); color: var(--accent); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#gate { margin-top: 12px; }

/* ---- run block ---- */
.runblock { border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--panel); padding: 28px 32px; margin: 24px 0; box-shadow: var(--shadow-card); }
/* A question with >1 recipe (kiem_tien = R3+R6) renders as ONE .runblock
   with several .answer-section inside instead of several .runblock cards
   stacked — the user only asked one thing (2026-09-13 feedback), the extra
   recipe is more detail on the SAME answer, not a separate answer. Single-
   recipe questions get exactly one section with no sub-heading, unchanged
   from before. */
.answer-section-h { font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }
.answer-sep { border: 0; border-top: 1px dashed var(--line); margin: 20px 0; }
/* Câu hỏi nhiều phần (router agent, 2026-10-05): "Bảng k — tiêu đề" + 1 dòng mô tả. */
.answer-section-h.answer-part-h { font-size: 15px; color: var(--ink); text-transform: none; letter-spacing: 0; }
.part-note { margin: 0 0 8px; font-size: 13px; }
/* Truy vấn kiểm tra AI tự chạy (2026-10-06): khối thu gọn cuối thẻ, chữ nhỏ, nhạt. */
.answer-checks { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 12px; font-size: 13px; }
.answer-checks > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.answer-check { margin-top: 14px; padding-left: 12px; border-left: 2px solid var(--line-soft); }
.answer-check-h { margin: 0 0 6px; font-size: 13px; color: var(--ink); }
.run-params { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.answer-section > .box:first-child { margin-top: 0; }
.qa-panel > .quick-divider:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.run-params code { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.run-foot { margin: 12px 0 0; font-size: 12px; }
.rerun-form { display: inline; margin-left: 6px; }
.rerun-btn {
  font: inherit; font-size: 12px; padding: 0; border: 0; background: transparent;
  color: var(--accent); cursor: pointer; text-decoration: underline;
}

table { border-collapse: collapse; width: 100%; font-size: 13px;
  font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 16px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--line-soft); position: sticky; top: 0; z-index: 1;
  padding: 12px 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); border-bottom: 1px solid var(--line); }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--accent-soft); }
.scroll { overflow-x: auto; border-radius: var(--radius-md);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.scroll table { border: 0; }

/* ---- phóng to bảng (2026-09-18) ---- */
.table-wrap { position: relative; }
.table-toolbar { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; }
.table-toolbar .scroll-hint { margin: 0; }
.table-expand-btn {
  /* In-flow in .table-toolbar above the table (2026-09-23) — no longer an
     absolute overlay, so it can't cover header text or be covered by the
     sticky <th>. */
  flex: none; margin-left: auto;
  width: 30px; height: 30px; padding: 0; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 15px; line-height: 1; opacity: .7;
  transition: opacity .12s, color .12s, border-color .12s, background .12s;
}
.table-expand-btn:hover {
  opacity: 1; color: var(--accent); border-color: var(--accent); background: var(--accent-soft);
}
.table-modal {
  border: 0; border-radius: var(--radius-lg); padding: 0; box-shadow: var(--shadow-card);
  width: 98vw; max-width: 1800px; height: 94vh;
}
.table-modal::backdrop { background: rgba(15, 18, 26, .55); }
.table-modal-close {
  position: absolute; top: 14px; right: 14px; z-index: 1;
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 15px; line-height: 1;
}
.table-modal-close:hover { color: var(--accent); border-color: var(--accent); }
.table-modal-body { height: 100%; overflow: auto; padding: 44px 20px 20px; }
/* KHÔNG tăng font-size ở đây (trước là 14px, > 13px mặc định) — cột dùng
   white-space:nowrap nên chữ to hơn kéo cột rộng hơn theo, ngốn gần hết
   phần rộng thêm của dialog, khiến bảng "trông vẫn y nguyên kích thước" dù
   khung ngoài đã phóng to (đúng bug user báo 2026-09-18). Mục đích nút ⤢ là
   nhường THÊM KHÔNG GIAN để thấy nhiều cột hơn, không phải zoom chữ to hơn. */
.table-modal-body thead th { position: sticky; top: 0; }

/* ---- phân trang bảng (2026-09-24) — footer gọn kiểu Material, căn phải,
   chữ nhỏ màu muted để không lấn át bảng. Nội dung do app.js dựng. ---- */
.table-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 6px 18px; margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.table-pager[hidden] { display: none; }
.table-pager label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.table-pager select { width: auto; }
/* Trong dialog ⤢ pager dính đáy khung cuộn để không phải cuộn hết trang mới thấy. */
.table-modal-body .table-pager { position: sticky; bottom: -20px; left: 0; z-index: 1;
  margin: 0 -20px -20px; padding: 10px 20px; background: var(--panel); border-top: 1px solid var(--line); }
.table-pager select, .table-pager input {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
.table-pager input { width: 56px; }
.table-pager .pg-range { min-width: 84px; text-align: center; font-variant-numeric: tabular-nums; }
.table-pager button {
  width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; background: transparent;
  color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; }
.table-pager button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.table-pager button:disabled { color: var(--line); cursor: default; }
.table-pager .pg-nav { display: flex; align-items: center; gap: 2px; }

.box { border-radius: var(--radius-md); padding: 16px 20px; margin: 16px 0; border: 1px solid var(--line); }
.box.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.box.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.box.ok  { background: var(--ok-bg);  border-color: var(--ok-line);  color: var(--ok-ink); }
.box ul { margin: 4px 0 0; padding-left: 18px; }
.box a { color: inherit; text-decoration: underline; }
/* AI explanation box — kept visually distinct from a plain card by tying it
   to the accent color (this is the AI narration, not a warning), instead of
   the neutral left-border it had before the reskin. */
.box.narration { background: var(--accent-soft); border-color: var(--line); border-left: 3px solid var(--accent); }
.box.narration > strong { color: var(--accent); }
.box.narration p { margin: 4px 0 0; }
.box.narration .md > :first-child { margin-top: 4px; }
.box.narration .md p { margin: 8px 0 0; }
.box.narration .md ul, .box.narration .md ol { margin: 6px 0 0; padding-left: 22px; }
.box.narration .md li { margin: 2px 0; }
.box.narration .md code { font-size: .9em; padding: 1px 5px; border-radius: 4px; background: var(--panel); }
/* SQL Sonnet soạn tự do (Nhánh B) — chưa qua DA review, phải giữ tông cảnh
   báo (amber) rõ ràng, không lẫn với card thường dù cùng bo góc/shadow mới. */
/* 2026-09-23 UI review: compact muted one-line note instead of a full amber
   box (it was louder than the result table). Meaning unchanged. */
.generated-sql-box { margin: 6px 0 10px; font-size: 12.5px; color: var(--muted); }
.generated-sql-box > summary {
  cursor: pointer; font-weight: 500; list-style: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.generated-sql-box > summary:hover { color: var(--ink); }
.generated-sql-box > summary::-webkit-details-marker { display: none; }
.generated-sql-box > summary::before {
  content: "👁"; flex: none; opacity: 0.6; filter: grayscale(1);
}
.generated-sql-box[open] > summary::before { opacity: 1; filter: none; }
.generated-sql-box > .generated-sql { margin-top: 10px; }

/* per-banner severity (Vòng 3 — compute_warnings trả list[{severity,text}]) */
.warnlist { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.warnlist li { padding: 6px 10px 6px 12px; border-radius: 7px; border-left: 3px solid var(--line); font-size: 13px; }
.warnlist li.sev-danger { border-left-color: var(--bad-line); background: var(--bad-bg); color: var(--bad-ink); }
.warnlist li.sev-warn   { border-left-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.warnlist li.sev-ok     { border-left-color: var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }

/* chart (inline SVG, app/charts.py) */
.chart-wrap { margin: 10px 0; }
.chart-svg { width: 100%; height: auto; max-width: 640px; display: block; }

.export-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; align-items: center; }
.export-actions .btn, .export-actions button { font-size: 12px; padding: 7px 13px; }
.inline-form { display: inline; }
/* "Đã lưu report" (2026-09-30, user báo "thòi lõi ra") — trước là 1 span
   trơn (chữ thường 15px, không viền) đứng cạnh 2 nút pill 12px có viền, nhìn
   như bị vỡ hàng. Giờ có box/padding khớp kích thước các nút anh em, màu
   "ok" (khớp ý nghĩa với pill "đã lưu report" ở đầu thẻ) thay vì chữ xám
   trơn, không có cursor/hover vì đây là trạng thái, không phải nút bấm. */
.export-saved {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 7px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--ok-line);
  background: var(--ok-bg); color: var(--ok-ink);
}
.export-saved::before { content: "✓"; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); color: var(--muted); background: var(--line-soft); }
.pill.prov { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.pill.stable { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.pill.flag { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
/* 2026-10-06 nguồn của số: recipe DA ("Theo định nghĩa chuẩn") / SQL AI tự soạn ("Phân tích khám phá"). */
.pill.std { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pill.explore { border-style: dashed; }
.interp-note { margin: 0 0 8px; font-size: 13px; }

.feed-item { display: flex; align-items: center; border-radius: var(--radius-sm); border-bottom: 1px solid var(--line-soft); }
.feed-item:hover .side-check { opacity: 1; }
.feed-row { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 10px; color: var(--ink); border-radius: var(--radius-sm); }
.feed-row:hover { text-decoration: none; }
.feed-item:hover { background: var(--line-soft); }
.single-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* "Bảng đã lưu = báo cáo sống" (2026-09-30, đợt 2 — user chê form dọc/
   checkbox gợi ý đợt 1, muốn giống thanh filter dashboard: ngang, gọn, ô
   danh sách kiểu chip). Đứng ở ĐẦU trang (_single_run.html), không phải
   cuối. */
.rerun-of-link { margin: 0 0 14px; }
.rerun-seq-link, .rerun-readonly-note { margin: 0 0 18px; }

.rerun-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); padding: 14px 16px; margin: 0 0 18px;
}
.rerun-bar-label {
  flex: none; align-self: center; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.rf-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rf-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.rf-field input[type=text], .rf-field input[type=date], .rf-field select {
  width: auto; max-width: none; font-size: 13px; padding: 6px 9px;
}
.rf-field input[type=text] { min-width: 120px; }
.rf-daterange {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px 6px;
}
.rf-daterange input[type=date] { border: 0; padding: 4px 2px; }
.rf-daterange span { color: var(--muted); font-size: 12px; }
.rf-chipbox {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 4px 6px; min-width: 160px; background: var(--panel);
}
.rf-chipbox:focus-within { border-color: var(--accent); }
.rf-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-pill);
  padding: 3px 4px 3px 9px; white-space: nowrap;
}
.rf-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: inherit; cursor: pointer; font-size: 13px; line-height: 1;
}
.rf-chip-x:hover { background: rgba(0, 0, 0, .12); }
.rf-chip-text {
  flex: 1; min-width: 70px; border: 0; padding: 3px 2px; font: inherit;
  background: transparent; color: var(--ink); outline: none;
}
.rf-apply {
  flex: none; align-self: center; font-size: 13px; padding: 7px 16px;
}

@media (max-width: 900px) {
  .rerun-bar { flex-direction: column; align-items: stretch; }
  .rerun-bar-label { align-self: flex-start; }
  .rf-apply { align-self: flex-start; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-areas: "top" "side" "main"; }
  .sidebar { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line);
    flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .side-section { flex: 1 1 200px; }
  /* .sidebar đổi sang hàng ngang + max-height 40vh ở mobile — 38vh (giá trị desktop) gần
     bằng cả khối, co lại cho vừa 1 cột bên trong .side-section row. Mobile chưa hỗ trợ
     chính thức (CLAUDE.md) — chỉ tránh lỗi rõ ràng, không tối ưu riêng. */
  #conv-list { max-height: 160px; }
  .data-note { display: none; }
  .sidebar { position: static; height: auto; }
  /* Touch/narrow screens can't hover to reveal the select checkbox — show
     it always here (mirrors the old always-visible-× behavior it replaced). */
  .side-check { opacity: 1; }
  /* Mobile stacks .shell to 1 column (grid-template-columns: 1fr) — dragging
     a column width is meaningless there, and .sidebar drops position:sticky
     above so the drag math (clientX = distance from left edge) no longer
     lines up either. Out of scope for mobile right now either way. */
  .sidebar-rsz { display: none; }
}

/* 2026-09-16 DA feedback ("tốc độ suy nghĩ và phản hồi của AI quá lâu") —
   Nhánh B thật sự mất 20-60s+ (nhiều lượt gọi AI + BigQuery tuần tự, xem
   app.js) — không rút ngắn được bằng CSS, nhưng trang trắng/đứng im suốt
   thời gian đó khiến CẢM GIÁC chậm hơn thực tế, dễ tưởng bị treo. Spinner +
   đổi chữ nút NGAY khi bấm gửi (app.js, trước khi có phản hồi server) để
   biết hệ thống vẫn đang chạy. */
.btn-spinner {
  display: inline-block; width: 13px; height: 13px; margin-right: 7px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; vertical-align: -2px;
  animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
button[disabled] { cursor: wait; opacity: .8; }

/* ---- Trạng thái "AI đang xử lý" (2026-09-25, app.js startAskProgress) —
   bong bóng câu hỏi + thẻ chờ có đồng hồ và các bước thật từ server
   (app/progress.py). Thẻ dùng lại .runblock; ô hỏi bị khoá khi đang chờ. ---- */
.pick.is-asking .qa-panel { display: none !important; }
form.is-locked .ask-box, form.is-locked [name="text"] { opacity: .65; }
form.is-locked [name="text"] { cursor: not-allowed; }
/* 2026-09-26 ("hơi cồng kềnh"): sau khi gửi, không hiện câu hỏi 2 lần —
   ô thật display:none (vẫn trong form), bản sao trống .ask-ghost giữ khung. */
.pending-hidden { display: none !important; }
.ask-ghost { display: none; }
form.is-sent [name="text"] { display: none; }
form.is-sent .ask-ghost { display: block; }
.ask-clarify.is-sent form { display: none; }
.ask-clarify.is-sent > p { margin: 0; }
.pending-turn { margin-top: 8px; }
/* trang chủ canh giữa dọc — khi chờ thì neo lên đầu, thẻ lớn dần xuống dưới không làm nhảy bong bóng */
.main-hero:has(.pending-turn) { align-items: flex-start; }
.pick-hero .pending-turn .turn-ask { margin-top: 0; }
.conv .pending-turn { margin-top: 0; }
.pending-turn .turn-ask { margin-top: 24px; }
/* Thẻ chờ gọn: 1 hàng tiêu đề + các bước nhỏ; 1 hiệu ứng duy nhất (vệt
   mảnh mép trên) ngoài spinner của bước hiện tại. */
.runblock.pending-card { position: relative; overflow: hidden; padding: 14px 20px; margin: 12px 0 24px; }
.pending-card::before {
  content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: pending-sweep 1.8s ease-in-out infinite;
}
@keyframes pending-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.pending-head { display: flex; align-items: baseline; gap: 12px; }
.pending-head strong { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.pending-time {
  margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.pending-steps { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; line-height: 1.45; }
.pending-steps li { display: flex; align-items: center; gap: 8px; padding: 1px 0; }
.pending-steps li.is-done { color: var(--muted); }
.pending-steps li.is-current { color: var(--ink); }
.step-icon {
  flex: none; width: 12px; height: 12px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
}
.is-done .step-icon { color: var(--ok-ink); }
.is-current .step-icon {
  box-sizing: border-box; border-radius: 50%;
  border: 1.5px solid var(--accent); border-right-color: transparent;
  animation: btn-spin .8s linear infinite;
}
.pending-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) {
  .pending-card::before, .is-current .step-icon { animation: none; }
}


/* Nút mắt ẩn/hiện "Cảnh báo điều kiện áp dụng" (2026-09-26) */
.warnbox-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.warn-eye { background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--muted, inherit); border-radius: 4px; line-height: 0; }
.warn-eye:hover { color: inherit; background: var(--line); }
.warn-eye .eye-off { display: none; }
html.warn-hidden .warnbox .warnlist { display: none; }
html.warn-hidden .warnbox { padding-top: 8px; padding-bottom: 8px; }
html.warn-hidden .warn-eye .eye-on { display: none; }
html.warn-hidden .warn-eye .eye-off { display: inline; }

/* ---- tab Sequence (2026-09-29, app/templates/_sequence.html) ---- */
.seq-page { max-width: 1100px; }
.seq-lead { margin: 0 0 4px; }
.seq-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 28px; }
.seq-grid > .field { margin: 0 0 16px; }
.seq-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seq-inline input[type=date] { width: auto; }
.seq-inline select { width: auto; max-width: 220px; }
.seq-cond { margin-bottom: 6px; flex-wrap: nowrap; }
.seq-cond select { flex: 1 1 150px; min-width: 0; max-width: 200px; }
.seq-cond input[type=text] { flex: 1 1 110px; min-width: 0; max-width: 150px; }
input[type=number].seq-num, .seq-form input[type=number] {
  width: 90px; padding: 8px 10px; font: inherit; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink);
}
.seq-form textarea {
  width: 100%; max-width: 640px; padding: 8px 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); resize: vertical;
}
.seq-form input[type=number]:focus-visible, .seq-form textarea:focus-visible {
  border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft);
}
.seq-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seq-seg label { display: flex; align-items: center; gap: 6px; margin: 0; padding: 7px 12px;
  font-weight: 500; font-size: 14px; cursor: pointer; border-right: 1px solid var(--line); }
.seq-seg label:last-child { border-right: 0; }
.seq-seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seq-seg input { accent-color: var(--accent); margin: 0; }
.field label.seq-check, .seq-check { display: flex; align-items: center; gap: 7px; font-weight: 500; margin-top: 8px; cursor: pointer; }
.seq-check input { accent-color: var(--accent); }
.seq-box { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
  padding: 10px 12px; max-height: 210px; overflow-y: auto; }
.seq-box-sm { max-height: 150px; }
.seq-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 16px; }
.seq-cols label { font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; margin: 0; font-weight: 400; }
.seq-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.btn-sm, button.btn-sm { padding: 5px 11px; font-size: 13px; }
.seq-adv { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.seq-adv > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.seq-fs { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 16px 14px; margin: 14px 0 0; min-width: 0; }
.seq-fs legend { padding: 0 6px; font-weight: 600; }
.seq-fs legend .seq-check { margin: 0; }
.seq-fs > .hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.seq-fs .seq-grid { margin-top: 6px; }
.seq-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.seq-est { font-size: 13.5px; }
.seq-est.ok { color: var(--ok-ink); }
.seq-est.bad { color: var(--bad-ink); }
.seq-est-wrap.htmx-request::before { content: "Đang ước tính…"; color: var(--muted); font-size: 13.5px; }
.seq-result { scroll-margin-top: 80px; }
a.seq-uid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
a.data-note.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
th.tl, td.tl { text-align: left; }  /* cột chuỗi/ID của run sequence */
td.seq-wrap { white-space: normal; min-width: 420px; max-width: 900px; overflow-wrap: anywhere; line-height: 1.5; }

/* ---- Đăng nhập / tài khoản (2026-10-06 UI fix) ---- */
/* Topbar: cụm điều hướng game (.topbar-links, margin-left:auto) | vạch |
   cụm tài khoản (link quản trị chỉ admin + menu người dùng <details>). */
.topbar-links a.data-note, .topbar-acct a.data-note, .user-menu-btn {
  display: inline-flex; align-items: center; height: 34px; line-height: 1;
}
.topbar-acct { display: flex; align-items: center; gap: 8px; }
.user-menu { position: relative; }
.user-menu-btn {
  list-style: none; cursor: pointer; user-select: none; gap: 7px;
  padding: 0 11px 0 12px; border-radius: var(--radius-pill); border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600;
  transition: color .12s, border-color .12s, background .12s;
}
.user-menu-btn::-webkit-details-marker { display: none; }
.user-menu-btn::marker { content: ""; }
.user-menu-btn:hover, .user-menu[open] .user-menu-btn {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.user-menu-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { color: var(--muted); transition: transform .12s; }
.user-menu[open] .user-menu-caret { transform: rotate(180deg); }
.user-menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 170px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.user-menu-pop form { margin: 0; }
.user-menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0;
  border-radius: var(--radius-sm); background: none; color: var(--ink);
  font: inherit; font-size: 14px; line-height: 1.3; cursor: pointer;
}
.user-menu-item:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
@media (max-width: 900px) {
  .topbar-acct-sep { display: none; }
  .topbar-acct { margin-left: auto; }
}

/* Banner "mật khẩu mặc định": dải mỏng ở đầu .main, định vị absolute để
   KHÔNG làm flex item của .main-hero (canh giữa ô hỏi). */
.main { position: relative; }
.pw-banner {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; margin: 0;
  padding: 6px 44px 6px clamp(20px, 5vw, 56px); font-size: 13px; line-height: 1.5;
  background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line);
}
.pw-banner a { color: inherit; font-weight: 700; text-decoration: underline; }
.main:has(> .pw-banner) { padding-top: 72px; }
.pw-banner-x {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%);
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.pw-banner-x:hover { background: var(--warn-line); }

/* Trang đăng nhập / đổi mật khẩu: 1 thẻ canh giữa màn hình. */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; }
.auth-card {
  width: 360px; max-width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 28px 28px 24px;
}
.auth-brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 22px; margin: 0 0 16px; }
.auth-note { font-size: 13px; margin: -8px 0 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.auth-field input, .auth-submit { width: 100%; height: 40px; font: inherit; font-size: 15px;
  border-radius: var(--radius-sm); }
.auth-field input {
  padding: 0 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
.auth-field input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-submit { margin-top: 4px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; transition: background .12s; }
.auth-submit:hover { background: var(--accent-hover); }
.auth-msg { margin: 0; padding: 8px 12px; font-size: 13px; line-height: 1.45;
  border-radius: var(--radius-sm); border: 1px solid; }
.auth-card > .auth-msg { margin-bottom: 14px; }
.auth-msg-bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.auth-msg-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.auth-msg-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.auth-foot { margin: 18px 0 0; font-size: 13px; text-align: center; }

/* ---- Trang quản trị (admin_users / admin_activity*) — không dùng shell ---- */
.adm-topbar .topbar-links { margin-left: auto; }
.auth-field select { width: 100%; max-width: none; height: 40px; padding: 0 10px; font-size: 15px; }
.auth-field input { max-width: none; }
.adm-main { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.adm-main h1 { margin-bottom: 18px; }
.adm-main h2 { margin: 32px 0 12px; }
.adm-main h3 { margin: 0 0 8px; }
.adm-msg { margin: 0 0 16px; }
.adm-note { font-size: 13px; margin: 0 0 12px; }
.adm-back { margin: 0 0 8px; font-size: 14px; }
.adm-table { background: var(--panel); }
.adm-table table { font-size: 13.5px; }
.adm-table th, .adm-table td { text-align: left; vertical-align: middle; padding: 10px 14px; }
.adm-table th.num, .adm-table td.num { text-align: right; }
.adm-table td.adm-wrap { white-space: normal; min-width: 260px; }
.adm-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 600; line-height: 1.6; border: 1px solid var(--line);
  background: var(--line-soft); color: var(--muted); }
td > .adm-tag:first-child { margin-left: 0; }
.adm-tag-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.adm-tag-ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.adm-tag-bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.adm-inline { display: flex; align-items: center; gap: 6px; margin: 0; }
.adm-actions { display: flex; align-items: center; gap: 8px; }
.adm-actions form { margin: 0; }
.adm-input, .adm-btn { height: 32px; font: inherit; font-size: 13px; border-radius: var(--radius-sm); }
.adm-input { width: 170px; padding: 0 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.adm-input-pw { width: 160px; }
.adm-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.adm-btn { display: inline-flex; align-items: center; padding: 0 12px; white-space: nowrap; }
.adm-card { max-width: 480px; margin-top: 36px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 22px 24px 24px; }
.adm-card h2 { margin: 0 0 16px; }
.adm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.adm-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 12px; }
.adm-filter .auth-field { width: 180px; }
.adm-filter .auth-field input, .adm-filter .auth-field select { font-size: 14px; }
.adm-filter-btn { height: 40px; padding: 0 20px; }
.adm-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 700px) {
  .adm-grid2, .adm-split { grid-template-columns: 1fr; }
  .adm-filter .auth-field { width: 100%; }
}
/* Bảng admin vừa khung 1100px: tiêu đề được xuống dòng, ô nhập gọn hơn. */
.adm-table thead th { white-space: normal; vertical-align: bottom; line-height: 1.35; }
.adm-table th, .adm-table td { padding: 10px 12px; }
.adm-table .adm-input { width: 130px; }
.adm-table .adm-input-pw { width: 140px; }
.adm-table td.adm-who { white-space: normal; min-width: 150px; }
.adm-table td.adm-who .adm-tag { margin: 4px 0 0; }
.adm-table .adm-input-pw { width: 120px; }
.adm-table .adm-input { width: 120px; }

/* ---------- Chart cho bảng kết quả (2026-10-07, Dashboard GĐ1; app/static/charts.js) ---------- */
.run-chart { margin: 10px 0 12px; }
.chart-box { margin: 0 0 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 12px 14px 10px; }
.chart-title { font-weight: 600; font-size: 14px; margin: 0 0 6px; color: var(--ink); }
.chart-canvas-wrap { position: relative; height: 280px; }
.chart-note { font-size: 12px; margin: 6px 0 0; }
.chart-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chart-editor > summary { list-style: none; cursor: pointer; display: inline-flex; font-size: 13px; padding: 5px 11px; }
.chart-editor > summary::-webkit-details-marker { display: none; }
.chart-editor[open] { flex-basis: 100%; }
.chart-form { margin-top: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); display: flex; flex-direction: column; gap: 10px; }
.cf-row { display: flex; flex-wrap: wrap; gap: 12px; }
.cf-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cf-row select, .cf-row input[type=text] { font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); min-width: 140px; }
.cf-title input[type=text] { min-width: 340px; }
.cf-y { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 6px 10px 8px; margin: 0;
  display: flex; flex-wrap: wrap; gap: 4px 14px; max-height: 160px; overflow: auto; }
.cf-y legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.cf-check { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cf-buttons { display: flex; gap: 8px; }
.chart-error { margin: 0; color: var(--bad-ink); background: var(--bad-bg); border: 1px solid var(--bad-line);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; }
.dash-save .btn, .dash-save-done { font-size: 13px; padding: 5px 11px; }
.dash-save-done { color: var(--ok-ink); display: inline-flex; align-items: center; }

/* ---------- Dashboard theo game (2026-10-07, GĐ2/GĐ3; app/static/dashboard.js) ---------- */
.dash { width: var(--dash-canvas-w, 1280px); margin: 0 auto; padding: 4px 0 40px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 12px; }
.dash-h1 { font-size: 20px; margin: 0 0 4px; }
.dash-sub { margin: 0; font-size: 13px; }
.dash-head-actions { display: flex; align-items: center; gap: 10px; }
.dash-layout-msg, .dash-filter-msg { font-size: 12px; }
.dash-filter { margin-bottom: 12px; }
.dash-partial { font-weight: 400; color: var(--muted); }
.dash-reset { font-size: 13px; padding: 6px 12px; }
.dash-nofilter { font-size: 13px; }
.dash-empty { padding: 18px 20px; }
.grid-stack { min-height: 120px; }
.grid-stack-item-content.dash-cell { display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.dash-cell.is-loading { opacity: .55; pointer-events: none; }
.dash-cell.is-loading .dash-cell-head::after { content: "Đang tải…"; font-size: 12px; color: var(--muted); margin-left: auto; }
.dash-cell-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px 12px; min-height: 34px; }
#dash.is-editing .dash-cell-head { cursor: move; }
.dash-cell-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-cell-tools { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: default; }
.dash-menu { position: relative; }
.dash-menu > summary { list-style: none; cursor: pointer; padding: 0 6px; border-radius: var(--radius-sm); font-size: 16px; line-height: 20px; }
.dash-menu > summary::-webkit-details-marker { display: none; }
.dash-menu > summary:hover { background: var(--line-soft); }
.dash-menu-pop { position: absolute; right: 0; top: 24px; z-index: 50; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); padding: 10px; display: flex; flex-direction: column; gap: 8px; width: 260px; }
.dash-rename { display: flex; gap: 6px; margin: 0; }
.dash-rename input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); }
.dash-menu-pop .btn { font-size: 12px; padding: 5px 10px; }
.dash-menu-pop form { margin: 0; }
.dash-del { color: var(--bad-ink); }
.dash-cell-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px; }
.dash-chart { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 0; padding: 0; margin: 0; background: transparent; }
.dash-chart .chart-canvas-wrap { flex: 1; min-height: 0; height: auto; }
.dash-chart .chart-note { margin: 2px 0 0; }
.dash-problem { font-size: 13px; margin: 8px 0; }
.dash-err { color: var(--bad-ink); background: var(--bad-bg); border: 1px solid var(--bad-line); border-radius: var(--radius-sm);
  padding: 4px 8px; font-size: 12px; margin: 0 0 6px; overflow: auto; max-height: 64px; }
.dash-cell-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 4px 12px 8px; font-size: 11.5px; }
.dash-scope { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dash-temp { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-pill); padding: 1px 8px; }
.dash-na { color: var(--muted); font-style: italic; }
.dash-setrun { font-size: 11.5px; padding: 2px 8px; }
/* Ô bảng thô trên dashboard (2026-10-07) */
.dash-table-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.dash-table { border-collapse: collapse; font-size: 12.5px; width: max-content; min-width: 100%; }
.dash-table th, .dash-table td { padding: 5px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; text-align: right; }
.dash-table th:first-child, .dash-table td:first-child { text-align: left; }
.dash-table thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; box-shadow: inset 0 -1px 0 var(--line); }
.dash-table-note { font-size: 11.5px; margin: 4px 0 0; }
.dash-chart-edit > summary { list-style: none; cursor: pointer; font-size: 12px; padding: 5px 10px; display: inline-flex; }
.dash-chart-edit > summary::-webkit-details-marker { display: none; }
.dash-chart-form { margin-top: 6px; padding: 8px; gap: 6px; }
.dash-chart-form label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.dash-chart-form select, .dash-chart-form input[type=text] { font: inherit; font-size: 12.5px; padding: 4px 6px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); }
.dash-chart-form .cf-y { max-height: 260px; }
.dash-chart-hint { font-size: 11px; margin: 0; }
.dash-menu-pop { max-height: 70vh; overflow: auto; width: 300px; }
/* Menu ⋯ của ô không bị cắt bởi khung ô; ô đang mở menu nổi lên trên ô khác. */
.grid-stack-item-content.dash-cell { overflow: visible !important; }
.grid-stack-item:has(.dash-menu[open]) { z-index: 100 !important; }
.dash-chart-form label.cf-check { flex-direction: row; align-items: center; gap: 4px; font-weight: 400; color: var(--ink); font-size: 12.5px; }

/* Trang Dashboard toàn màn hình (2026-10-07): không sidebar/ô hỏi; canvas rộng cố định, cửa sổ
   hẹp hơn -> cuộn ngang (không co/xếp lại ô). Chế độ XEM/SỬA: .is-editing trên #dash. */
.shell-full { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
.shell-full .main { padding: 20px 24px 60px; overflow-x: auto; }
.dash-back { margin: 0 0 6px; font-size: 13px; }
#dash:not(.is-editing) .dash-menu, #dash:not(.is-editing) .dash-edit-only,
#dash:not(.is-editing) .dash-sub-edit, #dash.is-editing .dash-view-only,
#dash.is-editing .dash-sub-view { display: none; }
#dash.is-editing .grid-stack { outline: 1px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-md);
  background-image: linear-gradient(to right, var(--line-soft) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
@media (max-width: 900px) { .shell-full { grid-template-areas: "top" "main"; } }

/* Tên hiển thị cột Y trong form chart: ô nhập luôn hiện, disabled + mờ khi cột chưa tick. */
.cf-y { flex-direction: column; flex-wrap: nowrap; gap: 0; max-height: 240px; }
.cf-yhead { position: sticky; top: -6px; background: var(--panel); padding: 2px 0; z-index: 1; display: flex; gap: 6px; font-size: 11.5px; color: var(--muted); margin: 0 0 3px; }
.cf-yhead span:first-child { flex: 1; min-width: 0; }
.cf-yhead span:last-child { width: 190px; }
.cf-yrow { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; flex: none; }
.cf-yrow .cf-check { flex: 1; min-width: 0; white-space: normal; }
.cf-ylabel-wrap { position: relative; width: 190px; flex: none; }
.cf-pen { position: absolute; left: 7px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.cf-yrow .cf-ylabel { font: inherit; font-size: 12.5px; padding: 4px 6px 4px 24px; border: 1px solid var(--ink-muted, #8a8f98);
  border-radius: var(--radius-sm); background: #fff; color: #111; width: 100%; box-sizing: border-box; }
.cf-yrow .cf-ylabel:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.cf-yrow .cf-ylabel:disabled { opacity: .45; background: var(--line-soft, #f1f1f1); cursor: not-allowed; }
.cf-yrow:has(.cf-ylabel:disabled) .cf-pen { opacity: .45; }
.dash-chart-form .cf-yrow .cf-ylabel-wrap, .dash-chart-form .cf-yhead span:last-child { width: 118px; }
.dash-chart-form .cf-yhead { font-size: 11px; }
.dash-chart-form .cf-y { max-height: 260px; }

/* Icon ⓘ (2026-10-07): phạm vi / cảnh báo / "Không áp bộ lọc" của ô dashboard + cảnh báo chart
   trong hội thoại — thay các dòng ghi chú luôn hiện dưới chart. Hover hoặc bấm (focus) để xem. */
.pb-info { position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; font-size: 13px; font-weight: 400; line-height: 1;
  color: var(--muted); cursor: help; flex: none; outline: none; }
.pb-info[hidden] { display: none; }
.pb-info:hover, .pb-info:focus { background: var(--line-soft); color: var(--ink); }
.pb-info.has-warn { color: var(--warn-ink); }
.pb-info-pop { display: none; position: absolute; left: 0; top: 22px; z-index: 60; width: 320px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: 12px; font-weight: 400;
  line-height: 1.45; white-space: normal; text-align: left; cursor: default; }
.pb-info:hover .pb-info-pop, .pb-info:focus .pb-info-pop, .pb-info:focus-within .pb-info-pop { display: block; }
.pb-info-line { display: block; }
.pb-info-line + .pb-info-line { margin-top: 4px; }
.pb-info-line[hidden] { display: none; }
.pb-info-warn { color: var(--warn-ink); }
.pb-info-pop .dash-na { font-style: italic; }
.grid-stack-item:has(.pb-info:hover), .grid-stack-item:has(.pb-info:focus) { z-index: 100 !important; }
.pb-info-pop .dash-scope, .pb-info-pop .dash-table-note, .pb-info-pop .chart-note {
  white-space: normal; overflow: visible; margin: 0; font-size: 12px; max-width: none; }
.chart-title .pb-info { vertical-align: -3px; margin-left: 4px; }

/* "Thêm bộ lọc chuẩn" (2026-10-07): trạng thái đang chạy trên ô + thông báo sau khi thêm. */
.dash-cell.dash-busy-filter { position: relative; }
.dash-cell.dash-busy-filter::after { content: "Đang thêm bộ lọc… (AI viết lại SQL, chạy thử và đối chiếu số liệu)"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--ink); z-index: 5; }
.dash-stdnote { max-height: 120px; }
.dash-flash { margin: 0 0 10px; font-size: 13px; border-color: var(--accent, #2563eb); }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: 120px; height: 100%;
  color: var(--muted, #888); font-size: 14px; }
.dash-empty-note { font-weight: 600; }

/* ---- Topbar gọn: menu "Công cụ ▾" (2026-10-08, việc 20) ---- */
.tools-pop { left: 0; right: auto; }
.user-menu-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.user-menu-item.on { color: var(--accent); font-weight: 600; }
.user-menu-sep { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* ---- Trang SQL (việc 20 GĐ1, _sql_lab.html) ---- */
.pill.sqllab { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.sql-page { max-width: 1500px; margin: 0 auto; }
.sql-lead { margin: 0 0 14px; }
.sql-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 18px; align-items: start; }
.sql-schema {
  position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); padding: 10px;
}
.sql-schema .hint { font-size: 12px; color: var(--muted); margin: 6px 2px 8px; }
.sql-filter { width: 100%; font-size: 13px; padding: 6px 9px; }
.sql-table > summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 4px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
}
.sql-table > summary:hover { background: var(--line-soft); }
.sql-tname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sql-ins {
  flex: none; width: 20px; height: 20px; padding: 0; border-radius: 5px; font-size: 14px; line-height: 1;
  background: var(--panel); color: var(--accent); border: 1px solid var(--line);
}
.sql-ins:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.sql-tdesc { font-size: 12px; color: var(--muted); margin: 2px 6px 4px 18px; }
.sql-cols { list-style: none; margin: 0 0 6px; padding: 0 0 0 14px; }
.sql-cols li { font-size: 12.5px; padding: 1px 0; }
.sql-col {
  background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-weight: 500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; cursor: pointer;
}
.sql-col:hover { background: none; color: var(--accent); text-decoration: underline; }
.sql-ctype { color: var(--muted); font-size: 11px; }
.sql-cdesc { color: var(--muted); font-size: 11.5px; margin: 0 0 3px; }
.sql-main { min-width: 0; }
.sql-form .CodeMirror, .sql-form textarea#sql-editor {
  height: auto; min-height: 260px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); color: var(--ink); font-size: 13px; width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sql-form .CodeMirror-scroll { min-height: 260px; }
.sql-form .CodeMirror-focused { border-color: var(--accent); }
.sql-form .CodeMirror-gutters { background: var(--bg); border-right: 1px solid var(--line); border-radius: var(--radius-md) 0 0 var(--radius-md); }
.sql-form .CodeMirror-cursor { border-left-color: var(--ink); }
.sql-form .CodeMirror .cm-keyword { color: var(--accent); font-weight: 600; }
.sql-form .CodeMirror .cm-comment { color: var(--muted); }
.sql-form .CodeMirror .cm-string, .sql-form .CodeMirror .cm-string-2 { color: var(--ok-ink); }
.sql-form .CodeMirror .cm-variable-2 { color: var(--warn-ink); }
.sql-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; }
.sql-bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sql-limit { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sql-title { width: 260px; font-size: 13px; padding: 7px 10px; }
.sql-aux { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.sql-aux-box { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); padding: 10px 14px; }
.sql-aux-box h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sql-params { display: flex; flex-direction: column; gap: 10px; }
.sql-param-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sql-param-row .sql-ptype { width: auto; font-size: 12px; padding: 5px 6px; }
.sql-param-row .rf-chipbox { flex: 1; }
.sql-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sql-chk { font-size: 13px; padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.sql-chk .btn { margin-top: 6px; display: inline-block; }
.sql-chk.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-ink); }
.sql-chk.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.sql-chk.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.sql-chk.info { color: var(--muted); }
.sql-history { margin: 16px 0 0; }
.sql-history > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.sql-history ul { margin: 8px 0 0; padding-left: 18px; font-size: 13.5px; }
#sql-checks.htmx-request { opacity: .6; }
.sql-param .rf-chipbox input.rf-chip-text { border: 0; padding: 3px 2px; min-width: 70px; box-shadow: none; }
.sql-bar #sql-est { order: 10; flex-basis: 100%; }

/* ---- Trang SQL: dataset + chart (2026-10-08) ---- */
.sql-ds-list h3 { font-size: 12px; margin: 10px 2px 4px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sql-ds-list ul { list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; }
.sql-ds-list li { padding: 3px 4px; border-radius: var(--radius-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sql-ds-list li.on { background: var(--accent-soft); font-weight: 600; }
.sql-ds-save { margin-top: 14px; }
.sql-ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; margin: 6px 0; }
.sql-ds-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sql-chart-builder { margin: 18px 0 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--panel); padding: 14px 18px; }
.sql-chart-builder h2 { font-size: 17px; margin: 0 0 6px; }
.sql-chart-builder h3 { font-size: 13px; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sql-chart-form { border: 0; padding: 0; }
/* 1 chỉ số = 1 dòng (2026-10-08): không xuống dòng, các ô co giãn chia đều bề ngang. */
.sql-metric-row { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; margin-bottom: 6px; }
.sql-metric-row [hidden] { display: none; }
.sql-metric-row select, .sql-metric-row input { width: auto; min-width: 0; font-size: 13px; padding: 6px 8px; }
.sql-metric-row .m-kind { flex: 0 0 76px; }
.sql-metric-row .m-sel { flex: 1 1 0; }
.sql-metric-row .m-mult { flex: 0 0 104px; }
.sql-metric-row .m-label { flex: 1.3 1 0; }
.sql-metric-row .m-div { flex: 0 0 auto; color: var(--muted); }
.sql-metric-row .m-del { flex: 0 0 auto; border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.sql-metric-row .m-del:hover { color: var(--bad-ink); background: var(--accent-soft); }
.sql-metrics + template + [data-metric-add] { margin-top: 2px; }
/* Kéo thả đổi thứ tự chỉ số (2026-10-08): tay kéo đầu dòng; vạch chỉ vị trí thả. */
.sql-metric-row .m-grip { flex: 0 0 auto; cursor: grab; color: var(--muted); user-select: none; padding: 2px 3px;
  letter-spacing: -3px; font-size: 14px; line-height: 1; border-radius: 4px; }
.sql-metric-row .m-grip:hover, .sql-metric-row .m-grip:focus-visible { color: var(--ink, inherit); background: var(--accent-soft); }
.sql-metric-row .m-grip:active { cursor: grabbing; }
.sql-metric-row.m-dragging { opacity: .45; }
.sql-metric-row.m-drop-before { box-shadow: 0 -2px 0 0 var(--accent); }
.sql-metric-row.m-drop-after { box-shadow: 0 2px 0 0 var(--accent); }
.seq-est.warn { color: var(--warn-ink); }
.dash-est { display: block; font-size: 12px; color: var(--muted); padding: 2px 0; }
.dash-est.bad { color: var(--bad-ink); }

/* ---------- Dashboard nhiều tab (2026-10-08; _dashboard.html, dashboard.js) ---------- */
.dash-tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px; margin: 0 0 12px;
  border-bottom: 1px solid var(--line); }
.dash-tab { display: inline-flex; align-items: center; gap: 2px; padding: 0 4px 0 0;
  border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; margin-bottom: -1px; }
.dash-tab-link { display: inline-block; padding: 8px 12px; font-size: 14px; color: var(--muted); text-decoration: none; }
.dash-tab-link:hover { color: var(--ink); }
.dash-tab.is-active { background: var(--panel); border-color: var(--line); }
.dash-tab.is-active .dash-tab-link { color: var(--ink); font-weight: 600; }
.dash-tab-tools { display: inline-flex; gap: 1px; }
.dash-tab-btn { border: none; background: none; color: var(--muted); cursor: pointer; padding: 2px 4px;
  font-size: 13px; line-height: 1; border-radius: 4px; }
.dash-tab-btn:hover { color: var(--ink); background: var(--accent-soft); }
.dash-tab-add { display: inline-flex; gap: 6px; align-items: center; margin: 0 0 4px 8px; }
.dash-tab-add input { width: 140px; font-size: 13px; padding: 5px 8px; }
.dash-tab-add .btn { font-size: 13px; padding: 5px 10px; }
#dash:not(.is-editing) .dash-tab-add { display: none; }
.dash-tab-msg { font-size: 12px; margin: 0 0 6px 10px; }
.dash-tabform { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dash-tabform select { font-size: 13px; max-width: 160px; }
.dash-tabsel { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.chart-actions .chart-editor > summary, .dash-save .inline-form { height: 34px; box-sizing: border-box; align-items: center; }
.chart-actions .chart-editor > summary { padding: 0 14px; }
/* Nút Lưu + chọn tab = 1 khối viền chung, ngăn bằng vạch dọc (2026-10-28) */
.dash-save .inline-form { display: inline-flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); overflow: hidden; }
.dash-save .inline-form .btn { margin: 0; height: 100%; padding: 0 14px; border: 0; border-radius: 0; background: transparent;
  white-space: nowrap; display: inline-flex; align-items: center; }
.dash-save .inline-form .btn:hover { background: var(--line-soft); }
.dash-save-tab { width: auto; height: 100%; margin: 0; max-width: 160px; font-size: 13px; box-sizing: border-box;
  padding: 0 28px 0 12px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background-color: var(--line-soft);
  box-shadow: none; }

/* Dashboard CJ (2026-10-13): câu hỏi chính từng tab, scorecard KPI, ô Platform khoá */
.dash-tabinfo { margin: 6px 0 10px; }
.dash-question { margin: 0 0 4px; font-size: 14px; }
.dash-missing { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.rf-platform select:disabled { opacity: .6; cursor: not-allowed; }
.dash-score { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; height: 100%; align-content: center; }
.dash-tile { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); min-width: 0; }
.dash-tile-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-tile-value { font-size: 24px; font-weight: 650; line-height: 1.2; }
.dash-tile-delta { font-size: 12px; margin-top: 2px; }
.dash-tile-delta.up { color: #1a7f4b; }
.dash-tile-delta.down { color: #c0392b; }
.dash-tile-delta.flat { color: var(--muted); }
.dash .dash-filter { flex-wrap: wrap; }
.dash-fgroup { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; padding-right: 14px; margin-right: 6px; border-right: 1px solid var(--line); position: relative; padding-top: 14px; }
.dash-fgroup:last-of-type { border-right: 0; }
.dash-fgroup-label { position: absolute; top: 0; left: 0; font-size: 10.5px; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.dash-heading { font-size: 17px; font-weight: 650; padding: 4px 2px 0; border-bottom: 1px solid var(--line); height: 100%; display: flex; align-items: flex-end; }
.dash-heading-cell { background: transparent !important; box-shadow: none !important; border: 0 !important; }
.dash-score.single { grid-template-columns: 1fr; }
.dash-score.single .dash-tile { border: 0; padding: 0 4px; background: transparent; }
.dash-score.single .dash-tile-label { display: none; }
.dash-score-cell .dash-cell-tools > a { display: none; }
.dash-score-cell .dash-cell-title { white-space: nowrap; overflow: visible; }
/* Ô bảng dashboard gọn hơn (2026-10-13): tiêu đề cột xuống dòng, ít padding -> ít phải cuộn ngang */
.dash-table { font-size: 12px; }
.dash-table th, .dash-table td { padding: 4px 7px; }
.dash-table thead th { white-space: normal; min-width: 64px; max-width: 120px; line-height: 1.2; vertical-align: bottom; }

/* Thanh lọc dashboard CJ (2026-10-13): PRIMARY | ACQUISITION cùng hàng, ô cao đều 36px, nút thẳng hàng */
.dash-filter-cj { flex-wrap: wrap; align-items: flex-end; gap: 8px 14px; padding: 10px 14px 12px; margin-bottom: 8px; }
.dash-filter-cj .rerun-bar-label { display: none; }
.dash-filter-cj .dash-partial { display: none; }
.dash-filter-cj .dash-fgroup { flex: none; gap: 8px 10px; align-items: flex-end; flex-wrap: nowrap; padding: 16px 0 0; margin: 0; border: 0; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] { padding-left: 14px; border-left: 1px solid var(--line); }
.dash-filter-cj .dash-fgroup-label { left: 0; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] .dash-fgroup-label { left: 14px; }
.dash-filter-cj .rf-field { flex: none; width: 128px; }
.dash-filter-cj .rf-field:has(.rf-daterange) { width: 238px; }
.dash-filter-cj .rf-field label { font-size: 11.5px; line-height: 16px; white-space: nowrap; }
.dash-filter-cj .rf-daterange, .dash-filter-cj .rf-chipbox { height: 36px; box-sizing: border-box; padding: 0 6px; }
.dash-filter-cj .rf-chipbox { min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.dash-filter-cj .rf-daterange input[type=date] { padding: 0 2px; font-size: 12.5px; height: 32px; }
.dash-filter-cj .rf-field input.rf-chip-text { min-width: 40px; padding: 0 2px; border: 0; box-shadow: none; background: transparent; width: 100%; height: 100%; }
.dash-filter-cj .dash-actions .btn, .dash-filter-cj .dash-actions .rf-apply { height: 36px; box-sizing: border-box; padding: 0 14px; font-size: 13px; line-height: 1; }
.dash-filter-cj .dash-actions .rf-apply { font-weight: 600; padding: 0 20px; }
.dash-filter-cj .dash-actions .btn.ghost { padding: 0 11px; font-size: 12.5px; color: var(--muted); }
.dash-filter-cj .dash-filter-msg { flex-basis: 100%; font-size: 12px; margin: 0; }
.dash-filter-cj .dash-filter-msg:empty { display: none; }
.dash-intro { margin: 8px 0 10px; font-size: 13px; color: var(--muted); line-height: 1.45; max-width: none; }
.dash-h1 .dash-info { font-size: 14px; vertical-align: middle; margin-left: 4px; }

/* Ô bảng dashboard: kính lúp tìm trong bảng; nút Bảng ↗/xlsx chỉ hiện ở chế độ Sửa (2026-10-14) */
#dash:not(.is-editing) .dash-cell-tools > a { display: none; }
.dash-search-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 4px; line-height: 1; border-radius: 4px; }
.dash-search-btn:hover { color: var(--accent); background: var(--accent-soft); }
.dash-search-box { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.dash-search-box[hidden] { display: none; }
.dash-search-input { flex: 1; min-width: 0; height: 26px; font-size: 12.5px; padding: 0 8px; box-sizing: border-box; }
.dash-search-count { font-size: 11.5px; white-space: nowrap; }
.dash-search-clear { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.dash-table tbody tr[hidden] { display: none; }

/* Phóng to ô (modal) + cột đầu dính khi cuộn ngang (2026-10-14) */
.dash-zoom-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 4px; line-height: 1; border-radius: 4px; }
.dash-zoom-btn:hover { color: var(--accent); background: var(--accent-soft); }
.dash-zoom-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 18, 30, .55); display: flex; align-items: center; justify-content: center; padding: 3vh 3vw; }
.dash-zoom-panel { width: 100%; height: 100%; max-width: 1800px; background: var(--panel); border-radius: var(--radius-md); box-shadow: 0 10px 40px rgba(0,0,0,.35); display: flex; flex-direction: column; padding: 14px 16px; box-sizing: border-box; min-height: 0; }
.dash-zoom-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dash-zoom-title { font-weight: 650; font-size: 16px; }
.dash-zoom-close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 6px; }
.dash-zoom-close:hover { color: var(--ink); }
.dash-zoom-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.dash-zoom-body .dash-table-wrap { flex: 1; min-height: 0; }
.dash-zoom-body .dash-table { font-size: 13px; }
.dash-zoom-body .chart-box, .dash-zoom-body .dash-chart { flex: 1; min-height: 0; }
.dash-zoom-body .chart-canvas-wrap { height: 100%; }
html.dash-zoom-open { overflow: hidden; }
.dash-table td:first-child, .dash-table th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; box-shadow: 2px 0 4px -2px rgba(0,0,0,.18); }
.dash-table thead th:first-child { z-index: 3; }


/* ---- Phase 3 (2026-10-14): bảng màu teal + nhấn theo nhóm câu hỏi (theo mẫu UI Son gửi) ---- */
.qgroup { --cat: var(--accent); --cat-bg: var(--accent-soft); }
.qgroup[data-cat="so_sanh_version"] { --cat: var(--tag-version); --cat-bg: var(--tag-version-bg); }
.qgroup[data-cat="theo_doi_hang_ngay"] { --cat: var(--tag-daily); --cat-bg: var(--tag-daily-bg); }
.qgroup[data-cat="theo_ngay_cai"] { --cat: var(--tag-cohort); --cat-bg: var(--tag-cohort-bg); }
.qgroup[data-cat="minigame"] { --cat: var(--tag-mini); --cat-bg: var(--tag-mini-bg); }
.qgroup[data-cat="ab_test"] { --cat: var(--tag-ab); --cat-bg: var(--tag-ab-bg); }
.qgroup[data-cat="level"] { --cat: var(--tag-level); --cat-bg: var(--tag-level-bg); }
.qgroup-h { color: var(--cat); }
.qgroup-h::before { background: var(--cat); }
.qgroup .qchip { background: var(--cat-bg); border-color: transparent; }
.qgroup .qchip .qchip-t { color: var(--cat); font-weight: 600; }
.qgroup .qchip:hover { border-color: var(--cat); }
.ask-box button, .ask-box button.btn.ghost { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.ask-box button:hover, .ask-box button.btn.ghost:hover { background: var(--accent-hover); }

/* ---- Phase 4 (2026-10-14): cấu trúc theo mẫu UI mới — topbar dạng nhóm nút, nút sáng/tối,
   sidebar có tab + tìm kiếm, lưới thẻ Phân tích nhanh ở trang chủ ---- */
.proj-switch { display: flex; flex-direction: column; gap: 0; padding: 4px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--line-soft); }
.proj-switch:hover { border-color: var(--accent); }
.proj-cap { font-size: 10.5px; line-height: 1.2; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.proj-switch select { min-width: 150px; padding: 0 4px 0 0; border: 0; background: transparent; font-size: 14px; }
.proj-switch select:hover, .proj-switch select:focus-visible { background: transparent; border: 0; }

.seg-nav { gap: 4px; padding: 4px; background: var(--line-soft); border-radius: 10px; }
.seg-nav a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg-nav a:hover { color: var(--ink); text-decoration: none; }
.seg-nav a.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

.cost-link { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font-size: 13px; }
.cost-link:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.cost-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.theme-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--line-soft); border-radius: 10px; }
.theme-seg button { display: inline-grid; place-items: center; width: 32px; height: 30px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer; }
.theme-seg button:hover { color: var(--ink); }
.theme-seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }

/* sidebar: tìm kiếm + tab Hội thoại / Đã lưu (mỗi lúc hiện 1 danh sách) */
.side-search { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--line-soft); color: var(--muted); }
.side-search:focus-within { border-color: var(--accent); }
.side-search input { flex: 1 1 auto; min-width: 0; border: 0; background: transparent; outline: 0;
  color: var(--ink); font: inherit; font-size: 14px; padding: 0; }
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--line-soft); border-radius: 10px; }
.side-tabs button { min-height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.side-tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.side-tabs .cnt { margin-left: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.side-section[data-side-panel] { margin-top: 0; padding-top: 0; border-top: 0; }
.side-section[data-side-panel="conv"] .side-h { display: none; }
.side-section[data-side-panel="runs"] .side-h-label { display: none; }
.side-section[data-side-panel="runs"] .side-h { justify-content: flex-end; padding-bottom: 4px; }
.side-section[hidden] { display: none; }
.side-item[hidden] { display: none; }

/* trang chủ: tiêu đề + lưới thẻ */
.pick-hero { max-width: 1040px; }
.pick-hero .eyebrow { display: block; text-align: center; margin-bottom: 6px; }
.pick-hero h1 { margin-bottom: 20px; }
.qhome { margin-top: 36px; }
.qhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.qhead h2 { margin: 0 0 2px; }
.qhead .sub { margin: 0; color: var(--muted); font-size: 13px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { min-height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s; }
.pill:hover { background: var(--line-soft); }
.pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.qcard { --cat: var(--accent); --cat-bg: var(--accent-soft);
  display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
  transition: border-color .12s, box-shadow .12s, transform .12s; }
.qcard:hover { border-color: var(--cat); box-shadow: var(--shadow-card); transform: translateY(-1px); text-decoration: none; }
.qcard[data-cat="so_sanh_version"] { --cat: var(--tag-version); --cat-bg: var(--tag-version-bg); }
.qcard[data-cat="theo_doi_hang_ngay"] { --cat: var(--tag-daily); --cat-bg: var(--tag-daily-bg); }
.qcard[data-cat="theo_ngay_cai"] { --cat: var(--tag-cohort); --cat-bg: var(--tag-cohort-bg); }
.qcard[data-cat="minigame"] { --cat: var(--tag-mini); --cat-bg: var(--tag-mini-bg); }
.qcard[data-cat="ab_test"] { --cat: var(--tag-ab); --cat-bg: var(--tag-ab-bg); }
.qcard[data-cat="level"] { --cat: var(--tag-level); --cat-bg: var(--tag-level-bg); }
.qcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qcard-top svg { color: var(--muted); transition: transform .12s, color .12s; }
.qcard:hover .qcard-top svg { color: var(--cat); transform: translateX(3px); }
.qtag { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--cat-bg); color: var(--cat); }
.qcard-title { font-weight: 600; font-size: 15px; line-height: 1.4; }
.qcard-desc { font-size: 13px; color: var(--muted); line-height: 1.5; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.qcard[hidden] { display: none; }

@media (max-width: 1180px) { .cost-link span { display: none; } }

/* thẻ gọn: bỏ mô tả dài, chỉ nhãn nhóm + tiêu đề (mô tả đầy đủ ở tooltip) */
.qcard { gap: 12px; padding: 14px 16px; }
.qgrid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.qcard-desc { -webkit-line-clamp: 2; }

/* ---- sửa lỗi UI 14/10 (chiều 2): dropdown ở chế độ tối, nút sáng/tối lệch, font chart ---- */
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
select option, select optgroup { background: var(--panel); color: var(--ink); }
.theme-seg { align-items: center; }
.theme-seg button, .theme-seg button:hover, .theme-seg button:active {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 30px; padding: 0; margin: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted); line-height: 0; transform: none; }
.theme-seg button:hover { color: var(--ink); background: var(--line-soft); }
.theme-seg button[aria-pressed="true"], .theme-seg button[aria-pressed="true"]:hover {
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.theme-seg svg { display: block; }

/* ---- Dashboard 14/10 (chiều): header chế độ sửa gọn, menu ⋯ rút gọn, màu cột bảng ---- */
.dash-head-actions .btn, .dash-head-actions button { white-space: nowrap; flex: none; padding-left: 16px; padding-right: 16px; }
.dash-head { align-items: flex-start; gap: 16px; }
.dash-sub-edit { display: block; max-width: 640px; font-size: 13px; line-height: 1.5; }
.dash-tab-btn { font-size: 12px; padding: 2px 5px; opacity: .7; }
.dash-tab-btn:hover { opacity: 1; }
.dash-filter-cj .rf-field:has(.rf-daterange) { width: 270px; }
.rf-daterange { gap: 6px; flex-wrap: nowrap; }
.rf-daterange input[type=date] { min-width: 118px; }
.dash-fgroup-label { margin-bottom: 4px; }
.cc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.cc-check { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.cc-row input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer; }
.dash-colors-form .btn { margin-top: 6px; }
/* danh sách cột trong "Màu cột": cuộn riêng để menu không dài quá màn hình */
.dash-colors-form .cc-list { max-height: 240px; overflow-y: auto; padding-right: 4px; margin: 4px 0; }

/* "Màu cột": mỗi cột có hàng ô màu có tên, hiện khi rê chuột / chạm vào cột */
.cc-row { display: block; padding: 6px 8px; border-radius: 8px; outline: 0; }
.cc-row:hover, .cc-row:focus-within { background: var(--line-soft); }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-name { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1px dashed var(--line); background: transparent; }
.cc-dot.on { border-color: transparent; }
.cc-status { display: block; min-height: 18px; font-size: 12px; padding: 4px 8px 0; }
.cc-swatches { display: none; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
.cc-row:hover .cc-swatches, .cc-row:focus-within .cc-swatches { display: flex; }
.cc-sw { position: relative; display: inline-block; cursor: pointer; }
.cc-sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.cc-sw span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; box-shadow: 0 0 0 1px var(--line); color: var(--muted); font-size: 12px; transition: transform .1s; }
.cc-sw:hover span { transform: scale(1.15); }
.cc-sw input:checked + span { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ink); }
.cc-sw input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.cc-sw-none span { background: var(--panel); }

/* ---- Bảng dashboard: tiêu đề cột có màu, ẩn cột, sắp xếp, nhãn số liệu (2026-10-14) ---- */
.dash-table thead th, .dash-table thead th:first-child { background: var(--accent-soft); color: var(--accent); }
.dash-table thead th { cursor: pointer; user-select: none; position: sticky; }
.dash-table thead th .th-l { display: inline; }
.dash-table thead th:hover { filter: brightness(.97); }
.th-x { border: 0; background: transparent; color: inherit; opacity: 0; cursor: pointer; font-size: 13px; line-height: 1;
  padding: 0 0 0 4px; margin: 0; width: auto; height: auto; box-shadow: none; }
.dash-table thead th:hover .th-x, .th-x:focus-visible { opacity: .7; }
.th-x:hover { opacity: 1 !important; }
.dash-table thead th[aria-sort] .th-l::after { content: " ▲"; font-size: 9px; }
.dash-table thead th[aria-sort="descending"] .th-l::after { content: " ▼"; }
.dash-hidden-cols { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 4px; }
.dash-hidden-cols[hidden] { display: none; }
.dh-chip { border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 999px;
  font-size: 11.5px; padding: 1px 8px; cursor: pointer; width: auto; height: auto; box-shadow: none; }
.dh-chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.cc-head { gap: 8px; }
.cc-eye { flex: none; border: 0; background: transparent; cursor: pointer; font-size: 13px; padding: 0 2px; width: auto; height: auto; box-shadow: none; }
.cc-eye.off { opacity: .35; filter: grayscale(1); }
.cc-eye-sp { flex: none; width: 19px; }
.cc-head .cc-name { flex: 1; }
.dash-labels-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px 5px; line-height: 1;
  border-radius: 4px; font-size: 11px; font-weight: 700; width: auto; height: auto; box-shadow: none; }
.dash-labels-btn:hover { color: var(--accent); background: var(--accent-soft); }
.dash-labels-btn.on { color: var(--accent-ink); background: var(--accent); }
.chart-title .dash-labels-btn { margin-left: 6px; vertical-align: middle; }

/* ---- Thanh lọc dashboard (2026-10-15, Son: "mất cân đối"): 1 hàng gọn PRIMARY | ACQUISITION | nút; cùng chiều cao 36px,
   nhãn nhóm + nhãn ô thẳng hàng, nút nằm cùng hàng với ô (không rơi xuống hàng riêng, không dồn góc) ---- */
.dash-filter-cj { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px 16px; padding: 10px 14px 12px; border-radius: 12px; }
.dash-filter-cj .dash-fgroup { display: flex; flex-direction: row; align-items: flex-end; gap: 10px; padding: 18px 0 0; position: relative; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] { padding-left: 16px; border-left: 1px solid var(--line); }
.dash-filter-cj .dash-fgroup-label { top: 0; margin: 0; line-height: 14px; font-size: 10.5px; letter-spacing: .08em; color: var(--accent); font-weight: 700; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] .dash-fgroup-label { left: 16px; }
.dash-filter-cj .rf-field { display: flex; flex-direction: column; gap: 4px; width: 118px; }
.dash-filter-cj .rf-field:has(.rf-daterange) { width: 254px; }
.dash-filter-cj .rf-field > label { margin: 0; height: 16px; line-height: 16px; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.dash-filter-cj .rf-daterange, .dash-filter-cj .rf-chipbox { height: 36px; border-radius: 8px; width: 100%; }
.dash-filter-cj .rf-daterange { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 0 8px; }
.dash-filter-cj .rf-daterange input[type=date] { min-width: 0; flex: 1; width: 0; }
.dash-filter-cj .rf-daterange.is-mixed { border-style: dashed; }
.dash-filter-cj .dash-actions { margin-left: auto; align-self: flex-end; display: flex; gap: 6px; padding-left: 16px; border-left: 1px solid var(--line); }
.dash-filter-cj .dash-actions .btn, .dash-filter-cj .dash-actions .rf-apply { height: 36px; border-radius: 8px; padding: 0 12px; white-space: nowrap; }
.dash-filter-cj .dash-actions .rf-apply { padding: 0 16px; }
.dash-filter-cj .dash-actions .btn.ghost { padding: 0 10px; border-color: var(--line); background: transparent; }
.dash-filter-cj .dash-actions .btn.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
/* 15/10 (Son: nút rơi xuống dưới khi có 5 ô ACQUISITION, vd Party Craft): nhóm ACQUISITION co giãn, các ô chia đều chỗ còn lại
   -> nút luôn cùng hàng tới ~1220px; hẹp hơn nữa mới xuống hàng (nút vẫn dồn phải, cao bằng ô). */
.dash-filter-cj { flex-wrap: wrap; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] { flex: 1 1 0; min-width: 0; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] .rf-field { flex: 1 1 88px; width: auto; min-width: 0; }
.dash-filter-cj .dash-fgroup[data-grp="primary"] { flex: none; }
.dash-filter-cj .dash-fgroup[data-grp="primary"] .rf-field { flex: none; }
.dash-filter-cj .dash-actions { flex: none; margin-left: 0; }
/* 26/10 (Son): nút Tải lại / Ước tính GB / Đặt lại ở HÀNG RIÊNG trên đầu thanh lọc (không còn dồn phải cạnh ô lọc);
   ô First visit date đủ rộng để hiện cả 2 ngày (ô ACQUISITION trước đó co còn ~88px nên mất ngày). */
.dash-filter-cj .dash-actions, .dash-filter:not(.dash-filter-cj) .dash-actions { flex: 0 0 100%; margin: 0; padding: 0; border-left: 0; align-self: auto; align-items: center; display: flex; gap: 8px; }
.dash-filter-cj .dash-actions .dash-filter-msg { flex-basis: auto; margin-left: 6px; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] { flex-wrap: wrap; }
.dash-filter-cj .dash-fgroup[data-grp="acq"] .rf-field:has(.rf-daterange) { flex: 0 0 254px; width: 254px; }

/* ---- Gợi ý thả xuống cho ô chip thanh lọc Dashboard (2026-10-15) ---- */
.dash-filter .rf-field { position: relative; }
.rf-opt-panel { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: 300px;
  max-height: 264px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 4px; }
.rf-opt { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; padding: 6px 10px; border-radius: 6px; cursor: pointer; box-shadow: none; height: auto; }
.rf-opt:hover, .rf-opt.hi { background: var(--accent-soft); color: var(--accent); }
.rf-opt-n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.rf-opt-note { color: var(--muted); font-size: 12.5px; padding: 8px 10px; }
/* Bảng markdown trong câu trả lời bằng lời (app/text_format.py::md_lite, 2026-10-18) */
.md-table-wrap { overflow-x: auto; max-width: 100%; margin: 6px 0; }
.md-table { border-collapse: collapse; font-size: 0.88em; line-height: 1.35; }
.md-table th, .md-table td { border: 1px solid var(--line, #d9dde3); padding: 4px 9px; text-align: left; vertical-align: top; }
.md-table th { background: rgba(127, 127, 127, 0.12); font-weight: 600; white-space: nowrap; }
.md-table .al-r { text-align: right; font-variant-numeric: tabular-nums; }
.md-table .al-c { text-align: center; }
.tech-detail { margin-top: 4px; font-size: 0.85em; }
.tech-detail pre { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; }
.warn-more { margin-top: 4px; font-size: 0.9em; }
.warn-more summary { cursor: pointer; color: var(--muted, #6b7280); }

/* 2026-10-23: dòng model trên thẻ tiến trình + nhãn Opus trên kết quả */
.pending-model { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pending-opus { font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--accent, #2a78d6); background: transparent; color: var(--accent, #2a78d6); cursor: pointer; }
.pending-opus:hover:not(:disabled) { background: var(--accent-soft, rgba(42,120,214,.12)); }
.pending-opus:disabled { opacity: .6; cursor: default; }
.pill.opus { border-color: #6250d6; color: #6250d6; background: rgba(98,80,214,.10); }

#dash.is-editing .dash-heading { cursor: text; }
#dash.is-editing .dash-heading:hover { background: var(--accent-soft, rgba(0,0,0,.04)); }

/* Ô "Level" từ → đến của thanh lọc dashboard (3/11/2026): gộp level_from + level_to vào 1 khối như ô khoảng ngày, cùng chiều cao 36px, rộng cố định 118px
   (các ô chip còn lại tự co) để 6 ô ACQUISITION nằm vừa 1 hàng. */
.rf-levelrange { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px 4px; background: var(--panel); box-sizing: border-box; }
.rf-levelrange select { border: 0; background: transparent; color: inherit; padding: 4px 0; width: 46px; min-width: 0; font-size: 13px; }
.rf-levelrange span { color: var(--muted); font-size: 12px; }
.dash-filter-cj .dash-fgroup .rf-field:has(.rf-levelrange) { flex: 0 0 auto; width: 118px; min-width: 0; }
.dash-filter-cj .rf-levelrange { height: 36px; padding: 0 4px; }
.dash-filter-cj .rf-levelrange select { height: 32px; font-size: 12.5px; }
