/* D-Page — toàn bộ giao diện trong một tệp, không cần bước build.
   Mọi màu đi qua biến CSS nên giao diện tối chỉ là đổi giá trị biến. */

:root {
  --bg: #f3f4f7; --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #eef0f4; --hover: #f1f3f7;
  --border: #e4e7ec; --border-strong: #cfd4dc;
  --text: #101828; --text-2: #475467; --text-3: #8a94a6;
  --primary: #4f46e5; --primary-hover: #4338ca; --primary-soft: #eef0ff; --on-primary: #ffffff;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e1; --bad: #c81e1e; --bad-soft: #fdecec; --info: #0369a1; --info-soft: #e3f2fb;
  --bubble-in: #ffffff; --bubble-out: #4f46e5; --bubble-out-text: #ffffff; --thread-bg: #eef0f5;
  --rail: #171a2b; --rail-text: #a4abc4; --rail-active: #ffffff;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .10);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Giao diện tối: theo hệ điều hành, trừ khi người dùng đã chọn sáng; hoặc do người dùng chủ động bật. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0f1117; --surface: #171a23; --surface-2: #1c202b; --surface-3: #232836; --hover: #222736;
  --border: #2a3040; --border-strong: #3a4256; --text: #eceef4; --text-2: #b3bacb; --text-3: #7d869b;
  --primary: #7c78ff; --primary-hover: #918eff; --primary-soft: #25274a; --on-primary: #0f1117;
  --ok: #4ade80; --ok-soft: #13301f; --warn: #fbbf24; --warn-soft: #382a0c; --bad: #f87171; --bad-soft: #3a1717; --info: #38bdf8; --info-soft: #0f2b3b;
  --bubble-in: #232836; --bubble-out: #5b55f0; --bubble-out-text: #ffffff; --thread-bg: #12141c; --rail: #0b0d13;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5); color-scheme: dark; } }
:root[data-theme="dark"] { --bg: #0f1117; --surface: #171a23; --surface-2: #1c202b; --surface-3: #232836; --hover: #222736;
  --border: #2a3040; --border-strong: #3a4256; --text: #eceef4; --text-2: #b3bacb; --text-3: #7d869b;
  --primary: #7c78ff; --primary-hover: #918eff; --primary-soft: #25274a; --on-primary: #0f1117;
  --ok: #4ade80; --ok-soft: #13301f; --warn: #fbbf24; --warn-soft: #382a0c; --bad: #f87171; --bad-soft: #3a1717; --info: #38bdf8; --info-soft: #0f2b3b;
  --bubble-in: #232836; --bubble-out: #5b55f0; --bubble-out-text: #ffffff; --thread-bg: #12141c; --rail: #0b0d13;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .5); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code { font: 12.5px ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; border: 3px solid transparent; }

.icon { flex: none; vertical-align: middle; }
.muted { color: var(--text-2); } .small { font-size: 12px; } .pad { padding: 10px 12px; } .spacer { flex: 1; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack-lg { display: flex; flex-direction: column; gap: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Nút, ô nhập */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); font-weight: 600; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; } .btn-danger:hover { filter: brightness(.93); background: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; } .btn-lg { height: 44px; font-size: 15px; } .btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.link-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: var(--text-2); font-size: 12px; font-weight: 600; }
.link-btn:hover, .link-btn.on { color: var(--primary); }
.input { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.is-invalid, .input.is-invalid:focus { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.input:disabled { background: var(--surface-3); color: var(--text-3); }
.input-sm { min-height: 30px; padding: 3px 8px; font-size: 13px; }
textarea.input { resize: vertical; line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 5px; } .field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); } .field-hint { font-size: 12px; color: var(--text-3); }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; } .check input { margin-top: 3px; accent-color: var(--primary); }
.radio-card { display: flex; gap: 11px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); } .radio-card input { margin-top: 3px; accent-color: var(--primary); }

.avatar { position: relative; display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; overflow: hidden; flex: none; letter-spacing: .02em; user-select: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ch-badge { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 800; flex: none; line-height: 1; box-shadow: 0 0 0 2px var(--surface); text-transform: none; }
.badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.pill-ok { background: var(--ok-soft); color: var(--ok); } .pill-warn { background: var(--warn-soft); color: var(--warn); } .pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--info-soft); color: var(--info); } .pill-primary { background: var(--primary-soft); color: var(--primary); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; } .dot-on { background: #22c55e; }
.tag-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.tag-pill { --tag: #64748b; display: inline-block; max-width: 92px; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--tag); background: color-mix(in srgb, var(--tag) 14%, transparent); }
.tag-pill-lg { max-width: none; font-size: 13px; line-height: 24px; padding: 0 10px; }
.tag-more { font-size: 11px; color: var(--text-3); }
.phone-chip { display: inline-flex; align-items: center; gap: 4px; border: 0; padding: 0 6px; border-radius: 5px; background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: inherit; }
.bubble .phone-chip { background: rgba(34, 197, 94, .18); color: inherit; text-decoration: underline dotted; }
.empty { display: grid; place-items: center; gap: 10px; padding: 48px 20px; color: var(--text-3); text-align: center; } .empty.small { padding: 28px 12px; }

/* ---------- Khung ứng dụng */
.app { display: flex; height: 100dvh; }
.boot-splash, .boot-error { margin: auto; text-align: center; color: var(--text-2); display: grid; gap: 12px; justify-items: center; }
.boot-logo { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-size: 26px; font-weight: 800; }
.rail { width: 68px; flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px; z-index: 5; }
.rail-logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-size: 20px; font-weight: 800; margin-bottom: 10px; }
.rail-logo:hover { text-decoration: none; }
.rail-nav { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
.rail-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 58px; padding: 8px 0 6px; border: 0; border-radius: 10px; background: transparent; color: var(--rail-text); font-size: 10.5px; font-weight: 600; }
.rail-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.rail-btn.active { background: rgba(255, 255, 255, .12); color: var(--rail-active); }
.rail-badge { position: absolute; top: 3px; right: 6px; box-shadow: 0 0 0 2px var(--rail); }
.rail-spacer { flex: 1; }
.rail-conn { display: grid; place-items: center; width: 100%; height: 22px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; }
.conn-connected { background: #22c55e; } .conn-disconnected { background: #ef4444; } .conn-reconnecting, .conn-connecting { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.rail-user { border: 0; background: none; padding: 0; border-radius: 50%; }
.main { flex: 1; min-width: 0; display: flex; }
.main-wrap { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; } .main-wrap > .main { min-height: 0; }
.plan-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 7px 14px; background: var(--warn-soft); border-bottom: 1px solid var(--warn); color: var(--text); font-size: 13px; line-height: 1.5; }
.plan-banner[hidden] { display: none; } .plan-banner svg { color: var(--warn); flex: none; }
.update-banner { background: var(--info-soft); border-bottom-color: var(--info); } .update-banner svg { color: var(--info); }
.addon-rule .rule-list { margin: 4px 0 0; padding-left: 18px; } .addon-rule .rule-list li { margin: 2px 0; }
.addon-pick .picker-row.is-disabled { opacity: .55; cursor: not-allowed; }
.addon-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }

