/* crm_ui — Argus CRM cho doanh nghiệp phần mềm quản trị trường học.
   Nền: assets/css/app.css (token + lớp hl-* của design-system, chép nguyên từ ui-design-social).
   File này chỉ thêm khung trang (thanh bên, topbar) và lớp bố cục cx-*. Không có màu cứng ngoài token,
   trừ chuỗi biểu đồ --s1..--s5 lấy từ ramp design-system (giống ui-design-social/assets/css/social-extras.css). */
:root { --s1: #1a65b5; --s2: #12a390; --s3: #7a5af8; --s4: #c2552c; --s5: #d99413; --cx-muted: #6e7a8a; }
html[data-theme="dark"] { --s1: #2f7fd6; --cx-muted: #93a0b0; }
/* --cx-muted thay cho --text-muted: app.css có ":root{--text-muted:var(--text-muted)}" tự tham chiếu (xem README ui-design-social). */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: var(--type-body); color: var(--text-body); background: var(--surface-canvas); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
.cx-mono { font-family: var(--font-mono); font-size: 12px; }
.cx-muted { color: var(--cx-muted); }
.cx-num { font-variant-numeric: tabular-nums; }
.cx-strong { color: var(--text-strong); font-weight: 600; }
.cx-ico { display: inline-block; flex: none; vertical-align: -2px; }

/* ── khung ─────────────────────────────────────────────────────────────── */
.cx-app { display: flex; height: 100vh; height: 100dvh; width: 100vw; overflow: hidden; }
.cx-nav { width: var(--nav-w, 232px); flex: none; background: var(--surface-nav); display: flex; flex-direction: column; border-right: 1px solid var(--border-inverse); z-index: 20; transition: width var(--dur-base, 180ms) var(--ease-standard, ease); }
.cx-brand { height: var(--topbar-h, 52px); display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border-inverse); flex: none; }
.cx-brand img { height: 34px; width: auto; }
.cx-word { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: #fff; line-height: 1; }
.cx-chip { font-family: var(--font-mono); font-size: 11px; color: var(--blue-300); background: rgba(56,189,248,.15); border: 1px solid rgba(56,189,248,.35); padding: 2px 6px; border-radius: 4px; letter-spacing: .08em; font-weight: 700; line-height: 1; }
.cx-nav-scroll { flex: 1; overflow-y: auto; padding: 14px 8px; display: flex; flex-direction: column; gap: 2px; }
.cx-nav-scroll > * { flex: none; }
.cx-nav-scroll::-webkit-scrollbar { width: 6px; } .cx-nav-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.cx-nav-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #5d7995; padding: 12px 10px 4px; white-space: nowrap; overflow: hidden; }
.cx-nav-item { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 6px 10px; border-radius: 6px; color: var(--text-inverse-muted); text-decoration: none; position: relative; white-space: nowrap; }
.cx-nav-item:hover { background: var(--surface-nav-hover); color: #fff; text-decoration: none; }
.cx-nav-item.is-active { background: var(--surface-nav-active); color: #fff; font-weight: 500; }
.cx-nav-item.is-active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--blue-400); }
.cx-nav-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cx-nav-count { flex: none !important; font-size: 10px; font-weight: 600; background: rgba(255,255,255,.1); color: #cfe0f1; padding: 1px 6px; border-radius: 999px; }
.cx-nav-count.is-alert { background: var(--red-600); color: #fff; }
.cx-nav-foot { border-top: 1px solid var(--border-inverse); padding: 10px 12px; display: flex; align-items: center; gap: 10px; color: var(--text-inverse-muted); font-size: 12px; flex: none; }
.cx-nav-foot b { color: #fff; font-weight: 600; display: block; font-size: 12.5px; }
/* thu gọn thanh bên chỉ áp dụng trên màn rộng; ≤ 900px thanh bên thành ngăn trượt (xem "responsive" cuối file) */
@media (min-width: 901px) {
  html[data-sidebar="collapsed"] .cx-nav { width: var(--nav-w-collapsed, 56px); }
  html[data-sidebar="collapsed"] .cx-nav .cx-word, html[data-sidebar="collapsed"] .cx-nav .cx-chip,
  html[data-sidebar="collapsed"] .cx-nav-item span, html[data-sidebar="collapsed"] .cx-nav-group,
  html[data-sidebar="collapsed"] .cx-nav-foot div { display: none; }
  html[data-sidebar="collapsed"] .cx-nav-group { display: block; height: 1px; padding: 0; margin: 8px 6px; background: var(--border-inverse); }
}
.cx-nav-scrim { display: none; }

.cx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cx-top { height: var(--topbar-h, 52px); flex: none; background: var(--surface-card); border-bottom: 1px solid var(--border-default); display: flex; align-items: center; gap: 10px; padding: 0 24px; }
.cx-crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--cx-muted); white-space: nowrap; overflow: hidden; }
.cx-crumb b { color: var(--text-strong); font-weight: 500; }
.cx-search { display: flex; align-items: center; gap: 8px; height: var(--control-h, 28px); width: 300px; padding: 0 8px; background: var(--surface-subtle); border: 1px solid var(--border-default); border-radius: 6px; color: var(--text-subtle); font-size: 12px; cursor: pointer; }
.cx-search > span:not(.cx-kbd) { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-kbd { font-family: var(--font-mono); font-size: 10px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 2px; padding: 1px 4px; color: var(--cx-muted); }
.cx-dot-alert { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 999px; background: var(--danger-solid); border: 1.5px solid var(--surface-card); }
.cx-content { flex: 1; overflow: auto; }
.cx-page { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ── đầu trang ─────────────────────────────────────────────────────────── */
.cx-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.cx-head > div { min-width: 0; max-width: 100%; }
.cx-eyebrow { font: var(--type-eyebrow); letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--accent-fg); }
.cx-title { font: var(--type-h1); color: var(--text-strong); margin: 4px 0 2px; }
.cx-sub { font-size: 13px; color: var(--cx-muted); margin: 0; max-width: 860px; }
.cx-head-r, .cx-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cx-row--between { justify-content: space-between; }
.cx-row--hero { flex-wrap: nowrap; }
.cx-spacer { flex: 1; }
.cx-stack { display: flex; flex-direction: column; gap: 12px; }
.cx-stack--sm { gap: 6px; }

/* ── lưới ──────────────────────────────────────────────────────────────── */
.cx-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.cx-g2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.cx-g3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cx-g4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cx-g21 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.cx-g12 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
.cx-g31 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.2fr); gap: 16px; }
.cx-g7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1180px) { .cx-g2, .cx-g3, .cx-g21, .cx-g12, .cx-g31 { grid-template-columns: minmax(0, 1fr); } .cx-g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cx-g7 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ── thẻ ───────────────────────────────────────────────────────────────── */
.cx-card { min-width: 0; display: flex; flex-direction: column; }
.cx-card .hl-card__head { align-items: center; padding: 10px 14px; }
.cx-card .hl-card__sub { font-size: 11px; color: var(--cx-muted); margin-top: 1px; }
.cx-card__body { padding: 14px; min-width: 0; }
.cx-card__body--flush { padding: 0; }
.cx-card__foot { padding: 8px 14px; border-top: 1px solid var(--border-subtle); background: var(--surface-subtle); font-size: 12px; color: var(--cx-muted); border-radius: 0 0 8px 8px; }
.cx-tile { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cx-tile .hl-metric__label { color: var(--cx-muted); display: flex; align-items: center; gap: 6px; }
.cx-tile .hl-metric__value { font-size: 24px; }
.cx-tile__foot { display: flex; flex-wrap: wrap; column-gap: 8px; row-gap: 2px; gap: 8px; align-items: center; font-size: 12px; color: var(--cx-muted); }
.cx-up { color: var(--success-fg); } .cx-down { color: var(--danger-fg); } .cx-warn { color: var(--warning-fg); }

/* ── bảng ──────────────────────────────────────────────────────────────── */
.cx-tablewrap { overflow: auto; max-width: 100%; }
.cx-table th { color: var(--cx-muted); }
.cx-table td { padding-top: 4px; padding-bottom: 4px; }
.cx-table td.r, .cx-table th.r { text-align: right; }
.cx-table td.c, .cx-table th.c { text-align: center; }
.cx-table tbody tr.is-click { cursor: pointer; }
.cx-table tbody tr.is-sel { background: var(--surface-selected); }
.cx-table td .cx-sub2 { display: block; font-size: 11px; color: var(--cx-muted); line-height: 1.2; }
.cx-table td.wrap { white-space: normal; padding-top: 6px; padding-bottom: 6px; }
.cx-cellname { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cx-cellname > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }

/* ── badge theo tone ───────────────────────────────────────────────────── */
.cx-b { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 500; white-space: nowrap; border: 1px solid; }
.cx-b i { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.cx-b--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }
.cx-b--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-fg); }
.cx-b--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }
.cx-b--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-fg); }
.cx-b--neutral { background: var(--neutral-bg); border-color: var(--neutral-border); color: var(--neutral-fg); }
.cx-b--accent { background: var(--rust-50); border-color: var(--rust-100); color: var(--rust-700); }
.cx-b--violet { background: var(--violet-50); border-color: var(--violet-100); color: var(--violet-700); }
html[data-theme="dark"] .cx-b--accent { background: rgba(194,85,44,.14); border-color: rgba(194,85,44,.35); color: #e8a283; }
html[data-theme="dark"] .cx-b--violet { background: rgba(122,90,248,.14); border-color: rgba(122,90,248,.35); color: #b7a6ff; }

.cx-av { width: 26px; height: 26px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; flex: none; background: var(--surface-sunken); color: var(--text-body); border: 1px solid var(--border-subtle); }
.cx-av--lg { width: 44px; height: 44px; font-size: 15px; }
.cx-av--sq { border-radius: 8px; }

/* ── điều khiển ────────────────────────────────────────────────────────── */
.cx-input { height: var(--control-h, 28px); border: 1px solid var(--border-default); border-radius: 6px; background: var(--surface-card); padding: 0 8px; color: var(--text-strong); font-size: 13px; outline: none; min-width: 0; }
.cx-input:focus { border-color: var(--border-accent); box-shadow: var(--focus-ring); }
select.cx-input { padding-right: 22px; }
textarea.cx-input { height: auto; padding: 6px 8px; resize: vertical; }
.cx-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cx-field > label { font: var(--type-label); color: var(--text-body); }
.cx-field .hint { font-size: 11px; color: var(--cx-muted); }
.cx-seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--surface-sunken); border-radius: 6px; padding: 2px; gap: 2px; }
.cx-seg button { border: 0; background: transparent; color: var(--cx-muted); height: 24px; padding: 0 10px; border-radius: 4px; font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.cx-seg button.is-on { background: var(--surface-card); color: var(--text-strong); box-shadow: var(--shadow-xs); }
.cx-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--border-default); overflow-x: auto; }
.cx-tabs button { border: 0; background: transparent; padding: 0 0 9px; font-size: 13px; font-weight: 500; color: var(--cx-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.cx-tabs button:hover { color: var(--text-body); }
.cx-tabs button.is-on { color: var(--text-accent); border-bottom-color: var(--border-accent); }
.cx-tabs .cnt { font-size: 10.5px; background: var(--surface-sunken); color: var(--cx-muted); padding: 0 6px; border-radius: 999px; }
.cx-pane { display: none; } .cx-pane.is-on { display: flex; flex-direction: column; gap: 16px; }
.cx-filter { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px dashed var(--border-strong); border-radius: 6px; font-size: 12px; color: var(--text-body); background: var(--surface-card); cursor: pointer; }
.cx-filter.is-on { border-style: solid; border-color: var(--border-accent); background: var(--accent-bg-subtle); color: var(--accent-fg); }
.cx-toggle { position: relative; width: 30px; height: 17px; border-radius: 999px; background: var(--n-300); border: 0; cursor: pointer; flex: none; transition: background-color 180ms; padding: 0; }
.cx-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 999px; background: #fff; box-shadow: var(--shadow-xs); transition: transform 180ms var(--ease-emphasis, ease); }
.cx-toggle.is-on { background: var(--accent-bg); } .cx-toggle.is-on::after { transform: translateX(13px); }
.cx-check { width: 15px; height: 15px; accent-color: var(--accent-bg); cursor: pointer; }

/* ── danh sách, mốc thời gian ──────────────────────────────────────────── */
.cx-list { display: flex; flex-direction: column; }
.cx-li { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border-subtle); min-width: 0; }
.cx-li:last-child { border-bottom: 0; }
.cx-li__main { flex: 1; min-width: 0; }
.cx-li__t { color: var(--text-strong); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-li__s { font-size: 11.5px; color: var(--cx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-li.is-click { cursor: pointer; } .cx-li.is-click:hover { background: var(--surface-hover); }
.cx-li.is-sel { background: var(--surface-selected); }
.cx-tl { position: relative; padding-left: 4px; }
.cx-tl-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; position: relative; }
.cx-tl-item::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 1px; background: var(--border-default); }
.cx-tl-item:last-child::before { display: none; }
.cx-tl-ico { width: 30px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-default); background: var(--surface-card); }
.cx-tl-body { min-width: 0; padding-top: 4px; }
.cx-tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cx-tl-head b { color: var(--text-strong); font-weight: 600; }
.cx-tl-meta { font-size: 11.5px; color: var(--cx-muted); }
.cx-tl-note { margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border-subtle); background: var(--surface-subtle); border-radius: 6px; font-size: 12.5px; }
.cx-kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 6px 12px; font-size: 12.5px; }
.cx-kv dt { color: var(--cx-muted); } .cx-kv dd { margin: 0; color: var(--text-strong); min-width: 0; overflow-wrap: anywhere; }

/* ── meter, thanh ──────────────────────────────────────────────────────── */
.cx-meter { height: 6px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; display: flex; min-width: 40px; }
.cx-meter > i { display: block; height: 100%; }
.cx-hbar { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 72px; gap: 10px; align-items: center; font-size: 12.5px; padding: 4px 0; }
.cx-hbar .cx-meter { height: 8px; }
.cx-hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.cx-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--cx-muted); }
.cx-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.cx-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.cx-chart text { fill: var(--cx-muted); font-size: 10.5px; font-family: var(--font-sans); }
.cx-chart .grid { stroke: var(--viz-grid); }
.cx-callout { display: flex; gap: 10px; padding: 10px 12px; border-radius: 8px; border: 1px solid; font-size: 12.5px; align-items: flex-start; }
.cx-callout--info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-fg); }
.cx-callout--warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-fg); }
.cx-callout--danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-fg); }
.cx-callout--success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-fg); }
.cx-callout b { color: inherit; }

/* ── kanban ────────────────────────────────────────────────────────────── */
.cx-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.cx-col { background: var(--surface-sunken); border-radius: 8px; display: flex; flex-direction: column; min-height: 420px; border: 1px solid var(--border-subtle); }
.cx-col.is-over { outline: 2px dashed var(--border-accent); outline-offset: -2px; }
.cx-col.is-block { outline: 2px dashed var(--danger-solid); outline-offset: -2px; }
.cx-col__head { padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.cx-col__title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-strong); }
.cx-col__meta { font-size: 11.5px; color: var(--cx-muted); display: flex; justify-content: space-between; }
.cx-col__gate { font-size: 11px; color: var(--cx-muted); display: flex; gap: 4px; align-items: center; }
.cx-col__cards { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.cx-deal { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 8px; padding: 10px; cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.cx-deal.is-new { border-color: var(--border-accent); box-shadow: var(--focus-ring); }
.cx-deal:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.cx-deal.is-drag { opacity: .45; }
.cx-deal__t { font-weight: 600; color: var(--text-strong); font-size: 12.5px; line-height: 1.3; }
.cx-deal__s { font-size: 11.5px; color: var(--cx-muted); }
.cx-deal__row { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; }

/* ── luồng hành trình ──────────────────────────────────────────────────── */
.cx-canvas { background-color: var(--surface-subtle); background-image: radial-gradient(var(--border-default) 1px, transparent 1px); background-size: 16px 16px; border-radius: 8px; padding: 22px; overflow: auto; }
.cx-flow { display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 640px; }
.cx-node { width: 270px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 8px; display: flex; overflow: hidden; box-shadow: var(--shadow-xs); cursor: pointer; }
.cx-node:hover { border-color: var(--border-strong); }
.cx-node.is-sel { border-color: var(--border-accent); box-shadow: var(--focus-ring); }
.cx-node__bar { width: 4px; flex: none; }
.cx-node__in { padding: 8px 10px; display: flex; gap: 9px; align-items: center; min-width: 0; flex: 1; }
.cx-node__k { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.cx-node__t { font-weight: 600; color: var(--text-strong); font-size: 12.5px; }
.cx-node__m { font-size: 11px; color: var(--cx-muted); }
.cx-edge { width: 1px; height: 22px; background: var(--border-strong); position: relative; }
.cx-branch { display: flex; gap: 28px; align-items: flex-start; position: relative; padding-top: 14px; }
.cx-branch::before { content: ""; position: absolute; top: 0; left: 135px; right: 135px; height: 1px; background: var(--border-strong); }
.cx-branch > div { display: flex; flex-direction: column; align-items: center; position: relative; }
.cx-branch > div::before { content: ""; position: absolute; top: -14px; height: 14px; width: 1px; background: var(--border-strong); }
.cx-edge-lbl { font-size: 10.5px; color: var(--cx-muted); background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 999px; padding: 1px 7px; margin-bottom: 6px; }

/* ── helpdesk 3 cột ────────────────────────────────────────────────────── */
.cx-desk { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; border: 1px solid var(--border-default); border-radius: 8px; background: var(--surface-card); height: calc(100vh - 210px); min-height: 560px; overflow: hidden; }
.cx-desk > div { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.cx-desk > div + div { border-left: 1px solid var(--border-default); }
.cx-desk__scroll { overflow-y: auto; flex: 1; }
.cx-msg { max-width: 78%; padding: 8px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.45; }
.cx-msg--in { background: var(--surface-sunken); align-self: flex-start; border-top-left-radius: 2px; }
.cx-msg--out { background: var(--accent-bg-subtle); align-self: flex-end; border-top-right-radius: 2px; color: var(--text-strong); }
.cx-msg--note { background: var(--warning-bg); border: 1px dashed var(--warning-border); align-self: stretch; max-width: none; color: var(--warning-fg); }
.cx-msg__m { font-size: 10.5px; color: var(--cx-muted); margin-top: 3px; }
@media (max-width: 1280px) { .cx-desk { grid-template-columns: 300px minmax(0, 1fr); } .cx-desk > div:nth-child(3) { display: none; } }

/* ── lớp phủ ───────────────────────────────────────────────────────────── */
.cx-scrim { position: fixed; inset: 0; background: var(--surface-overlay); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 80; }
.cx-dialog { background: var(--surface-card); border-radius: 12px; box-shadow: var(--shadow-xl); width: 100%; max-width: 560px; max-height: 100%; display: flex; flex-direction: column; animation: cx-rise 260ms var(--ease-emphasis, ease); }
.cx-dialog--lg { max-width: 860px; }
.cx-dialog__h { padding: 16px 18px 10px; display: flex; gap: 10px; align-items: flex-start; }
.cx-dialog__h h3 { margin: 0; font: var(--type-h3); color: var(--text-strong); }
.cx-dialog__b { padding: 0 18px 16px; overflow: auto; }
.cx-dialog__f { padding: 12px 18px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-subtle); border-radius: 0 0 12px 12px; }
.cx-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 540px; max-width: 100vw; background: var(--surface-card); border-left: 1px solid var(--border-default); box-shadow: var(--shadow-xl); z-index: 81; display: flex; flex-direction: column; animation: cx-slide 260ms var(--ease-emphasis, ease); }
.cx-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.cx-toast { width: 360px; background: var(--surface-card); border: 1px solid var(--border-default); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 10px 12px; display: flex; gap: 10px; font-size: 12.5px; animation: cx-slide 180ms var(--ease-emphasis, ease); }
.cx-toast b { display: block; color: var(--text-strong); }
@keyframes cx-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cx-slide { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── tiện ích ──────────────────────────────────────────────────────────── */
.cx-pill-sel { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.cx-box { border: 1px solid var(--border-default); border-radius: 8px; padding: 10px 12px; background: var(--surface-card); }
.cx-box--dashed { border-style: dashed; border-color: var(--border-strong); background: var(--surface-subtle); }
.cx-box--sel { border-color: var(--border-accent); background: var(--surface-selected); }
.cx-h4 { font: var(--type-h4); color: var(--text-strong); margin: 0; }
.cx-small { font-size: 11.5px; }
.cx-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.cx-matrix td.c { width: 74px; }
.cx-code { font-family: var(--font-mono); font-size: 11.5px; background: var(--surface-sunken); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 10px 12px; white-space: pre; overflow: auto; color: var(--text-body); margin: 0; line-height: 1.5; }
.cx-heat td.h { text-align: center; font-variant-numeric: tabular-nums; font-size: 12px; height: 30px; }
.cx-stepper { display: flex; gap: 0; align-items: center; flex-wrap: wrap; }
.cx-step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cx-muted); padding: 4px 0; }
.cx-step i { width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 10.5px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface-card); }
.cx-step.is-done i { background: var(--success-solid); border-color: var(--success-solid); color: #fff; }
.cx-step.is-cur { color: var(--text-strong); font-weight: 600; } .cx-step.is-cur i { background: var(--accent-bg); border-color: var(--accent-bg); color: #fff; }
.cx-step + .cx-step::before { content: ""; width: 26px; height: 1px; background: var(--border-strong); margin: 0 8px; }
.cx-kb-art { font-size: 13px; line-height: 1.6; color: var(--text-body); }
.cx-kb-art h2 { font: var(--type-h2); color: var(--text-strong); margin: 0 0 6px; }
.cx-kb-art h4 { font: var(--type-h4); color: var(--text-strong); margin: 14px 0 4px; }
.cx-kb-art ol, .cx-kb-art ul { margin: 4px 0; padding-left: 20px; }
.cx-portal { border: 1px solid var(--border-default); border-radius: 10px; overflow: hidden; background: var(--surface-card); }
.cx-portal__hero { background: var(--blue-800); color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.cx-portal__hero h3 { margin: 0; font: var(--type-h2); color: #fff; }
.cx-hide { display: none !important; }

/* ── responsive ────────────────────────────────────────────────────────── */
/* ≤ 900px: thanh bên thành ngăn trượt (nút panel-left mở / đóng, html[data-nav-open]); topbar rút gọn. */
@media (max-width: 900px) {
  .cx-nav { position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 86vw); z-index: 70; transform: translateX(-100%); transition: transform var(--dur-base, 180ms) var(--ease-standard, ease); box-shadow: none; }
  html[data-nav-open] .cx-nav { transform: none; box-shadow: var(--shadow-xl); }
  html[data-nav-open] .cx-nav-scrim { display: block; position: fixed; inset: 0; background: var(--surface-overlay); z-index: 69; }
  .cx-nav-item { min-height: 40px; }
  .cx-top { padding: 0 12px; gap: 6px; }
  .cx-crumb > :not(b) { display: none; }
  .cx-crumb b { overflow: hidden; text-overflow: ellipsis; }
  .cx-search { width: 32px; height: 32px; padding: 0; justify-content: center; flex: none; }
  .cx-search > span { display: none; }
  .cx-top [data-act="quick-create"] > span { display: none; }
  .cx-desk { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .cx-desk > div { max-height: 70vh; }
  .cx-desk > div + div { border-left: 0; border-top: 1px solid var(--border-default); }
  .cx-desk > div:nth-child(3) { display: flex; }
}
/* ≤ 640px: điện thoại */
@media (max-width: 640px) {
  .cx-top [data-act="help"] { display: none; }
  .cx-page { padding: 14px 14px 32px; gap: 12px; }
  .cx-title { font-size: 22px; line-height: 1.25; }
  .cx-head { align-items: stretch; }
  .cx-head-r { width: 100%; }
  .cx-row--hero { flex-wrap: wrap; }
  .cx-row--hero > div:first-of-type { flex-basis: calc(100% - 60px) !important; }
  .cx-tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .cx-tile { padding: 10px 12px; }
  .cx-tile .hl-metric__value { font-size: 20px; }
  .cx-g7 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cx-g2, .cx-g3, .cx-g21, .cx-g12, .cx-g31 { gap: 12px; }
  .cx-card .hl-card__head { flex-wrap: wrap; gap: 6px; }
  .cx-card__body { padding: 12px; }
  .cx-li { padding: 9px 12px; }
  .cx-kv { grid-template-columns: minmax(90px, 38%) minmax(0, 1fr); }
  .cx-hbar { grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) auto !important; gap: 8px; }
  .cx-input { max-width: 100%; }
  .cx-head-r .cx-input, .cx-row > .cx-input { flex: 1 1 160px; }
  .cx-tabs { gap: 14px; }
  .cx-board { grid-auto-columns: minmax(78vw, 1fr); scroll-snap-type: x mandatory; }
  .cx-col { scroll-snap-align: start; min-height: 300px; }
  .cx-step + .cx-step::before { width: 12px; margin: 0 4px; }
  .cx-canvas { padding: 12px; }
  .cx-msg { max-width: 90%; }
  .cx-scrim { padding: 10px; align-items: flex-end; }
  .cx-dialog { max-height: calc(100dvh - 20px); }
  .cx-dialog__h { padding: 14px 14px 8px; }
  .cx-dialog__b { padding: 0 14px 14px; }
  .cx-dialog__f { padding: 10px 14px; flex-wrap: wrap; }
  .cx-toasts { left: 10px; right: 10px; bottom: 10px; }
  .cx-toast { width: auto; }
}