/* ---------- Hội thoại: 3 cột */
.inbox { flex: 1; min-width: 0; display: grid; grid-template-columns: 348px minmax(0, 1fr) 340px; }
.inbox.side-hidden { grid-template-columns: 348px minmax(0, 1fr); } .inbox.side-hidden .col-side { display: none; }
.col-list { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); }
.list-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 9px; border-bottom: 1px solid var(--border); }
.list-head-row { display: flex; align-items: center; gap: 6px; }
.channel-picker { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 700; }
.channel-picker:hover { border-color: var(--border-strong); }
.channel-picker-label { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-box { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-3); }
.search-box:focus-within { box-shadow: 0 0 0 2px var(--primary); background: var(--surface); }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); min-height: 0; padding: 0; box-shadow: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip-clear { border-style: dashed; color: var(--bad); }
.chip-count { min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10.5px; line-height: 15px; text-align: center; }
.chip.active .chip-count { background: rgba(255, 255, 255, .28); }
.conv-scroll { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.conv-scroll.is-loading .conv-list { opacity: .5; }
.stale-pill { position: sticky; top: 8px; z-index: 2; display: flex; align-items: center; gap: 6px; margin: 8px auto -38px; height: 30px; padding: 0 12px; border: 0; border-radius: 15px;
  background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 700; box-shadow: var(--shadow); }
.list-more { padding: 14px; text-align: center; color: var(--text-3); font-size: 12px; }
.conv { --ch: #64748b; position: relative; display: flex; gap: 10px; padding: 10px 12px 10px 13px; border-bottom: 1px solid var(--border); cursor: pointer; outline-offset: -2px; }
.conv::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ch); opacity: .85; }
.conv:hover { background: var(--hover); } .conv.selected { background: var(--primary-soft); }
.conv-avatar { position: relative; flex: none; height: 42px; } .conv-avatar .ch-badge { position: absolute; right: -3px; bottom: -3px; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-mid, .conv-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.conv-time { font-size: 11.5px; color: var(--text-3); flex: none; }
.conv-snippet { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 13px; }
.conv-replied { color: var(--text-3); display: inline-flex; }
.conv.unread .conv-name { font-weight: 800; } .conv.unread .conv-snippet { color: var(--text); font-weight: 600; } .conv.unread .conv-time { color: var(--primary); font-weight: 700; }
.conv-bottom { margin-top: 2px; min-height: 18px; color: var(--text-3); }
.conv-type, .conv-phone, .conv-order { display: inline-flex; } .conv-phone { color: var(--ok); } .conv-order { color: var(--primary); }
.conv-tags { display: inline-flex; gap: 4px; min-width: 0; overflow: hidden; }
.conv-channel { flex: 1; min-width: 0; text-align: right; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Popover, menu */
.popover { position: fixed; z-index: 60; min-width: 190px; max-width: min(360px, calc(100vw - 16px)); max-height: min(440px, calc(100vh - 24px)); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); animation: pop .1s ease-out; }
.popover-wide { min-width: 290px; }
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.picker { padding: 6px; display: flex; flex-direction: column; } .picker-title { padding: 6px 8px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.picker-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; } .picker-row:hover { background: var(--hover); }
.picker-row input { accent-color: var(--primary); } .picker-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { padding: 5px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; }
.menu-item:hover { background: var(--hover); } .menu-item.active { color: var(--primary); font-weight: 700; } .menu-item.danger { color: var(--bad); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.emoji-grid { display: grid; grid-template-columns: repeat(10, 32px); gap: 2px; padding: 8px; }
.emoji { width: 32px; height: 32px; border: 0; border-radius: 7px; background: none; font-size: 19px; line-height: 1; } .emoji:hover { background: var(--hover); }

/* ---------- Luồng chat */
.col-thread { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--thread-bg); }
.col-thread.dragging::after { content: "Thả tệp vào đây để đính kèm"; position: absolute; inset: 10px; z-index: 20; display: grid; place-items: center; border: 2px dashed var(--primary); border-radius: 14px;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); font-size: 17px; font-weight: 700; pointer-events: none; }
.thread-empty { margin: auto; display: grid; justify-items: center; gap: 8px; color: var(--text-3); text-align: center; padding: 24px; } .thread-empty h3 { color: var(--text-2); font-size: 17px; }
.thread-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.thread-head { display: flex; align-items: center; gap: 11px; min-height: 62px; padding: 9px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.head-avatar { position: relative; flex: none; line-height: 0; } .head-avatar .ch-badge { position: absolute; right: -3px; bottom: -3px; }
.head-main { flex: 1; min-width: 0; }
.head-name { display: flex; align-items: center; gap: 9px; font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .head-name .phone-chip { font-size: 12.5px; line-height: 20px; }
.head-sub { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.assign-btn { max-width: 190px; } .assign-btn span { overflow: hidden; text-overflow: ellipsis; }
.only-mobile { display: none; }
.thread-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 8px; overscroll-behavior: contain; }
.post-card { display: flex; gap: 12px; padding: 11px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.post-thumb { width: 84px; height: 64px; object-fit: cover; border-radius: 7px; flex: none; background: var(--surface-3); }
.post-label { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.post-text { margin: 3px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.older-row { text-align: center; padding: 4px 0 10px; }
.messages { display: flex; flex-direction: column; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; color: var(--text-3); font-size: 12px; font-weight: 600; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg { display: flex; gap: 8px; max-width: 100%; margin-top: 2px; } .msg.first { margin-top: 10px; }
.msg.out { justify-content: flex-end; }
.msg-avatar { width: 28px; flex: none; align-self: flex-end; }
.msg-col { display: flex; flex-direction: column; align-items: flex-start; max-width: min(72%, 560px); min-width: 0; } .msg.out .msg-col { align-items: flex-end; }
.bubble { padding: 8px 12px; border-radius: 16px; background: var(--bubble-in); box-shadow: 0 1px 1px rgba(16, 24, 40, .05); overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.msg.in .bubble { border-bottom-left-radius: 5px; } .msg.in.first .bubble { border-top-left-radius: 16px; } .msg.in:not(.first) .bubble { border-top-left-radius: 5px; } .msg.in.last .bubble { border-bottom-left-radius: 16px; }
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-bottom-right-radius: 5px; } .msg.out:not(.first) .bubble { border-top-right-radius: 5px; } .msg.out.last .bubble { border-bottom-right-radius: 16px; }
.msg.out .bubble a { color: inherit; text-decoration: underline; }
.bubble-plain { background: none !important; box-shadow: none; padding: 0; }
.bubble-text { white-space: pre-wrap; }
.msg.is-hidden .bubble { opacity: .55; } .msg.is-failed .bubble { background: var(--bad-soft); color: var(--bad); }
.hidden-note { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.attachments { display: flex; flex-direction: column; gap: 6px; } .bubble-text + .attachments { margin-top: 7px; }
.img-grid { display: grid; gap: 4px; grid-template-columns: 1fr; max-width: 300px; } .img-grid.n2, .img-grid.n3, .img-grid.n4 { grid-template-columns: 1fr 1fr; }
.img-grid img { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: 10px; background: var(--surface-3); } .img-grid:not(.n1) img { aspect-ratio: 1 / 1 !important; }
.sticker img { max-width: 120px; background: none; }
.img-broken { display: flex; align-items: center; gap: 6px; padding: 14px; border-radius: 10px; background: var(--surface-3); color: var(--text-3); font-size: 12px; }
.media { max-width: 300px; border-radius: 10px; } .media-audio { max-width: 260px; }
.file-chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; background: rgba(127, 127, 127, .13); color: inherit; max-width: 280px; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.msg-actions { display: flex; align-items: center; gap: 12px; margin: 4px 4px 0; } .error-text { font-size: 12px; color: var(--bad); }
.msg-meta { display: flex; align-items: center; gap: 5px; margin: 3px 4px 0; font-size: 11.5px; color: var(--text-3); }
.status { display: inline-flex; align-items: center; gap: 3px; } .status-read { color: var(--primary); } .status-failed { color: var(--bad); font-weight: 700; }
.msg-event { align-self: center; display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; padding: 3px 12px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); font-size: 12px; }
.msg-event time { color: var(--text-3); }
.new-msg-pill { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: 0; border-radius: 16px;
  background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 12.5px; box-shadow: var(--shadow); }
.typing-row { min-height: 20px; padding: 0 20px; font-size: 12px; color: var(--text-2); }
.typing-dots { display: inline-flex; gap: 3px; margin-right: 7px; } .typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; } .typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.tag-bar { display: flex; align-items: center; gap: 6px; padding: 7px 14px; background: var(--surface); border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; } .tag-bar::-webkit-scrollbar { display: none; }
.tag-bar-label { color: var(--text-3); display: inline-flex; flex: none; }
.tag-btn { --tag: #64748b; flex: none; height: 24px; padding: 0 10px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent); background: transparent; color: var(--tag); font-size: 12px; font-weight: 700; }
.tag-btn:hover { background: color-mix(in srgb, var(--tag) 12%, transparent); } .tag-btn.on { background: var(--tag); border-color: var(--tag); color: #fff; }
.composer { position: relative; padding: 0 14px 12px; background: var(--surface); }
.composer-box { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer-input { display: block; width: 100%; max-height: 160px; padding: 10px 12px 4px; border: 0; outline: 0; resize: none; background: transparent; line-height: 1.45; }
.composer-tools { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; min-width: 32px; padding: 0 7px; justify-content: center; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.tool-btn:hover { background: var(--hover); color: var(--text); } .tool-toggle { border: 1px solid var(--border); margin-left: 4px; } .tool-toggle.on { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.composer-hint { flex: 1; min-width: 0; text-align: right; padding-right: 10px; font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-btn { height: 34px; width: 44px; padding: 0; border-radius: 9px; }
.attach-row { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 8px; }
.attach-chip { display: flex; align-items: center; gap: 7px; max-width: 210px; padding: 4px 4px 4px 6px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: 12px; }
.attach-chip img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; } .attach-chip.loading { opacity: .55; animation: pulse 1s infinite; }
.reply-banner { display: flex; align-items: center; gap: 7px; padding: 5px 8px; margin-bottom: 7px; border-left: 3px solid var(--primary); border-radius: 5px; background: var(--primary-soft); font-size: 12.5px; color: var(--text-2); }
.reply-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-popup { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); z-index: 10; max-height: 330px; overflow: auto; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.qr-title { display: flex; justify-content: space-between; gap: 10px; padding: 6px 9px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.qr-item { display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 9px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; } .qr-item:hover, .qr-item.active { background: var(--primary-soft); }
.qr-shortcut { flex: none; font: 700 12.5px ui-monospace, Consolas, monospace; color: var(--primary); background: none; padding: 0; }
.qr-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

/* ---------- Bảng thông tin khách */
.col-side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }
.side-empty { margin: auto; padding: 24px; text-align: center; }
.side-tabs { display: flex; border-bottom: 1px solid var(--border); flex: none; }
.side-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; border: 0; border-bottom: 2px solid transparent; background: none; font-weight: 700; color: var(--text-2); }
.side-tab.active { color: var(--primary); border-bottom-color: var(--primary); } .side-tab .chip-count { background: var(--surface-3); color: var(--text-2); }
.side-content { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; }
.profile { display: flex; align-items: center; gap: 12px; } .profile-name { font-size: 16px; font-weight: 800; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0 4px; }
.kpi { display: grid; justify-items: center; padding: 8px 2px; border-radius: 9px; background: var(--surface-2); text-align: center; } .kpi strong { font-size: 16px; } .kpi span { font-size: 10.5px; color: var(--text-3); }
.kpi.ok strong { color: var(--ok); } .kpi.bad strong { color: var(--bad); }
.side-section { margin-top: 16px; } .side-section h4 { margin-bottom: 8px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.side-form { display: flex; flex-direction: column; gap: 8px; }
.side-row { display: flex; align-items: flex-start; gap: 8px; } .side-row-icon { display: grid; place-items: center; width: 22px; height: 36px; color: var(--text-3); flex: none; }
.notes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.note { padding: 9px 11px; border-radius: 9px; background: var(--warn-soft); } .note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 11.5px; color: var(--text-2); }
.orders { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.order-card { padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 9px; }
.order-card.kind-ok { border-left-color: var(--ok); } .order-card.kind-bad { border-left-color: var(--bad); } .order-card.kind-warn { border-left-color: var(--warn); } .order-card.kind-info { border-left-color: var(--info); } .order-card.kind-primary { border-left-color: var(--primary); }
.order-top, .order-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; } .order-items { margin: 6px 0; font-size: 13px; color: var(--text-2); }
.form-title { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 800; }
.product-search { position: relative; }
.product-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 8; max-height: 250px; overflow: auto; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.product-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; } .product-row:hover { background: var(--hover); }
.product-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-lines { display: flex; flex-direction: column; gap: 8px; } .order-line { padding: 8px 10px; border-radius: 9px; background: var(--surface-2); } .order-line-name { font-weight: 600; margin-bottom: 5px; }
.order-line-controls { display: flex; align-items: center; gap: 4px; } .qty { min-width: 24px; text-align: center; font-weight: 700; } .input-price { margin-left: auto; width: 116px; min-height: 30px; padding: 3px 8px; text-align: right; }
.order-totals { display: flex; flex-direction: column; gap: 4px; padding-top: 10px; border-top: 1px dashed var(--border-strong); } .order-totals div { display: flex; justify-content: space-between; color: var(--text-2); }
.order-totals .grand { color: var(--text); font-size: 15px; margin-top: 3px; } .order-totals .grand strong { color: var(--primary); }

/* ---------- Trang thường (đơn hàng, thống kê, cài đặt) */
.page-host { flex: 1; min-width: 0; overflow-y: auto; }
.page { max-width: 1240px; margin: 0 auto; padding: 22px 26px 40px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; } .page-head h2 { font-size: 21px; } .page-tools .search-box { width: 320px; background: var(--surface); border: 1px solid var(--border); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; } .panel-head h3 { font-size: 15.5px; } .panel-head p { margin-top: 3px; max-width: 720px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; } .panel .table-wrap { border-radius: 9px; }
.table { width: 100%; border-collapse: collapse; } .table th { text-align: left; padding: 10px 14px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; } .table tr:last-child td { border-bottom: 0; } .table tbody tr:hover td { background: var(--surface-2); }
.table-compact th, .table-compact td { padding: 8px 10px; } .table th.num, .table td.num { text-align: right; }
.cell-main { display: flex; align-items: center; gap: 8px; font-weight: 600; } .strong-link { font-weight: 800; } .row-off td { opacity: .5; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; white-space: nowrap; } .table-more { text-align: center; }
.status-select { width: 138px; font-weight: 700; } .status-select.kind-ok { color: var(--ok); } .status-select.kind-bad { color: var(--bad); } .status-select.kind-warn { color: var(--warn); } .status-select.kind-info { color: var(--info); } .status-select.kind-primary { color: var(--primary); }
.callout { margin-top: 14px; padding: 11px 14px; border-radius: 9px; background: var(--info-soft); color: var(--text); font-size: 13px; line-height: 1.7; }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 3px; position: sticky; top: 0; }
.settings-link { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: none; font-weight: 600; color: var(--text-2); text-align: left; }
.settings-link:hover { background: var(--surface-3); } .settings-link.active { background: var(--primary-soft); color: var(--primary); }
.tag-list, .reply-list { display: flex; flex-direction: column; } .tag-row, .reply-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); } .tag-row:last-child, .reply-row:last-child { border-bottom: 0; }
.reply-row .reply-text { flex: 1; min-width: 0; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; } .reply-row .qr-shortcut { width: 92px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; } .swatch-btn { width: 30px; height: 30px; border-radius: 8px; border: 3px solid transparent; } .swatch-btn.on { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.monitor { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.monitor-cell { display: grid; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); } .monitor-cell strong { font-size: 18px; font-variant-numeric: tabular-nums; } .monitor-cell span { font-size: 11.5px; color: var(--text-3); }
.monitor-note { grid-column: 1 / -1; padding: 10px 12px; border-radius: 9px; background: var(--primary-soft); font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.stat-card { display: flex; gap: 12px; align-items: center; padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.stat-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); flex: none; } .stat-value { font-size: 21px; font-weight: 800; line-height: 1.15; } .stat-label { color: var(--text-2); font-size: 12.5px; }
.stats-body { display: flex; flex-direction: column; gap: 16px; } .two-panels { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); } .legend span { display: inline-flex; align-items: center; gap: 6px; } .swatch { width: 11px; height: 11px; border-radius: 3px; } .swatch-in, .bar-in { background: #6366f1; } .swatch-out, .bar-out { background: #14b8a6; }
.day-bars { display: flex; flex-direction: column; gap: 7px; } .day-bar-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 96px; align-items: center; gap: 10px; }
.day-bar-label { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; } .day-bar-tracks { display: flex; flex-direction: column; gap: 2px; } .bar { height: 8px; min-width: 2px; border-radius: 0 4px 4px 0; }
.day-bar-value { font-size: 12px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- Lớp phủ */
/* ---------- Khung báo tin mới (core/notify.js): góc trên phải, nổi hẳn lên, bấm là mở hội thoại */
.notify-stack { position: fixed; top: 14px; right: 16px; z-index: 75; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.notify-card { pointer-events: auto; position: relative; display: flex; gap: 11px; align-items: flex-start; padding: 12px 34px 12px 12px; border-radius: 12px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 5px solid var(--primary); box-shadow: 0 14px 34px rgba(15, 23, 42, .22); cursor: pointer; animation: notify-in .25s cubic-bezier(.2, .9, .3, 1.2); }
.notify-card:hover { border-color: var(--primary); } .notify-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.notify-card.leaving { opacity: 0; transform: translateX(24px); transition: opacity .2s, transform .2s; }
.notify-card.is-hint { border-left-color: var(--warn); }
.nc-avatar { position: relative; flex: none; } .nc-channel { position: absolute; right: -4px; bottom: -4px; border: 2px solid var(--surface); border-radius: 50%; display: inline-flex; }
.nc-hint-icon { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--warn-soft); color: var(--warn); }
.nc-body { flex: 1; min-width: 0; }
.nc-top { display: flex; align-items: baseline; gap: 6px; } .nc-name { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-kind, .nc-time { font-size: 12px; color: var(--text-3); white-space: nowrap; } .nc-time { margin-left: auto; color: var(--primary); font-weight: 600; }
.nc-text { margin-top: 3px; font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.nc-meta { margin-top: 3px; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-action { margin-top: 5px; font-size: 13px; font-weight: 700; color: var(--primary); }
.nc-close { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 3px; border-radius: 6px; display: grid; place-items: center; }
.nc-close:hover { background: var(--hover); color: var(--text); }
@keyframes notify-in { from { opacity: 0; transform: translateX(40px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 760px) { .notify-stack { top: auto; bottom: 64px; right: 8px; left: 8px; width: auto; flex-direction: column-reverse; } }
.notify-opt { align-items: flex-start; } .notify-volume { width: 100%; accent-color: var(--primary); }
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { max-width: 380px; padding: 11px 15px; border-radius: 10px; background: #1f2433; color: #fff; font-weight: 600; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast-error { background: #b91c1c; } .toast-success { background: #15803d; } .toast.leaving { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px; background: rgba(10, 12, 20, .55); animation: fade .12s; } @keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-height: calc(100dvh - 36px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px 6px; } .modal-header h3 { font-size: 16.5px; }
.modal-body { padding: 10px 18px 16px; overflow-y: auto; } .modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 13px 18px; border-top: 1px solid var(--border); }

/* ---------- Đăng nhập */
.login-page { display: grid; place-items: center; overflow: auto; padding: 20px; background: radial-gradient(900px 500px at 15% 0%, color-mix(in srgb, #6366f1 22%, transparent), transparent), radial-gradient(800px 500px at 100% 100%, color-mix(in srgb, #a855f7 18%, transparent), transparent), var(--bg); }
.login-card { width: 100%; max-width: 390px; padding: 30px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; } .login-brand h1 { font-size: 23px; line-height: 1.1; } .login-brand p { color: var(--text-2); }
.login-error { padding: 9px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-weight: 600; } .login-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ---------- Màn hình hẹp */
@media (max-width: 1100px) { .inbox, .inbox.side-hidden { grid-template-columns: 310px minmax(0, 1fr); } .inbox:not(.side-hidden) .col-side { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100vw); z-index: 40; box-shadow: var(--shadow); }
  .composer-hint { display: none; } .two-panels { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { flex-direction: column-reverse; } .rail { width: 100%; height: 56px; flex-direction: row; padding: 0 8px; justify-content: space-around; } .rail-logo, .rail-spacer, .rail-conn { display: none; }
  .rail-nav { flex-direction: row; justify-content: space-around; } .rail-btn { width: 64px; padding: 5px 0 3px; } .main { min-height: 0; }
  .inbox, .inbox.side-hidden { grid-template-columns: minmax(0, 1fr); } .inbox .col-thread { display: none; } .inbox.has-selection .col-list { display: none; } .inbox.has-selection .col-thread { display: flex; }
  .only-mobile { display: inline-grid; } .assign-btn span { display: none; } .msg-col { max-width: 84%; } .page { padding: 16px 14px 30px; } .settings-layout { grid-template-columns: minmax(0, 1fr); } .settings-nav { flex-direction: row; overflow-x: auto; position: static; }
  .settings-link { flex: none; } .page-tools .search-box { width: 100%; } .page-tools { width: 100%; } .emoji-grid { grid-template-columns: repeat(8, 32px); } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* =====================================================================================================
   LỚP GIAO DIỆN "HIỆN ĐẠI": các cột thành thẻ nổi bo tròn, màu chuyển sắc nhẹ, khoảng thở rộng hơn, thao tác rõ hơn.
   Đặt cuối tệp để ghi đè lớp nền phía trên — muốn quay về giao diện phẳng chỉ cần bỏ khối này.
   ===================================================================================================== */
:root { --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #a855f7 100%); --radius: 12px; --radius-sm: 9px; --card-radius: 18px;
  --bg: #eef0f6; --thread-bg: #f6f7fb; --ring: 0 0 0 1px var(--border), 0 1px 2px rgba(16, 24, 40, .04), 0 12px 32px -12px rgba(16, 24, 40, .12); }
:root[data-theme="dark"] { --bg: #0b0d13; --thread-bg: #131620; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0b0d13; --thread-bg: #131620; } }
body { font-size: 14.5px; letter-spacing: -.003em; }

.rail { width: 76px; margin: 10px 0 10px 10px; border-radius: var(--card-radius); background: linear-gradient(180deg, #1b1e33, #12142200), var(--rail); box-shadow: var(--ring); }
.rail-logo, .boot-logo { background: var(--grad); box-shadow: 0 6px 16px -4px rgba(124, 58, 237, .55); }
.rail-btn { width: 62px; padding: 9px 0 7px; border-radius: 14px; transition: background .15s, color .15s, transform .15s; }
.rail-btn:hover { transform: translateY(-1px); }
.rail-btn.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px rgba(124, 58, 237, .8); }

.inbox { gap: 10px; padding: 10px; grid-template-columns: 372px minmax(0, 1fr) 352px; }
.inbox.side-hidden { grid-template-columns: 372px minmax(0, 1fr); }
.col-list, .col-thread, .col-side { border: 0; border-radius: var(--card-radius); box-shadow: var(--ring); overflow: hidden; }
.list-head { padding: 14px 14px 10px; gap: 10px; border-bottom: 0; }
.channel-picker { height: 40px; border-radius: 12px; border-color: transparent; background: var(--surface-3); }
.search-box { height: 40px; border-radius: 12px; }
.chip { height: 28px; padding: 0 11px; border-color: transparent; background: var(--surface-3); transition: background .12s, transform .12s; }
.chip:hover { background: var(--border); transform: translateY(-1px); }
.chip.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 14px -6px rgba(124, 58, 237, .7); }
.chip-clear { background: transparent; border: 1px dashed var(--border-strong); }

.conv-list { padding: 2px 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.conv { padding: 11px 12px 11px 14px; border-bottom: 0; border-radius: 14px; transition: background .12s; }
.conv::before { top: 14px; bottom: 14px; left: 3px; width: 3px; border-radius: 3px; }
.conv.selected { background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 28%, transparent); }
.conv.unread .conv-name::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; background: var(--primary); vertical-align: middle; }
.conv-name { font-size: 14.5px; } .conv-snippet { font-size: 13.5px; }
.badge { background: linear-gradient(135deg, #f43f5e, #e11d48); }

.thread-head { min-height: 68px; padding: 11px 18px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); }
.thread-scroll { padding: 18px 22px 10px; }
.bubble { padding: 9px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
.msg.out .bubble { background: var(--grad); }
.msg.in.first .bubble, .msg.in.last .bubble, .msg.out.last .bubble { border-radius: 18px; } .msg.in.last .bubble { border-bottom-left-radius: 6px; } .msg.out.last .bubble { border-bottom-right-radius: 6px; }
.day-sep span { padding: 3px 12px; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.day-sep::before, .day-sep::after { background: transparent; }
.msg-event { background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.tag-bar { padding: 9px 18px; border-top: 0; background: transparent; }
.tag-btn { height: 26px; padding: 0 12px; border-radius: 13px; transition: transform .12s; } .tag-btn:hover { transform: translateY(-1px); }
.composer { padding: 0 16px 16px; background: transparent; }
.composer-box { border-radius: 18px; border-color: transparent; box-shadow: var(--ring); }
.composer-box:focus-within { box-shadow: 0 0 0 2px var(--primary), 0 12px 32px -12px rgba(99, 102, 241, .35); }
.composer-input { padding: 13px 16px 4px; font-size: 14.5px; }
.send-btn, .btn-primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 18px -8px rgba(124, 58, 237, .8); transition: transform .12s, filter .12s; }
.send-btn:hover, .btn-primary:hover { background: var(--grad); filter: brightness(1.07); transform: translateY(-1px); }
.send-btn { width: 46px; height: 36px; border-radius: 12px; }
.new-msg-pill, .stale-pill { background: var(--grad); color: #fff; }

.thread-empty { gap: 14px; max-width: 460px; }
.empty-art { display: grid; place-items: center; width: 96px; height: 96px; border-radius: 30px; background: var(--grad); color: #fff; box-shadow: 0 20px 40px -16px rgba(124, 58, 237, .7); }
.thread-empty h3 { font-size: 20px; color: var(--text); }
.tips { display: grid; gap: 8px; margin-top: 8px; width: 100%; text-align: left; }
.tip { display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-radius: 14px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); color: var(--text-2); font-size: 13.5px; }
.tip kbd { flex: none; min-width: 52px; padding: 2px 8px; border-radius: 7px; background: var(--surface-3); color: var(--text); font: 700 12px ui-monospace, Consolas, monospace; text-align: center; }

.side-tabs { padding: 8px 8px 0; border-bottom: 0; gap: 4px; }
.side-tab { height: 38px; border: 0; border-radius: 11px; } .side-tab.active { background: var(--primary-soft); border: 0; }
.kpi { border-radius: 14px; padding: 10px 2px; } .note { border-radius: 12px; } .order-card { border-radius: 14px; }
.panel, .stat-card, .table-wrap { border: 0; border-radius: var(--card-radius); box-shadow: var(--ring); }
.stat-icon { background: var(--grad); color: #fff; border-radius: 13px; }
.bar-in, .swatch-in { background: #7c6cf6; } .bar { height: 9px; border-radius: 5px; }
.settings-link { height: 42px; border-radius: 12px; } .settings-link.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -10px rgba(124, 58, 237, .8); }
.modal { border-radius: 20px; } .popover { border-radius: 14px; border: 0; box-shadow: var(--ring), 0 24px 48px -16px rgba(16, 24, 40, .25); }
.input { border-radius: 11px; } .login-card { border-radius: 24px; border: 0; box-shadow: var(--ring), 0 32px 64px -24px rgba(99, 102, 241, .35); }
.login-hint { margin-top: 14px; text-align: center; font-size: 13px; color: var(--text-2); }
.callout { border-radius: 12px; }

@media (max-width: 1100px) { .inbox, .inbox.side-hidden { grid-template-columns: 320px minmax(0, 1fr); } }
@media (max-width: 760px) { .rail { width: auto; margin: 0; border-radius: 0; } .rail-btn { width: 64px; } .inbox, .inbox.side-hidden { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
  .col-list, .col-thread, .col-side { border-radius: 0; box-shadow: none; } }

/* ---------- Kết nối Facebook: nút, danh sách trang, các bước hướng dẫn */
.btn-facebook { background: #1877f2; border-color: #1877f2; color: #fff; } .btn-facebook:hover { background: #0f66d9; border-color: #0f66d9; }
.btn-facebook .ch-badge { box-shadow: none; background: #fff !important; color: #1877f2; }
.page-list { display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.page-row { padding: 9px 10px; border-radius: 12px; } .page-row .picker-name { display: grid; white-space: normal; }
/* Lý do / kết quả hiện NGAY dưới từng trang trong hộp chọn trang Facebook (chữ thường, không tooltip — điện thoại không có hover). */
.page-note { line-height: 1.45; overflow-wrap: anywhere; } .page-note[hidden] { display: none; }
/* Điện thoại 360px: nhãn ("Đã kết nối", "Thiếu quyền") xuống dòng riêng thay vì bóp cột tên còn vài px. */
.page-row { flex-wrap: wrap; } .page-row .picker-name { flex: 1 1 150px; }
.text-ok { color: var(--ok); } .text-bad { color: var(--bad); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.6; } .steps code { word-break: break-all; }

/* ---------- Gói dịch vụ Đơn Lộc: hạn mức kênh, mua thêm kênh (VietQR), màn hình chặn */
.callout-warn { background: var(--warn-soft); } .callout.small { margin-top: 0; font-size: 12.5px; line-height: 1.6; }
/* Chặn khách + báo xấu: khối cảnh báo ở cột khách / form lên đơn, nhãn trên danh sách + đầu khung chat, dải thay ô soạn tin khi khách bị chặn */
.callout-bad { background: var(--bad-soft); }
.flag-callout { display: flex; gap: 8px; align-items: flex-start; } .flag-callout > svg { flex: none; margin-top: 3px; }
.callout-bad.flag-callout > svg { color: var(--bad); } .callout-warn.flag-callout > svg { color: var(--warn); }
.flag-callout .btn { margin-top: 6px; }
.flag-list { margin: 0; padding-left: 18px; line-height: 1.6; color: var(--text-2); }
.flag-pill { display: inline-flex; align-items: center; gap: 3px; flex: none; padding: 0 6px; border-radius: 20px; font-size: 11px; font-weight: 700; line-height: 18px; white-space: nowrap; }
.flag-pill.is-report { background: var(--bad-soft); color: var(--bad); } .flag-pill.is-blocked { background: var(--surface-3); color: var(--text-2); }
.blocked-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.blocked-bar[hidden] { display: none; } .blocked-bar > svg { flex: none; color: var(--bad); } .blocked-bar > span { flex: 1; min-width: 0; }
.blocked-bar { margin-bottom: 7px; padding: 6px 8px 6px 10px; font-size: 12.5px; line-height: 1.45; } .blocked-bar .btn { flex: none; }
.side-flags { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; } .side-flags:empty { display: none; }
.side-flag-actions { display: flex; gap: 8px; flex-wrap: wrap; } .side-flag-actions:empty { display: none; }
.side-orders-flags { margin-bottom: 10px; } .side-orders-flags:empty { display: none; }
/* Tab Đơn hàng đang mở form lên đơn + có cảnh báo: cảnh báo ở trên, form (vốn chiếm trọn cột, margin âm) co vào phần còn lại — nút "Tạo đơn" không bị đẩy khuất */
.side-content.with-flags { display: flex; flex-direction: column; }
.side-content.with-flags > .side-orders-flags { flex: none; margin-bottom: 8px; }
.side-content.with-flags > .order-form-side { flex: 1 1 auto; height: auto; margin: 0 -14px -14px; }
.entitlement { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2, var(--surface-3)); box-shadow: 0 0 0 1px var(--border); }
.entitlement-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.meter { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.meter-head { display: flex; align-items: center; gap: 8px; } .meter-count { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-bar { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; } .meter-bar span { display: block; height: 100%; border-radius: 4px; background: var(--grad, var(--primary)); }
.meter-over .meter-bar span { background: var(--bad); } .meter-over .meter-count { color: var(--bad); }
.addon-list { margin: 0; padding-left: 18px; color: var(--text-2); line-height: 1.7; }
.months-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .months-input { width: 78px; }
.quote-box { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); font-size: 13.5px; }
.quote-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quote-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 8px; border-top: 1px dashed var(--border-strong); } .quote-total strong { font-size: 20px; color: var(--primary); }
.pay-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 18px; align-items: start; }
.pay-qr-wrap { display: grid; place-items: center; padding: 10px; border-radius: 14px; background: #fff; box-shadow: 0 0 0 1px var(--border); } .pay-qr { display: block; width: 216px; height: 216px; }
.pay-lines { display: grid; gap: 2px; } .pay-line { display: grid; grid-template-columns: 104px minmax(0, 1fr) 28px; align-items: center; gap: 8px; min-height: 30px; font-size: 13.5px; } .pay-line strong { word-break: break-word; }
.pay-status { display: flex; align-items: center; gap: 9px; color: var(--text-2); font-size: 13px; }
.spinner { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) { .pay-layout { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Zalo cá nhân: nút kết nối + hộp quét QR */
.btn-zalo { background: #0068ff; border-color: #0068ff; color: #fff; } .btn-zalo:hover { background: #0055d4; border-color: #0055d4; }
.btn-zalo .ch-badge { box-shadow: none; background: #fff !important; color: #0068ff; }
.zalo-link { justify-items: center; } .zalo-qr { width: 240px; min-height: 240px; margin: 0 auto; } .steps.small { font-size: 13px; gap: 4px; }

.blocked-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg, var(--surface-3)); }
.blocked-card { max-width: 520px; display: grid; gap: 14px; justify-items: center; padding: 34px 32px; border-radius: 24px; background: var(--surface); box-shadow: var(--ring, 0 0 0 1px var(--border)), 0 32px 64px -24px rgba(16, 24, 40, .3); text-align: center; }
.blocked-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 22px; background: var(--warn-soft); color: var(--warn); }
.blocked-card h2 { margin: 0; font-size: 20px; } .blocked-reason { margin: 0; font-size: 15px; line-height: 1.65; color: var(--text); } .blocked-actions { justify-content: center; margin-top: 6px; }

/* Bang hieu suat nhan su: to mau toc do tra loi (<=5 phut tot, <=30 phut tam, tren nua la cham) */
.speed-ok { color: var(--ok); font-weight: 600; }
.speed-warn { color: var(--warn); font-weight: 600; }
.speed-bad { color: var(--bad); font-weight: 600; }
/* Thanh trai: vach ngan giua cac nhom chuc nang (Ban hang / Theo doi / Thiet lap) */
.rail-sep { width: 30px; height: 1px; margin: 5px 0; background: rgba(255, 255, 255, .14); flex: none; }
/* ---------- Form len don (soi guong trang tao don cua Don Loc CRM) ---------- */
.seg-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.seg { padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; }
.seg:hover { border-color: var(--primary); }
.seg.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.seg-check { margin-left: 6px; white-space: nowrap; }

.stack-xs { display: flex; flex-direction: column; gap: 6px; }
.radio-card-sm { padding: 7px 10px; }
.radio-card-sm .muted { margin-top: 1px; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.input-bad { border-color: var(--bad); }
.ok-text { color: var(--ok); } .warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

.line-total { min-width: 78px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-totals .row-input { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-totals .row-input .input { max-width: 150px; text-align: right; }

/* Ten rieng, khong dung lai .quote-box cua trang thanh toan goi dich vu (dong 433) — bi tha ke padding 12px 14px vao cot hep. */
.ship-quote-box { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; }
.quote-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); text-align: left; color: var(--text); }
.quote-row:hover { border-color: var(--primary); }
.quote-row.active { border-color: var(--primary); background: var(--primary-soft); }
/* ================= Thanh loc icon ben trai cot danh sach hoi thoai ================= */
/* .col-list von la cot doc; nay thanh hang ngang: [thanh loc][phan con lai] */
.col-list { flex-direction: row; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.filter-rail {
  flex: none; width: 46px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  /* 17px tren: cho icon dau tien thang hang voi o chon kenh ben canh (.list-head padding 14px + o cao 40px) */
  padding: 17px 0 10px; border-right: 1px solid var(--border); background: var(--surface-2);
  overflow: visible; z-index: 3;
}
.frail-btn {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer;
  transition: background .12s, color .12s;
}
.frail-btn:hover { background: var(--surface-3); color: var(--text); }
.frail-btn.active { background: var(--primary); color: var(--on-primary); }
.frail-clear, .frail-clear:hover { color: var(--bad); }
.frail-sep { width: 22px; height: 1px; margin: 4px 0; background: var(--border); flex: none; }

/* Chu chi hien khi re chuot - day la yeu cau: icon thay cho text, di chuot vao moi hien text */
.frail-label {
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%) translateX(-4px);
  padding: 5px 10px; border-radius: 8px; white-space: nowrap; font-size: 12.5px; font-weight: 600;
  background: var(--text); color: var(--surface); box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; z-index: 20;
}
.frail-btn:hover .frail-label, .frail-btn:focus-visible .frail-label { opacity: 1; transform: translateY(-50%) translateX(0); }
.frail-badge { position: absolute; top: -2px; right: -2px; box-shadow: 0 0 0 2px var(--surface-2); }

@media (max-width: 760px) { .filter-rail { width: 42px; } .frail-btn { width: 32px; height: 32px; } }

/* Cua so thap (dien thoai nam ngang, cua so bi keo thap): 11 nut khong du cho -> cho thanh tu cuon.
   overflow-y: auto cat mat nhan bay ra, nen tat nhan va de chu thich cua trinh duyet (title) lam viec thay. */
@media (max-height: 640px) {
  .filter-rail { min-height: 0; overflow-y: auto; overflow-x: clip; scrollbar-width: none; padding-top: 14px; gap: 0; }
  .filter-rail::-webkit-scrollbar { width: 0; }
  .frail-label { display: none; }
}

/* ================= Form len don NAM TRONG cot phai (khong bung cua so) ================= */
/* Van thay khung chat ben canh -> nhan vien vua nhap don vua doc duoc khach dang nhan gi. */
/* .side-content co padding 14px: margin am keo form tran het khung, con height phai cong lai 28px (100% tinh theo content-box)
   thi chan form moi cham day cot — neu khong se treo lo lung cach day 28px. */
.order-form-side { display: flex; flex-direction: column; height: calc(100% + 28px); min-height: 0; margin: -14px; }
.ofs-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex: none; }
.ofs-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ofs-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ofs-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.ofs { display: flex; flex-direction: column; gap: 8px; }
.ofs > h4 { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.ofs-foot {
  flex: none; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.ofs-foot-sum { display: flex; align-items: baseline; justify-content: space-between; }
.ofs-foot-sum strong { font-size: 17px; }
.ofs-foot-btn { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.tab-dot { width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: var(--warn); display: inline-block; vertical-align: middle; }

/* Trong cot hep: cac o tien va dong san pham phai co lai cho vua */
.order-form-side .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order-form-side .order-line-controls { flex-wrap: wrap; gap: 4px; }
.order-form-side .input-price { width: 84px; }
.order-form-side .line-total { min-width: 0; margin-left: auto; }
.order-form-side .order-totals .row-input .input { max-width: 116px; }
.order-form-side .quote-row { grid-template-columns: 1fr auto; row-gap: 2px; }
/* Thap hon 240px: .ofs-body la khung cuon nen danh sach ket qua dai se bi cat mat phan duoi. */
.order-form-side .product-results { max-height: 190px; overflow-y: auto; }
/* ================= O ho so khach vua duoc may tu cap nhat tu tin cua khach ================= */
/* Nhay nhe mot cai roi tat: nhan vien BIET la may vua doi, khong tuong minh go nham. */
.vua-cap-nhat {
  animation: vua-cap-nhat 1.8s ease-out;
}
@keyframes vua-cap-nhat {
  0%   { background: var(--ok-soft); border-color: var(--ok); }
  70%  { background: var(--ok-soft); border-color: var(--ok); }
  100% { background: var(--surface); border-color: var(--border); }
}
@media (prefers-reduced-motion: reduce) { .vua-cap-nhat { animation: none; box-shadow: 0 0 0 2px var(--ok-soft); } }
/* Dong nhac nho nam giua cac o ho so — dung .callout co san, chi noi long khoang cach cho vua cot hep. */
.side-form .callout { margin-top: 0; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.side-form .callout .link-btn { text-align: left; }

/* Dai hoi lai trong form len don khi may tu doc duoc SDT/dia chi moi tu tin khach.
   KHONG tu thay so tren don: so do la so buu ta goi va la khoa Don Loc dung de nhan ra khach. */
.ofs-hoi-lai { margin-top: 0; display: flex; flex-direction: column; gap: 5px; }
.ofs-hoi-dong { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.ofs-hoi-dong > span:nth-child(2) { flex: 1; min-width: 0; word-break: break-word; font-weight: 600; }
.ofs-hoi-lai .link-btn { color: var(--primary); }

/* ===== Nut "Lay thong tin" dan duoi bong bong chat cua khach =====
   Khach go ten/SDT/dia chi la co nut; mot cu bam la ho so khach VA don hang dang mo deu co ngay. */
.lay-tt {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-strong);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.lay-tt-list { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12.5px; line-height: 1.5; }
.lay-tt-mot { display: block; overflow-wrap: anywhere; }
.lay-tt-nut { flex: none; white-space: nowrap; }
.lay-tt-nut:disabled { opacity: .5; }
/* Bong bong cua khach nen mau sang: nut dung mau vien ro cho doc duoc o ca hai che do sang/toi */
.bubble .lay-tt-nut { background: var(--surface); border: 1px solid var(--primary); color: var(--primary); font-weight: 700; }
.bubble .lay-tt-nut:hover:not(:disabled) { background: var(--primary); color: var(--on-primary); }

/* ================= Bao cao chi so nhan vien ================= */
.report-head { flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.report-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-range { display: flex; align-items: center; gap: 6px; }
.input-date { width: 150px; padding-top: 6px; padding-bottom: 6px; }
.stat-delta { margin-left: 8px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.delta { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.delta-good { color: var(--ok); } .delta-bad { color: var(--bad); }
.report-table { min-width: 1080px; }
.report-table td .delta { display: block; margin-left: 0; }
.report-row { cursor: pointer; }
.report-row:hover td { background: var(--hover); }
.report-row.open td { background: var(--surface-2); font-weight: 600; }
.report-row-off td { opacity: .6; }
.report-caret { display: inline-grid; place-items: center; width: 16px; color: var(--text-3); }
.report-day td { background: var(--surface-2); font-size: 12.5px; }
.report-day td:first-child { padding-left: 46px; color: var(--text-2); }
.report-total td { border-top: 2px solid var(--border-strong); background: var(--surface-2); font-weight: 700; }
.report-legend dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 10px 0 0; font-size: 13px; }
.report-legend dt { font-weight: 600; }
.report-legend dd { margin: 0; }
.dot-online { display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--ok); vertical-align: middle; }
@media (max-width: 760px) { .report-legend dl { grid-template-columns: 1fr; } .report-legend dd { margin-bottom: 6px; } }
.report-table th:first-child, .report-table td:first-child { min-width: 230px; }
.report-table th { white-space: nowrap; }

/* ===== Khoa API (Cai dat) ===== */
.code-block { margin: 0; padding: 10px 12px; border-radius: 9px; background: var(--surface-3); color: var(--text); font: 12.5px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.input-mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.pill-muted { background: var(--surface-3); color: var(--text-3); }
/* Giá bán + giá gốc gạch ngang + "-20%" khi đang giảm giá (core/dom.js priceTag) — như web shop Đơn Lộc */
.price-tag { display: inline-flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
.price-list { color: var(--text-3); font-size: .9em; }
.price-off { padding: 0 5px; border-radius: 4px; background: var(--bad-soft); color: var(--bad); font-size: 11px; font-weight: 700; }
td code { font: 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text-2); }

/* ---------- Trợ lý AI trong khung chat: nút "AI soạn", bảng gợi ý, tin của trợ lý, dải tự trả lời */
.ai-btn { color: var(--primary); } .ai-btn:hover { background: var(--primary-soft); color: var(--primary); }
/* "AI gợi ý trả lời": nút nhỏ cạnh tin mới nhất của khách + dải báo sau khi AI viết vào ô nhập */
.bubble-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; min-width: 0; flex-wrap: wrap; }
.bubble-row > .bubble { flex: 0 1 auto; }
.ai-quick { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px 0 9px; border-radius: 999px; flex: none;
  font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; color: var(--primary); background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent); box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
  transition: background .15s, color .15s, box-shadow .15s, transform .15s; }
.ai-quick:hover:not(:disabled) { background: var(--primary); color: var(--on-primary); box-shadow: 0 3px 10px color-mix(in srgb, var(--primary) 32%, transparent); transform: translateY(-1px); }
.ai-quick:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ai-quick:disabled { cursor: progress; opacity: .85; }
.ai-quick .spinner { width: 12px; height: 12px; border-width: 2px; }
.ai-quick.is-locked { color: var(--text-3); background: var(--surface-2); border-color: var(--border); box-shadow: none; }
.ai-quick.is-locked:hover { color: var(--text-2); background: var(--surface-3); transform: none; box-shadow: none; }
.ai-quick-strip { display: flex; flex-direction: column; gap: 5px; padding: 7px 10px; margin-bottom: 6px; border-radius: 10px; font-size: 12.5px;
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent); }
.ai-quick-strip[hidden] { display: none; }
.ai-quick-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); } .ai-quick-head > svg { color: var(--primary); flex: none; }
.ai-quick-head .spacer { flex: 1; }
.ai-quick-pending { padding: 6px 8px; border-radius: 8px; background: var(--surface); border: 1px dashed color-mix(in srgb, var(--primary) 35%, transparent); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-quick-products { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
/* Chip "Đối chiếu": tên dài thì cắt (…) — GIÁ (kể cả giá gốc gạch ngang + -%) luôn hiện đủ. */
.ai-quick-product { display: inline-flex; align-items: baseline; gap: 5px; min-width: 0; max-width: 100%; }
.ai-quick-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-quick-product > strong, .ai-quick-product > .price-tag { flex: none; }
.ai-locked-steps { margin: 4px 0; padding-left: 20px; line-height: 1.6; }
@media (max-width: 760px) { .ai-quick { height: 30px; } .ai-quick-product { flex-wrap: wrap; } .ai-quick-name { white-space: normal; } }
.ai-panel { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 4px); z-index: 9; display: flex; flex-direction: column; gap: 9px; max-height: min(460px, 60dvh); overflow: auto;
  padding: 10px 12px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ai-panel:focus { outline: none; }
.ai-head { display: flex; align-items: center; gap: 7px; color: var(--primary); } .ai-head strong { color: var(--text); font-size: 13.5px; }
.ai-head-hint { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.ai-body { display: flex; flex-direction: column; gap: 8px; }
.ai-loading { display: flex; align-items: center; gap: 9px; padding: 14px 4px; color: var(--text-2); font-size: 13px; }
.ai-error { display: flex; align-items: flex-start; gap: 7px; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); font-size: 13px; line-height: 1.5; } .ai-error svg { flex: none; margin-top: 2px; }
.ai-text { display: block; width: 100%; min-height: 64px; max-height: 220px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); line-height: 1.5; resize: vertical; }
.ai-text:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ai-note { display: flex; align-items: flex-start; gap: 7px; padding: 8px 11px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; line-height: 1.5; }
.ai-note svg { flex: none; margin-top: 2px; } .ai-note span { color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-products { display: flex; flex-direction: column; gap: 3px; }
.ai-products-title { padding: 2px 2px 1px; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.ai-product { display: flex; align-items: baseline; gap: 10px; padding: 5px 9px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; }
.ai-product-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-product strong { flex: none; font-variant-numeric: tabular-nums; } .ai-product .is-out { color: var(--bad); font-weight: 600; }
.ai-product .price-tag { flex: none; }
@media (max-width: 760px) { .ai-product { flex-wrap: wrap; } .ai-product-name { flex-basis: 100%; white-space: normal; } }
.ai-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .ai-usage { flex: 1; min-width: 0; color: var(--text-3); }
.msg.out:not(.is-failed) .bubble.bubble-bot { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent); }
.msg.out .bubble.bubble-bot a { color: var(--primary); }
.bot-tag { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font-weight: 700; line-height: 17px; }
.bot-strip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; margin-bottom: 7px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text-2); font-size: 12.5px; }
.bot-strip > svg { flex: none; color: var(--primary); } .bot-strip.is-paused { background: var(--warn-soft); } .bot-strip.is-paused > svg { color: var(--warn); }
.bot-strip-text { flex: 1; min-width: 0; line-height: 1.4; }
.bot-strip .btn { flex: none; height: 26px; padding: 0 10px; font-size: 12.5px; }
/* Công tắc "AI tự trả lời" của riêng khách đang mở (đầu khung chat): xanh = trợ lý được trả lời khách này; xám + gạch chéo = nhân viên đã tắt */
.bot-toggle { gap: 5px; padding: 0 9px; border-color: transparent; background: var(--ok-soft); color: var(--ok); font-weight: 600; white-space: nowrap; }
.bot-toggle:hover { background: var(--ok-soft); border-color: var(--ok); }
.bot-toggle[hidden] { display: none; }
.bot-toggle.is-off { background: var(--surface-3); color: var(--text-2); }
.bot-toggle.is-off:hover { border-color: var(--border-strong); }
.bot-toggle-ico { position: relative; display: inline-flex; }
.bot-toggle.is-off .bot-toggle-ico::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); }
@media (max-width: 760px) { .ai-btn-label, .ai-head-hint { display: none; } .ai-panel { left: 8px; right: 8px; } .composer-tools { flex-wrap: wrap; row-gap: 2px; } }

/* ================= AI len don: chi DIEN SAN form — nhan vien xem lai roi tu bam "Tao don" ================= */
/* Nut "AI dien tu hoi thoai" o dau form: tieu de co lai (cat "…"), nut giu nguyen kich thuoc. */
.ofs-head .ofs-title { flex: 1; }
.ofs-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ofs-ai-btn { flex: none; gap: 5px; padding: 0 9px; color: var(--primary); }
.ofs-ai-btn .spinner, .side-order-actions .spinner { width: 12px; height: 12px; }

/* Dai "AI: tom tat" o dau than form */
.callout.ofs-ai-banner { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; }
.ofs-ai-banner-head { display: flex; align-items: flex-start; gap: 6px; }
.ofs-ai-banner-head > .icon { flex: none; margin-top: 3px; color: var(--primary); }
.ofs-ai-banner-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ofs-ai-banner .icon-btn { width: 24px; height: 24px; margin: -2px -4px 0 0; }
.ofs-ai-missing { color: var(--warn); font-weight: 600; }
.ofs-ai-banner .link-btn { color: var(--primary); }

/* Hop "Chua khop san pham": mon khach hoi ma AI khong chac la san pham nao — nhan vien bam chon, AI khong tu chon ho */
.ofs-ai-unmatched { display: flex; flex-direction: column; gap: 8px; padding: 9px 10px; border: 1px dashed var(--warn); border-radius: 9px; background: var(--warn-soft); font-size: 13px; }
.ofs-ai-unmatched-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--warn); }
.ofs-ai-unmatched-head .muted { color: var(--text-2); }
.ofs-ai-item { display: flex; flex-direction: column; gap: 5px; }
.ofs-ai-item + .ofs-ai-item { padding-top: 8px; border-top: 1px dashed var(--border-strong); }
.ofs-ai-item-top { display: flex; align-items: flex-start; gap: 6px; }
.ofs-ai-item-q { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.ofs-ai-item .icon-btn { width: 24px; height: 24px; margin: -3px -4px 0 0; }
.ofs-ai-item .chip-row { align-items: center; }
.ofs-ai-unmatched .ofs-ai-chip { height: auto; min-height: 26px; max-width: 100%; padding: 3px 10px; white-space: normal; text-align: left; line-height: 1.35;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.ofs-ai-unmatched .ofs-ai-chip:hover { border-color: var(--primary); color: var(--primary); }
.ofs-ai-unmatched .link-btn { color: var(--primary); }

/* Cot phai, tab Don hang: "Tao don hang" + "AI len don" cung mot hang. Flex (khong dung grid 2 cot): AI tat thi chi con
   mot nut, grid se de trong cot thu hai + khoang gap lam nut tao don hut 8px. */
.side-order-actions { display: flex; gap: 8px; }
.side-order-actions > .btn-primary { flex: 1; min-width: 0; }
.side-order-actions > .btn:not(.btn-primary) { flex: none; color: var(--primary); }

/* ---------- Trợ lý AI (Cài đặt) */
.ai-instructions { min-height: 220px; resize: vertical; font-size: 13.5px; line-height: 1.55; }
.ai-field-foot { display: flex; align-items: flex-start; gap: 6px 12px; flex-wrap: wrap; }
.ai-counter { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; } .ai-counter.bad-text { color: var(--bad); }
.ai-warn { display: flex; gap: 10px; align-items: flex-start; } .ai-warn .icon { color: var(--warn); margin-top: 2px; }
.ai-channel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.ai-channel { align-items: center; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ai-channel input { margin-top: 0; } .ai-channel:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.ai-channel-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.ai-hours { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.ai-days { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-day { align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 16px; font-size: 13px; font-weight: 600; }
.ai-day input { margin-top: 0; } .ai-day:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
/* ---------- Tự trả lời: khung giờ trực tự đặt (views/ai-schedule.js) — danh sách khung, tô đỏ khung trùng, lịch tuần 24 giờ */
.ai-sched-list { display: flex; flex-direction: column; gap: 8px; }
/* Dòng khung giờ tự xuống hàng ở MỌI độ rộng (khung cài đặt hẹp hơn cửa sổ: máy tính bảng, màn hình chia đôi): số khung · giờ · ngày · nút xóa. */
.ai-sched-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ai-sched-row > .icon-btn { margin-left: auto; }
.ai-sched-row.is-conflict { border-color: var(--bad); background: var(--bad-soft); }
.ai-sched-no { font-weight: 700; font-size: 13px; white-space: nowrap; }
.ai-sched-row.is-conflict .ai-sched-no { color: var(--bad); }
.ai-sched-times { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-sched-time { width: 118px; }
.ai-sched-days { gap: 4px; flex: 1 1 250px; }
.ai-sched-days .ai-day { padding: 3px 8px; font-size: 12px; }
.ai-sched-actions { align-items: center; gap: 6px; }
.ai-sched-issues ul { margin: 4px 0 0; padding-left: 18px; }
.ai-sched-empty { padding: 6px 2px; }
.ai-sched-chart { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.ai-sched-day, .ai-sched-ticks { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; }
.ai-sched-daylabel { font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.ai-sched-scale { position: relative; height: 14px; }
.ai-sched-scale span { position: absolute; transform: translateX(-50%); font-size: 10.5px; color: var(--text-3); }
.ai-sched-scale span:first-child { transform: none; } .ai-sched-scale span:last-child { transform: translateX(-100%); }
.ai-sched-bar { position: relative; height: 14px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.ai-sched-seg { position: absolute; top: 0; bottom: 0; background: var(--primary); opacity: .85; }
.ai-sched-seg.is-conflict { background: var(--bad); opacity: 1; z-index: 1; }
.ai-sched-now { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--warn); z-index: 2; }
.ai-sched-summary { line-height: 1.5; }
@media (max-width: 760px) {
  .ai-sched-no { flex: 1 1 auto; }
  .ai-sched-row > .icon-btn { order: -1; margin-left: 0; }
  .ai-sched-no { order: -2; }
  .ai-sched-times, .ai-sched-days { flex: 1 1 100%; }
  .ai-sched-time { width: auto; flex: 1 1 100px; min-width: 100px; }
}
.ai-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.ai-dirty { color: var(--warn); font-weight: 600; }
.ai-thinking { display: flex; align-items: center; gap: 8px; }
.ai-chat { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: var(--radius); background: var(--thread-bg); }
.ai-chat-row { display: flex; } .ai-chat-row.out { justify-content: flex-end; }
.ai-bubble { max-width: min(80%, 520px); padding: 8px 12px; border-radius: 16px; background: var(--bubble-in); box-shadow: 0 0 0 1px var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-chat-row.out .ai-bubble { background: var(--bubble-out); color: var(--bubble-out-text); box-shadow: none; }
.ai-bubble-empty { font-style: italic; opacity: .8; }
.ai-flag { white-space: normal; padding: 3px 10px; font-size: 12px; line-height: 1.4; }
.ai-preview-products { margin: 0; padding-left: 18px; color: var(--text-2); line-height: 1.7; }
.ai-sys-line { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.ai-sys-url { overflow-wrap: anywhere; }
.ai-allow { min-width: 150px; } .ai-limit { width: 110px; }
@media (max-width: 760px) { .ai-savebar .btn { flex: 1; } .ai-bubble { max-width: 90%; } .ai-channel-list { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Gói Chatbot AI (mua thêm + Đơn Lộc duyệt) ở đầu Cài đặt › Trợ lý AI */
.ai-pkg { display: flex; flex-direction: column; gap: 5px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.ai-pkg.is-active { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--primary-soft); }
.ai-pkg.is-off { border-style: dashed; }
.ai-pkg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .ai-pkg-head > .icon { color: var(--primary); }

/* ---------- Khóa OpenAI của shop (Cài đặt › Trợ lý AI): shop tự trả tiền AI, khóa chỉ đi một chiều */
.ai-key { display: flex; flex-direction: column; gap: 7px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.ai-key.is-missing { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.ai-key-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .ai-key-head > .icon { color: var(--primary); }
.ai-key-input { font-family: var(--mono, ui-monospace, monospace); min-width: 0; }
.ai-key-input.is-masked { -webkit-text-security: disc; }
.ai-key .btn-row { margin: 0; }
.ai-key-guide summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.ai-key-guide ol { margin: 6px 0; padding-left: 20px; line-height: 1.65; color: var(--text-2); }
.ai-provider-tabs { gap: 6px; }
.ai-provider-tab { display: inline-flex; align-items: center; gap: 6px; }
.ai-provider-state { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); }
.ai-provider-tab.active .ai-provider-state { background: color-mix(in srgb, var(--on-primary) 22%, transparent); color: var(--on-primary); }
@media (max-width: 560px) { .ai-provider-tabs .seg { flex: 1 1 100%; justify-content: center; } }
@media (max-width: 760px) { .ai-key .input-row { flex-wrap: wrap; } .ai-key .input-row .input { flex-basis: 100%; } .ai-key .input-row .btn { flex: 1; } }

/* ---------- Huấn luyện chatbot (Cài đặt › Trợ lý AI): kiến thức sản phẩm + combo học từ Đơn Lộc, phạm vi tư vấn */
.ai-kb-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .ai-kb-tools .input[type="search"] { flex: 1 1 220px; min-width: 0; } .ai-kb-tools select.input { width: auto; max-width: 100%; min-width: 0; text-overflow: ellipsis; }
.ai-kb-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ai-kb-list > .muted { padding: 12px; }
.ai-kb-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-top: 1px solid var(--border); } .ai-kb-row:first-child { border-top: 0; }
.ai-kb-row.is-off { background: var(--surface-2); } .ai-kb-row.is-off .ai-kb-main strong { color: var(--text-2); }
.ai-kb-check { padding-top: 2px; }
.ai-kb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-kb-title { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-kb-snippet { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ai-kb-more { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); line-height: 1.55; overflow-wrap: anywhere; }
.ai-kb-side { text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
/* Phân trang danh sách kiến thức: thanh trên (đang xem món nào / tổng · số trang · số món mỗi trang) + thanh dưới (số trang · đến trang) */
.ai-kb-listing { display: flex; flex-direction: column; gap: 8px; }
.ai-kb-pager { display: flex; gap: 6px 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.ai-kb-pager[hidden] { display: none; }
.ai-kb-pager-top { justify-content: space-between; }
.ai-kb-range { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-kb-pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: center; }
.ai-kb-page { min-width: 32px; padding: 0 8px; justify-content: center; font-variant-numeric: tabular-nums; }
.ai-kb-page.is-current, .ai-kb-page.is-current:disabled { background: var(--primary); border-color: var(--primary); color: var(--on-primary); opacity: 1; }
.ai-kb-gap { min-width: 18px; text-align: center; }
.ai-kb-size-wrap { display: inline-flex; } .ai-kb-size { width: auto; }
.ai-kb-jump-wrap { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; } .ai-kb-jump { width: 84px; }
.ai-kb-list.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s; }
@media (max-width: 760px) { .ai-kb-pager-top { justify-content: center; } .ai-kb-page { min-width: 40px; } }
/* Nhiều cửa hàng: tích chọn cửa hàng chatbot học; giá / tồn từng cửa hàng ở mỗi món */
.ai-kb-stores { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.ai-kb-stores .btn-row { margin: 0; }
.ai-kb-store-list { display: flex; flex-direction: column; gap: 8px; }
.ai-kb-store-row .pill { margin-left: 6px; }
.ai-kb-side { max-width: 50%; min-width: 0; } .ai-kb-offer { overflow-wrap: anywhere; white-space: normal; }
.price-tag > * { white-space: nowrap; }
.ai-kb-select-tools { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; } .ai-kb-select-tools .check { flex: 1 1 280px; min-width: 0; }
.ai-kb-select-tools[hidden] { display: none; }
/* Chọn thông minh */
.ai-smart-opts { display: flex; gap: 16px; flex-wrap: wrap; }
.ai-smart-preview { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.ai-smart-list { margin: 0; padding-left: 20px; line-height: 1.6; overflow-wrap: anywhere; }
@media (max-width: 760px) { .ai-kb-row { flex-wrap: wrap; } .ai-kb-side { flex-direction: row; flex-wrap: wrap; gap: 4px 10px; align-items: center; width: 100%; justify-content: flex-start; padding-left: 26px; } .ai-kb-side { max-width: none; } }

/* ---------- Chọn gói Chatbot AI (hộp mua): nhiều gói do Super Admin Đơn Lộc tạo */
.ai-plan-list { display: flex; flex-direction: column; gap: 8px; }
.ai-plan { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); }
.ai-plan.is-picked { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.ai-plan input[type="radio"] { margin-top: 3px; flex: none; }
.ai-plan-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ai-plan-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .ai-plan-price { white-space: nowrap; }
.ai-plan-features { margin: 2px 0 0; padding-left: 18px; line-height: 1.6; color: var(--text-2); }

/* =====================================================================================================
   ĐIỆN THOẠI + CẢM ỨNG
   Đặt cuối tệp để ghi đè các lớp phía trên. Mọi thứ nằm trong @media nên giao diện máy tính KHÔNG đổi.
   - (pointer: coarse)  : thiết bị cảm ứng (điện thoại, máy tính bảng) → vùng chạm to hơn, ô nhập 16px (iOS không tự phóng to trang).
   - (max-width: 760px) : bố cục điện thoại. PHẢI khớp PHONE_QUERY trong js/core/responsive.js.
   Muốn quay về bản cũ chỉ cần bỏ khối này.
   ===================================================================================================== */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Phần tử chỉ dùng trên một loại thiết bị: mặc định theo máy tính, khối điện thoại bên dưới đảo lại. */
.head-phone-phone, .ico-phone, .side-mobile-head { display: none; }
.ico-desktop { display: inline-flex; }
.rail-btn.rail-more { display: none; }

/* Tiêu đề chat co theo BỀ RỘNG CỦA CỘT CHAT chứ không theo cửa sổ: máy tính bảng đặt dọc chỉ còn ~330px cho cột chat (cột danh sách chiếm 320px),
   điện thoại thì cả màn hình. Hẹp hơn 560px: số điện thoại xuống dòng phụ, dòng phụ không xuống dòng (cắt bằng "…"), nút phân công chỉ còn ảnh người phụ trách. */
.col-thread { container: thread / inline-size; }
.head-name-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.head-name .phone-chip { flex: none; }
@container thread (max-width: 560px) {
  .head-phone-desktop { display: none; }
  .head-sub { flex-wrap: nowrap; gap: 6px; overflow: hidden; white-space: nowrap; }
  .head-sub .head-phone-phone { display: inline-flex; flex: none; }
  .head-sub-text { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
  .head-sub .pill { flex: 0 1 auto; min-width: 0; }
  .head-sub .pill-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .head-sub .pill-muted { display: none; } /* nhãn "demo" của kênh thử: không đủ chỗ */
  .assign-btn .assign-name { display: none; }
  .assign-btn > .icon:last-child { display: none; } /* mũi tên xổ xuống: bỏ cho tiêu đề rộng thêm 14px */
  .bot-toggle .bot-toggle-label { display: none; } /* công tắc AI chỉ còn biểu tượng: màu xanh = bật, xám gạch chéo = tắt (tên đầy đủ ở title / aria-label) */
  .bot-toggle { padding: 0 8px; }
  .head-unread { display: none; } /* "Đánh dấu chưa đọc" vào menu ⋯ — nhường chỗ cho tên + số điện thoại */
  .assign-btn { padding: 0 8px; }
  .ico-desktop { display: none; } .ico-phone { display: inline-flex; }
}
/* Bảng "Thêm" (điện thoại): người dùng + các trang còn lại + menu tài khoản */
.sheet-menu { display: flex; flex-direction: column; gap: 10px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.sheet-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sheet-user-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; }
.sheet-user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-group { display: flex; flex-direction: column; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.sheet-item { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 12px; border: 0; border-radius: 11px; background: none; color: var(--text); font-size: 15.5px; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
.sheet-item:hover { background: var(--hover); text-decoration: none; }
.sheet-item:active { background: var(--surface-3); }
.sheet-item .icon { color: var(--text-2); }
.sheet-item.active { color: var(--primary); background: var(--primary-soft); } .sheet-item.active .icon { color: var(--primary); }
.sheet-item.danger, .sheet-item.danger .icon { color: var(--bad); }
.sheet-item-label { flex: 1; min-width: 0; }

@keyframes sheet-in { from { transform: translateY(36px); opacity: .55; } }
@keyframes notify-in-top { from { opacity: 0; transform: translateY(-18px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Cảm ứng: vùng chạm to hơn, không phóng to khi bấm vào ô nhập, không kéo-để-tải-lại giữa lúc đang làm việc */
@media (pointer: coarse) {
  html, body { overscroll-behavior-y: none; }
  a, button, input, select, textarea, summary, label, [role="button"], [role="tab"], [role="option"] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  /* iOS Safari tự phóng to trang khi ô nhập có chữ nhỏ hơn 16px và không thu lại → cả giao diện bị lệch */
  :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]) { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }

  .btn { height: 42px; padding: 0 16px; } .btn-sm { height: 38px; padding: 0 13px; } .btn-lg { height: 48px; }
  .icon-btn { width: 40px; height: 40px; }
  .input { min-height: 44px; padding: 9px 12px; } .input-sm { min-height: 38px; padding: 5px 10px; }
  .chip { height: 34px; padding: 0 14px; font-size: 13px; }
  .tool-btn { height: 40px; min-width: 40px; }
  .tag-btn { height: 32px; }
  .seg { padding: 10px 15px; }
  .side-tab { height: 46px; }
  .settings-link { height: 44px; }
  .picker-row { padding: 11px 10px; }
  .menu-item { padding: 12px 12px; }
  .link-btn { padding: 7px 4px; font-size: 13px; }
  .phone-chip { padding: 3px 9px; }
  .check { min-height: 34px; align-items: center; } .check input { margin-top: 0; }
  .emoji-grid { grid-template-columns: repeat(7, 42px); } .emoji { width: 42px; height: 42px; font-size: 22px; }
  .popover { max-height: min(440px, calc(100dvh - 24px)); }
  .qr-item, .product-row { min-height: 44px; align-items: center; }
  .qr-title .muted { display: none; } /* gợi ý phím ↑↓ · Enter · Esc: vô nghĩa trên cảm ứng */

  /* Chạm là phản hồi ngay, không dùng vệt sáng mặc định của trình duyệt */
  .btn:active:not(:disabled) { filter: brightness(.93); }
  .icon-btn:active, .tool-btn:active, .menu-item:active, .picker-row:active, .settings-link:active, .side-tab:active { background: var(--surface-3); }
  .conv:active { background: var(--hover); }
  .chip:active, .frail-btn:active, .seg:active, .tag-btn:active, .rail-btn:active { transform: scale(.96); }
}

/* Không có chuột: :hover dính lại sau cú chạm → các hiệu ứng nhấc lên trông như lỗi */
@media (hover: none) {
  .rail-btn:hover, .chip:hover, .tag-btn:hover, .send-btn:hover, .btn-primary:hover, .ai-quick:hover:not(:disabled) { transform: none; }
  .btn-primary:hover, .send-btn:hover { filter: none; }
}

/* Bộ lọc hội thoại: thanh icon dọc chỉ dùng được khi có chuột (tên nút hiện khi rê chuột). Điện thoại và mọi thiết bị KHÔNG có chuột (máy tính bảng)
   → hàng nút CÓ CHỮ cuộn ngang nằm dưới ô tìm kiếm. */
@media (max-width: 760px), (hover: none) {
  .col-list { flex-direction: column; }
  /* Bỏ lớp bọc để đầu danh sách / thanh lọc / danh sách trở thành ba khối cùng cấp và xếp lại bằng order */
  .list-main { display: contents; }
  .list-head { order: 1; }
  .filter-rail { order: 2; }
  .conv-scroll { order: 3; }
  .filter-rail { flex: none; width: auto; min-height: 0; flex-direction: row; align-items: center; gap: 6px; padding: 4px 12px 10px; border: 0; background: transparent;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; z-index: auto; }
  .filter-rail::-webkit-scrollbar { display: none; }
  .frail-btn { flex: none; width: auto; height: 36px; padding: 0 13px 0 11px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
    border-radius: 18px; background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
  .frail-btn:hover { background: var(--surface); color: var(--text-2); }
  .frail-btn.active, .frail-btn.active:hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
  .frail-btn.frail-clear, .frail-btn.frail-clear:hover { color: var(--bad); border-style: dashed; background: transparent; }
  .frail-btn .frail-label, .frail-btn:hover .frail-label, .frail-btn:focus-visible .frail-label {
    position: static; display: inline; transform: none; opacity: 1; padding: 0; border-radius: 0; background: none; box-shadow: none; color: inherit; font-size: inherit; font-weight: inherit; pointer-events: auto; z-index: auto; }
  .frail-badge { position: static; margin-left: 1px; box-shadow: none; }
  .frail-sep { width: 1px; height: 20px; margin: 0 2px; }
}
@media (max-width: 760px) {
  /* ---------- Khung ứng dụng: bám theo vùng NHÌN THẤY (visualViewport) để bàn phím ảo không che ô soạn tin */
  .app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vvh, 100dvh); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .main-wrap { padding-top: env(safe-area-inset-top); }

  /* ---------- Thanh điều hướng dưới: 3 trang hằng ngày + "Thêm" */
  .rail { width: 100%; height: auto; margin: 0; padding: 0 6px env(safe-area-inset-bottom); border-radius: 0; flex-direction: row; justify-content: stretch; align-items: stretch; gap: 0;
    background: var(--rail); box-shadow: 0 -1px 0 rgba(255, 255, 255, .06); z-index: 30; }
  .rail-logo, .rail-spacer, .rail-conn, .rail-user, .rail-sep { display: none; }
  .rail-nav { flex: 1; min-width: 0; flex-direction: row; align-items: stretch; justify-content: space-around; gap: 2px; padding: 4px 0; }
  .rail-btn { flex: 1 1 0; width: auto; min-width: 0; height: 52px; padding: 6px 2px 4px; gap: 3px; justify-content: center; border-radius: 14px; }
  .rail-btn[data-tier="secondary"] { display: none; }
  .rail-btn.rail-more { display: flex; }
  .rail-btn:hover { transform: none; }
  .rail-btn.active { box-shadow: none; }
  .rail-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
  .rail-badge { top: 1px; right: auto; left: calc(50% + 5px); }
  .rail-more .conn-dot { position: absolute; top: 7px; left: calc(50% + 7px); width: 10px; height: 10px; box-shadow: 0 0 0 2px var(--rail); }
  .rail-more .conn-connected { display: none; }
  /* Đang trong một cuộc chat: nhường chỗ cho ô soạn tin (như mọi ứng dụng nhắn tin) — nút quay lại trên tiêu đề đưa về danh sách */
  .app:has(.inbox.has-selection:not([hidden])) > .rail { display: none; }

  /* ---------- Hộp thư: mỗi lúc một khung */
  .inbox, .inbox.side-hidden { position: relative; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .col-list { background: var(--surface); }
  .list-head { padding: 10px 12px 6px; gap: 8px; }
  .channel-picker, .search-box { height: 42px; }
  .search-box input { font-size: 16px; }


  .conv-list { padding: 0 6px 12px; }
  .conv { padding: 12px 12px 12px 14px; }

  /* ---------- Luồng chat */
  .col-thread { background: var(--thread-bg); }
  .thread-head { min-height: 58px; padding: 6px 6px 6px 2px; gap: 6px; background: var(--surface); backdrop-filter: none; border-bottom: 1px solid var(--border); }
  .thread-head > .icon-btn.only-mobile { width: 42px; height: 42px; flex: none; }
  .head-main { display: flex; flex-direction: column; justify-content: center; gap: 1px; }
  .head-name { font-size: 15.5px; gap: 6px; }
  .head-sub { font-size: 12.5px; }
  .head-actions { gap: 0; }
  .assign-btn { min-width: 42px; height: 42px; padding: 0 8px; border-radius: 12px; }
  .thread-head .bot-toggle { min-width: 38px; height: 40px; padding: 0 6px; justify-content: center; border-radius: 12px; }
  .thread-head .assign-btn { min-width: 40px; padding: 0 6px; }
  .assign-btn span.avatar { display: inline-grid; } /* luật cũ ".assign-btn span { display: none }" (chỉ định ẩn tên người phụ trách) cũng ẩn luôn ảnh đại diện */
  .ico-desktop { display: none; } .ico-phone { display: inline-flex; }

  .thread-scroll { padding: 10px 10px 6px; }
  .msg-avatar { display: none; } /* cuộc chat 1-1: ảnh khách ở tiêu đề rồi, bỏ đi để bong bóng rộng thêm 36px */
  .msg-col { max-width: 88%; }
  .bubble { font-size: 15px; padding: 8px 13px; }
  .day-sep { margin: 10px 0 8px; }
  .post-card { padding: 9px; gap: 10px; }
  .post-thumb { width: 68px; height: 54px; }
  .new-msg-pill { bottom: 132px; }
  .lay-tt-nut { height: 36px; }

  .tag-bar { padding: 6px 10px; gap: 6px; }
  .tag-btn { height: 30px; padding: 0 13px; }
  .typing-row { padding: 0 14px; }

  .composer { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
  .composer-box { border-radius: 22px; }
  .composer-input { padding: 11px 14px 2px; max-height: 128px; }
  .composer-tools { flex-wrap: nowrap; padding: 2px 4px 5px; gap: 0; }
  .tool-btn { flex: none; }
  .tool-toggle { flex: 0 1 auto; min-width: 0; margin-left: 2px; }
  .tool-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .send-btn { flex: none; margin-left: auto; width: 54px; height: 40px; border-radius: 15px; }
  .qr-popup { left: 8px; right: 8px; max-height: 42dvh; }
  .ai-panel { max-height: 58dvh; }
  /* Bàn phím ảo đang mở: chỉ còn ~1/2 màn hình → nhường chỗ cho tin nhắn */
  .kb-open .tag-bar, .kb-open .typing-row, .kb-open .new-msg-pill { display: none; }

  /* ---------- Thông tin khách: phủ kín khung chính, có thanh trên cùng với nút quay lại */
  .inbox:not(.side-hidden) .col-side { position: absolute; inset: 0; width: auto; z-index: 40; box-shadow: none; border-left: 0; background: var(--surface); }
  .side-mobile-head { display: flex; align-items: center; gap: 4px; flex: none; min-height: 54px; padding: 6px 12px 6px 4px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .side-mobile-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16.5px; }
  .side-mobile-head .icon-btn { width: 44px; height: 44px; }
  .side-tabs { padding: 6px 10px 0; }
  .side-content { padding: 14px 14px 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .ofs-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .ofs-head { padding: 8px 8px 8px 4px; }
  .order-form-side .input-price { width: 96px; }

  /* ---------- Trang thường (đơn hàng, thống kê, báo cáo, nhân sự, cài đặt) */
  .page-host { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .page { padding: 14px 14px 28px; gap: 14px; }
  .page-head { gap: 10px; }
  .page-head h2 { font-size: 20px; }
  .page > .chip-row, .page-head .chip-row { flex-wrap: nowrap; overflow-x: auto; margin-inline: -14px; padding-inline: 14px; scrollbar-width: none; }
  .page > .chip-row::-webkit-scrollbar, .page-head .chip-row::-webkit-scrollbar { display: none; }
  .page > .chip-row .chip, .page-head .chip-row .chip { flex: none; }
  .panel { padding: 14px; border-radius: 16px; }
  .panel-head { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .callout { padding: 10px 12px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .stat-icon { width: 34px; height: 34px; border-radius: 11px; }
  .stat-value { font-size: 19px; }
  .day-bar-row { grid-template-columns: 40px minmax(0, 1fr) 84px; gap: 8px; }

  /* Cài đặt: các mục thành hàng nút tròn cuộn ngang */
  .settings-layout { gap: 12px; }
  .settings-nav { margin-inline: -14px; padding: 2px 14px 6px; gap: 8px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-link { height: 40px; padding: 0 15px; border-radius: 20px; background: var(--surface); box-shadow: 0 0 0 1px var(--border); white-space: nowrap; scroll-snap-align: start; }
  .settings-link.active { box-shadow: 0 8px 18px -10px rgba(124, 58, 237, .8); }

  /* Báo cáo */
  .report-head { align-items: stretch; }
  .report-tools { width: 100%; gap: 8px; }
  .report-range { width: 100%; }
  .input-date { flex: 1; min-width: 0; width: auto; }
  .report-table { min-width: 940px; }
  .report-table th:first-child, .report-table td:first-child { min-width: 168px; position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); }
  .report-table th:first-child { background: var(--surface-2); }
  .report-table td:first-child { background: var(--surface); }
  .report-row.open td:first-child, .report-day td:first-child, .report-total td:first-child { background: var(--surface-2); }
  .report-day td:first-child { padding-left: 14px; }
  .report-table .cell-main .muted.small { display: none; }
  .report-table td.num { white-space: nowrap; }

  /* ---------- Bảng → thẻ: mỗi dòng của bảng có lớp .table-cards thành một thẻ "nhãn / giá trị" (nhãn lấy từ tiêu đề cột, gắn bởi core/responsive.js).
     Bảng báo cáo (.report-table) giữ dạng bảng cuộn ngang, cột tên nhân viên dính bên trái. */
  .table-wrap:has(> .table-cards) { overflow: visible; background: transparent; border-radius: 0; box-shadow: none; }
  .table-cards, .table-cards tfoot { display: block; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-cards tbody { display: flex; flex-direction: column; gap: 8px; }
  .table-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--ring); }
  .panel .table-cards tr { background: var(--surface-2); box-shadow: none; }
  .table-cards td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 1px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); }
  .table-cards td:first-child, .table-cards td[colspan], .table-cards td.actions { grid-column: 1 / -1; }
  .table-cards td:first-child::before { display: none; }
  .table-cards td.num, .table-cards td.num.muted { text-align: left; }
  .table-cards td:empty { display: none; }
  .table-cards .pill { white-space: normal; text-align: left; } /* nhãn trạng thái dài ("Demo (không gửi ra ngoài)") xuống dòng trong ô thay vì tràn sang ô bên cạnh */
  .table-cards td.actions { justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); }
  .table-cards tr.row-off { opacity: .55; } .table-cards .row-off td { opacity: 1; }
  .table-more { padding-top: 4px; } .table-more .btn { width: 100%; }
  /* Đơn hàng: thẻ dựng riêng cho dễ đọc — mã đơn + trạng thái, người nhận, hàng, tổng tiền */
  .table-cards.orders-table tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "code status" "who who" "items items" "total when" "total by"; align-items: center; }
  .table-cards.orders-table td[data-label]::before { display: none; }
  .table-cards.orders-table td.o-code { grid-area: code; font-size: 15.5px; }
  .table-cards.orders-table td.o-code a { display: inline-block; padding: 9px 0; margin: -9px 0; } /* vùng chạm của mã đơn (mở hội thoại) cao ≥ 40px mà thẻ không phình ra */
  .table-cards.orders-table td.o-who { grid-area: who; }
  .table-cards.orders-table td.o-items { grid-area: items; }
  .table-cards.orders-table td.o-total { grid-area: total; font-size: 17px; }
  .table-cards.orders-table td.o-status { grid-area: status; }
  .table-cards.orders-table td.o-by { grid-area: by; text-align: right; }
  .table-cards.orders-table td.o-when { grid-area: when; text-align: right; }
  .table-cards.orders-table td[colspan] { grid-area: auto; grid-column: 1 / -1; }
  .status-select { width: 148px; }
  .empty { padding: 36px 16px; }
  /* ---------- Hộp thoại → bảng trượt từ đáy màn hình; bám theo vùng nhìn thấy nên bàn phím ảo không đè lên */
  /* minmax(0, 1fr): cột lưới mặc định là "auto" nên nội dung không xuống dòng được (tên dài…) làm cả bảng rộng hơn màn hình */
  .modal-overlay { inset: auto 0 auto 0; top: var(--vv-top, 0px); height: var(--vvh, 100%); grid-template-columns: minmax(0, 1fr); place-items: end center; padding: 0; }
  .modal { max-width: none !important; width: 100%; max-height: calc(var(--vvh, 100dvh) - 12px); border-radius: 22px 22px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .28);
    padding-bottom: env(safe-area-inset-bottom); animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1); }
  .modal::before { content: ""; flex: none; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--border-strong); }
  .modal-header { padding: 10px 16px 4px 18px; }
  .modal-body { padding: 8px 18px 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal-footer { padding: 12px 16px; gap: 10px; } .modal-footer .btn { flex: 1; }
  .modal .two-col { grid-template-columns: minmax(0, 1fr); }
  .sheet-nav .modal-body { padding-top: 4px; }

  /* ---------- Thông báo: tin mới hiện phía TRÊN (ngón cái đang ở dưới, ô soạn tin nằm dưới); thông báo ngắn nằm trên thanh dưới */
  .notify-stack { top: calc(env(safe-area-inset-top) + 8px); bottom: auto; left: 8px; right: 8px; width: auto; flex-direction: column; }
  .notify-card { animation-name: notify-in-top; }
  .notify-card.leaving { transform: translateY(-14px); }
  .toast-host { left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 70px); align-items: stretch; }
  .toast { max-width: none; text-align: center; }
  .update-banner .btn, .plan-banner .link-btn { margin-left: auto; }

  /* ---------- Đăng nhập */
  .login-page { align-items: start; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .login-card { margin: auto; padding: 26px 20px; border-radius: 22px; }
  .blocked-card { padding: 26px 20px; }
}

/* Màn hình hẹp (điện thoại 320–380px): tiêu đề chat phải nhường chỗ cho số điện thoại — bỏ ảnh đại diện (huy hiệu kênh vẫn ở danh sách).
   Trước 30/09/2026 chỉ ≤350px; thêm công tắc "AI" + nút ⋯ (chặn / báo xấu) thì 360–375px cũng thiếu chỗ (số điện thoại bị cắt mất 2–3 số cuối). */
@media (max-width: 380px) {
  .thread-head .head-avatar { display: none; }
  .head-sub .head-phone-phone { padding: 3px 7px; }
}

/* Điện thoại nằm ngang / cửa sổ thấp: thanh trái không đủ chỗ cho mọi mục → gọn lại và cho cuộn */
@media (min-width: 761px) and (max-height: 520px) and (pointer: coarse) {
  .rail { margin: 6px 0 6px 6px; padding: 6px 0; overflow-y: auto; scrollbar-width: none; justify-content: flex-start; }
  .rail::-webkit-scrollbar { display: none; }
  .rail-logo { display: none; }
  .rail-btn { padding: 6px 0 4px; }
  .rail-spacer { flex: none; min-height: 6px; }
  .thread-head { min-height: 56px; padding-block: 6px; }
  .composer { padding-bottom: 8px; }
}

/* =====================================================================================================
   ẢNH SẢN PHẨM ĐƠN LỘC CHO TRỢ LÝ AI (30/09/2026)
   Cài đặt › Trợ lý AI: chế độ gửi ảnh + ảnh trong khung "Thử trợ lý"; "AI gợi ý trả lời" / "AI soạn" gắn ảnh vào tin;
   Huấn luyện chatbot: ảnh bìa từng món. Chỉ dùng biến màu sẵn có ở :root → giao diện tối tự đổi theo.
   ===================================================================================================== */
/* Ảnh bìa nhỏ cạnh tên món (/api/ai/product-image/{key}) */
.ai-thumb { flex: none; width: 28px; height: 28px; border-radius: 6px; object-fit: cover; background: var(--surface-3); box-shadow: 0 0 0 1px var(--border); vertical-align: middle; }
.ai-thumb-sm { width: 22px; height: 22px; border-radius: 5px; margin-right: 6px; }
.ai-product.has-img, .ai-quick-product.has-img { align-items: center; }
.ai-quick-product .ai-thumb { width: 22px; height: 22px; border-radius: 5px; }
/* Nút "+ Ảnh": gắn ảnh của món vào tin đang soạn */
.ai-img-add { display: inline-flex; align-items: center; gap: 2px; flex: none; height: 22px; padding: 0 8px 0 6px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  background: var(--surface); color: var(--primary); font-size: 11.5px; font-weight: 700; line-height: 1; white-space: nowrap; transition: background .12s, color .12s, border-color .12s; }
.ai-img-add:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ai-img-add:disabled { opacity: .55; cursor: progress; }
/* Ô ảnh vuông bấm mở ảnh gốc (khung "Thử trợ lý", bảng "AI soạn") */
.ai-photo { display: grid; place-items: center; flex: none; width: 88px; height: 88px; border-radius: 12px; overflow: hidden; background: var(--surface-3); color: var(--text-3); box-shadow: 0 0 0 1px var(--border); }
.ai-photo:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--primary); }
.ai-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ai-photo-broken { display: grid; place-items: center; width: 100%; height: 100%; }
/* "Thử trợ lý": ảnh trợ lý gửi ngay sau câu trả lời — mỗi món một hàng, canh phải như tin gửi đi, tên món bên dưới */
.ai-chat-photos { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 0; max-width: min(80%, 520px); }
.ai-photo-grid { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.ai-photo-cap { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-2); }
/* Bảng "AI soạn": ảnh gợi ý gửi kèm, ngay dưới câu gợi ý */
.ai-images { display: flex; flex-direction: column; gap: 5px; }
.ai-images-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-images .ai-photo { width: 64px; height: 64px; border-radius: 9px; }
/* Dải "AI gợi ý trả lời": dòng báo đã gắn N ảnh vào tin */
.ai-quick-images { display: flex; align-items: center; gap: 6px; color: var(--text-2); } .ai-quick-images > svg { flex: none; color: var(--primary); }
/* Chip đính kèm là ảnh AI tự gắn theo câu gợi ý: nền màu chính nhạt để nhân viên nhận ra trước khi gửi */
.attach-chip.attach-ai { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--primary-soft); }
/* Cài đặt › Tự trả lời khách: ô "Số ảnh mỗi món" không kéo hết bề ngang */
.ai-img-per { max-width: 320px; margin-top: 4px; }
/* Huấn luyện chatbot: ảnh bìa từng món — chưa có ảnh thì ô trống có biểu tượng */
.ai-kb-thumb { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; overflow: hidden; background: var(--surface-3); color: var(--text-3); box-shadow: 0 0 0 1px var(--border); }
.ai-kb-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
a.ai-kb-thumb:hover { text-decoration: none; box-shadow: 0 0 0 2px var(--primary); }
.ai-kb-thumb.is-empty { background: var(--surface-2); opacity: .85; }
@media (max-width: 760px) {
  .ai-product.has-img .ai-product-name { flex-basis: calc(100% - 38px); } /* tên món đứng cạnh ảnh, giá / tồn / "+ Ảnh" xuống dòng dưới */
  .ai-photo { width: 76px; height: 76px; }
  .ai-chat-photos { max-width: 90%; }
  .ai-img-per { max-width: none; }
  .ai-kb-thumb { width: 32px; height: 32px; }
}
@media (pointer: coarse) { .ai-img-add { height: 30px; padding: 0 11px 0 9px; font-size: 12.5px; } }

/* =====================================================================================================
   CHATBOT TỰ LÊN ĐƠN · NGUỒN ĐƠN · THẺ MẶC ĐỊNH (30/09/2026)
   Trang Đơn hàng + thẻ đơn ở cột phải: người tạo "Trợ lý AI", cửa hàng nhận đơn, "Nguồn: …"; form lên đơn: ô "Nguồn đơn";
   Cài đặt › Tự trả lời khách: "Tự lên đơn"; Cài đặt › Thẻ hội thoại: nhãn "Mặc định". Chỉ dùng biến màu sẵn có ở :root → giao diện tối tự đổi theo.
   ===================================================================================================== */
/* Dòng phụ của đơn (dưới mã đơn / đầu thẻ đơn): chatbot tạo · cửa hàng · nguồn — xuống dòng thay vì tràn cột hẹp */
.order-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; min-width: 0; margin-top: 3px; font-size: 12px; font-weight: 500; line-height: 1.35; color: var(--text-2); }
.order-card .order-meta { margin-top: 5px; }
.order-store { min-width: 0; overflow-wrap: anywhere; }
.order-meta .order-source { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
/* Người tạo là chatbot: biểu tượng lấp lánh + màu chính, phân biệt với tên nhân viên */
.order-bot { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.order-bot .icon { flex: none; }
/* Form lên đơn: ô "Nguồn đơn" nằm giữa cửa hàng và loại đơn — tách nhẹ khỏi dòng gợi ý của cửa hàng */
.ofs-source { margin-top: 2px; }
/* Cài đặt › Tự lên đơn: ô cửa hàng nhận đơn không kéo hết bề ngang, thụt theo chữ của ô tích phía trên */
.ai-auto-order > .check + .ai-order-store { margin-top: 6px; }
.ai-order-store { max-width: 440px; padding-left: 24px; }
/* Cài đặt › Thẻ hội thoại: nhãn "Mặc định" của thẻ D-Page tự gắn (không có nút xóa) */
.tag-system { flex: none; }
.tag-row .tag-pill-lg { min-width: 0; } /* tên thẻ dài co lại (…) để nhãn "Mặc định" và nút sửa không bị đẩy ra ngoài */
@media (max-width: 760px) {
  .ai-order-store { max-width: none; padding-left: 0; }
  .tag-row { gap: 8px; }
  .table-cards.orders-table td.o-code .order-meta { margin-top: 4px; }
  .table-cards.orders-table .order-bot { justify-content: flex-end; }
}

/* ============================================================================================================
   DẠY AI RIÊNG (Cài đặt › Trợ lý AI › Huấn luyện chatbot — 01/10/2026): thẻ hướng dẫn 3 bước, thanh thẻ, trình soạn bài dạy (món / combo / dòng / hỏi đáp chung),
   bàn thử, các thẻ Dòng sản phẩm / Chưa trả lời được / Câu khách hay hỏi. Chỉ dùng biến màu đã khai trong :root (sáng + tối).
   ============================================================================================================ */
.ai-kb-train { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 3px; }
.ai-kb-teach { align-self: flex-end; margin-top: 4px; white-space: nowrap; }
/* Hai nút cạnh nhau ở mỗi dòng món: "AI tự viết bài" (AI viết nháp rồi mở trình soạn) + "Dạy AI" / "Sửa bài dạy". */
.ai-kb-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-self: flex-end; margin-top: 4px; }
.ai-kb-actions .ai-kb-teach { align-self: auto; margin-top: 0; }
.ai-kb-autowrite { white-space: nowrap; color: var(--primary); border-color: var(--primary); }
.ai-kb-autowrite:hover:not(:disabled) { background: var(--primary-soft); }
.ai-kb-autowrite:disabled { opacity: .6; cursor: progress; }
/* Máy tính bảng dọc (761–940px): cột phải của dòng món chỉ còn ~50% bề rộng — xếp hai nút DỌC để cột tên món không bị bóp hẹp. */
@media (min-width: 761px) and (max-width: 940px) { .ai-kb-actions { flex-direction: column; align-items: flex-end; } }
.chip-mini { height: 20px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.chip-add { white-space: normal; height: auto; min-height: 26px; padding: 3px 10px; text-align: left; border-style: dashed; background: var(--surface-2); }
.chip-add:hover { border-color: var(--primary); color: var(--primary); }
.chip-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip-link { cursor: pointer; } .chip-link:hover { border-color: var(--primary); color: var(--primary); }
.chip-ok { border-color: var(--ok); color: var(--ok); }
.chip-bad { border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.chip-x { border: 0; background: none; padding: 0 0 0 2px; font-size: 15px; line-height: 1; color: var(--text-3); }
.chip-x:hover { color: var(--bad); }
.warn-text { color: var(--warn); }

.ai-train-overview { display: flex; flex-direction: column; gap: 10px; }
.ai-train-guide { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 10px 14px; }
.ai-train-guide > summary { cursor: pointer; list-style-position: inside; }
.ai-train-steps { list-style: none; margin: 10px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ai-train-steps li { display: flex; gap: 10px; align-items: flex-start; }
.ai-train-step-n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; }
.ai-train-steps li.is-done .ai-train-step-n { background: var(--ok-soft); color: var(--ok); }
.ai-train-steps .btn { margin-top: 4px; white-space: normal; height: auto; min-height: 30px; text-align: left; } .ai-train-steps li > div { min-width: 0; }
.ai-train-priority { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ai-train-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ai-train-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.ai-train-tile { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
button.ai-train-tile:hover { border-color: var(--primary); }
.ai-train-tile strong { font-size: 18px; }

.ai-train-tabbar { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; width: 0; min-width: 100%; } /* width 0 + min-width 100%: thanh thẻ cuộn ngang, không kéo rộng trang Cài đặt trên điện thoại */
.ai-train-tab-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.ai-train-tab-btn:hover { color: var(--text); }
.ai-train-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.ai-train-tab-btn .chip-count { background: var(--surface-3); color: var(--text-2); }
.ai-train-tabhost { min-width: 0; }
.ai-train-tab { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ai-train-tab-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.ai-train-tab-head > .muted { flex: 1; min-width: 0; }
.ai-train-tab-head .btn, .ai-train-tab-head select { flex: none; }

.ai-train-line-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-train-line-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ai-train-line-card.is-off { opacity: .7; }
.ai-train-line-order { display: flex; flex-direction: column; } .ai-train-line-order .icon { transform: rotate(90deg); }
.ai-train-line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.ai-train-line-actions { flex: none; display: flex; gap: 6px; align-items: center; }
.ai-train-gap-group { display: flex; flex-direction: column; gap: 8px; }
.ai-train-gap-group > summary { cursor: pointer; font-weight: 600; }
.ai-train-gap-card, .ai-train-mined { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow-wrap: anywhere; }
.ai-train-mined-row { display: flex; flex-direction: column; gap: 3px; padding: 6px 0; border-top: 1px dashed var(--border); align-items: flex-start; }
.ai-train-faq-view { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; }
.ai-train-draft-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ai-train-draft-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ai-train-alias-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-top: 1px solid var(--border); }
.ai-train-checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.ai-train-suggested { font-weight: 600; }

/* ----- Trình soạn */
.ai-train-sheet .modal-body { padding-top: 6px; }
.ai-train-wrap { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ai-train-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ai-train-head > .callout { flex-basis: 100%; }
.ai-train-thumb { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.ai-train-head-main { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 5px; overflow-wrap: anywhere; }
.ai-train-head-title { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.ai-train-quality { flex: 0 1 260px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; } .ai-train-quality .ai-train-meter { align-self: stretch; }
.ai-train-meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.ai-train-meter span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.ai-train-todo { margin: 0; padding-left: 16px; }
.ai-train-cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ai-train-form { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ai-train-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; position: sticky; top: 0; }
.ai-train-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; }
.ai-train-card h4, .ai-train-side-gaps h4 { font-size: 13.5px; }
.ai-train-tpl { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.ai-train-empty { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed var(--primary); border-radius: var(--radius); background: var(--primary-soft); }
/* Dải trạng thái "AI viết nháp" (đang viết / đã viết N mục / chưa thêm được gì / lỗi + Thử lại). */
.ai-train-autodraft { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--primary-soft); font-size: 13px; line-height: 1.55; }
.ai-train-autodraft { flex-wrap: wrap; }
.ai-train-autodraft > div { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.ai-train-autodraft > svg { flex: none; margin-top: 2px; } .ai-train-autodraft .spinner { margin-top: 3px; }
.ai-train-autodraft ul { margin: 4px 0 0; padding-left: 18px; }
.ai-train-autodraft.is-done { border-color: var(--ok); background: var(--ok-soft); } .ai-train-autodraft.is-done > svg { color: var(--ok); }
.ai-train-autodraft.is-warn { border-color: var(--warn); background: var(--warn-soft); } .ai-train-autodraft.is-warn > svg { color: var(--warn); }
.ai-train-autodraft.is-error { border-color: var(--bad); background: var(--bad-soft); } .ai-train-autodraft.is-error > svg { color: var(--bad); }
.ai-train-sec { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.ai-train-sec > summary { cursor: pointer; padding: 9px 12px; font-weight: 600; }
.ai-train-sec > summary .muted { font-weight: 400; }
.ai-train-sec-body { display: flex; flex-direction: column; gap: 8px; padding: 0 12px 12px; min-width: 0; }
.ai-train-rule { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-train-rule h4 { font-size: 13.5px; }
.ai-train-rule-preview { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.ai-train-members { margin: 0; padding-left: 18px; columns: 2; overflow-wrap: anywhere; }
.ai-train-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); min-height: 36px; }
.ai-train-chips .chip { white-space: normal; height: auto; min-height: 24px; }
.ai-train-chips > input { flex: 1 1 140px; min-width: 120px; border: 0; background: none; box-shadow: none; }
.ai-train-chips > input:focus { outline: none; }
.ai-train-sugg { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.ai-train-sugg-box { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.ai-train-sugg-box > strong { flex-basis: 100%; }
.ai-train-lines { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.ai-train-line { display: flex; gap: 6px; align-items: center; width: 100%; }
.ai-train-line .input { flex: 1; min-width: 0; }
.ai-train-text { position: relative; }
.ai-train-text textarea { width: 100%; resize: vertical; }
.ai-train-count { position: absolute; right: 8px; bottom: 4px; pointer-events: none; }
.ai-train-dates { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-train-faq { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.ai-train-faq > .btn { align-self: flex-start; }
.ai-train-faq-card { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ai-train-faq-row { display: flex; gap: 8px; align-items: center; } .ai-train-faq-row .input { flex: 1; min-width: 0; font-weight: 600; }
.ai-train-faq-n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 11px; font-weight: 700; color: var(--text-2); }
.ai-train-faq-card textarea { width: 100%; resize: vertical; }
.ai-train-faq-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-train-faq-tools .icon-btn .icon { transform: rotate(90deg); }
.ai-train-picker { display: flex; flex-direction: column; gap: 5px; }
.ai-train-pick-results { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.ai-train-pick-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); text-align: left; }
.ai-train-pick-row:hover { border-color: var(--primary); }
.ai-train-why { display: flex; flex-direction: column; gap: 6px; }
.ai-train-ai-mark { font-weight: 600; margin-left: 6px; }
.ai-train-preview { display: flex; flex-direction: column; gap: 6px; }
.ai-train-json { margin: 4px 0 0; max-height: 260px; overflow: auto; padding: 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 11.5px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-train-warn-list { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 3px; }
.ai-train-warn-list .link-btn { text-align: left; white-space: normal; color: inherit; }
.ai-train-tests { display: flex; flex-direction: column; gap: 10px; }
.ai-train-test { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--border); }
.ai-train-bubbles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.ai-train-bubble-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-train-bubble { padding: 8px 11px; border-radius: 12px 12px 12px 4px; background: var(--surface); border: 1px solid var(--border); overflow-wrap: anywhere; }
.ai-train-bubble.is-handoff { border-color: var(--warn); }
.ai-train-checks-out { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-train-verdict { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.ai-train-side-gaps { display: flex; flex-direction: column; gap: 6px; }
.ai-train-gap { padding: 6px 8px; border-left: 3px solid var(--warn); background: var(--surface-2); overflow-wrap: anywhere; }
.ai-train-footer { position: sticky; bottom: -16px; z-index: 2; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0; margin-bottom: -16px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-train-footer > .input { flex: 1 1 200px; min-width: 0; max-width: 340px; }
.ai-train-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-train-history li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.teach-btn { color: var(--primary); }
.msg-event .teach-btn { margin-left: 6px; font-size: 12px; }

@media (max-width: 900px) { .ai-train-cols { grid-template-columns: minmax(0, 1fr); } .ai-train-side { position: static; } }
@media (max-width: 760px) {
  .ai-train-sheet { max-height: var(--vvh, 100dvh) !important; height: var(--vvh, 100dvh); border-radius: 0 !important; }
  .ai-train-sheet::before { display: none; }
  .ai-train-tab-head { flex-direction: column; }
  .ai-train-line-card { flex-wrap: wrap; } .ai-train-line-actions { width: 100%; justify-content: flex-end; }
  .ai-train-members { columns: 1; }
  .ai-train-footer > .input { max-width: none; flex-basis: 100%; order: 5; }
  .ai-train-footer .btn { flex: 1 1 auto; }
  .ai-kb-teach { align-self: auto; margin-top: 0; }
  .ai-kb-actions { align-self: auto; margin-top: 0; justify-content: flex-start; }
}

/* ---------- Xóa dữ liệu của một khách (views/erase-customer.js, chỉ quản trị hệ thống) */
.ec-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; } .ec-fieldset:disabled { opacity: .7; }
.ec-h { margin: 6px 0 2px; font-size: 13.5px; }
.ec-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.ec-results-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ec-channel { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ec-loose { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ec-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ec-log li { padding: 8px 0; border-top: 1px solid var(--border); } .ec-log li:first-child { border-top: 0; }
.ec-log-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ec-plan[aria-busy="true"] > :last-child { opacity: .55; transition: opacity .15s; }
.ec .table-wrap { max-width: 100%; }
@media (max-width: 760px) { .ec .table-cards tr { background: var(--surface-2); box-shadow: none; } }

/* ---------- Quản trị viên cửa hàng tự xóa kênh + dữ liệu (js/views/channel-purge.js) */
.callout-ok { background: var(--ok-soft); } .callout-ok.flag-callout > svg { color: var(--ok); }
.cp-name { overflow-wrap: anywhere; }
.cp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cp-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.cp-stat strong { font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cp-detail summary { cursor: pointer; font-size: 13px; color: var(--text-2); } .cp-detail ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; display: grid; gap: 6px; }
.cp-progress { outline: none; } .cp-progress .row-center { display: flex; align-items: center; gap: 10px; }
.icon-btn.icon-btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 520px) { .cp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Trợ lý trả lời theo nội dung dịch vụ (js/views/ai-source.js, ai-content.js) */
.ai-source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; transition: opacity .15s; }
.ai-source-grid.is-saving { opacity: .6; pointer-events: none; }
.ai-source-card { position: relative; display: flex; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; }
.ai-source-card:hover { border-color: var(--border-strong); }
.ai-source-card input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.ai-source-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.ai-source-card:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.ai-source-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ai-source-head { display: flex; align-items: center; gap: 8px; }
.ai-source-ico { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); flex: none; }
.ai-source-card:has(input:checked) .ai-source-ico { background: var(--grad, var(--primary)); color: #fff; }
.ai-source-tag { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.ai-source-note .callout { margin-top: 0; }

.ac-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ac-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ac-tools .input[type="search"] { flex: 1 1 220px; min-width: 0; } .ac-tools select.input { width: auto; max-width: 100%; min-width: 0; text-overflow: ellipsis; }
.ac-chip-n { min-width: 16px; padding: 0 5px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 10.5px; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums; }
.chip.active .ac-chip-n { background: rgba(255, 255, 255, .28); color: #fff; }
.ac-banner { display: flex; gap: 10px 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ac-list-host { display: flex; flex-direction: column; gap: 8px; }
.ac-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ac-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); } .ac-row:first-child { border-top: 0; }
.ac-row.is-off { background: var(--surface-2); } .ac-row.is-off .ac-title { color: var(--text-2); }
.ac-row.is-draft { box-shadow: inset 3px 0 0 var(--warn); }
.ac-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ac-title-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ac-title { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; overflow-wrap: anywhere; } .ac-title:hover { color: var(--primary); }
.ac-meta { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.ac-summary { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text-2); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.ac-missing { color: var(--text-3); }
.ac-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.ac-side-btns { display: flex; gap: 2px; }
.ac-foot-note { text-align: right; }
.ac-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; margin-top: 2px; }
.ac-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; } .ac-switch input:disabled { cursor: progress; }
.ac-slider { position: absolute; inset: 0; border-radius: 11px; background: var(--border-strong); transition: background .15s; }
.ac-slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.ac-switch input:checked + .ac-slider { background: var(--ok); } .ac-switch input:checked + .ac-slider::after { transform: translateX(16px); }
.ac-switch input:focus-visible + .ac-slider { outline: 2px solid var(--primary); outline-offset: 2px; }
.ac-empty { display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2); }
.ac-empty-grid, .ac-tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.ac-start { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: left; cursor: pointer; transition: border-color .12s, transform .12s; }
.ac-start:hover { border-color: var(--primary); transform: translateY(-1px); } .ac-start strong { display: flex; align-items: center; gap: 6px; }
.ac-tpl { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.ac-editor { display: flex; flex-direction: column; gap: 14px; }
.ac-kind { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ac-sec { margin-top: 2px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); }
.ac-counted { display: flex; flex-direction: column; } .ac-count { align-self: flex-end; margin-top: 2px; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ac-quality { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border); }
.ac-quality-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ac-faq { display: flex; flex-direction: column; gap: 8px; } .ac-faq-foot { display: flex; align-items: center; gap: 10px; }
.ac-faq-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.ac-faq-row > .icon-btn { grid-column: 2; grid-row: 1 / span 2; align-self: start; } .ac-faq-a { grid-column: 1; }
.ac-state { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.ac-import-text { min-height: 220px; font-size: 13.5px; line-height: 1.55; resize: vertical; }
.ac-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ac-selectall { padding: 2px 0; }
.ac-cand-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ac-cand { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--border); } .ac-cand:first-child { border-top: 0; }
.ac-cand > input { margin-top: 3px; accent-color: var(--primary); }
.ac-full { margin-top: 4px; } .ac-full > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.ac-full-body { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; line-height: 1.55; overflow-wrap: anywhere; }
@media (max-width: 760px) { .ai-source-grid { grid-template-columns: 1fr; } .ac-kind { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .ac-row { flex-wrap: wrap; }
  .ac-side { flex-direction: row; width: 100%; justify-content: space-between; align-items: center; padding-left: 50px; }
  .ac-actions { justify-content: flex-start; }
}

/* Bình luận: nút Xóa, bình luận đã xóa, bình luận chưa đọc được chữ (18/10/2026 — xóa bình luận xấu trên Trang) */
.link-btn.danger-link:hover { color: var(--bad); }
.bubble-deleted { display: inline-flex; align-items: center; gap: 6px; font-style: italic; color: var(--text-3); }
.msg.in .bubble:has(> .bubble-deleted) { background: transparent; border: 1px dashed var(--border); box-shadow: none; }
.cmt-notext { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.cmt-notext .link-btn { color: var(--primary); }
